@liforma/client 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +14 -1
  3. package/dist/byo/audioCapture.d.ts +24 -0
  4. package/dist/byo/audioCapture.d.ts.map +1 -0
  5. package/dist/byo/index.d.ts +8 -0
  6. package/dist/byo/index.d.ts.map +1 -0
  7. package/dist/byo/index.js +307 -0
  8. package/dist/byo/index.js.map +1 -0
  9. package/dist/byo/mic.d.ts +27 -0
  10. package/dist/byo/mic.d.ts.map +1 -0
  11. package/dist/byo/pcm.d.ts +33 -0
  12. package/dist/byo/pcm.d.ts.map +1 -0
  13. package/dist/byo/pcmCarry.d.ts +17 -0
  14. package/dist/byo/pcmCarry.d.ts.map +1 -0
  15. package/dist/byo/resample.d.ts +18 -0
  16. package/dist/byo/resample.d.ts.map +1 -0
  17. package/dist/byo/turn.d.ts +39 -0
  18. package/dist/byo/turn.d.ts.map +1 -0
  19. package/dist/byo/types.d.ts +74 -0
  20. package/dist/byo/types.d.ts.map +1 -0
  21. package/dist/deepgram/connectDeepgramAgent.d.ts +51 -0
  22. package/dist/deepgram/connectDeepgramAgent.d.ts.map +1 -0
  23. package/dist/deepgram/deepgramAgentMessages.d.ts +31 -0
  24. package/dist/deepgram/deepgramAgentMessages.d.ts.map +1 -0
  25. package/dist/deepgram/index.d.ts +4 -0
  26. package/dist/deepgram/index.d.ts.map +1 -0
  27. package/dist/deepgram/index.js +142 -0
  28. package/dist/deepgram/index.js.map +1 -0
  29. package/dist/elevenlabs/connectElevenLabsAgent.d.ts +23 -0
  30. package/dist/elevenlabs/connectElevenLabsAgent.d.ts.map +1 -0
  31. package/dist/elevenlabs/index.d.ts +4 -0
  32. package/dist/elevenlabs/index.d.ts.map +1 -0
  33. package/dist/elevenlabs/index.js +89 -0
  34. package/dist/elevenlabs/index.js.map +1 -0
  35. package/dist/google/connectGeminiLive.d.ts +34 -0
  36. package/dist/google/connectGeminiLive.d.ts.map +1 -0
  37. package/dist/google/index.d.ts +4 -0
  38. package/dist/google/index.d.ts.map +1 -0
  39. package/dist/google/index.js +98 -0
  40. package/dist/google/index.js.map +1 -0
  41. package/dist/livekit/connectLiveKitAgent.d.ts +46 -0
  42. package/dist/livekit/connectLiveKitAgent.d.ts.map +1 -0
  43. package/dist/livekit/index.d.ts +3 -0
  44. package/dist/livekit/index.d.ts.map +1 -0
  45. package/dist/livekit/index.js +113 -0
  46. package/dist/livekit/index.js.map +1 -0
  47. package/dist/next/byo/audioCapture.d.ts +24 -0
  48. package/dist/next/byo/audioCapture.d.ts.map +1 -0
  49. package/dist/next/byo/pcm.d.ts +33 -0
  50. package/dist/next/byo/pcm.d.ts.map +1 -0
  51. package/dist/next/byo/resample.d.ts +18 -0
  52. package/dist/next/byo/resample.d.ts.map +1 -0
  53. package/dist/next/index.js +675 -474
  54. package/dist/next/index.js.map +1 -1
  55. package/dist/next/v2/embed/iframeHost.d.ts +16 -1
  56. package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
  57. package/dist/next/v2/embed/protocol.d.ts +41 -1
  58. package/dist/next/v2/embed/protocol.d.ts.map +1 -1
  59. package/dist/next/v2/experience.d.ts +14 -2
  60. package/dist/next/v2/experience.d.ts.map +1 -1
  61. package/dist/next/v2/speech/captureMediaStreamTrack.d.ts +1 -1
  62. package/dist/next/v2/speech/captureMediaStreamTrack.d.ts.map +1 -1
  63. package/dist/next/v2/speech/speechController.d.ts.map +1 -1
  64. package/dist/next/v2/speech/types.d.ts +13 -0
  65. package/dist/next/v2/speech/types.d.ts.map +1 -1
  66. package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
  67. package/dist/next/widget/styles.d.ts +1 -1
  68. package/dist/next/widget/styles.d.ts.map +1 -1
  69. package/dist/npm/byo/audioCapture.d.ts +24 -0
  70. package/dist/npm/byo/audioCapture.d.ts.map +1 -0
  71. package/dist/npm/byo/pcm.d.ts +33 -0
  72. package/dist/npm/byo/pcm.d.ts.map +1 -0
  73. package/dist/npm/byo/resample.d.ts +18 -0
  74. package/dist/npm/byo/resample.d.ts.map +1 -0
  75. package/dist/npm/index.js +700 -499
  76. package/dist/npm/index.js.map +1 -1
  77. package/dist/npm/v2/embed/iframeHost.d.ts +16 -1
  78. package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
  79. package/dist/npm/v2/embed/protocol.d.ts +41 -1
  80. package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
  81. package/dist/npm/v2/experience.d.ts +14 -2
  82. package/dist/npm/v2/experience.d.ts.map +1 -1
  83. package/dist/npm/v2/speech/captureMediaStreamTrack.d.ts +1 -1
  84. package/dist/npm/v2/speech/captureMediaStreamTrack.d.ts.map +1 -1
  85. package/dist/npm/v2/speech/speechController.d.ts.map +1 -1
  86. package/dist/npm/v2/speech/types.d.ts +13 -0
  87. package/dist/npm/v2/speech/types.d.ts.map +1 -1
  88. package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
  89. package/dist/npm/widget/styles.d.ts +1 -1
  90. package/dist/npm/widget/styles.d.ts.map +1 -1
  91. package/dist/openai/connectOpenAiRealtime.d.ts +41 -0
  92. package/dist/openai/connectOpenAiRealtime.d.ts.map +1 -0
  93. package/dist/openai/connectOpenAiRealtimeWebRtc.d.ts +37 -0
  94. package/dist/openai/connectOpenAiRealtimeWebRtc.d.ts.map +1 -0
  95. package/dist/openai/index.d.ts +5 -0
  96. package/dist/openai/index.d.ts.map +1 -0
  97. package/dist/openai/index.js +282 -0
  98. package/dist/openai/index.js.map +1 -0
  99. package/dist/react/byo/audioCapture.d.ts +24 -0
  100. package/dist/react/byo/audioCapture.d.ts.map +1 -0
  101. package/dist/react/byo/pcm.d.ts +33 -0
  102. package/dist/react/byo/pcm.d.ts.map +1 -0
  103. package/dist/react/byo/resample.d.ts +18 -0
  104. package/dist/react/byo/resample.d.ts.map +1 -0
  105. package/dist/react/index.js +696 -495
  106. package/dist/react/index.js.map +1 -1
  107. package/dist/react/v2/embed/iframeHost.d.ts +16 -1
  108. package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
  109. package/dist/react/v2/embed/protocol.d.ts +41 -1
  110. package/dist/react/v2/embed/protocol.d.ts.map +1 -1
  111. package/dist/react/v2/experience.d.ts +14 -2
  112. package/dist/react/v2/experience.d.ts.map +1 -1
  113. package/dist/react/v2/speech/captureMediaStreamTrack.d.ts +1 -1
  114. package/dist/react/v2/speech/captureMediaStreamTrack.d.ts.map +1 -1
  115. package/dist/react/v2/speech/speechController.d.ts.map +1 -1
  116. package/dist/react/v2/speech/types.d.ts +13 -0
  117. package/dist/react/v2/speech/types.d.ts.map +1 -1
  118. package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
  119. package/dist/react/widget/styles.d.ts +1 -1
  120. package/dist/react/widget/styles.d.ts.map +1 -1
  121. package/dist/sdk/v2/client.js +37 -10
  122. package/dist/sdk/v2/client.js.map +1 -1
  123. package/package.json +55 -7
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["_a","F","initializer","util.jsonStringifyReplacer","core.$ZodAsyncError","util.finalizeIssue","core.config","errors.$ZodError","safeParse","errors.$ZodRealError","safeParseAsync","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","content","util.aborted","util.explicitlyAborted","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","isObject","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","core._isoDateTime","core._isoDate","core._isoTime","core._isoDuration","core.formatError","core.flattenError","util.jsonStringifyReplacer","parse.parse","parse.safeParse","parse.parseAsync","parse.safeParseAsync","parse.encode","parse.decode","parse.encodeAsync","parse.decodeAsync","parse.safeEncode","parse.safeDecode","parse.safeEncodeAsync","parse.safeDecodeAsync","util.mergeDefs","core.clone","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","core._number","core._int","processors.booleanProcessor","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","#render","#teardown","#cleanup","#root","#boolAttr","#shouldLoad","#hovering","#scrollParallax","#avatarReady","#backgroundReady","#foregroundReady","#parallaxX","#parallaxY","#avatarLoadFailed","#pointerDown","#applyHostBox","#mount","#controller","#host"],"sources":["../../../src/shims/localStack.ts","../../../src/shims/apiBaseUrl.ts","../../../src/v2/api/sessionEndpointRequest.ts","../../../node_modules/zod/v4/core/core.js","../../../node_modules/zod/v4/core/util.js","../../../node_modules/zod/v4/core/errors.js","../../../node_modules/zod/v4/core/parse.js","../../../node_modules/zod/v4/core/regexes.js","../../../node_modules/zod/v4/core/checks.js","../../../node_modules/zod/v4/core/doc.js","../../../node_modules/zod/v4/core/versions.js","../../../node_modules/zod/v4/core/schemas.js","../../../node_modules/zod/v4/core/registries.js","../../../node_modules/zod/v4/core/api.js","../../../node_modules/zod/v4/core/to-json-schema.js","../../../node_modules/zod/v4/core/json-schema-processors.js","../../../node_modules/zod/v4/classic/iso.js","../../../node_modules/zod/v4/classic/errors.js","../../../node_modules/zod/v4/classic/parse.js","../../../node_modules/zod/v4/classic/schemas.js","../../../src/v2/types/sessionManifestSchema.ts","../../../src/v2/api/mintPublicSession.ts","../../../src/v2/conversationProcessor.ts","../../../src/v2/embed/playerReachability.ts","../../../src/v2/embed/protocol.ts","../../../src/v2/embed/iframeHost.ts","../../../src/v2/embed/readyGate.ts","../../../src/v2/shims/embedBaseUrl.ts","../../../src/v2/speechOnlyManifest.ts","../../../src/v2/experienceEvents.ts","../../../src/v2/speech/types.ts","../../../src/v2/speech/captureMediaStreamTrack.ts","../../../src/v2/speech/speechController.ts","../../../src/v2/experience.ts","../../../src/v2/embed/returnNavigation.ts","../../../src/svelte/experienceLoadError.ts","../../../src/svelte/experienceLoadErrorStyles.ts","../../../src/svelte/experienceLoadErrorOverlay.ts","../../../src/v2/liforma-experience.ts","../../../src/thumbnail/toGalleryThumbUrl.ts","../../../src/thumbnail/hostedLaunchUrl.ts","../../../src/thumbnail/thumbLoadScheduler.ts","../../../src/thumbnail/lazyLoad.ts","../../../src/thumbnail/scrollParallax.ts","../../../src/thumbnail/attachThumbnailParallax.ts","../../../src/thumbnail/styles.ts","../../../src/thumbnail/ensureStyles.ts","../../../src/v2/liforma-experience-thumbnail.ts","../../../src/v2/api/fetchExperiencePreview.ts","../../../src/widget/dockGeometry.ts","../../../src/widget/styles.ts","../../../src/widget/mountExperienceWidget.ts","../../../src/v2/liforma-experience-widget.ts","../../../src/v2/index.ts"],"sourcesContent":["/**\n * Opt-in local monorepo stack (api :3001, player :3002).\n * Never inferred from hostname alone — third-party demos run on localhost against production.\n */\nexport function useExplicitLocalStack(): boolean {\n\tif ((globalThis as { __LIFORMA_STACK?: string }).__LIFORMA_STACK === 'local') {\n\t\treturn true;\n\t}\n\n\tif (typeof location === 'undefined') {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\treturn new URLSearchParams(location.search).get('stack') === 'local';\n\t} catch {\n\t\treturn false;\n\t}\n}\n","import { useExplicitLocalStack } from './localStack';\n\nconst PRODUCTION_API_BASE_URL = 'https://api.liforma.ai';\nconst LOCAL_API_BASE_URL = 'http://localhost:3001';\n\nfunction readConfiguredApiBaseUrl(): string | null {\n\tconst globalValue = (globalThis as { __LIFORMA_API_BASE_URL?: string }).__LIFORMA_API_BASE_URL;\n\tif (globalValue?.trim()) {\n\t\treturn globalValue.trim().replace(/\\/$/, '');\n\t}\n\n\tif (typeof document === 'undefined') {\n\t\treturn null;\n\t}\n\n\tconst script =\n\t\tdocument.querySelector('script[data-liforma-sdk][src*=\"client.js\"]') ??\n\t\tdocument.querySelector('script[src*=\"/sdk/v2/client.js\"]');\n\tconst fromScript = script?.getAttribute('data-api-base-url')?.trim();\n\tif (fromScript) {\n\t\treturn fromScript.replace(/\\/$/, '');\n\t}\n\n\treturn null;\n}\n\n/**\n * Browser-visible API origin for Liforma HTTP calls from the CDN SDK.\n *\n * Defaults to production. Local stack is opt-in only — never inferred from\n * `localhost` hostname (third-party demos run on localhost against production).\n *\n * Override order:\n * 1. `window.__LIFORMA_API_BASE_URL`\n * 2. `data-api-base-url` on the SDK script tag\n * 3. `window.__LIFORMA_STACK === 'local'` or host `?stack=local` → http://localhost:3001\n * 4. production default → https://api.liforma.ai\n */\nexport function resolvePublicApiBaseUrl(): string {\n\tconst configured = readConfiguredApiBaseUrl();\n\tif (configured) {\n\t\treturn configured;\n\t}\n\n\tif (useExplicitLocalStack()) {\n\t\treturn LOCAL_API_BASE_URL;\n\t}\n\n\treturn PRODUCTION_API_BASE_URL;\n}\n","import type { StartButtonOptions } from '../types/sessionInteraction';\n\nexport type SessionEndpointRequestOptions = {\n\treadonly experienceId: string;\n\treadonly language?: 'en' | 'es';\n\treadonly mode?: 'conversation' | 'presenter';\n\t/** @deprecated Response ownership is derived from mode. */\n\treadonly responseMode?: 'managed' | 'custom' | 'manual';\n\treadonly speechInputMode?: 'auto' | 'manual' | 'off';\n\treadonly startButton?: StartButtonOptions;\n\treadonly speechOnly?: boolean;\n};\n\nexport function createSessionEndpointRequest(\n\tsessionEndpoint: string,\n\toptions: SessionEndpointRequestOptions\n): { readonly url: string; readonly init: RequestInit } {\n\tconst endpoint = sessionEndpoint.trim();\n\tif (!endpoint) {\n\t\tthrow new Error('sessionEndpoint must not be empty.');\n\t}\n\tif (typeof location === 'undefined') {\n\t\tthrow new Error('sessionEndpoint is only available in a browser.');\n\t}\n\n\tconst url = new URL(endpoint, location.href);\n\tif (url.origin !== location.origin) {\n\t\tthrow new Error('sessionEndpoint must be same-origin.');\n\t}\n\n\tconst experienceId = options.experienceId.trim();\n\tif (!experienceId) {\n\t\tthrow new Error('sessionEndpoint requires experienceId.');\n\t}\n\n\treturn {\n\t\turl: url.toString(),\n\t\tinit: {\n\t\t\tmethod: 'POST',\n\t\t\tcredentials: 'same-origin',\n\t\t\theaders: {\n\t\t\t\tAccept: 'application/json',\n\t\t\t\t'Content-Type': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\texperienceId,\n\t\t\t\t...(options.language ? { language: options.language } : {}),\n\t\t\t\t...(options.mode ? { mode: options.mode } : {}),\n\t\t\t\t...(options.responseMode ? { responseMode: options.responseMode } : {}),\n\t\t\t\t...(options.speechInputMode ? { speechInputMode: options.speechInputMode } : {}),\n\t\t\t\t...(options.startButton ? { startButton: options.startButton } : {}),\n\t\t\t\t...(options.speechOnly !== undefined ? { speechOnly: options.speechOnly } : {})\n\t\t\t})\n\t\t}\n\t};\n}\n","var _a;\n/** A special constant with type `never` */\nexport const NEVER = /*@__PURE__*/ 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}\n(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});\nexport const globalConfig = globalThis.__zod_globalConfig;\nexport function config(newConfig) {\n if (newConfig)\n Object.assign(globalConfig, newConfig);\n return globalConfig;\n}\n","import { globalConfig } from \"./core.js\";\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 ratio = val / step;\n const roundedRatio = Math.round(ratio);\n // Use a relative epsilon scaled to the magnitude of the result\n const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);\n if (Math.abs(ratio - roundedRatio) < tolerance)\n return 0;\n return ratio - roundedRatio;\n}\nconst EVALUATING = /* @__PURE__*/ 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 = /* @__PURE__*/ cached(() => {\n // Skip the probe under `jitless`: strict CSPs report the caught `new Function`\n // as a `securitypolicyviolation` even though the throw is swallowed.\n if (globalConfig.jitless) {\n return false;\n }\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 if (o instanceof Map)\n return new Map(o);\n if (o instanceof Set)\n return new Set(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 = /* @__PURE__*/ new Set([\"string\", \"number\", \"symbol\"]);\nexport const primitiveTypes = /* @__PURE__*/ new Set([\n \"string\",\n \"number\",\n \"bigint\",\n \"boolean\",\n \"symbol\",\n \"undefined\",\n]);\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 if (a._zod.def.checks?.length) {\n throw new Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");\n }\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: b._zod.def.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}\n// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).\n// Used to respect `abort: true` in .refine() even for checks that have a `when` function.\nexport function explicitlyAborted(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 === false) {\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 message = iss.message\n ? iss.message\n : (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 const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;\n rest.path ?? (rest.path = []);\n rest.message = message;\n if (ctx?.reportInput) {\n rest.input = _input;\n }\n return rest;\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, path = []) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\" && issue.errors.length) {\n issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues }, [...path, ...issue.path]);\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues }, [...path, ...issue.path]);\n }\n else {\n const fullpath = [...path, ...issue.path];\n if (fullpath.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < fullpath.length) {\n const el = fullpath[i];\n const terminal = i === fullpath.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 };\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 }, [...path, ...issue.path]));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues }, [...path, ...issue.path]);\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues }, [...path, ...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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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\";\n/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link cuid2} instead.\n * See https://github.com/paralleldrive/cuid.\n */\nexport const cuid = /^[cC][0-9a-z]{6,}$/;\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,}$/;\nexport const httpProtocol = /^https?$/;\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: 4,\n patch: 3,\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 if (util.explicitlyAborted(payload))\n continue;\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 // When normalize is off, require :// for http/https URLs\n // This prevents strings like \"http:example.com\" or \"https:/path\" from being silently accepted\n if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {\n if (!/^https?:\\/\\//i.test(trimmed)) {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"url\",\n note: \"Invalid URL format\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n return;\n }\n }\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});\n/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.\n * See https://github.com/paralleldrive/cuid.\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 // atob ignores whitespace, so reject it up front.\n if (/\\s/.test(data))\n return false;\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.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, isOptionalIn, isOptionalOut) {\n const isPresent = key in input;\n if (result.issues.length) {\n // For optional-in/out schemas, ignore errors on absent keys.\n if (isOptionalIn && isOptionalOut && !isPresent) {\n return;\n }\n final.issues.push(...util.prefixIssues(key, result.issues));\n }\n if (!isPresent && !isOptionalIn) {\n if (!result.issues.length) {\n final.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [key],\n });\n }\n return;\n }\n if (result.value === undefined) {\n if (isPresent) {\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 const keySet = def.keySet;\n const _catchall = def.catchall._zod;\n const t = _catchall.def.type;\n const isOptionalIn = _catchall.optin === \"optional\";\n const isOptionalOut = _catchall.optout === \"optional\";\n for (const key in input) {\n // skip __proto__ so it can't replace the result prototype via the\n // assignment setter on the plain {} we build into\n if (key === \"__proto__\")\n continue;\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, isOptionalIn, isOptionalOut)));\n }\n else {\n handlePropertyResult(r, payload, key, input, isOptionalIn, 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 isOptionalIn = el._zod.optin === \"optional\";\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, isOptionalIn, isOptionalOut)));\n }\n else {\n handlePropertyResult(r, payload, key, input, isOptionalIn, 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 isOptionalIn = schema?._zod?.optin === \"optional\";\n const isOptionalOut = schema?._zod?.optout === \"optional\";\n doc.write(`const ${id} = ${parseStr(key)};`);\n if (isOptionalIn && isOptionalOut) {\n // For optional-in/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 if (!isOptionalIn) {\n doc.write(`\n const ${id}_present = ${k} in input;\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 if (!${id}_present && !${id}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${k}]\n });\n }\n\n if (${id}_present) {\n if (${id}.value === undefined) {\n newResult[${k}] = undefined;\n } else {\n newResult[${k}] = ${id}.value;\n }\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 first = def.options.length === 1 ? def.options[0]._zod.run : null;\n inst._zod.parse = (payload, ctx) => {\n if (first) {\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 first = def.options.length === 1 ? def.options[0]._zod.run : null;\n inst._zod.parse = (payload, ctx) => {\n if (first) {\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 // Fall back to union matching when the fast discriminator path fails:\n // - explicitly enabled via unionFallback, or\n // - during backward direction (encode), since codec-based discriminators\n // have different values in forward vs backward directions\n if (def.unionFallback || ctx.direction === \"backward\") {\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 options: Array.from(disc.value.keys()),\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 optinStart = getTupleOptStart(items, \"optin\");\n const optoutStart = getTupleOptStart(items, \"optout\");\n if (!def.rest) {\n if (input.length < optinStart) {\n payload.issues.push({\n code: \"too_small\",\n minimum: optinStart,\n inclusive: true,\n input,\n inst,\n origin: \"array\",\n });\n return payload;\n }\n if (input.length > items.length) {\n payload.issues.push({\n code: \"too_big\",\n maximum: items.length,\n inclusive: true,\n input,\n inst,\n origin: \"array\",\n });\n }\n }\n // Run every item in parallel, collecting results into an indexed\n // array. The post-processing in `handleTupleResults` walks them in\n // order so it can decide whether an absent optional-output error can\n // truncate the tail or must be reported to preserve required output.\n const itemResults = new Array(items.length);\n for (let i = 0; i < items.length; i++) {\n const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);\n if (r instanceof Promise) {\n proms.push(r.then((rr) => {\n itemResults[i] = rr;\n }));\n }\n else {\n itemResults[i] = r;\n }\n }\n if (def.rest) {\n let i = items.length - 1;\n const rest = input.slice(items.length);\n for (const el of rest) {\n i++;\n const result = def.rest._zod.run({ value: el, issues: [] }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((r) => handleTupleResult(r, payload, i)));\n }\n else {\n handleTupleResult(result, payload, i);\n }\n }\n }\n if (proms.length) {\n return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));\n }\n return handleTupleResults(itemResults, payload, items, input, optoutStart);\n };\n});\nfunction getTupleOptStart(items, key) {\n for (let i = items.length - 1; i >= 0; i--) {\n if (items[i]._zod[key] !== \"optional\")\n return i + 1;\n }\n return 0;\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}\nfunction handleTupleResults(itemResults, final, items, input, optoutStart) {\n // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional\n // rule, but only after `optoutStart`: the first index where the output\n // tuple tail can be absent.\n for (let i = 0; i < items.length; i++) {\n const r = itemResults[i];\n const isPresent = i < input.length;\n if (r.issues.length) {\n if (!isPresent && i >= optoutStart) {\n final.value.length = i;\n break;\n }\n final.issues.push(...util.prefixIssues(i, r.issues));\n }\n final.value[i] = r.value;\n }\n // Drop trailing slots that produced `undefined` for absent input\n // (the array analog of an absent optional key on an object). The\n // `i >= input.length` floor is critical: an explicit `undefined`\n // *inside* the input must be preserved even when the schema is\n // optional-out (e.g. `z.string().or(z.undefined())` accepting an\n // explicit undefined value).\n for (let i = final.value.length - 1; i >= input.length; i--) {\n if (items[i]._zod.optout === \"optional\" && final.value[i] === undefined) {\n final.value.length = i;\n }\n else {\n break;\n }\n }\n return final;\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 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 if (keyResult.issues.length) {\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 continue;\n }\n const outKey = keyResult.value;\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[outKey] = result.value;\n }));\n }\n else {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(key, result.issues));\n }\n payload.value[outKey] = 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 // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()\n for (const key of Reflect.ownKeys(input)) {\n if (key === \"__proto__\")\n continue;\n if (!Object.prototype.propertyIsEnumerable.call(input, key))\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.optin = \"optional\";\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 payload.fallback = true;\n return payload;\n });\n }\n if (_out instanceof Promise) {\n throw new core.$ZodAsyncError();\n }\n payload.value = _out;\n payload.fallback = true;\n return payload;\n };\n});\nfunction handleOptionalResult(result, input) {\n if (input === undefined && (result.issues.length || result.fallback)) {\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 input = payload.value;\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise)\n return result.then((r) => handleOptionalResult(r, input));\n return handleOptionalResult(result, input);\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 inst._zod.optin = \"optional\";\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 payload.fallback = true;\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 payload.fallback = true;\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, fallback: left.fallback }, 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 $ZodPreprocess = /*@__PURE__*/ core.$constructor(\"$ZodPreprocess\", (inst, def) => {\n $ZodPipe.init(inst, def);\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 // Cache the resolved inner type on the shared `def` so all clones of this\n // lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,\n // preserving identity for cycle detection on recursive schemas.\n util.defineLazy(inst._zod, \"innerType\", () => {\n const d = def;\n if (!d._cachedInner)\n d._cachedInner = def.getter();\n return d._cachedInner;\n });\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/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link _cuid2} instead.\n * See https://github.com/paralleldrive/cuid.\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, params) {\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 }, params);\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\" && \"_prefault\" in result.schema)\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 // The `id` in `.meta()` is a Zod-specific registration tag used to extract\n // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it\n // from the output body where it would otherwise leak. The id is preserved\n // implicitly via the $defs key (and via $ref paths).\n const rootMetaId = ctx.metadataRegistry.get(schema)?.id;\n if (rootMetaId !== undefined && result.id === rootMetaId)\n delete result.id;\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 if (seen.def.id === seen.defId)\n delete seen.def.id;\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 if (_schema._zod.traits.has(\"$ZodCodec\"))\n return true;\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 // when both minimum and exclusiveMinimum exist, pick the more restrictive one\n const exMin = typeof exclusiveMinimum === \"number\" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);\n const exMax = typeof exclusiveMaximum === \"number\" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);\n const legacy = ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\";\n if (exMin) {\n if (legacy) {\n json.minimum = exclusiveMinimum;\n json.exclusiveMinimum = true;\n }\n else {\n json.exclusiveMinimum = exclusiveMinimum;\n }\n }\n else if (typeof minimum === \"number\") {\n json.minimum = minimum;\n }\n if (exMax) {\n if (legacy) {\n json.maximum = exclusiveMaximum;\n json.exclusiveMaximum = true;\n }\n else {\n json.exclusiveMaximum = exclusiveMaximum;\n }\n }\n else if (typeof maximum === \"number\") {\n json.maximum = maximum;\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, {\n ...params,\n path: [...params.path, \"items\"],\n });\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 inIsTransform = def.in._zod.traits.has(\"$ZodTransform\");\n const innerType = ctx.io === \"input\" ? (inIsTransform ? 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 = /*@__PURE__*/ core.$constructor(\"ZodError\", initializer);\nexport const ZodRealError = /*@__PURE__*/ 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\";\n// Lazy-bind builder methods.\n//\n// Builder methods (`.optional`, `.array`, `.refine`, ...) live as\n// non-enumerable getters on each concrete schema constructor's\n// prototype. On first access from an instance the getter allocates\n// `fn.bind(this)` and caches it as an own property on that instance,\n// so detached usage (`const m = schema.optional; m()`) still works\n// and the per-instance allocation only happens for methods actually\n// touched.\n//\n// One install per (prototype, group), memoized by `_installedGroups`.\nconst _installedGroups = /* @__PURE__ */ new WeakMap();\nfunction _installLazyMethods(inst, group, methods) {\n const proto = Object.getPrototypeOf(inst);\n let installed = _installedGroups.get(proto);\n if (!installed) {\n installed = new Set();\n _installedGroups.set(proto, installed);\n }\n if (installed.has(group))\n return;\n installed.add(group);\n for (const key in methods) {\n const fn = methods[key];\n Object.defineProperty(proto, key, {\n configurable: true,\n enumerable: false,\n get() {\n const bound = fn.bind(this);\n Object.defineProperty(this, key, {\n configurable: true,\n writable: true,\n enumerable: true,\n value: bound,\n });\n return bound;\n },\n set(v) {\n Object.defineProperty(this, key, {\n configurable: true,\n writable: true,\n enumerable: true,\n value: v,\n });\n },\n });\n }\n}\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 // Parse-family is intentionally kept as per-instance closures: these are\n // the hot path AND the most-detached methods (`arr.map(schema.parse)`,\n // `const { parse } = schema`, etc.). Eager closures here mean callers pay\n // ~12 closure allocations per schema but get monomorphic call sites and\n // detached usage that \"just works\".\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 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 // All builder methods are placed on the internal prototype as lazy-bind\n // getters. On first access per-instance, a bound thunk is allocated and\n // cached as an own property; subsequent accesses skip the getter. This\n // means: no per-instance allocation for unused methods, full\n // detachability preserved (`const m = schema.optional; m()` works), and\n // shared underlying function references across all instances.\n _installLazyMethods(inst, \"ZodType\", {\n check(...chks) {\n const def = this.def;\n return this.clone(util.mergeDefs(def, {\n checks: [\n ...(def.checks ?? []),\n ...chks.map((ch) => typeof ch === \"function\" ? { _zod: { check: ch, def: { check: \"custom\" }, onattach: [] } } : ch),\n ],\n }), { parent: true });\n },\n with(...chks) {\n return this.check(...chks);\n },\n clone(def, params) {\n return core.clone(this, def, params);\n },\n brand() {\n return this;\n },\n register(reg, meta) {\n reg.add(this, meta);\n return this;\n },\n refine(check, params) {\n return this.check(refine(check, params));\n },\n superRefine(refinement, params) {\n return this.check(superRefine(refinement, params));\n },\n overwrite(fn) {\n return this.check(checks.overwrite(fn));\n },\n optional() {\n return optional(this);\n },\n exactOptional() {\n return exactOptional(this);\n },\n nullable() {\n return nullable(this);\n },\n nullish() {\n return optional(nullable(this));\n },\n nonoptional(params) {\n return nonoptional(this, params);\n },\n array() {\n return array(this);\n },\n or(arg) {\n return union([this, arg]);\n },\n and(arg) {\n return intersection(this, arg);\n },\n transform(tx) {\n return pipe(this, transform(tx));\n },\n default(d) {\n return _default(this, d);\n },\n prefault(d) {\n return prefault(this, d);\n },\n catch(params) {\n return _catch(this, params);\n },\n pipe(target) {\n return pipe(this, target);\n },\n readonly() {\n return readonly(this);\n },\n describe(description) {\n const cl = this.clone();\n core.globalRegistry.add(cl, { description });\n return cl;\n },\n meta(...args) {\n // overloaded: meta() returns the registered metadata, meta(data)\n // returns a clone with `data` registered. The mapped type picks\n // up the second overload, so we accept variadic any-args and\n // return `any` to satisfy both at runtime.\n if (args.length === 0)\n return core.globalRegistry.get(this);\n const cl = this.clone();\n core.globalRegistry.add(cl, args[0]);\n return cl;\n },\n isOptional() {\n return this.safeParse(undefined).success;\n },\n isNullable() {\n return this.safeParse(null).success;\n },\n apply(fn) {\n return fn(this);\n },\n });\n Object.defineProperty(inst, \"description\", {\n get() {\n return core.globalRegistry.get(inst)?.description;\n },\n configurable: true,\n });\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 _installLazyMethods(inst, \"_ZodString\", {\n regex(...args) {\n return this.check(checks.regex(...args));\n },\n includes(...args) {\n return this.check(checks.includes(...args));\n },\n startsWith(...args) {\n return this.check(checks.startsWith(...args));\n },\n endsWith(...args) {\n return this.check(checks.endsWith(...args));\n },\n min(...args) {\n return this.check(checks.minLength(...args));\n },\n max(...args) {\n return this.check(checks.maxLength(...args));\n },\n length(...args) {\n return this.check(checks.length(...args));\n },\n nonempty(...args) {\n return this.check(checks.minLength(1, ...args));\n },\n lowercase(params) {\n return this.check(checks.lowercase(params));\n },\n uppercase(params) {\n return this.check(checks.uppercase(params));\n },\n trim() {\n return this.check(checks.trim());\n },\n normalize(...args) {\n return this.check(checks.normalize(...args));\n },\n toLowerCase() {\n return this.check(checks.toLowerCase());\n },\n toUpperCase() {\n return this.check(checks.toUpperCase());\n },\n slugify() {\n return this.check(checks.slugify());\n },\n });\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: core.regexes.httpProtocol,\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}\n/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link ZodCUID2} instead.\n * See https://github.com/paralleldrive/cuid.\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});\n/**\n * Validates a CUID v1 string.\n *\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.\n * See https://github.com/paralleldrive/cuid.\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 _installLazyMethods(inst, \"ZodNumber\", {\n gt(value, params) {\n return this.check(checks.gt(value, params));\n },\n gte(value, params) {\n return this.check(checks.gte(value, params));\n },\n min(value, params) {\n return this.check(checks.gte(value, params));\n },\n lt(value, params) {\n return this.check(checks.lt(value, params));\n },\n lte(value, params) {\n return this.check(checks.lte(value, params));\n },\n max(value, params) {\n return this.check(checks.lte(value, params));\n },\n int(params) {\n return this.check(int(params));\n },\n safe(params) {\n return this.check(int(params));\n },\n positive(params) {\n return this.check(checks.gt(0, params));\n },\n nonnegative(params) {\n return this.check(checks.gte(0, params));\n },\n negative(params) {\n return this.check(checks.lt(0, params));\n },\n nonpositive(params) {\n return this.check(checks.lte(0, params));\n },\n multipleOf(value, params) {\n return this.check(checks.multipleOf(value, params));\n },\n step(value, params) {\n return this.check(checks.multipleOf(value, params));\n },\n finite() {\n return this;\n },\n });\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 _installLazyMethods(inst, \"ZodArray\", {\n min(n, params) {\n return this.check(checks.minLength(n, params));\n },\n nonempty(params) {\n return this.check(checks.minLength(1, params));\n },\n max(n, params) {\n return this.check(checks.maxLength(n, params));\n },\n length(n, params) {\n return this.check(checks.length(n, params));\n },\n unwrap() {\n return this.element;\n },\n });\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 _installLazyMethods(inst, \"ZodObject\", {\n keyof() {\n return _enum(Object.keys(this._zod.def.shape));\n },\n catchall(catchall) {\n return this.clone({ ...this._zod.def, catchall: catchall });\n },\n passthrough() {\n return this.clone({ ...this._zod.def, catchall: unknown() });\n },\n loose() {\n return this.clone({ ...this._zod.def, catchall: unknown() });\n },\n strict() {\n return this.clone({ ...this._zod.def, catchall: never() });\n },\n strip() {\n return this.clone({ ...this._zod.def, catchall: undefined });\n },\n extend(incoming) {\n return util.extend(this, incoming);\n },\n safeExtend(incoming) {\n return util.safeExtend(this, incoming);\n },\n merge(other) {\n return util.merge(this, other);\n },\n pick(mask) {\n return util.pick(this, mask);\n },\n omit(mask) {\n return util.omit(this, mask);\n },\n partial(...args) {\n return util.partial(ZodOptional, this, args[0]);\n },\n required(...args) {\n return util.required(ZodNonOptional, this, args[0]);\n },\n });\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 // v3-compat: z.record(valueType, params?) — defaults keyType to z.string()\n if (!valueType || !valueType._zod) {\n return new ZodRecord({\n type: \"record\",\n keyType: string(),\n valueType: keyType,\n ...util.normalizeParams(valueType),\n });\n }\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 payload.fallback = true;\n return payload;\n });\n }\n payload.value = output;\n payload.fallback = true;\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 function invertCodec(codec) {\n const def = codec._zod.def;\n return new ZodCodec({\n type: \"pipe\",\n in: def.out,\n out: def.in,\n transform: def.reverseTransform,\n reverseTransform: def.transform,\n });\n}\nexport const ZodPreprocess = /*@__PURE__*/ core.$constructor(\"ZodPreprocess\", (inst, def) => {\n ZodPipe.init(inst, def);\n core.$ZodPreprocess.init(inst, def);\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, params) {\n return core._superRefine(fn, params);\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\nexport function preprocess(fn, schema) {\n return new ZodPreprocess({\n type: \"pipe\",\n in: transform(fn),\n out: schema,\n });\n}\n","import { z } from 'zod';\n\nimport type { SessionManifest } from './sessionManifest';\n\nconst closeButtonSchema = z\n\t.object({\n\t\tvisible: z.boolean().optional(),\n\t\tstyle: z.enum(['icon', 'text']).optional(),\n\t\tlabel: z.string().nullable().optional(),\n\t\tposition: z.string().optional()\n\t})\n\t.nullable()\n\t.optional();\n\nconst integrationSchema = z\n\t.object({\n\t\treturnUrl: z.string().optional(),\n\t\tnavigateOnClose: z.boolean().optional()\n\t})\n\t.optional();\n\nconst startButtonSchema = z.object({\n\tlabel: z.string().min(1).max(80).optional(),\n\tariaLabel: z.string().min(1).max(120).optional(),\n\tplacement: z.enum(['center', 'bottom-center', 'bottom-left', 'bottom-right']).optional(),\n\tvariant: z.enum(['primary', 'secondary', 'minimal']).optional(),\n\tappearance: z\n\t\t.object({\n\t\t\tbackgroundColor: z.string().min(1).max(64).optional(),\n\t\t\ttextColor: z.string().min(1).max(64).optional(),\n\t\t\tborderColor: z.string().min(1).max(64).optional(),\n\t\t\tborderRadiusPx: z.number().min(0).max(999).optional(),\n\t\t\tsize: z.enum(['small', 'medium', 'large']).optional(),\n\t\t\tshadow: z.enum(['none', 'soft', 'strong']).optional()\n\t\t})\n\t\t.optional()\n});\n\nconst characterSchema = z.object({\n\tcharacterId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tavatarId: z.string().min(1),\n\tvoiceId: z.string().min(1),\n\tsttLang: z.string().min(1),\n\tagentId: z.string().min(1),\n\tappearance: z\n\t\t.object({\n\t\t\tcostume: z.string().optional(),\n\t\t\tcostumeClothes: z.string().optional(),\n\t\t\thair: z.string().optional()\n\t\t})\n\t\t.optional()\n});\n\nconst locationPlacementSchema = z.object({\n\tcx: z.number(),\n\tcy: z.number(),\n\tscale: z.number(),\n\tdistanceM: z.number()\n});\n\nconst locationSceneSchema = z.object({\n\ttype: z.literal('image'),\n\tlayers: z.array(z.string()),\n\tassets: z.record(z.string(), z.record(z.string(), z.string()))\n});\n\nconst pipelinePlacementSchema = z.enum(['browser', 'cloud']);\n\nconst pipelineStageSchema = z.object({\n\tplacement: pipelinePlacementSchema,\n\tprovider: z.string().min(1),\n\tmodel: z.string().min(1).optional(),\n\tconfig: z.record(z.string(), z.unknown()).default({})\n});\n\nconst pipelineAnimationSchema = z.object({\n\tenabled: z.boolean(),\n\tplacement: pipelinePlacementSchema.optional(),\n\tsource: z.enum(['azureViseme', 'speechToAnimation', 'none']),\n\tprovider: z.string().min(1).optional(),\n\tmodel: z.string().min(1).optional(),\n\tconfig: z.record(z.string(), z.unknown()).default({})\n});\n\nconst pipelineSchema = z.object({\n\tstt: pipelineStageSchema,\n\tllm: pipelineStageSchema,\n\ttts: pipelineStageSchema,\n\tanimation: pipelineAnimationSchema\n});\n\nexport const sessionManifestSchema = z.object({\n\tschemaVersion: z.literal(1),\n\tsessionId: z.string().min(1),\n\texperienceId: z.string().min(1),\n\texpiresAt: z.string().min(1),\n\tsessionToken: z.string().min(1),\n\texperience: z.object({\n\t\ttitle: z.string(),\n\t\tslug: z.string(),\n\t\tmode: z.enum(['conversation', 'presenter']),\n\t\tresponseMode: z.enum(['managed', 'custom', 'manual']),\n\t\tspeechInputMode: z.enum(['auto', 'manual', 'off']),\n\t\tstartButton: startButtonSchema.optional(),\n\t\topeningMessage: z.string().optional()\n\t}),\n\ttransport: z.object({\n\t\ttype: z.literal('http'),\n\t\tconfig: z.object({\n\t\t\tapiBaseUrl: z.string().min(1)\n\t\t})\n\t}),\n\truntime: z.object({\n\t\tcdnBaseUrl: z.string().min(1),\n\t\tinput: z.literal('browserStt'),\n\t\trenderer: z.literal('morph2d')\n\t}),\n\tpipeline: pipelineSchema.optional(),\n\tcapabilities: z.array(z.string()),\n\tcharacters: z.array(characterSchema).min(1),\n\tactiveCharacterId: z.string().min(1),\n\tlocation: z\n\t\t.object({\n\t\t\tlocationId: z.string(),\n\t\t\ttitle: z.string(),\n\t\t\tscene: locationSceneSchema.optional(),\n\t\t\tplacement: locationPlacementSchema.optional(),\n\t\t\tmetersPerDepth: z.number().positive().optional(),\n\t\t\thasZoomVariant: z.boolean().optional()\n\t\t})\n\t\t.optional(),\n\tworld: z\n\t\t.object({\n\t\t\tworldId: z.string(),\n\t\t\trulesetVersion: z.number()\n\t\t})\n\t\t.optional(),\n\tstate: z.object({\n\t\tschemaVersion: z.literal(1),\n\t\tvalues: z.record(z.string(), z.unknown())\n\t}),\n\ttools: z.array(z.unknown()),\n\tintegration: integrationSchema,\n\tcloseButton: closeButtonSchema,\n\tbilling: z\n\t\t.object({\n\t\t\tpayer: z.literal('creator'),\n\t\t\tmeterId: z.string()\n\t\t})\n\t\t.optional(),\n\tlanguage: z.enum(['en', 'es']).optional(),\n\tlanguagePackRevision: z.string().optional(),\n\tprocessorId: z.string().optional()\n}).superRefine((manifest, ctx) => {\n\tconst active = manifest.activeCharacterId;\n\tconst found = manifest.characters.some((c) => c.characterId === active);\n\tif (!found) {\n\t\tctx.addIssue({\n\t\t\tcode: 'custom',\n\t\t\tmessage: 'activeCharacterId must reference a character in characters[]',\n\t\t\tpath: ['activeCharacterId']\n\t\t});\n\t}\n});\n\n/** Apply API defaults for interaction modes omitted by older mint paths. */\nexport function normalizeSessionManifestInput(data: unknown): unknown {\n\tif (!data || typeof data !== 'object') return data;\n\tconst record = { ...(data as Record<string, unknown>) };\n\tconst experience = record.experience;\n\tif (!experience || typeof experience !== 'object') return record;\n\n\tconst exp = { ...(experience as Record<string, unknown>) };\n\tconst mode = exp.mode === 'presenter' ? 'presenter' : 'conversation';\n\tif (exp.responseMode === undefined) {\n\t\texp.responseMode = mode === 'presenter' ? 'manual' : 'managed';\n\t}\n\tif (exp.speechInputMode === undefined) {\n\t\texp.speechInputMode = mode === 'presenter' ? 'manual' : 'auto';\n\t}\n\trecord.experience = exp;\n\treturn record;\n}\n\nfunction formatZodIssues(error: z.ZodError): string {\n\treturn error.issues\n\t\t.map((issue) => {\n\t\t\tconst path = issue.path.length > 0 ? issue.path.join('.') : '(root)';\n\t\t\treturn `${path}: ${issue.message}`;\n\t\t})\n\t\t.join('; ');\n}\n\nexport function parseSessionManifest(data: unknown): SessionManifest {\n\tconst result = sessionManifestSchema.safeParse(normalizeSessionManifestInput(data));\n\tif (!result.success) {\n\t\tthrow new Error(`Invalid Session Manifest from Liforma API — ${formatZodIssues(result.error)}`);\n\t}\n\treturn result.data as SessionManifest;\n}\n\nexport function manifestHasSessionCredential(manifest: SessionManifest): boolean {\n\treturn manifest.sessionToken.trim().length > 0;\n}\n","import { resolvePublicApiBaseUrl } from '../../shims/apiBaseUrl';\nimport { createSessionEndpointRequest } from './sessionEndpointRequest';\nimport { parseSessionManifest } from '../types/sessionManifestSchema';\nimport type { SessionManifest } from '../types/sessionManifest';\nimport type { StartButtonOptions } from '../types/sessionInteraction';\n\ntype MintErrorPayload = {\n\treadonly code?: string;\n\treadonly message?: string;\n\treadonly origin?: string;\n\treadonly experienceId?: string;\n};\n\nfunction currentPageOrigin(): string | undefined {\n\ttry {\n\t\tif (typeof globalThis.location?.origin === 'string' && globalThis.location.origin) {\n\t\t\treturn globalThis.location.origin;\n\t\t}\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nfunction formatPublicMintError(experienceId: string, status: number, text: string): string {\n\tlet payload: MintErrorPayload | undefined;\n\ttry {\n\t\tpayload = JSON.parse(text) as MintErrorPayload;\n\t} catch {\n\t\t/* keep */\n\t}\n\n\tconst pageOrigin = currentPageOrigin();\n\tconst apiMessage = payload?.message?.trim();\n\tconst code = payload?.code;\n\n\tif (\n\t\tcode === 'origin_not_allowed' ||\n\t\t(/^Origin not allowed/i.test(apiMessage ?? '') && pageOrigin)\n\t) {\n\t\tif (apiMessage && apiMessage.includes(experienceId) && apiMessage.includes('allowed origin')) {\n\t\t\treturn apiMessage;\n\t\t}\n\t\tconst origin = payload?.origin ?? pageOrigin ?? '(unknown origin)';\n\t\treturn (\n\t\t\t`Your origin ${origin} is not an allowed origin for experience ${experienceId}. ` +\n\t\t\t`If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), ` +\n\t\t\t`open Workspace → Settings → Origins, add ${origin} to the list of allowed origins, ` +\n\t\t\t`and ensure “Allow public client-only embeds” is enabled.`\n\t\t);\n\t}\n\n\tif (code === 'browser_embeds_disabled' || /^Browser embeds are not enabled/i.test(apiMessage ?? '')) {\n\t\tif (apiMessage && apiMessage.includes('Allow public client-only embeds')) {\n\t\t\treturn apiMessage;\n\t\t}\n\t\treturn (\n\t\t\t`Browser embeds are not enabled for experience ${experienceId}. ` +\n\t\t\t`If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), ` +\n\t\t\t`open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`\n\t\t);\n\t}\n\n\tif (\n\t\tcode === 'experience_unavailable' ||\n\t\t/^Experience is not available\\.?$/i.test(apiMessage ?? '') ||\n\t\t/^Unknown experience\\.?$/i.test(apiMessage ?? '')\n\t) {\n\t\tif (apiMessage && apiMessage.includes('No playable experience found')) {\n\t\t\treturn apiMessage;\n\t\t}\n\t\treturn (\n\t\t\t`No playable experience found for “${experienceId}”. ` +\n\t\t\t`Check that the experience id is correct (it should look like exp_…), ` +\n\t\t\t`and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). ` +\n\t\t\t`Deleted, archived, and unpublished experiences cannot be started from a browser embed.`\n\t\t);\n\t}\n\n\tif (apiMessage) return apiMessage;\n\tconst trimmed = text.trim().slice(0, 500);\n\treturn trimmed || `Public session mint failed (${status})`;\n}\n\nexport async function mintPublicSession(\n\texperienceId: string,\n\toptions?: {\n\t\treadonly language?: 'en' | 'es';\n\t\treadonly mode?: 'conversation' | 'presenter';\n\t\t/** @deprecated Response ownership is derived from mode. */\n\t\treadonly responseMode?: 'managed' | 'custom' | 'manual';\n\t\treadonly speechInputMode?: 'auto' | 'manual' | 'off';\n\t\treadonly startButton?: StartButtonOptions;\n\t\treadonly speechOnly?: boolean;\n\t}\n): Promise<SessionManifest> {\n\tconst apiBaseUrl = resolvePublicApiBaseUrl();\n\tconst body: Record<string, unknown> = { experienceId };\n\tif (options?.language) body.language = options.language;\n\tif (options?.mode) body.mode = options.mode;\n\tif (options?.responseMode) body.responseMode = options.responseMode;\n\tif (options?.speechInputMode) body.speechInputMode = options.speechInputMode;\n\tif (options?.startButton) body.startButton = options.startButton;\n\tif (options?.speechOnly !== undefined) body.speechOnly = options.speechOnly;\n\tconst res = await fetch(`${apiBaseUrl}/v1/public-sessions`, {\n\t\tmethod: 'POST',\n\t\theaders: { 'Content-Type': 'application/json' },\n\t\tbody: JSON.stringify(body)\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text();\n\t\tthrow new Error(formatPublicMintError(experienceId, res.status, text));\n\t}\n\tlet raw: unknown;\n\ttry {\n\t\traw = await res.json();\n\t} catch {\n\t\tthrow new Error('Public session mint returned invalid JSON.');\n\t}\n\n\treturn parseSessionManifest(raw);\n}\n\nexport type FetchSessionManifestOptions = {\n\treadonly experienceId: string;\n\treadonly language?: 'en' | 'es';\n\treadonly mode?: 'conversation' | 'presenter';\n\t/** @deprecated Response ownership is derived from mode. */\n\treadonly responseMode?: 'managed' | 'custom' | 'manual';\n\treadonly speechInputMode?: 'auto' | 'manual' | 'off';\n\treadonly startButton?: StartButtonOptions;\n\treadonly speechOnly?: boolean;\n\treadonly signal?: AbortSignal;\n\treadonly timeoutMs?: number;\n};\n\nexport async function fetchSessionManifest(\n\tsessionEndpoint: string,\n\toptions: FetchSessionManifestOptions\n): Promise<SessionManifest> {\n\tconst request = createSessionEndpointRequest(sessionEndpoint, options);\n\n\tconst controller = new AbortController();\n\tconst abortFromCaller = () => controller.abort(options.signal?.reason);\n\tif (options.signal?.aborted) {\n\t\tabortFromCaller();\n\t} else {\n\t\toptions.signal?.addEventListener('abort', abortFromCaller, { once: true });\n\t}\n\tconst timeoutId = globalThis.setTimeout(\n\t\t() => controller.abort(new DOMException('Session endpoint timed out.', 'TimeoutError')),\n\t\toptions.timeoutMs ?? 30_000\n\t);\n\n\tlet res: Response;\n\ttry {\n\t\tres = await fetch(request.url, {\n\t\t\t...request.init,\n\t\t\tsignal: controller.signal\n\t\t});\n\t} finally {\n\t\tglobalThis.clearTimeout(timeoutId);\n\t\toptions.signal?.removeEventListener('abort', abortFromCaller);\n\t}\n\n\tif (!res.ok) {\n\t\tconst text = await res.text();\n\t\tlet message = text.slice(0, 500) || `Session endpoint failed (${res.status})`;\n\t\ttry {\n\t\t\tconst j = JSON.parse(text) as { message?: string };\n\t\t\tif (j.message) message = j.message;\n\t\t} catch {\n\t\t\t/* keep */\n\t\t}\n\t\tthrow new Error(message);\n\t}\n\tif (!res.headers.get('content-type')?.toLowerCase().includes('application/json')) {\n\t\tthrow new Error('Session endpoint must return a JSON Session Manifest.');\n\t}\n\n\tlet raw: unknown;\n\ttry {\n\t\traw = await res.json();\n\t} catch {\n\t\tthrow new Error('Session endpoint returned invalid JSON.');\n\t}\n\n\treturn parseSessionManifest(raw);\n}\n","import type {\n\tConversationProcessorContext,\n\tConversationProcessorFn,\n\tConversationProcessorResult,\n\tNormalizedProcessorSpeech,\n\tProcessorDispatchResult,\n\tSpeakBehavior\n} from './types/sessionInteraction';\n\nexport function isAsyncIterableString(value: unknown): value is AsyncIterable<string> {\n\tif (value == null || typeof value !== 'object') return false;\n\treturn typeof (value as AsyncIterable<string>)[Symbol.asyncIterator] === 'function';\n}\n\nexport function normalizeConversationProcessorResult(\n\tresult: ConversationProcessorResult\n): NormalizedProcessorSpeech {\n\tif (typeof result === 'string') {\n\t\tconst text = result.trim();\n\t\tif (!text) {\n\t\t\tthrow new Error('conversationProcessor returned empty text.');\n\t\t}\n\t\treturn { text };\n\t}\n\n\tconst text = result.text.trim();\n\tif (!text) {\n\t\tthrow new Error('conversationProcessor returned empty text.');\n\t}\n\n\treturn {\n\t\ttext,\n\t\t...(result.characterId ? { characterId: result.characterId } : {}),\n\t\t...(result.behavior ? { behavior: result.behavior } : {})\n\t};\n}\n\nexport async function runConversationProcessor(\n\tprocessor: ConversationProcessorFn,\n\tcontext: ConversationProcessorContext\n): Promise<NormalizedProcessorSpeech> {\n\tconst dispatch = await dispatchConversationProcessor(processor, context);\n\tif (dispatch.kind !== 'complete') {\n\t\tthrow new Error('conversationProcessor returned a stream; use dispatchConversationProcessor.');\n\t}\n\treturn dispatch.speech;\n}\n\nexport async function dispatchConversationProcessor(\n\tprocessor: ConversationProcessorFn,\n\tcontext: ConversationProcessorContext\n): Promise<ProcessorDispatchResult> {\n\tconst result = await processor(context);\n\tif (isAsyncIterableString(result)) {\n\t\treturn { kind: 'stream', stream: result };\n\t}\n\treturn {\n\t\tkind: 'complete',\n\t\tspeech: normalizeConversationProcessorResult(result)\n\t};\n}\n","const LOCAL_PLAYER_DEV_PORT = '3002';\n\nexport function formatPlayerUnreachableMessage(playerOrigin: string): string {\n\tconst url = new URL(playerOrigin);\n\tconst isLocalHost = url.hostname === 'localhost' || url.hostname === '127.0.0.1';\n\n\tif (isLocalHost) {\n\t\tconst devPort = url.port || LOCAL_PLAYER_DEV_PORT;\n\t\treturn (\n\t\t\t`Cannot connect to the Liforma player at ${playerOrigin} — nothing is listening on port ${devPort}. ` +\n\t\t\t`Start the player dev server in player.liforma.ai (npm run dev).`\n\t\t);\n\t}\n\n\treturn (\n\t\t`Cannot connect to the Liforma player at ${playerOrigin}. ` +\n\t\t`The embed did not load; check your network connection and player URL configuration.`\n\t);\n}\n\nexport async function assertPlayerReachable(\n\tembedUrl: string,\n\tplayerOrigin: string\n): Promise<void> {\n\ttry {\n\t\tawait fetch(embedUrl, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t\tsignal: AbortSignal.timeout(8_000)\n\t\t});\n\t} catch {\n\t\tthrow new Error(formatPlayerUnreachableMessage(playerOrigin));\n\t}\n}\n\nexport function postMessageToPlayer(\n\ttarget: Window,\n\tmessage: unknown,\n\tplayerOrigin: string,\n\ttransfer?: Transferable[]\n): void {\n\ttry {\n\t\tif (transfer && transfer.length > 0) {\n\t\t\ttarget.postMessage(message, playerOrigin, transfer);\n\t\t} else {\n\t\t\ttarget.postMessage(message, playerOrigin);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof DOMException && error.name === 'SecurityError') {\n\t\t\tthrow new Error(formatPlayerUnreachableMessage(playerOrigin), { cause: error });\n\t\t}\n\t\tthrow error;\n\t}\n}\n","import type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tSpeakBehavior,\n\tSessionModeChange,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from '../types/sessionInteraction';\nimport type {\n\tCompleteSpeechQueuePolicy,\n\tSpeechAudioFormat,\n\tSpeechInterruptOptions,\n\tSpeechPlayEmbedSource,\n\tStreamingSpeechQueuePolicy\n} from '../speech/types';\n\nexport const EMBED_MESSAGE_SCHEMA_VERSION = 2 as const;\n\n/** Outbound postMessage versions accepted from the player embed. */\nexport const SUPPORTED_EMBED_MESSAGE_SCHEMA_VERSIONS: ReadonlySet<number> = new Set([1, 2]);\n\nexport function isSupportedEmbedMessageSchemaVersion(version: unknown): boolean {\n\treturn typeof version === 'number' && SUPPORTED_EMBED_MESSAGE_SCHEMA_VERSIONS.has(version);\n}\n\nexport type CloseEvent = {\n\treadonly sessionId?: string;\n\treadonly reason: 'user' | 'destroy';\n\treadonly returnUrl?: string;\n};\n\nexport type EmbedOutboundMessage =\n\t| {\n\t\t\treadonly type: 'close';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: CloseEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'stateUpdate';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly state: 'loading' | 'scene' | 'ready' | 'error' };\n\t }\n\t| {\n\t\t\treadonly type: 'commandResult';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly ok: boolean;\n\t\t\t\treadonly error?: string;\n\t\t\t\treadonly result?: unknown;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'userTranscript';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: UserTranscriptUpdate;\n\t }\n\t| {\n\t\t\treadonly type: 'characterSpeechStarted';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: CharacterSpeechEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'characterSpeechEnded';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: CharacterSpeechEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'conversationUpdate';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly conversation: readonly ConversationMessage[] };\n\t }\n\t| {\n\t\t\treadonly type: 'listeningState';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly listening: boolean };\n\t }\n\t| {\n\t\t\treadonly type: 'userSpeechStarted';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: UserSpeechBoundaryEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'userSpeechEnded';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: UserSpeechBoundaryEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'modeChange';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly mode: SessionModeChange };\n\t }\n\t| {\n\t\t\treadonly type: 'message';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: ConversationMessage;\n\t }\n\t| {\n\t\t\treadonly type: 'started';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly mode: 'conversation' | 'presenter' };\n\t }\n\t| {\n\t\t\treadonly type: 'widgetReady';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'widgetExpand';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'widgetCollapse';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'widgetAudioSettings';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly open: boolean };\n\t };\n\nexport type WidgetChromeMode = 'collapsed' | 'loading' | 'expanded';\n\nexport type EmbedInboundMessage =\n\t| {\n\t\t\treadonly type: 'manifest';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly manifest: unknown };\n\t }\n\t| {\n\t\t\treadonly type: 'parentHello';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t }\n\t| {\n\t\t\treadonly type: 'speak';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly text: string;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly behavior?: SpeakBehavior;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'startListening';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly correlationId: string };\n\t }\n\t| {\n\t\t\treadonly type: 'stopListening';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly correlationId: string };\n\t }\n\t| {\n\t\t\treadonly type: 'getConversation';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly correlationId: string };\n\t }\n\t| {\n\t\t\treadonly type: 'listenOnce';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly timeoutMs?: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speakStreamStart';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly behavior?: SpeakBehavior;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speakStreamChunk';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly streamId: string;\n\t\t\t\treadonly text: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speakStreamEnd';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly streamId: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'widgetSetChrome';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly mode: WidgetChromeMode };\n\t }\n\t| {\n\t\t\treadonly type: 'widgetToggleAudioSettings';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'speechPlay';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly source: SpeechPlayEmbedSource;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly transcript?: string;\n\t\t\t\treadonly history?: 'none' | 'commit';\n\t\t\t\treadonly queue?: CompleteSpeechQueuePolicy;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceBegin';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly format: SpeechAudioFormat;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly queue: StreamingSpeechQueuePolicy;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceWrite';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly audio: ArrayBuffer;\n\t\t\t\treadonly byteLength: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceClose';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly transcript?: string;\n\t\t\t\treadonly history?: 'none' | 'commit';\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceCancel';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechInterrupt';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t} & SpeechInterruptOptions;\n\t };\n\nexport type EmbedState = 'loading' | 'scene' | 'ready' | 'error';\n\nconst OUTBOUND_TYPES = new Set([\n\t'close',\n\t'stateUpdate',\n\t'commandResult',\n\t'userTranscript',\n\t'characterSpeechStarted',\n\t'characterSpeechEnded',\n\t'conversationUpdate',\n\t'listeningState',\n\t'userSpeechStarted',\n\t'userSpeechEnded',\n\t'modeChange',\n\t'message',\n\t'started',\n\t'widgetReady',\n\t'widgetExpand',\n\t'widgetCollapse',\n\t'widgetAudioSettings'\n]);\n\nexport function parseOutboundMessage(data: unknown): EmbedOutboundMessage | null {\n\tif (!data || typeof data !== 'object') return null;\n\tconst msg = data as Partial<EmbedOutboundMessage>;\n\tif (!isSupportedEmbedMessageSchemaVersion(msg.schemaVersion)) return null;\n\tif (!msg.type || !OUTBOUND_TYPES.has(msg.type)) return null;\n\tif (\n\t\tmsg.type === 'widgetReady' ||\n\t\tmsg.type === 'widgetExpand' ||\n\t\tmsg.type === 'widgetCollapse'\n\t) {\n\t\treturn msg as EmbedOutboundMessage;\n\t}\n\tif (msg.type === 'widgetAudioSettings') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tif (typeof (payload as { open?: unknown }).open !== 'boolean') return null;\n\t\treturn msg as EmbedOutboundMessage;\n\t}\n\tif (!msg.payload || typeof msg.payload !== 'object') return null;\n\treturn msg as EmbedOutboundMessage;\n}\n\nconst INBOUND_TYPES = new Set([\n\t'manifest',\n\t'parentHello',\n\t'speak',\n\t'startListening',\n\t'stopListening',\n\t'getConversation',\n\t'listenOnce',\n\t'speakStreamStart',\n\t'speakStreamChunk',\n\t'speakStreamEnd',\n\t'widgetSetChrome',\n\t'widgetToggleAudioSettings',\n\t'speechPlay',\n\t'speechUtteranceBegin',\n\t'speechUtteranceWrite',\n\t'speechUtteranceClose',\n\t'speechUtteranceCancel',\n\t'speechInterrupt'\n]);\n\nexport function parseInboundMessage(data: unknown): EmbedInboundMessage | null {\n\tif (!data || typeof data !== 'object') return null;\n\tconst msg = data as Partial<EmbedInboundMessage>;\n\tif (!isSupportedEmbedMessageSchemaVersion(msg.schemaVersion)) return null;\n\tif (!msg.type || !INBOUND_TYPES.has(msg.type)) return null;\n\tif (msg.type === 'parentHello') return msg as EmbedInboundMessage;\n\tif (msg.type === 'widgetToggleAudioSettings') return msg as EmbedInboundMessage;\n\tif (msg.type === 'widgetSetChrome') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tconst mode = (payload as { mode?: unknown }).mode;\n\t\tif (mode !== 'collapsed' && mode !== 'loading' && mode !== 'expanded') return null;\n\t\treturn msg as EmbedInboundMessage;\n\t}\n\tif (msg.type === 'speakStreamChunk') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tconst streamId = (payload as { streamId?: unknown }).streamId;\n\t\tconst text = (payload as { text?: unknown }).text;\n\t\tif (typeof streamId !== 'string' || !streamId.trim()) return null;\n\t\tif (typeof text !== 'string') return null;\n\t\treturn msg as EmbedInboundMessage;\n\t}\n\tconst payload = (msg as { payload?: unknown }).payload;\n\tif (!payload || typeof payload !== 'object') return null;\n\treturn msg as EmbedInboundMessage;\n}\n\nexport function createManifestMessage(manifest: unknown): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'manifest',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\tpayload: { manifest }\n\t};\n}\n\nexport function createParentHelloMessage(): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'parentHello',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION\n\t};\n}\n\nexport function createWidgetSetChromeMessage(mode: WidgetChromeMode): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'widgetSetChrome',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\tpayload: { mode }\n\t};\n}\n\nexport function createWidgetToggleAudioSettingsMessage(): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'widgetToggleAudioSettings',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\tpayload: {}\n\t};\n}\n","import {\n\tassertPlayerReachable,\n\tformatPlayerUnreachableMessage,\n\tpostMessageToPlayer\n} from './playerReachability';\nimport type { CloseEvent, EmbedInboundMessage, EmbedOutboundMessage, EmbedState } from './protocol';\nimport {\n\tcreateManifestMessage,\n\tcreateParentHelloMessage,\n\tcreateWidgetSetChromeMessage,\n\tcreateWidgetToggleAudioSettingsMessage,\n\tEMBED_MESSAGE_SCHEMA_VERSION,\n\tparseOutboundMessage,\n\ttype WidgetChromeMode\n} from './protocol';\nimport type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tSpeakBehavior,\n\tSessionModeChange,\n\tSpeechResult as LegacySpeakResult,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from '../types/sessionInteraction';\nimport type {\n\tCompleteSpeechQueuePolicy,\n\tSpeechAudioFormat,\n\tSpeechInterruptOptions,\n\tSpeechPlayEmbedSource,\n\tSpeechResult,\n\tStreamingSpeechQueuePolicy\n} from '../speech/types';\n\nexport type IframeHostEventMap = {\n\tclose: CloseEvent;\n\tstateUpdate: EmbedState;\n\tuserTranscript: UserTranscriptUpdate;\n\tcharacterSpeechStarted: CharacterSpeechEvent;\n\tcharacterSpeechEnded: CharacterSpeechEvent;\n\tconversationUpdate: readonly ConversationMessage[];\n\tlisteningState: boolean;\n\tstarted: { readonly mode: 'conversation' | 'presenter' };\n\twidgetReady: void;\n\twidgetExpand: void;\n\twidgetCollapse: void;\n\twidgetAudioSettings: boolean;\n};\n\nexport type IframeHostOptions = {\n\treadonly container: HTMLElement;\n\treadonly src: string;\n\treadonly playerOrigin: string;\n\t/** Transparent iframe for ExperienceWidget warm overlay over a thumb. */\n\treadonly transparent?: boolean;\n\treadonly onClose?: (event: CloseEvent) => void;\n\treadonly onStateUpdate?: (state: EmbedState) => void;\n\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void;\n\treadonly onUserSpeechStarted?: (event: UserSpeechBoundaryEvent) => void;\n\treadonly onUserSpeechEnded?: (event: UserSpeechBoundaryEvent) => void;\n\treadonly onCharacterSpeechStarted?: (event: CharacterSpeechEvent) => void;\n\treadonly onCharacterSpeechEnded?: (event: CharacterSpeechEvent) => void;\n\treadonly onConversationUpdate?: (conversation: readonly ConversationMessage[]) => void;\n\treadonly onMessage?: (message: ConversationMessage) => void;\n\treadonly onListeningState?: (listening: boolean) => void;\n\treadonly onModeChange?: (mode: SessionModeChange) => void;\n\treadonly onStarted?: (event: { readonly mode: 'conversation' | 'presenter' }) => void;\n\treadonly onWidgetReady?: () => void;\n\treadonly onWidgetExpand?: () => void;\n\treadonly onWidgetCollapse?: () => void;\n\treadonly onWidgetAudioSettings?: (open: boolean) => void;\n};\n\nexport type IframeHost = {\n\twaitForLoad(): Promise<void>;\n\tpostParentHello(): void;\n\tpostManifest(manifest: unknown): void;\n\tpostWidgetSetChrome(mode: WidgetChromeMode): void;\n\tpostWidgetToggleAudioSettings(): void;\n\tspeak(options: {\n\t\ttext: string;\n\t\tcharacterId?: string;\n\t\tbehavior?: SpeakBehavior;\n\t}): Promise<LegacySpeakResult>;\n\tstartListening(): Promise<void>;\n\tstopListening(): Promise<UtteranceResult>;\n\tlistenOnce(options?: { readonly timeoutMs?: number }): Promise<UtteranceResult>;\n\tspeakProcessorStream(\n\t\tstream: AsyncIterable<string>,\n\t\toptions?: {\n\t\t\treadonly characterId?: string;\n\t\t\treadonly behavior?: SpeakBehavior;\n\t\t\treadonly signal?: AbortSignal;\n\t\t}\n\t): Promise<LegacySpeakResult>;\n\tspeechPlay(options: {\n\t\tsource: SpeechPlayEmbedSource;\n\t\tcharacterId?: string;\n\t\ttranscript?: string;\n\t\thistory?: 'none' | 'commit';\n\t\tqueue?: CompleteSpeechQueuePolicy;\n\t\tsignal?: AbortSignal;\n\t}): Promise<SpeechResult>;\n\tspeechUtteranceBegin(options: {\n\t\tutteranceId: string;\n\t\tformat: SpeechAudioFormat;\n\t\tcharacterId?: string;\n\t\tqueue: StreamingSpeechQueuePolicy;\n\t}): Promise<void>;\n\tspeechUtteranceWrite(options: {\n\t\tutteranceId: string;\n\t\taudio: ArrayBuffer;\n\t\tbyteLength: number;\n\t}): Promise<{ readonly bufferedMs: number }>;\n\tspeechUtteranceClose(options: {\n\t\tutteranceId: string;\n\t\ttranscript?: string;\n\t\thistory?: 'none' | 'commit';\n\t}): Promise<SpeechResult>;\n\tspeechUtteranceCancel(options: { utteranceId: string }): Promise<SpeechResult>;\n\tspeechInterrupt(options: SpeechInterruptOptions): Promise<readonly SpeechResult[]>;\n\tgetConversation(): Promise<readonly ConversationMessage[]>;\n\tdestroy(): void;\n};\n\nfunction newCorrelationId(): string {\n\tif (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n\t\treturn `cmd_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`;\n\t}\n\treturn `cmd_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;\n}\n\nconst SPEECH_WRITE_COMMAND_TIMEOUT_MS = 30_000;\n\nexport function createIframeHost(options: IframeHostOptions): IframeHost {\n\tconst container = options.container;\n\tconst containerPosition = getComputedStyle(container).position;\n\tif (containerPosition === 'static') {\n\t\tcontainer.style.position = 'relative';\n\t}\n\n\tconst iframe = document.createElement('iframe');\n\tiframe.src = options.src;\n\tiframe.title = 'Liforma experience';\n\tiframe.setAttribute(\n\t\t'allow',\n\t\t'microphone; autoplay; clipboard-read; clipboard-write'\n\t);\n\t// Absolute fill so the player viewport matches the host box even when the host\n\t// height comes from flex or min-height (percentage height:100% often collapses).\n\tiframe.style.cssText = options.transparent\n\t\t? 'display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;'\n\t\t: 'display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;';\n\tif (options.transparent) {\n\t\tiframe.setAttribute('allowtransparency', 'true');\n\t}\n\n\tlet destroyed = false;\n\tconst pendingCommands = new Map<\n\t\tstring,\n\t\t{\n\t\t\tresolve: (value: unknown) => void;\n\t\t\treject: (error: Error) => void;\n\t\t}\n\t>();\n\n\tconst loadPromise = new Promise<void>((resolve, reject) => {\n\t\tconst onLoad = () => {\n\t\t\tcleanup();\n\t\t\tvoid assertPlayerReachable(options.src, options.playerOrigin).then(resolve, reject);\n\t\t};\n\t\tconst onError = () => {\n\t\t\tcleanup();\n\t\t\treject(new Error(formatPlayerUnreachableMessage(options.playerOrigin)));\n\t\t};\n\t\tconst cleanup = () => {\n\t\t\tiframe.removeEventListener('load', onLoad);\n\t\t\tiframe.removeEventListener('error', onError);\n\t\t};\n\t\tiframe.addEventListener('load', onLoad);\n\t\tiframe.addEventListener('error', onError);\n\t});\n\n\tconst onMessage = (event: MessageEvent) => {\n\t\tif (destroyed) return;\n\t\tif (event.source !== iframe.contentWindow) return;\n\t\tif (event.origin !== options.playerOrigin) return;\n\n\t\tconst message = parseOutboundMessage(event.data);\n\t\tif (!message) return;\n\n\t\tswitch (message.type) {\n\t\t\tcase 'close':\n\t\t\t\toptions.onClose?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'stateUpdate':\n\t\t\t\toptions.onStateUpdate?.(message.payload.state);\n\t\t\t\tbreak;\n\t\t\tcase 'commandResult': {\n\t\t\t\tconst pending = pendingCommands.get(message.payload.correlationId);\n\t\t\t\tif (!pending) return;\n\t\t\t\tpendingCommands.delete(message.payload.correlationId);\n\t\t\t\tif (message.payload.ok) {\n\t\t\t\t\tpending.resolve(message.payload.result);\n\t\t\t\t} else {\n\t\t\t\t\tpending.reject(new Error(message.payload.error ?? 'Command failed.'));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'userTranscript':\n\t\t\t\toptions.onUserTranscript?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'characterSpeechStarted':\n\t\t\t\toptions.onCharacterSpeechStarted?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'characterSpeechEnded':\n\t\t\t\toptions.onCharacterSpeechEnded?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'conversationUpdate':\n\t\t\t\toptions.onConversationUpdate?.(message.payload.conversation);\n\t\t\t\tbreak;\n\t\t\tcase 'listeningState':\n\t\t\t\toptions.onListeningState?.(message.payload.listening);\n\t\t\t\tbreak;\n\t\t\tcase 'userSpeechStarted':\n\t\t\t\toptions.onUserSpeechStarted?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'userSpeechEnded':\n\t\t\t\toptions.onUserSpeechEnded?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'modeChange':\n\t\t\t\toptions.onModeChange?.(message.payload.mode);\n\t\t\t\tbreak;\n\t\t\tcase 'message':\n\t\t\t\toptions.onMessage?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'started':\n\t\t\t\toptions.onStarted?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'widgetReady':\n\t\t\t\toptions.onWidgetReady?.();\n\t\t\t\tbreak;\n\t\t\tcase 'widgetExpand':\n\t\t\t\toptions.onWidgetExpand?.();\n\t\t\t\tbreak;\n\t\t\tcase 'widgetCollapse':\n\t\t\t\toptions.onWidgetCollapse?.();\n\t\t\t\tbreak;\n\t\t\tcase 'widgetAudioSettings':\n\t\t\t\toptions.onWidgetAudioSettings?.(message.payload.open);\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\twindow.addEventListener('message', onMessage);\n\tcontainer.replaceChildren(iframe);\n\t// Absolute iframe does not contribute to parent height — keep a usable floor when\n\t// the host only sized itself from previous in-flow content.\n\tif (container.clientHeight < 2 && !container.style.minHeight) {\n\t\tconst computedMin = getComputedStyle(container).minHeight;\n\t\tif (computedMin === '0px' || computedMin === 'auto') {\n\t\t\tcontainer.style.minHeight = '480px';\n\t\t}\n\t}\n\n\tconst postToIframe = (message: EmbedInboundMessage, transfer?: Transferable[]) => {\n\t\tif (destroyed) return;\n\t\tconst target = iframe.contentWindow;\n\t\tif (!target) {\n\t\t\tthrow new Error(formatPlayerUnreachableMessage(options.playerOrigin));\n\t\t}\n\t\tpostMessageToPlayer(target, message, options.playerOrigin, transfer);\n\t};\n\n\tconst postCommand = <T>(\n\t\tmessage: EmbedInboundMessage,\n\t\ttimeoutMs = 120_000,\n\t\ttransfer?: Transferable[]\n\t): Promise<T> => {\n\t\tconst correlationId =\n\t\t\tmessage.type !== 'parentHello' && message.payload && 'correlationId' in message.payload\n\t\t\t\t? (message.payload.correlationId as string)\n\t\t\t\t: newCorrelationId();\n\n\t\tif (message.type !== 'parentHello' && message.payload && 'correlationId' in message.payload) {\n\t\t\t// correlationId already set\n\t\t} else if (message.type !== 'parentHello' && message.payload) {\n\t\t\t(message.payload as { correlationId: string }).correlationId = correlationId;\n\t\t}\n\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tpendingCommands.set(correlationId, {\n\t\t\t\tresolve: (value) => resolve(value as T),\n\t\t\t\treject\n\t\t\t});\n\t\t\tpostToIframe(message, transfer);\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (!pendingCommands.has(correlationId)) return;\n\t\t\t\tpendingCommands.delete(correlationId);\n\t\t\t\treject(new Error('Timed out waiting for player command result.'));\n\t\t\t}, timeoutMs);\n\t\t});\n\t};\n\n\treturn {\n\t\twaitForLoad() {\n\t\t\treturn loadPromise;\n\t\t},\n\t\tpostParentHello() {\n\t\t\tpostToIframe(createParentHelloMessage());\n\t\t},\n\t\tpostManifest(manifest) {\n\t\t\tif (destroyed) return;\n\t\t\tconst target = iframe.contentWindow;\n\t\t\tif (!target) {\n\t\t\t\tthrow new Error('Liforma embed iframe is not ready.');\n\t\t\t}\n\t\t\tconst message = createManifestMessage(manifest);\n\t\t\tconst postOnce = () => {\n\t\t\t\tif (destroyed) return;\n\t\t\t\tpostMessageToPlayer(target, message, options.playerOrigin);\n\t\t\t};\n\t\t\tpostOnce();\n\t\t\tfor (let attempt = 1; attempt <= 12; attempt += 1) {\n\t\t\t\twindow.setTimeout(postOnce, attempt * 75);\n\t\t\t}\n\t\t},\n\t\tpostWidgetSetChrome(mode) {\n\t\t\tpostToIframe(createWidgetSetChromeMessage(mode));\n\t\t},\n\t\tpostWidgetToggleAudioSettings() {\n\t\t\tpostToIframe(createWidgetToggleAudioSettingsMessage());\n\t\t},\n\t\tspeak(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<LegacySpeakResult>({\n\t\t\t\ttype: 'speak',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\ttext: options.text,\n\t\t\t\t\t...(options.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t...(options.behavior ? { behavior: options.behavior } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tstartListening() {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<void>({\n\t\t\t\ttype: 'startListening',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: { correlationId }\n\t\t\t});\n\t\t},\n\t\tstopListening() {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<UtteranceResult>({\n\t\t\t\ttype: 'stopListening',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: { correlationId }\n\t\t\t});\n\t\t},\n\t\tlistenOnce(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<UtteranceResult>({\n\t\t\t\ttype: 'listenOnce',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\t...(options?.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tasync speakProcessorStream(stream, options) {\n\t\t\tconst startCorrelationId = newCorrelationId();\n\t\t\tconst endCorrelationId = newCorrelationId();\n\t\t\tconst started = await postCommand<{ streamId: string }>({\n\t\t\t\ttype: 'speakStreamStart',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId: startCorrelationId,\n\t\t\t\t\t...(options?.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t...(options?.behavior ? { behavior: options.behavior } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst streamId = started.streamId;\n\t\t\ttry {\n\t\t\t\tfor await (const chunk of stream) {\n\t\t\t\t\tif (options?.signal?.aborted) {\n\t\t\t\t\t\tthrow new DOMException('Processor stream aborted.', 'AbortError');\n\t\t\t\t\t}\n\t\t\t\t\tif (!chunk) continue;\n\t\t\t\t\tpostToIframe({\n\t\t\t\t\t\ttype: 'speakStreamChunk',\n\t\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\t\tpayload: { streamId, text: chunk }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (options?.signal?.aborted) {\n\t\t\t\t\tthrow new DOMException('Processor stream aborted.', 'AbortError');\n\t\t\t\t}\n\t\t\t\treturn await postCommand<LegacySpeakResult>({\n\t\t\t\t\ttype: 'speakStreamEnd',\n\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\tpayload: { correlationId: endCorrelationId, streamId }\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait postCommand<LegacySpeakResult>({\n\t\t\t\t\t\ttype: 'speakStreamEnd',\n\t\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\t\tpayload: { correlationId: endCorrelationId, streamId }\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t/* stream may already be torn down */\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tspeechPlay(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\tconst transfer: Transferable[] = [];\n\t\t\tif (options.source.kind === 'pcm' || options.source.kind === 'encoded') {\n\t\t\t\ttransfer.push(options.source.data);\n\t\t\t}\n\t\t\treturn postCommand<SpeechResult>(\n\t\t\t\t{\n\t\t\t\t\ttype: 'speechPlay',\n\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\tpayload: {\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tsource: options.source,\n\t\t\t\t\t\t...(options.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {}),\n\t\t\t\t\t\t...(options.history ? { history: options.history } : {}),\n\t\t\t\t\t\t...(options.queue ? { queue: options.queue } : {})\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t120_000,\n\t\t\t\ttransfer\n\t\t\t);\n\t\t},\n\t\tspeechUtteranceBegin(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<void>({\n\t\t\t\ttype: 'speechUtteranceBegin',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\tformat: options.format,\n\t\t\t\t\tqueue: options.queue,\n\t\t\t\t\t...(options.characterId ? { characterId: options.characterId } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechUtteranceWrite(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<{ bufferedMs: number }>(\n\t\t\t\t{\n\t\t\t\t\ttype: 'speechUtteranceWrite',\n\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\tpayload: {\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\t\taudio: options.audio,\n\t\t\t\t\t\tbyteLength: options.byteLength\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tSPEECH_WRITE_COMMAND_TIMEOUT_MS,\n\t\t\t\t[options.audio]\n\t\t\t);\n\t\t},\n\t\tspeechUtteranceClose(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<SpeechResult>({\n\t\t\t\ttype: 'speechUtteranceClose',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {}),\n\t\t\t\t\t...(options.history ? { history: options.history } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechUtteranceCancel(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<SpeechResult>({\n\t\t\t\ttype: 'speechUtteranceCancel',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechInterrupt(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<readonly SpeechResult[]>({\n\t\t\t\ttype: 'speechInterrupt',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\t...options\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tgetConversation() {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<readonly ConversationMessage[]>({\n\t\t\t\ttype: 'getConversation',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: { correlationId }\n\t\t\t});\n\t\t},\n\t\tdestroy() {\n\t\t\tif (destroyed) return;\n\t\t\tdestroyed = true;\n\t\t\tfor (const pending of pendingCommands.values()) {\n\t\t\t\tpending.reject(new Error('Iframe host destroyed.'));\n\t\t\t}\n\t\t\tpendingCommands.clear();\n\t\t\twindow.removeEventListener('message', onMessage);\n\t\t\tiframe.remove();\n\t\t}\n\t};\n}\n\n","export type ReadyGate<T> = {\n\tsetValue(value: T): void;\n\tmarkReady(): void;\n};\n\n/** Emits once after both an asynchronous value and readiness signal are available. */\nexport function createReadyGate<T>(onReady: (value: T) => void): ReadyGate<T> {\n\tlet value: T | undefined;\n\tlet ready = false;\n\tlet emitted = false;\n\n\tconst emitIfPossible = (): void => {\n\t\tif (emitted || !ready || value === undefined) return;\n\t\temitted = true;\n\t\tonReady(value);\n\t};\n\n\treturn {\n\t\tsetValue(nextValue) {\n\t\t\tvalue = nextValue;\n\t\t\temitIfPossible();\n\t\t},\n\t\tmarkReady() {\n\t\t\tready = true;\n\t\t\temitIfPossible();\n\t\t}\n\t};\n}\n","import { useExplicitLocalStack } from '../../shims/localStack';\n\nconst PRODUCTION_PLAYER_EMBED_URL = 'https://player.liforma.ai/embed';\nconst LOCAL_PLAYER_EMBED_URL = 'http://localhost:3002/embed';\n\nfunction readConfiguredEmbedUrl(): string | null {\n\tconst globalValue = (globalThis as { __LIFORMA_PLAYER_EMBED_URL?: string })\n\t\t.__LIFORMA_PLAYER_EMBED_URL;\n\tif (globalValue?.trim()) {\n\t\treturn globalValue.trim().replace(/\\/$/, '');\n\t}\n\n\tif (typeof document === 'undefined') {\n\t\treturn null;\n\t}\n\n\tconst script =\n\t\tdocument.querySelector('script[data-liforma-sdk][src*=\"client.js\"]') ??\n\t\tdocument.querySelector('script[src*=\"/sdk/v2/client.js\"]');\n\tconst fromScript = script?.getAttribute('data-player-embed-url')?.trim();\n\tif (fromScript) {\n\t\treturn fromScript.replace(/\\/$/, '');\n\t}\n\n\treturn null;\n}\n\n/**\n * Hosted player embed document URL (iframe `src` base).\n *\n * Defaults to production. Local stack is opt-in only — never inferred from\n * `localhost` hostname (third-party demos run on localhost against production).\n *\n * Override order:\n * 1. `window.__LIFORMA_PLAYER_EMBED_URL`\n * 2. `data-player-embed-url` on the SDK script tag\n * 3. `window.__LIFORMA_STACK === 'local'` or host `?stack=local` → http://localhost:3002/embed\n * 4. production → https://player.liforma.ai/embed\n */\nexport function resolvePublicPlayerEmbedUrl(): string {\n\tconst configured = readConfiguredEmbedUrl();\n\tif (configured) {\n\t\treturn configured.endsWith('/embed') ? configured : `${configured}/embed`;\n\t}\n\n\tif (useExplicitLocalStack()) {\n\t\treturn LOCAL_PLAYER_EMBED_URL;\n\t}\n\n\treturn PRODUCTION_PLAYER_EMBED_URL;\n}\n\nexport function buildManifestEmbedUrl(\n\tembedBaseUrl?: string,\n\tdebug?: boolean,\n\tlocationId?: string,\n\tavatarId?: string,\n\tfit?: 'full' | 'face',\n\tui?: 'widget',\n\tshowClose?: boolean\n): string {\n\tconst base = (embedBaseUrl ?? resolvePublicPlayerEmbedUrl()).replace(/\\/$/, '');\n\tconst embedRoot = base.endsWith('/embed') ? base : `${base}/embed`;\n\tconst url = new URL(embedRoot);\n\tconst loc = locationId?.trim();\n\tif (loc) {\n\t\turl.searchParams.set('locationId', loc);\n\t}\n\tconst avatar = avatarId?.trim();\n\tif (avatar) {\n\t\turl.searchParams.set('avatarId', avatar);\n\t}\n\tif (fit === 'face') {\n\t\turl.searchParams.set('fit', 'face');\n\t}\n\tif (ui === 'widget') {\n\t\turl.searchParams.set('ui', 'widget');\n\t}\n\tif (showClose) {\n\t\turl.searchParams.set('close', '1');\n\t}\n\tif (debug) {\n\t\turl.searchParams.set('debug', 'true');\n\t}\n\treturn withEmbedParentOrigin(url.toString());\n}\n\nexport function buildPublicEmbedUrl(\n\texperienceId: string,\n\tembedBaseUrl?: string,\n\tlanguage?: 'en' | 'es',\n\tlocationId?: string,\n\tavatarId?: string,\n\tdebug?: boolean\n): string {\n\tconst base = (embedBaseUrl ?? resolvePublicPlayerEmbedUrl()).replace(/\\/$/, '');\n\tconst embedRoot = base.endsWith('/embed') ? base : `${base}/embed`;\n\tconst url = new URL(embedRoot);\n\turl.searchParams.set('experienceId', experienceId);\n\tif (language && language !== 'en') {\n\t\turl.searchParams.set('language', language);\n\t}\n\tconst loc = locationId?.trim();\n\tif (loc) {\n\t\turl.searchParams.set('locationId', loc);\n\t}\n\tconst avatar = avatarId?.trim();\n\tif (avatar) {\n\t\turl.searchParams.set('avatarId', avatar);\n\t}\n\tif (debug) {\n\t\turl.searchParams.set('debug', 'true');\n\t}\n\treturn withEmbedParentOrigin(url.toString());\n}\n\n/** Tell the player embed which origin may receive postMessage events (SDK parent page). */\nexport function withEmbedParentOrigin(embedUrl: string): string {\n\tif (typeof location === 'undefined') return embedUrl;\n\tconst url = new URL(embedUrl);\n\turl.searchParams.set('parentOrigin', location.origin);\n\treturn url.toString();\n}\n\nexport function resolvePlayerOrigin(embedUrl: string): string {\n\treturn new URL(embedUrl).origin;\n}\n","import { parseSessionManifest } from './types/sessionManifestSchema';\nimport type { SessionManifest } from './types/sessionManifest';\n\nfunction speechOnlyCapabilities(capabilities: readonly string[]): readonly string[] {\n\tconst withoutAvatar = capabilities.filter((capability) => capability !== 'avatar');\n\tif (withoutAvatar.includes('voice')) {\n\t\treturn withoutAvatar;\n\t}\n\treturn ['voice', ...withoutAvatar];\n}\n\n/**\n * Strip avatar rendering and location scene assets from a Session Manifest.\n * Used when integrators request voice-only mode without authoring a separate experience.\n */\nexport function applySpeechOnlyManifest(manifest: SessionManifest): SessionManifest {\n\treturn parseSessionManifest({\n\t\t...manifest,\n\t\tcapabilities: speechOnlyCapabilities(manifest.capabilities),\n\t\tpipeline: {\n\t\t\t...manifest.pipeline,\n\t\t\tanimation: {\n\t\t\t\tenabled: false,\n\t\t\t\tsource: 'none',\n\t\t\t\tconfig: {}\n\t\t\t}\n\t\t},\n\t\tlocation: {\n\t\t\tlocationId: manifest.location?.locationId?.trim() || 'speech-only',\n\t\t\ttitle: manifest.location?.title?.trim() || ''\n\t\t}\n\t});\n}\n","import type { ReadyEvent } from './experience';\nimport type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tConversationProcessorErrorEvent,\n\tStartedEvent,\n\tSessionModeChange,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate\n} from './types/sessionInteraction';\n\nexport type ExperienceEvents = {\n\treadonly ready: ReadyEvent;\n\treadonly started: StartedEvent;\n\treadonly userTranscript: UserTranscriptUpdate;\n\treadonly userSpeechStarted: UserSpeechBoundaryEvent;\n\treadonly userSpeechEnded: UserSpeechBoundaryEvent;\n\treadonly characterSpeechStarted: CharacterSpeechEvent;\n\treadonly characterSpeechEnded: CharacterSpeechEvent;\n\treadonly conversationUpdate: readonly ConversationMessage[];\n\treadonly message: ConversationMessage;\n\treadonly listeningState: boolean;\n\treadonly modeChange: SessionModeChange;\n\treadonly conversationProcessorError: ConversationProcessorErrorEvent;\n};\n\nexport type ExperienceEventName = keyof ExperienceEvents;\n\ntype HandlerSet<K extends ExperienceEventName> = Set<(event: ExperienceEvents[K]) => void>;\n\nexport type ExperienceEventRegistry = {\n\treadonly [K in ExperienceEventName]: HandlerSet<K>;\n};\n\nexport function createExperienceEventRegistry(): ExperienceEventRegistry {\n\treturn {\n\t\tready: new Set(),\n\t\tstarted: new Set(),\n\t\tuserTranscript: new Set(),\n\t\tuserSpeechStarted: new Set(),\n\t\tuserSpeechEnded: new Set(),\n\t\tcharacterSpeechStarted: new Set(),\n\t\tcharacterSpeechEnded: new Set(),\n\t\tconversationUpdate: new Set(),\n\t\tmessage: new Set(),\n\t\tlisteningState: new Set(),\n\t\tmodeChange: new Set(),\n\t\tconversationProcessorError: new Set()\n\t};\n}\n\nexport function subscribeExperienceEvent<K extends ExperienceEventName>(\n\tregistry: ExperienceEventRegistry,\n\tevent: K,\n\thandler: (payload: ExperienceEvents[K]) => void\n): () => void {\n\tregistry[event].add(handler);\n\treturn () => registry[event].delete(handler);\n}\n\nexport function emitExperienceEvent<K extends ExperienceEventName>(\n\tregistry: ExperienceEventRegistry,\n\tevent: K,\n\tpayload: ExperienceEvents[K]\n): void {\n\tfor (const handler of registry[event]) {\n\t\thandler(payload);\n\t}\n}\n\nexport function clearExperienceEventRegistry(registry: ExperienceEventRegistry): void {\n\tfor (const key of Object.keys(registry) as ExperienceEventName[]) {\n\t\tregistry[key].clear();\n\t}\n}\n","/**\n * Phase A public speech contract for Experience.speech\n * (docs/plans/2026/08/experience-play-audio-api.plan.md).\n */\n\nexport type SpeechAudioFormat = {\n\treadonly encoding: 'pcm_s16le';\n\treadonly sampleRate: number;\n\treadonly channels: 1;\n};\n\n/** Complete one-shot ops only (`speak` / `play`). */\nexport type CompleteSpeechQueuePolicy = 'append' | 'replace-active' | 'replace-all';\n\n/** Live streams only — `append` is forbidden. */\nexport type StreamingSpeechQueuePolicy = 'replace-active' | 'replace-all';\n\nexport type SpeechTerminalStatus = 'completed' | 'interrupted' | 'cancelled' | 'destroyed';\n\nexport type SpeechAnimationMode = 'tracked' | 'partially-tracked' | 'energy-fallback' | 'none';\n\nexport type SpeechResult = {\n\treadonly utteranceId: string;\n\treadonly characterId: string;\n\treadonly status: SpeechTerminalStatus;\n\treadonly durationMs: number;\n\treadonly transcript?: string;\n\treadonly animation: {\n\t\treadonly mode: SpeechAnimationMode;\n\t\treadonly trackedDurationMs: number;\n\t\treadonly fallbackDurationMs: number;\n\t\treadonly warningCodes?: readonly string[];\n\t};\n};\n\nexport type SpeechInterruptOptions =\n\t| { readonly utteranceId: string }\n\t| { readonly characterId: string }\n\t| { readonly scope?: 'active' | 'all' };\n\nexport type SpeechSpeakOptions = {\n\treadonly text: string;\n\treadonly characterId?: string;\n\treadonly queue?: CompleteSpeechQueuePolicy;\n\treadonly signal?: AbortSignal;\n};\n\n/** Raw PCM one-shot (Phase A). */\nexport type SpeechPlayPcmAudio = {\n\treadonly data: ArrayBuffer | Uint8Array;\n\treadonly format: SpeechAudioFormat;\n};\n\n/**\n * Encoded media bytes (wav/mp3/…). Player decodes via Web Audio — not api/models.\n * `encoding` is a MIME type such as `audio/mpeg` or `audio/wav`.\n */\nexport type SpeechPlayEncodedAudio = {\n\treadonly data: ArrayBuffer | Uint8Array | Blob;\n\treadonly encoding: string;\n\t/** Preferred pcm sample rate after decode (default 24000 when decoded rate is unsupported). */\n\treadonly sampleRate?: number;\n};\n\n/** Fetch + decode in the player (URL must allow CORS from player.liforma.ai). */\nexport type SpeechPlayUrlAudio = {\n\treadonly url: string;\n\treadonly sampleRate?: number;\n};\n\n/**\n * Live audio track. Captured to PCM in the **host** SDK (not transferable across the embed).\n * Prefer `createUtterance({ track })` for long streams; `play({ audio: { track } })` runs until\n * the track ends then closes the utterance.\n */\nexport type SpeechPlayMediaStreamAudio = {\n\treadonly track: MediaStreamTrack;\n\t/** Target pcm sample rate after capture (default 24000). */\n\treadonly sampleRate?: number;\n};\n\nexport type SpeechPlayAudio =\n\t| SpeechPlayPcmAudio\n\t| SpeechPlayEncodedAudio\n\t| SpeechPlayUrlAudio\n\t| SpeechPlayMediaStreamAudio;\n\nexport type SpeechPlayOptions = {\n\treadonly audio: SpeechPlayAudio;\n\treadonly characterId?: string;\n\treadonly transcript?: string;\n\treadonly history?: 'none' | 'commit';\n\treadonly queue?: CompleteSpeechQueuePolicy;\n\treadonly signal?: AbortSignal;\n};\n\n/** Embed / player wire format for {@link SpeechPlayOptions.audio}. */\nexport type SpeechPlayEmbedSource =\n\t| {\n\t\t\treadonly kind: 'pcm';\n\t\t\treadonly data: ArrayBuffer;\n\t\t\treadonly format: SpeechAudioFormat;\n\t }\n\t| {\n\t\t\treadonly kind: 'encoded';\n\t\t\treadonly data: ArrayBuffer;\n\t\t\treadonly encoding: string;\n\t\t\treadonly sampleRate?: number;\n\t }\n\t| {\n\t\t\treadonly kind: 'url';\n\t\t\treadonly url: string;\n\t\t\treadonly sampleRate?: number;\n\t };\n\nexport function isSpeechPlayPcmAudio(audio: SpeechPlayAudio): audio is SpeechPlayPcmAudio {\n\treturn (\n\t\t'data' in audio &&\n\t\t'format' in audio &&\n\t\t(audio as SpeechPlayPcmAudio).format != null &&\n\t\t!('track' in audio)\n\t);\n}\n\nexport function isSpeechPlayUrlAudio(audio: SpeechPlayAudio): audio is SpeechPlayUrlAudio {\n\treturn 'url' in audio && typeof (audio as SpeechPlayUrlAudio).url === 'string';\n}\n\nexport function isSpeechPlayMediaStreamAudio(\n\taudio: SpeechPlayAudio\n): audio is SpeechPlayMediaStreamAudio {\n\tif (!('track' in audio)) return false;\n\tconst track = (audio as SpeechPlayMediaStreamAudio).track as unknown;\n\tif (track == null || typeof track !== 'object') return false;\n\tif (typeof MediaStreamTrack !== 'undefined' && track instanceof MediaStreamTrack) {\n\t\treturn true;\n\t}\n\t// Duck-type for non-DOM / test environments.\n\treturn 'kind' in track && 'readyState' in track;\n}\n\nexport function isSpeechPlayEncodedAudio(audio: SpeechPlayAudio): audio is SpeechPlayEncodedAudio {\n\treturn (\n\t\t!isSpeechPlayPcmAudio(audio) &&\n\t\t!isSpeechPlayUrlAudio(audio) &&\n\t\t!isSpeechPlayMediaStreamAudio(audio) &&\n\t\t'encoding' in audio &&\n\t\ttypeof (audio as SpeechPlayEncodedAudio).encoding === 'string'\n\t);\n}\n\nexport type SpeechCreateUtteranceOptions = {\n\t/**\n\t * Required unless `track` is set. When `track` is provided without `format`, defaults to\n\t * pcm_s16le mono at `sampleRate` (or 24000).\n\t */\n\treadonly format?: SpeechAudioFormat;\n\t/** Optional live track — host captures and writes until the track ends. */\n\treadonly track?: MediaStreamTrack;\n\t/** Used with `track` when `format` is omitted (default 24000). */\n\treadonly sampleRate?: number;\n\treadonly characterId?: string;\n\treadonly queue?: StreamingSpeechQueuePolicy;\n\treadonly signal?: AbortSignal;\n};\n\nexport type SpeechUtteranceCloseOptions = {\n\treadonly transcript?: string;\n\treadonly history?: 'none' | 'commit';\n};\n\nexport type SpeechWriteOptions = {\n\treadonly timeoutMs?: number;\n};\n\nexport type SpeechUtterance = {\n\treadonly id: string;\n\treadonly characterId: string;\n\treadonly result: Promise<SpeechResult>;\n\twrite(audio: ArrayBuffer | Uint8Array, options?: SpeechWriteOptions): Promise<void>;\n\tclose(options?: SpeechUtteranceCloseOptions): Promise<SpeechResult>;\n\tcancel(): Promise<SpeechResult>;\n};\n\nexport type SpeechController = {\n\tspeak(options: SpeechSpeakOptions): Promise<SpeechResult>;\n\tplay(options: SpeechPlayOptions): Promise<SpeechResult>;\n\tcreateUtterance(options: SpeechCreateUtteranceOptions): SpeechUtterance;\n\tinterrupt(options?: SpeechInterruptOptions): Promise<readonly SpeechResult[]>;\n};\n\n/** Accepted PCM sample rates (Phase A). */\nexport const SPEECH_ACCEPTED_SAMPLE_RATES = [\n\t8000, 16000, 22050, 24000, 44100, 48000\n] as const;\n\nexport const SPEECH_LIMITS = {\n\tMAX_CHUNK_BYTES: 64 * 1024,\n\tRECOMMENDED_CHUNK_MS_MIN: 20,\n\tRECOMMENDED_CHUNK_MS_MAX: 200,\n\tMAX_BUFFERED_AUDIO_MS: 8_000,\n\tPLAYBACK_JITTER_BUFFER_MS: 150,\n\tPLAYBACK_JITTER_BUFFER_MS_MIN: 80,\n\tPLAYBACK_JITTER_BUFFER_MS_MAX: 250,\n\tMAX_UTTERANCE_DURATION_MS: 90_000,\n\tMAX_PENDING_WRITES: 8,\n\tDEFAULT_WRITE_TIMEOUT_MS: 5_000\n} as const;\n\nexport class UnsupportedSpeechOperationError extends Error {\n\treadonly name = 'UnsupportedSpeechOperationError';\n\tconstructor(\n\t\treadonly operation: string,\n\t\treadonly requiredCapability: string\n\t) {\n\t\tsuper(`Speech operation \"${operation}\" requires capability \"${requiredCapability}\".`);\n\t}\n}\n\nexport class SpeechUtteranceClosedError extends Error {\n\treadonly name = 'SpeechUtteranceClosedError';\n\tconstructor(message = 'Cannot write to a closed or cancelled speech utterance.') {\n\t\tsuper(message);\n\t}\n}\n\nexport class SpeechRuntimeError extends Error {\n\treadonly name = 'SpeechRuntimeError';\n\tconstructor(message: string, options?: { cause?: unknown }) {\n\t\tsuper(message, options);\n\t}\n}\n\nexport class SpeechBufferTimeoutError extends Error {\n\treadonly name = 'SpeechBufferTimeoutError';\n\tconstructor(message = 'Timed out waiting for speech buffer capacity.') {\n\t\tsuper(message);\n\t}\n}\n\nexport function emptyAnimationResult(\n\tmode: SpeechAnimationMode = 'none'\n): SpeechResult['animation'] {\n\treturn {\n\t\tmode,\n\t\ttrackedDurationMs: 0,\n\t\tfallbackDurationMs: 0\n\t};\n}\n\nexport function isAcceptedSampleRate(rate: number): boolean {\n\treturn (SPEECH_ACCEPTED_SAMPLE_RATES as readonly number[]).includes(rate);\n}\n\nexport function assertPcmFormat(format: SpeechAudioFormat): void {\n\tif (format.encoding !== 'pcm_s16le') {\n\t\tthrow new SpeechRuntimeError(`Unsupported audio encoding: ${format.encoding}`);\n\t}\n\tif (format.channels !== 1) {\n\t\tthrow new SpeechRuntimeError(`Unsupported channel count: ${format.channels}`);\n\t}\n\tif (!isAcceptedSampleRate(format.sampleRate)) {\n\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${format.sampleRate}`);\n\t}\n}\n\nexport function assertSpeechPlayAudio(audio: SpeechPlayAudio): void {\n\tif (isSpeechPlayPcmAudio(audio)) {\n\t\tassertPcmFormat(audio.format);\n\t\treturn;\n\t}\n\tif (isSpeechPlayUrlAudio(audio)) {\n\t\tconst url = audio.url.trim();\n\t\tif (!url) throw new SpeechRuntimeError('Audio URL must be non-empty.');\n\t\tif (audio.sampleRate !== undefined && !isAcceptedSampleRate(audio.sampleRate)) {\n\t\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${audio.sampleRate}`);\n\t\t}\n\t\treturn;\n\t}\n\tif (isSpeechPlayMediaStreamAudio(audio)) {\n\t\tif (audio.track.kind !== 'audio') {\n\t\t\tthrow new SpeechRuntimeError('speech.play track must be an audio MediaStreamTrack.');\n\t\t}\n\t\tif (audio.sampleRate !== undefined && !isAcceptedSampleRate(audio.sampleRate)) {\n\t\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${audio.sampleRate}`);\n\t\t}\n\t\treturn;\n\t}\n\tif (isSpeechPlayEncodedAudio(audio)) {\n\t\tconst encoding = audio.encoding.trim().toLowerCase();\n\t\tif (!encoding) throw new SpeechRuntimeError('Encoded audio MIME type is required.');\n\t\tif (encoding === 'pcm_s16le') {\n\t\t\tthrow new SpeechRuntimeError('Use format: { encoding: \"pcm_s16le\", … } for raw PCM.');\n\t\t}\n\t\tif (audio.sampleRate !== undefined && !isAcceptedSampleRate(audio.sampleRate)) {\n\t\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${audio.sampleRate}`);\n\t\t}\n\t\treturn;\n\t}\n\tthrow new SpeechRuntimeError('Unsupported speech.play audio shape.');\n}\n\nexport function resolveCreateUtteranceFormat(\n\toptions: SpeechCreateUtteranceOptions\n): SpeechAudioFormat {\n\tif (options.format) {\n\t\tassertPcmFormat(options.format);\n\t\treturn options.format;\n\t}\n\tif (options.track) {\n\t\tconst sampleRate = options.sampleRate ?? 24_000;\n\t\tconst format: SpeechAudioFormat = {\n\t\t\tencoding: 'pcm_s16le',\n\t\t\tsampleRate,\n\t\t\tchannels: 1\n\t\t};\n\t\tassertPcmFormat(format);\n\t\treturn format;\n\t}\n\tthrow new SpeechRuntimeError('createUtterance requires format or track.');\n}\n\nexport function toUint8Array(data: ArrayBuffer | Uint8Array): Uint8Array {\n\treturn data instanceof Uint8Array ? data : new Uint8Array(data);\n}\n\nexport function queuePolicyToEmbedBehavior(\n\tqueue: CompleteSpeechQueuePolicy | StreamingSpeechQueuePolicy | undefined\n): 'enqueue' | 'interrupt' {\n\tif (queue === 'replace-active' || queue === 'replace-all') return 'interrupt';\n\treturn 'enqueue';\n}\n","/**\n * Host-side MediaStreamTrack → mono pcm_s16le capture for experience.speech.\n * Capture stays in the SDK (host page); player only receives PCM chunks.\n */\n\nimport { SPEECH_LIMITS, SpeechRuntimeError, toUint8Array } from './types';\nimport type { SpeechUtterance } from './types';\n\nexport type CaptureMediaStreamTrackOptions = {\n\treadonly track: MediaStreamTrack;\n\treadonly utterance: SpeechUtterance;\n\treadonly sampleRate: number;\n\treadonly signal?: AbortSignal;\n};\n\nfunction floatToPcm16Le(input: Float32Array): ArrayBuffer {\n\tconst out = new ArrayBuffer(input.length * 2);\n\tconst view = new DataView(out);\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst s = Math.max(-1, Math.min(1, input[i]!));\n\t\tview.setInt16(i * 2, s < 0 ? s * 0x8000 : s * 0x7fff, true);\n\t}\n\treturn out;\n}\n\ntype ScriptProcessor = AudioNode & {\n\tonaudioprocess: ((ev: AudioProcessingEvent) => void) | null;\n};\n\n/**\n * Capture a live audio track into an open utterance until the track ends or abort.\n * Uses ScriptProcessor so the SDK does not need a bundled AudioWorklet module.\n */\nexport async function pipeMediaStreamTrackToUtterance(\n\toptions: CaptureMediaStreamTrackOptions\n): Promise<void> {\n\tconst { track, utterance, sampleRate, signal } = options;\n\tif (typeof MediaStreamTrack === 'undefined' || !(track instanceof MediaStreamTrack)) {\n\t\tthrow new SpeechRuntimeError('MediaStreamTrack is not available in this environment.');\n\t}\n\tif (track.kind !== 'audio') {\n\t\tthrow new SpeechRuntimeError('speech.play track must be an audio MediaStreamTrack.');\n\t}\n\tif (track.readyState === 'ended') {\n\t\treturn;\n\t}\n\tif (signal?.aborted) {\n\t\treturn;\n\t}\n\n\tconst AudioContextCtor =\n\t\ttypeof AudioContext !== 'undefined'\n\t\t\t? AudioContext\n\t\t\t: (globalThis as unknown as { webkitAudioContext?: typeof AudioContext })\n\t\t\t\t\t.webkitAudioContext;\n\tif (!AudioContextCtor) {\n\t\tthrow new SpeechRuntimeError('Web Audio is required to capture MediaStreamTrack PCM.');\n\t}\n\n\tconst ctx = new AudioContextCtor({ sampleRate });\n\tconst stream = new MediaStream([track]);\n\tconst source = ctx.createMediaStreamSource(stream);\n\tconst silent = ctx.createGain();\n\tsilent.gain.value = 0;\n\n\tconst createScriptProcessor = (\n\t\tctx as AudioContext & {\n\t\t\tcreateScriptProcessor?: (\n\t\t\t\tbufferSize: number,\n\t\t\t\tinputChannels: number,\n\t\t\t\toutputChannels: number\n\t\t\t) => ScriptProcessor;\n\t\t}\n\t).createScriptProcessor?.bind(ctx);\n\n\tif (!createScriptProcessor) {\n\t\tawait ctx.close().catch(() => undefined);\n\t\tthrow new SpeechRuntimeError('ScriptProcessor is unavailable for MediaStreamTrack capture.');\n\t}\n\n\tconst processor = createScriptProcessor(4096, 1, 1);\n\tlet writeChain: Promise<void> = Promise.resolve();\n\tlet stopped = false;\n\n\tconst teardownGraph = () => {\n\t\tif (stopped) return;\n\t\tstopped = true;\n\t\tprocessor.onaudioprocess = null;\n\t\ttry {\n\t\t\tsource.disconnect();\n\t\t\tprocessor.disconnect();\n\t\t\tsilent.disconnect();\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t\tvoid ctx.close().catch(() => undefined);\n\t};\n\n\tprocessor.onaudioprocess = (ev) => {\n\t\tif (stopped || signal?.aborted) return;\n\t\tconst input = ev.inputBuffer.getChannelData(0);\n\t\tconst bytes = toUint8Array(floatToPcm16Le(input));\n\t\twriteChain = writeChain\n\t\t\t.then(async () => {\n\t\t\t\tif (stopped || signal?.aborted) return;\n\t\t\t\tlet offset = 0;\n\t\t\t\twhile (offset < bytes.byteLength) {\n\t\t\t\t\tconst end = Math.min(offset + SPEECH_LIMITS.MAX_CHUNK_BYTES, bytes.byteLength);\n\t\t\t\t\tconst slice = bytes.subarray(offset, end);\n\t\t\t\t\toffset = end;\n\t\t\t\t\tif (slice.byteLength === 0) continue;\n\t\t\t\t\tawait utterance.write(slice);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(() => {\n\t\t\t\tteardownGraph();\n\t\t\t});\n\t};\n\n\tsource.connect(processor);\n\tprocessor.connect(silent);\n\tsilent.connect(ctx.destination);\n\tif (ctx.state === 'suspended') {\n\t\tawait ctx.resume().catch(() => undefined);\n\t}\n\n\tawait new Promise<void>((resolve) => {\n\t\tconst finish = () => {\n\t\t\tteardownGraph();\n\t\t\tvoid writeChain.finally(resolve);\n\t\t};\n\t\ttrack.addEventListener('ended', finish, { once: true });\n\t\tsignal?.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\tvoid utterance.cancel().catch(() => undefined);\n\t\t\t\tfinish();\n\t\t\t},\n\t\t\t{ once: true }\n\t\t);\n\t\tif (track.readyState === 'ended' || signal?.aborted) {\n\t\t\tfinish();\n\t\t}\n\t});\n}\n","import type { IframeHost } from '../embed/iframeHost';\nimport type { SpeakBehavior } from '../types/sessionInteraction';\nimport type { SpeechResult as EmbedSpeakResult } from '../types/sessionInteraction';\nimport {\n\tSPEECH_LIMITS,\n\tSpeechBufferTimeoutError,\n\tSpeechRuntimeError,\n\tSpeechUtteranceClosedError,\n\tUnsupportedSpeechOperationError,\n\tassertSpeechPlayAudio,\n\temptyAnimationResult,\n\tisSpeechPlayEncodedAudio,\n\tisSpeechPlayMediaStreamAudio,\n\tisSpeechPlayPcmAudio,\n\tisSpeechPlayUrlAudio,\n\tqueuePolicyToEmbedBehavior,\n\tresolveCreateUtteranceFormat,\n\ttoUint8Array,\n\ttype SpeechAudioFormat,\n\ttype SpeechController,\n\ttype SpeechCreateUtteranceOptions,\n\ttype SpeechInterruptOptions,\n\ttype SpeechPlayAudio,\n\ttype SpeechPlayEmbedSource,\n\ttype SpeechPlayOptions,\n\ttype SpeechResult,\n\ttype SpeechSpeakOptions,\n\ttype SpeechTerminalStatus,\n\ttype SpeechUtterance,\n\ttype SpeechUtteranceCloseOptions,\n\ttype SpeechWriteOptions,\n\ttype StreamingSpeechQueuePolicy\n} from './types';\nimport { pipeMediaStreamTrackToUtterance } from './captureMediaStreamTrack';\n\nasync function toSpeechPlayEmbedSource(\n\taudio: SpeechPlayAudio,\n\tsignal?: AbortSignal\n): Promise<SpeechPlayEmbedSource> {\n\tif (isSpeechPlayMediaStreamAudio(audio)) {\n\t\tthrow new SpeechRuntimeError('MediaStreamTrack play is handled on the host before embed.');\n\t}\n\tif (isSpeechPlayPcmAudio(audio)) {\n\t\tconst data = toUint8Array(audio.data);\n\t\tif ((data.byteLength & 1) !== 0) {\n\t\t\tthrow new SpeechRuntimeError('PCM byte length must be even.');\n\t\t}\n\t\treturn {\n\t\t\tkind: 'pcm',\n\t\t\tdata: data.slice().buffer,\n\t\t\tformat: audio.format\n\t\t};\n\t}\n\tif (isSpeechPlayUrlAudio(audio)) {\n\t\treturn {\n\t\t\tkind: 'url',\n\t\t\turl: audio.url.trim(),\n\t\t\t...(audio.sampleRate !== undefined ? { sampleRate: audio.sampleRate } : {})\n\t\t};\n\t}\n\tif (!isSpeechPlayEncodedAudio(audio)) {\n\t\tthrow new SpeechRuntimeError('Unsupported speech.play audio shape.');\n\t}\n\tlet bytes: Uint8Array;\n\tif (typeof Blob !== 'undefined' && audio.data instanceof Blob) {\n\t\tif (signal?.aborted) throw new DOMException('Play aborted.', 'AbortError');\n\t\tbytes = new Uint8Array(await audio.data.arrayBuffer());\n\t} else {\n\t\tbytes = toUint8Array(audio.data as ArrayBuffer | Uint8Array);\n\t}\n\treturn {\n\t\tkind: 'encoded',\n\t\tdata: bytes.slice().buffer,\n\t\tencoding: audio.encoding.trim(),\n\t\t...(audio.sampleRate !== undefined ? { sampleRate: audio.sampleRate } : {})\n\t};\n}\n\nexport type {\n\tSpeechAudioFormat,\n\tSpeechController,\n\tSpeechCreateUtteranceOptions,\n\tSpeechInterruptOptions,\n\tSpeechPlayOptions,\n\tSpeechResult,\n\tSpeechSpeakOptions,\n\tSpeechUtterance,\n\tSpeechUtteranceCloseOptions,\n\tSpeechWriteOptions\n} from './types';\n\nexport type SpeechCapabilities = {\n\treadonly textSpeech: boolean;\n\treadonly externalSpeechAudio: boolean;\n};\n\nexport type SpeechControllerHost = {\n\treadonly getIframeHost: () => IframeHost | null;\n\treadonly assertSessionStarted: () => void;\n\treadonly getCapabilities: () => SpeechCapabilities;\n\treadonly getActiveCharacterId: () => string;\n\treadonly onProcessorInterrupt?: () => void;\n};\n\ntype PendingWrite = {\n\treadonly resolve: () => void;\n\treadonly reject: (error: Error) => void;\n};\n\nfunction newUtteranceId(): string {\n\tif (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n\t\treturn `utt_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`;\n\t}\n\treturn `utt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;\n}\n\nfunction mapEmbedSpeakResult(\n\tresult: EmbedSpeakResult,\n\tstatus: SpeechTerminalStatus = 'completed'\n): SpeechResult {\n\treturn {\n\t\tutteranceId: result.speechId,\n\t\tcharacterId: result.characterId,\n\t\tstatus,\n\t\tdurationMs: result.durationMs,\n\t\ttranscript: result.text,\n\t\tanimation: {\n\t\t\tmode: 'tracked',\n\t\t\ttrackedDurationMs: result.durationMs,\n\t\t\tfallbackDurationMs: 0\n\t\t}\n\t};\n}\n\nfunction settleError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\treturn new SpeechRuntimeError(String(error));\n}\n\nfunction isAbortError(error: unknown): boolean {\n\treturn (\n\t\t(error instanceof DOMException && error.name === 'AbortError') ||\n\t\t(error instanceof Error && error.name === 'AbortError')\n\t);\n}\n\nclass HostSpeechUtterance implements SpeechUtterance {\n\treadonly id: string;\n\treadonly characterId: string;\n\treadonly result: Promise<SpeechResult>;\n\n\tprivate readonly format: SpeechAudioFormat;\n\tprivate readonly host: SpeechControllerHost;\n\tprivate readonly signal?: AbortSignal;\n\tprivate settleResolve!: (value: SpeechResult) => void;\n\tprivate settleReject!: (error: Error) => void;\n\tprivate settled = false;\n\tprivate closed = false;\n\tprivate writeChain: Promise<void> = Promise.resolve();\n\tprivate pendingWriteCount = 0;\n\tprivate readonly pendingWriteWaiters: PendingWrite[] = [];\n\tprivate bufferedMs = 0;\n\tprivate readonly sampleRate: number;\n\tprivate readonly beginPromise: Promise<void>;\n\n\tconstructor(options: {\n\t\treadonly id: string;\n\t\treadonly characterId: string;\n\t\treadonly format: SpeechAudioFormat;\n\t\treadonly queue: StreamingSpeechQueuePolicy;\n\t\treadonly host: SpeechControllerHost;\n\t\treadonly signal?: AbortSignal;\n\t}) {\n\t\tthis.id = options.id;\n\t\tthis.characterId = options.characterId;\n\t\tthis.format = options.format;\n\t\tthis.host = options.host;\n\t\tthis.signal = options.signal;\n\t\tthis.sampleRate = options.format.sampleRate;\n\t\tthis.result = new Promise<SpeechResult>((resolve, reject) => {\n\t\t\tthis.settleResolve = resolve;\n\t\t\tthis.settleReject = reject;\n\t\t});\n\t\t// Prevent unhandled rejection if caller only uses close()/cancel().\n\t\tvoid this.result.catch(() => undefined);\n\n\t\tconst iframe = this.requireHost();\n\t\tthis.beginPromise = iframe\n\t\t\t.speechUtteranceBegin({\n\t\t\t\tutteranceId: this.id,\n\t\t\t\tformat: this.format,\n\t\t\t\tcharacterId: this.characterId,\n\t\t\t\tqueue: options.queue\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tthis.fail(settleError(error));\n\t\t\t\tthrow settleError(error);\n\t\t\t});\n\n\t\tthis.signal?.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\tvoid this.cancel();\n\t\t\t},\n\t\t\t{ once: true }\n\t\t);\n\t}\n\n\tasync write(audio: ArrayBuffer | Uint8Array, options?: SpeechWriteOptions): Promise<void> {\n\t\tif (this.closed || this.settled) {\n\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t}\n\t\tawait this.beginPromise.catch(() => undefined);\n\t\tif (this.closed || this.settled) {\n\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t}\n\t\tconst bytes = toUint8Array(audio);\n\t\tif ((bytes.byteLength & 1) !== 0) {\n\t\t\tthrow new SpeechRuntimeError('PCM chunk byte length must be even (complete s16 samples).');\n\t\t}\n\t\tif (bytes.byteLength > SPEECH_LIMITS.MAX_CHUNK_BYTES) {\n\t\t\tthrow new SpeechRuntimeError(\n\t\t\t\t`PCM chunk exceeds MAX_CHUNK_BYTES (${SPEECH_LIMITS.MAX_CHUNK_BYTES}).`\n\t\t\t);\n\t\t}\n\t\tif (bytes.byteLength === 0) return;\n\n\t\tconst timeoutMs = options?.timeoutMs ?? SPEECH_LIMITS.DEFAULT_WRITE_TIMEOUT_MS;\n\t\tawait this.acquireWriteSlot(timeoutMs);\n\n\t\tconst chunkMs = (bytes.byteLength / 2 / this.sampleRate) * 1000;\n\t\tif (this.bufferedMs + chunkMs > SPEECH_LIMITS.MAX_UTTERANCE_DURATION_MS) {\n\t\t\tthis.releaseWriteSlot();\n\t\t\tthrow new SpeechRuntimeError('Utterance exceeds MAX_UTTERANCE_DURATION_MS.');\n\t\t}\n\n\t\tconst run = async () => {\n\t\t\tif (this.closed || this.settled) {\n\t\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t\t}\n\t\t\tconst iframe = this.requireHost();\n\t\t\tconst copy = bytes.slice();\n\t\t\tconst writePromise = iframe.speechUtteranceWrite({\n\t\t\t\tutteranceId: this.id,\n\t\t\t\taudio: copy.buffer,\n\t\t\t\tbyteLength: copy.byteLength\n\t\t\t});\n\t\t\tconst ack = await Promise.race([\n\t\t\t\twritePromise,\n\t\t\t\tnew Promise<never>((_, reject) => {\n\t\t\t\t\tsetTimeout(() => reject(new SpeechBufferTimeoutError()), timeoutMs);\n\t\t\t\t})\n\t\t\t]);\n\t\t\tthis.bufferedMs = Math.max(0, ack.bufferedMs);\n\t\t};\n\n\t\tconst tracked = this.writeChain.then(run, run);\n\t\tthis.writeChain = tracked.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined\n\t\t);\n\t\ttry {\n\t\t\tawait tracked;\n\t\t} finally {\n\t\t\tthis.releaseWriteSlot();\n\t\t}\n\t}\n\n\tasync close(options?: SpeechUtteranceCloseOptions): Promise<SpeechResult> {\n\t\tif (this.settled) return this.result;\n\t\tthis.closed = true;\n\t\tawait this.beginPromise.catch(() => undefined);\n\t\tawait this.writeChain.catch(() => undefined);\n\t\ttry {\n\t\t\tconst iframe = this.requireHost();\n\t\t\tconst result = await iframe.speechUtteranceClose({\n\t\t\t\tutteranceId: this.id,\n\t\t\t\ttranscript: options?.transcript,\n\t\t\t\thistory: options?.history ?? 'none'\n\t\t\t});\n\t\t\tthis.resolve(result);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tconst err = settleError(error);\n\t\t\tthis.fail(err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync cancel(): Promise<SpeechResult> {\n\t\tif (this.settled) return this.result;\n\t\tthis.closed = true;\n\t\ttry {\n\t\t\tconst iframe = this.host.getIframeHost();\n\t\t\tif (iframe) {\n\t\t\t\tconst result = await iframe.speechUtteranceCancel({ utteranceId: this.id });\n\t\t\t\tthis.resolve(result);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tconst cancelled: SpeechResult = {\n\t\t\t\tutteranceId: this.id,\n\t\t\t\tcharacterId: this.characterId,\n\t\t\t\tstatus: 'cancelled',\n\t\t\t\tdurationMs: 0,\n\t\t\t\tanimation: emptyAnimationResult('none')\n\t\t\t};\n\t\t\tthis.resolve(cancelled);\n\t\t\treturn cancelled;\n\t\t} catch (error) {\n\t\t\tconst err = settleError(error);\n\t\t\tthis.fail(err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** Adopt an interrupt settlement from the player without a second cancel RPC. */\n\tadoptExternalResult(result: SpeechResult): void {\n\t\tthis.resolve(result);\n\t}\n\n\tprivate requireHost(): IframeHost {\n\t\tconst iframe = this.host.getIframeHost();\n\t\tif (!iframe) {\n\t\t\tthrow new SpeechRuntimeError('Speech session is not attached.');\n\t\t}\n\t\treturn iframe;\n\t}\n\n\tprivate resolve(result: SpeechResult): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tthis.settleResolve(Object.freeze(result));\n\t\tthis.flushWriteWaiters(new SpeechUtteranceClosedError());\n\t}\n\n\tprivate fail(error: Error): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tthis.settleReject(error);\n\t\tthis.flushWriteWaiters(error);\n\t}\n\n\tprivate async acquireWriteSlot(timeoutMs: number): Promise<void> {\n\t\tif (this.pendingWriteCount < SPEECH_LIMITS.MAX_PENDING_WRITES) {\n\t\t\tthis.pendingWriteCount += 1;\n\t\t\treturn;\n\t\t}\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\treject(new SpeechBufferTimeoutError());\n\t\t\t}, timeoutMs);\n\t\t\tthis.pendingWriteWaiters.push({\n\t\t\t\tresolve: () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tthis.pendingWriteCount += 1;\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate releaseWriteSlot(): void {\n\t\tthis.pendingWriteCount = Math.max(0, this.pendingWriteCount - 1);\n\t\tconst next = this.pendingWriteWaiters.shift();\n\t\tnext?.resolve();\n\t}\n\n\tprivate flushWriteWaiters(error: Error): void {\n\t\twhile (this.pendingWriteWaiters.length > 0) {\n\t\t\tthis.pendingWriteWaiters.shift()?.reject(error);\n\t\t}\n\t}\n}\n\nexport function createSpeechController(host: SpeechControllerHost): SpeechController {\n\tlet openUtterance: HostSpeechUtterance | null = null;\n\n\tconst requireCapability = (operation: string, capability: keyof SpeechCapabilities) => {\n\t\tconst caps = host.getCapabilities();\n\t\tif (!caps[capability]) {\n\t\t\tthrow new UnsupportedSpeechOperationError(operation, capability);\n\t\t}\n\t};\n\n\tconst controller: SpeechController = {\n\t\tasync speak(options: SpeechSpeakOptions): Promise<SpeechResult> {\n\t\t\thost.assertSessionStarted();\n\t\t\trequireCapability('speak', 'textSpeech');\n\t\t\tif (options.signal?.aborted) {\n\t\t\t\tthrow new DOMException('Speak aborted.', 'AbortError');\n\t\t\t}\n\t\t\tconst queue = options.queue ?? 'append';\n\t\t\tconst behavior: SpeakBehavior = queuePolicyToEmbedBehavior(queue);\n\t\t\tif (behavior === 'interrupt') {\n\t\t\t\thost.onProcessorInterrupt?.();\n\t\t\t\tif (openUtterance) {\n\t\t\t\t\tvoid openUtterance.cancel();\n\t\t\t\t\topenUtterance = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst iframe = host.getIframeHost();\n\t\t\tif (!iframe) throw new SpeechRuntimeError('Speech session is not attached.');\n\n\t\t\tconst speakPromise = iframe.speak({\n\t\t\t\ttext: options.text,\n\t\t\t\tcharacterId: options.characterId,\n\t\t\t\tbehavior\n\t\t\t});\n\n\t\t\tif (options.signal) {\n\t\t\t\tconst signal = options.signal;\n\t\t\t\treturn await new Promise<SpeechResult>((resolve, reject) => {\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\tvoid iframe.speechInterrupt({ scope: 'active' }).catch(() => undefined);\n\t\t\t\t\t\treject(new DOMException('Speak aborted.', 'AbortError'));\n\t\t\t\t\t};\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\t\t\t\t\tspeakPromise.then(\n\t\t\t\t\t\t(legacy) => {\n\t\t\t\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\t\t\t\tresolve(mapEmbedSpeakResult(legacy, 'completed'));\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\t\t\t\tif (isAbortError(error)) {\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tutteranceId: `utt_interrupted`,\n\t\t\t\t\t\t\t\t\tcharacterId: options.characterId ?? host.getActiveCharacterId(),\n\t\t\t\t\t\t\t\t\tstatus: 'interrupted',\n\t\t\t\t\t\t\t\t\tdurationMs: 0,\n\t\t\t\t\t\t\t\t\ttranscript: options.text,\n\t\t\t\t\t\t\t\t\tanimation: emptyAnimationResult('none')\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(settleError(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\ttry {\n\t\t\t\tconst legacy = await speakPromise;\n\t\t\t\treturn mapEmbedSpeakResult(legacy, 'completed');\n\t\t\t} catch (error) {\n\t\t\t\tif (isAbortError(error)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tutteranceId: `utt_interrupted`,\n\t\t\t\t\t\tcharacterId: options.characterId ?? host.getActiveCharacterId(),\n\t\t\t\t\t\tstatus: 'interrupted',\n\t\t\t\t\t\tdurationMs: 0,\n\t\t\t\t\t\ttranscript: options.text,\n\t\t\t\t\t\tanimation: emptyAnimationResult('none')\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tthrow settleError(error);\n\t\t\t}\n\t\t},\n\n\t\tasync play(options: SpeechPlayOptions): Promise<SpeechResult> {\n\t\t\thost.assertSessionStarted();\n\t\t\trequireCapability('play', 'externalSpeechAudio');\n\t\t\tassertSpeechPlayAudio(options.audio);\n\t\t\tif (options.signal?.aborted) {\n\t\t\t\tthrow new DOMException('Play aborted.', 'AbortError');\n\t\t\t}\n\t\t\tconst queue = options.queue ?? 'append';\n\t\t\tif (queue === 'replace-active' || queue === 'replace-all') {\n\t\t\t\thost.onProcessorInterrupt?.();\n\t\t\t\tif (openUtterance) {\n\t\t\t\t\tvoid openUtterance.cancel();\n\t\t\t\t\topenUtterance = null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isSpeechPlayMediaStreamAudio(options.audio)) {\n\t\t\t\tconst sampleRate = options.audio.sampleRate ?? 24_000;\n\t\t\t\tconst utterance = controller.createUtterance({\n\t\t\t\t\tformat: { encoding: 'pcm_s16le', sampleRate, channels: 1 },\n\t\t\t\t\ttrack: options.audio.track,\n\t\t\t\t\tcharacterId: options.characterId,\n\t\t\t\t\tqueue: queue === 'append' ? 'replace-active' : queue,\n\t\t\t\t\tsignal: options.signal\n\t\t\t\t});\n\t\t\t\treturn utterance.result;\n\t\t\t}\n\n\t\t\tconst iframe = host.getIframeHost();\n\t\t\tif (!iframe) throw new SpeechRuntimeError('Speech session is not attached.');\n\t\t\tconst source = await toSpeechPlayEmbedSource(options.audio, options.signal);\n\t\t\treturn iframe.speechPlay({\n\t\t\t\tsource,\n\t\t\t\tcharacterId: options.characterId,\n\t\t\t\ttranscript: options.transcript,\n\t\t\t\thistory: options.history ?? 'none',\n\t\t\t\tqueue,\n\t\t\t\tsignal: options.signal\n\t\t\t});\n\t\t},\n\n\t\tcreateUtterance(options: SpeechCreateUtteranceOptions): SpeechUtterance {\n\t\t\thost.assertSessionStarted();\n\t\t\trequireCapability('createUtterance', 'externalSpeechAudio');\n\t\t\tconst format = resolveCreateUtteranceFormat(options);\n\t\t\tif (options.track && options.track.kind !== 'audio') {\n\t\t\t\tthrow new SpeechRuntimeError('createUtterance track must be an audio MediaStreamTrack.');\n\t\t\t}\n\t\t\tconst queue: StreamingSpeechQueuePolicy = options.queue ?? 'replace-active';\n\t\t\tif (queue !== 'replace-active' && queue !== 'replace-all') {\n\t\t\t\tthrow new SpeechRuntimeError('createUtterance queue must be replace-active or replace-all.');\n\t\t\t}\n\t\t\thost.onProcessorInterrupt?.();\n\t\t\tif (openUtterance) {\n\t\t\t\tvoid openUtterance.cancel();\n\t\t\t\topenUtterance = null;\n\t\t\t}\n\t\t\tconst utterance = new HostSpeechUtterance({\n\t\t\t\tid: newUtteranceId(),\n\t\t\t\tcharacterId: options.characterId ?? host.getActiveCharacterId(),\n\t\t\t\tformat,\n\t\t\t\tqueue,\n\t\t\t\thost,\n\t\t\t\tsignal: options.signal\n\t\t\t});\n\t\t\topenUtterance = utterance;\n\t\t\tvoid utterance.result.finally(() => {\n\t\t\t\tif (openUtterance === utterance) openUtterance = null;\n\t\t\t});\n\t\t\tif (options.track) {\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait pipeMediaStreamTrackToUtterance({\n\t\t\t\t\t\t\ttrack: options.track!,\n\t\t\t\t\t\t\tutterance,\n\t\t\t\t\t\t\tsampleRate: format.sampleRate,\n\t\t\t\t\t\t\tsignal: options.signal\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (options.signal?.aborted) return;\n\t\t\t\t\t\tawait utterance.close({ history: 'none' });\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tawait utterance.cancel().catch(() => undefined);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\t\t\treturn utterance;\n\t\t},\n\n\t\tasync interrupt(options?: SpeechInterruptOptions): Promise<readonly SpeechResult[]> {\n\t\t\thost.assertSessionStarted();\n\t\t\thost.onProcessorInterrupt?.();\n\t\t\tconst iframe = host.getIframeHost();\n\t\t\tif (!iframe) return [];\n\t\t\tconst results = await iframe.speechInterrupt(options ?? { scope: 'active' });\n\t\t\tif (openUtterance) {\n\t\t\t\tconst match = results.find((r) => r.utteranceId === openUtterance!.id);\n\t\t\t\tif (match) openUtterance.adoptExternalResult(match);\n\t\t\t\topenUtterance = null;\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t};\n\n\treturn controller;\n}\n","import { fetchSessionManifest } from './api/mintPublicSession';\nimport { mintPublicSession } from './api/mintPublicSession';\nimport { dispatchConversationProcessor } from './conversationProcessor';\nimport { createIframeHost, type IframeHost } from './embed/iframeHost';\nimport { createReadyGate } from './embed/readyGate';\nimport type { CloseEvent, EmbedState } from './embed/protocol';\nimport {\n\tbuildManifestEmbedUrl,\n\tresolvePlayerOrigin,\n\tresolvePublicPlayerEmbedUrl\n} from './shims/embedBaseUrl';\nimport {\n\tmanifestHasSessionCredential,\n\tparseSessionManifest\n} from './types/sessionManifestSchema';\nimport type { SessionManifest } from './types/sessionManifest';\nimport { applySpeechOnlyManifest } from './speechOnlyManifest';\nimport {\n\tclearExperienceEventRegistry,\n\tcreateExperienceEventRegistry,\n\temitExperienceEvent,\n\tsubscribeExperienceEvent,\n\ttype ExperienceEventName,\n\ttype ExperienceEvents\n} from './experienceEvents';\nimport {\n\tcreateSpeechController,\n\ttype SpeechCapabilities,\n\ttype SpeechController\n} from './speech/speechController';\nimport type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tConversationProcessorFn,\n\tExperienceFit,\n\tExperienceMode,\n\tListenOnceOptions,\n\tResponseMode,\n\tSpeechInputMode,\n\tStartButtonOptions,\n\tStartedEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from './types/sessionInteraction';\n\nexport type { CloseEvent };\nexport type {\n\tCharacterSpeechEvent,\n\tCharacterSpeechSource,\n\tCharacterSpeechTerminalReason,\n\tConversationMessage,\n\tConversationProcessorContext,\n\tConversationProcessorErrorEvent,\n\tConversationProcessorFn,\n\tConversationProcessorResult,\n\tExperienceFit,\n\tListenOnceOptions,\n\tSpeakOptions,\n\tTextSpeakResult,\n\tSpeechResult as LegacySpeakResult,\n\tStartButtonAppearance,\n\tStartButtonOptions,\n\tStartButtonPlacement,\n\tStartButtonShadow,\n\tStartButtonSize,\n\tStartButtonVariant,\n\tSessionModeChange,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from './types/sessionInteraction';\nexport type {\n\tSpeechAudioFormat,\n\tSpeechController,\n\tSpeechCreateUtteranceOptions,\n\tSpeechInterruptOptions,\n\tSpeechPlayAudio,\n\tSpeechPlayEncodedAudio,\n\tSpeechPlayOptions,\n\tSpeechPlayPcmAudio,\n\tSpeechPlayUrlAudio,\n\tSpeechResult,\n\tSpeechSpeakOptions,\n\tSpeechUtterance\n} from './speech';\nexport {\n\tSPEECH_LIMITS,\n\tSpeechBufferTimeoutError,\n\tSpeechRuntimeError,\n\tSpeechUtteranceClosedError,\n\tUnsupportedSpeechOperationError\n} from './speech';\n\nexport type { ExperienceEventName, ExperienceEvents } from './experienceEvents';\n\nexport type StartSessionOptions =\n\t| {\n\t\t\treadonly experienceId: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\t/** @deprecated Response ownership is derived from mode. */\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\t/** Scene framing: `face` cover-zooms onto the mesh face oval. Default `full`. */\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\t/** ExperienceWidget warm embed chrome (`?ui=widget`). */\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly experienceId: string;\n\t\t\treadonly sessionEndpoint: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\t/** @deprecated Response ownership is derived from mode. */\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\t/** Scene framing: `face` cover-zooms onto the mesh face oval. Default `full`. */\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\t/** ExperienceWidget warm embed chrome (`?ui=widget`). */\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly manifest: unknown;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly acceptCredentialExposure?: boolean;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\t/** Scene framing: `face` cover-zooms onto the mesh face oval. Default `full`. */\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\t/** ExperienceWidget warm embed chrome (`?ui=widget`). */\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t };\n\nexport type AttachOptions = {\n\treadonly container: HTMLElement;\n\treadonly onStateUpdate?: (state: EmbedState) => void;\n\treadonly onWidgetReady?: () => void;\n\treadonly onWidgetExpand?: () => void;\n\treadonly onWidgetCollapse?: () => void;\n\treadonly onWidgetAudioSettings?: (open: boolean) => void;\n\t/**\n\t * Show the in-player close control. Set when the host provides `onClose`\n\t * and/or `returnUrl`. Widget chrome keeps its own toolbar close separately.\n\t */\n\treadonly showClose?: boolean;\n};\n\nexport type { EmbedState };\n\nexport type ReadyEvent = {\n\treadonly manifest: SessionManifest;\n};\n\nexport type LiformaPlayer = {\n\tclose(): void;\n\tdestroy(): void;\n\ton(event: 'close', handler: (event: CloseEvent) => void): void;\n};\n\ntype SessionLaunch =\n\t| {\n\t\t\treadonly kind: 'public';\n\t\t\treadonly experienceId: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly kind: 'manifest';\n\t\t\treadonly manifest: SessionManifest;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly kind: 'sessionEndpoint';\n\t\t\treadonly experienceId: string;\n\t\t\treadonly sessionEndpoint: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t };\n\nfunction applyStartButtonOptions(\n\tmanifest: SessionManifest,\n\tstartButton: StartButtonOptions | undefined\n): SessionManifest {\n\tif (!startButton) return manifest;\n\treturn parseSessionManifest({\n\t\t...manifest,\n\t\texperience: {\n\t\t\t...manifest.experience,\n\t\t\tstartButton\n\t\t}\n\t});\n}\n\nexport class Experience {\n\tprivate readonly launch: SessionLaunch;\n\tprivate readonly conversationProcessor: ConversationProcessorFn | null;\n\tprivate iframeHost: IframeHost | null = null;\n\tprivate attachInFlight: Promise<LiformaPlayer> | null = null;\n\tprivate endpointAbortController: AbortController | null = null;\n\tprivate processorAbortController: AbortController | null = null;\n\tprivate processorChain: Promise<void> = Promise.resolve();\n\tprivate resolvedManifest: SessionManifest | null;\n\tprivate closed = false;\n\tprivate attached = false;\n\tprivate readonly closeHandlers: ((event: CloseEvent) => void)[] = [];\n\tprivate readonly eventRegistry = createExperienceEventRegistry();\n\tprivate readyEvent: ReadyEvent | null = null;\n\tprivate startedEvent: StartedEvent | null = null;\n\tprivate conversationCache: readonly ConversationMessage[] = [];\n\t/** Public speech API — text TTS and BYO PCM (`speak` / `play` / `createUtterance` / `interrupt`). */\n\treadonly speech: SpeechController;\n\n\tprivate constructor(launch: SessionLaunch) {\n\t\tthis.launch = launch;\n\t\tthis.conversationProcessor = launch.conversationProcessor ?? null;\n\t\tthis.resolvedManifest = launch.kind === 'manifest' ? launch.manifest : null;\n\t\tthis.speech = createSpeechController({\n\t\t\tgetIframeHost: () => this.iframeHost,\n\t\t\tassertSessionStarted: () => this.assertSessionStarted(),\n\t\t\tgetCapabilities: () => resolveSpeechCapabilities(this.resolvedManifest),\n\t\t\tgetActiveCharacterId: () =>\n\t\t\t\tthis.resolvedManifest?.activeCharacterId ?? 'character_unknown',\n\t\t\tonProcessorInterrupt: () => {\n\t\t\t\tthis.processorAbortController?.abort();\n\t\t\t\tthis.processorAbortController = null;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic async startSession(options: StartSessionOptions): Promise<Experience> {\n\t\tif ('sessionEndpoint' in options) {\n\t\t\treturn new Experience({\n\t\t\t\tkind: 'sessionEndpoint',\n\t\t\t\texperienceId: options.experienceId,\n\t\t\t\tsessionEndpoint: options.sessionEndpoint,\n\t\t\t\tlanguage: options.language,\n\t\t\t\tlocationId: options.locationId,\n\t\t\t\tavatarId: options.avatarId,\n\t\t\t\tembedBaseUrl: options.embedBaseUrl,\n\t\t\t\tdebug: options.debug,\n\t\t\t\tmode: options.mode,\n\t\t\t\tresponseMode: options.responseMode,\n\t\t\t\tspeechInputMode: options.speechInputMode,\n\t\t\t\tstartButton: options.startButton,\n\t\t\t\tspeechOnly: options.speechOnly,\n\t\t\t\tfit: options.fit,\n\t\t\t\tui: options.ui,\n\t\t\t\tonStart: options.onStart,\n\t\t\t\tonUserTranscript: options.onUserTranscript,\n\t\t\t\tconversationProcessor: options.conversationProcessor\n\t\t\t});\n\t\t}\n\n\t\tif ('experienceId' in options) {\n\t\t\treturn new Experience({\n\t\t\t\tkind: 'public',\n\t\t\t\texperienceId: options.experienceId,\n\t\t\t\tlanguage: options.language,\n\t\t\t\tlocationId: options.locationId,\n\t\t\t\tavatarId: options.avatarId,\n\t\t\t\tembedBaseUrl: options.embedBaseUrl,\n\t\t\t\tdebug: options.debug,\n\t\t\t\tmode: options.mode,\n\t\t\t\tresponseMode: options.responseMode,\n\t\t\t\tspeechInputMode: options.speechInputMode,\n\t\t\t\tstartButton: options.startButton,\n\t\t\t\tspeechOnly: options.speechOnly,\n\t\t\t\tfit: options.fit,\n\t\t\t\tui: options.ui,\n\t\t\t\tonStart: options.onStart,\n\t\t\t\tonUserTranscript: options.onUserTranscript,\n\t\t\t\tconversationProcessor: options.conversationProcessor\n\t\t\t});\n\t\t}\n\n\t\tconst manifest = parseSessionManifest(options.manifest);\n\t\tif (manifestHasSessionCredential(manifest) && !options.acceptCredentialExposure) {\n\t\t\tthrow new Error(\n\t\t\t\t'Credential-bearing Session Manifest requires acceptCredentialExposure: true. ' +\n\t\t\t\t\t'Prefer experienceId, sessionEndpoint, or client-side mint instead of SSR page data.'\n\t\t\t);\n\t\t}\n\n\t\treturn new Experience({\n\t\t\tkind: 'manifest',\n\t\t\tmanifest: options.speechOnly ? applySpeechOnlyManifest(manifest) : manifest,\n\t\t\tembedBaseUrl: options.embedBaseUrl,\n\t\t\tdebug: options.debug,\n\t\t\tstartButton: options.startButton,\n\t\t\tspeechOnly: options.speechOnly,\n\t\t\tfit: options.fit,\n\t\t\tui: options.ui,\n\t\t\tonStart: options.onStart,\n\t\t\tonUserTranscript: options.onUserTranscript,\n\t\t\tconversationProcessor: options.conversationProcessor\n\t\t});\n\t}\n\n\tgetManifest(): SessionManifest | null {\n\t\treturn this.resolvedManifest;\n\t}\n\n\ton<K extends ExperienceEventName>(\n\t\tevent: K,\n\t\thandler: (event: ExperienceEvents[K]) => void\n\t): () => void {\n\t\tconst unsubscribe = subscribeExperienceEvent(this.eventRegistry, event, handler);\n\t\tif (event === 'ready' && this.readyEvent) {\n\t\t\tqueueMicrotask(() => handler(this.readyEvent as ExperienceEvents[K]));\n\t\t}\n\t\tif (event === 'started' && this.startedEvent) {\n\t\t\tqueueMicrotask(() => handler(this.startedEvent as ExperienceEvents[K]));\n\t\t}\n\t\treturn unsubscribe;\n\t}\n\n\tasync attach(options: AttachOptions): Promise<LiformaPlayer> {\n\t\tif (this.closed) {\n\t\t\tthrow new Error('Session has ended.');\n\t\t}\n\t\tif (!options.container) {\n\t\t\tthrow new Error('Experience.attach requires a DOM container element.');\n\t\t}\n\t\tif (this.attached && this.iframeHost) {\n\t\t\treturn this.createPlayerFacade();\n\t\t}\n\t\tif (this.attachInFlight) {\n\t\t\treturn this.attachInFlight;\n\t\t}\n\n\t\tthis.attachInFlight = this.attachInternal(options).finally(() => {\n\t\t\tthis.attachInFlight = null;\n\t\t});\n\t\treturn this.attachInFlight;\n\t}\n\n\tprivate async attachInternal(options: AttachOptions): Promise<LiformaPlayer> {\n\t\tif (this.closed) {\n\t\t\tthrow new Error('Session has ended.');\n\t\t}\n\t\tif (this.attached && this.iframeHost) {\n\t\t\treturn this.createPlayerFacade();\n\t\t}\n\t\tif (this.iframeHost) {\n\t\t\tthis.iframeHost.destroy();\n\t\t\tthis.iframeHost = null;\n\t\t}\n\n\t\tconst embedBaseUrl = this.launch.embedBaseUrl ?? resolvePublicPlayerEmbedUrl();\n\t\tconst debug = this.launch.debug === true;\n\t\tconst speechOnly = this.launch.speechOnly === true;\n\t\t// The SDK owns minting for every launch kind and posts the resolved manifest.\n\t\t// Do not put experienceId in the iframe URL or the player will mint a second,\n\t\t// default-mode session before the parent manifest arrives.\n\t\tconst iframeSrc = buildManifestEmbedUrl(\n\t\t\tembedBaseUrl,\n\t\t\tdebug,\n\t\t\tspeechOnly || this.launch.kind === 'manifest' ? undefined : this.launch.locationId,\n\t\t\tspeechOnly || this.launch.kind === 'manifest' ? undefined : this.launch.avatarId,\n\t\t\tthis.launch.fit,\n\t\t\tthis.launch.ui,\n\t\t\toptions.showClose === true\n\t\t);\n\t\tconst playerOrigin = resolvePlayerOrigin(iframeSrc);\n\n\t\tlet resolveLoadingUi: (() => void) | null = null;\n\t\tconst loadingUiPromise = new Promise<void>((resolve) => {\n\t\t\tresolveLoadingUi = resolve;\n\t\t});\n\t\tlet resolveReadyUi: (() => void) | null = null;\n\t\tconst readyUiPromise = new Promise<void>((resolve) => {\n\t\t\tresolveReadyUi = resolve;\n\t\t});\n\t\tconst readyGate = createReadyGate<SessionManifest>((readyManifest) => {\n\t\t\tif (this.readyEvent) return;\n\t\t\tthis.readyEvent = { manifest: readyManifest };\n\t\t\temitExperienceEvent(this.eventRegistry, 'ready', this.readyEvent);\n\t\t});\n\n\t\tconst onUserTranscript = this.launch.onUserTranscript;\n\n\t\tconst iframeHost = createIframeHost({\n\t\t\tcontainer: options.container,\n\t\t\tsrc: iframeSrc,\n\t\t\tplayerOrigin,\n\t\t\ttransparent: this.launch.ui === 'widget',\n\t\t\tonClose: (event) => {\n\t\t\t\tfor (const handler of this.closeHandlers) {\n\t\t\t\t\thandler(event);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonStateUpdate: (state) => {\n\t\t\t\toptions.onStateUpdate?.(state);\n\t\t\t\tif (state === 'loading' && resolveLoadingUi) {\n\t\t\t\t\tresolveLoadingUi();\n\t\t\t\t\tresolveLoadingUi = null;\n\t\t\t\t}\n\t\t\t\tif (state === 'ready' && resolveReadyUi) {\n\t\t\t\t\tresolveReadyUi();\n\t\t\t\t\tresolveReadyUi = null;\n\t\t\t\t}\n\t\t\t\tif (state === 'ready') {\n\t\t\t\t\treadyGate.markReady();\n\t\t\t\t}\n\t\t\t},\n\t\t\tonUserTranscript: (update) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'userTranscript', update);\n\t\t\t\tvoid onUserTranscript?.(update);\n\t\t\t\tthis.queueProcessorTurn(update);\n\t\t\t},\n\t\t\tonUserSpeechStarted: (event) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'userSpeechStarted', event);\n\t\t\t},\n\t\t\tonUserSpeechEnded: (event) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'userSpeechEnded', event);\n\t\t\t},\n\t\t\tonCharacterSpeechStarted: (event: CharacterSpeechEvent) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'characterSpeechStarted', event);\n\t\t\t},\n\t\t\tonCharacterSpeechEnded: (event: CharacterSpeechEvent) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'characterSpeechEnded', event);\n\t\t\t},\n\t\t\tonListeningState: (listening) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'listeningState', listening);\n\t\t\t},\n\t\t\tonModeChange: (mode) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'modeChange', mode);\n\t\t\t},\n\t\t\tonMessage: (message) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'message', message);\n\t\t\t},\n\t\t\tonStarted: (event) => {\n\t\t\t\tif (!this.startedEvent) {\n\t\t\t\t\tthis.startedEvent = event;\n\t\t\t\t\temitExperienceEvent(this.eventRegistry, 'started', event);\n\t\t\t\t\tvoid this.launch.onStart?.(event);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonConversationUpdate: (conversation) => {\n\t\t\t\tthis.conversationCache = conversation;\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'conversationUpdate', conversation);\n\t\t\t},\n\t\t\tonWidgetReady: () => options.onWidgetReady?.(),\n\t\t\tonWidgetExpand: () => options.onWidgetExpand?.(),\n\t\t\tonWidgetCollapse: () => options.onWidgetCollapse?.(),\n\t\t\tonWidgetAudioSettings: (open) => options.onWidgetAudioSettings?.(open)\n\t\t});\n\t\tthis.iframeHost = iframeHost;\n\n\t\tconst mintInteraction = this.resolveMintInteraction();\n\n\t\tconst manifestPromise =\n\t\t\tthis.launch.kind === 'sessionEndpoint'\n\t\t\t\t? (() => {\n\t\t\t\t\t\tthis.endpointAbortController = new AbortController();\n\t\t\t\t\t\treturn fetchSessionManifest(this.launch.sessionEndpoint, {\n\t\t\t\t\t\t\texperienceId: this.launch.experienceId,\n\t\t\t\t\t\t\tlanguage: this.launch.language,\n\t\t\t\t\t\t\tmode: mintInteraction.mode,\n\t\t\t\t\t\t\tresponseMode: mintInteraction.responseMode,\n\t\t\t\t\t\t\tspeechInputMode: mintInteraction.speechInputMode,\n\t\t\t\t\t\t\tstartButton: this.launch.startButton,\n\t\t\t\t\t\t\tspeechOnly: this.launch.speechOnly,\n\t\t\t\t\t\t\tsignal: this.endpointAbortController.signal\n\t\t\t\t\t\t});\n\t\t\t\t\t})()\n\t\t\t\t: this.launch.kind === 'public'\n\t\t\t\t\t? mintPublicSession(this.launch.experienceId, {\n\t\t\t\t\t\t\tlanguage: this.launch.language,\n\t\t\t\t\t\t\tmode: mintInteraction.mode,\n\t\t\t\t\t\t\tresponseMode: mintInteraction.responseMode,\n\t\t\t\t\t\t\tspeechInputMode: mintInteraction.speechInputMode,\n\t\t\t\t\t\t\tstartButton: this.launch.startButton,\n\t\t\t\t\t\t\tspeechOnly: this.launch.speechOnly\n\t\t\t\t\t\t})\n\t\t\t\t\t: Promise.resolve(this.launch.kind === 'manifest' ? this.launch.manifest : null);\n\n\t\tlet manifest: SessionManifest | null;\n\t\ttry {\n\t\t\t[, manifest] = await Promise.all([iframeHost.waitForLoad(), manifestPromise]);\n\t\t} catch (error) {\n\t\t\tiframeHost.destroy();\n\t\t\tif (this.iframeHost === iframeHost) {\n\t\t\t\tthis.iframeHost = null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.endpointAbortController = null;\n\t\t}\n\t\tiframeHost.postParentHello();\n\n\t\tif (manifest) {\n\t\t\tlet effectiveManifest = applyStartButtonOptions(manifest, this.launch.startButton);\n\t\t\tif (this.launch.speechOnly) {\n\t\t\t\teffectiveManifest = applySpeechOnlyManifest(effectiveManifest);\n\t\t\t}\n\t\t\tthis.assertBrowserCustomManifest(effectiveManifest);\n\t\t\tthis.resolvedManifest = effectiveManifest;\n\t\t\tiframeHost.postManifest(effectiveManifest);\n\t\t\treadyGate.setValue(effectiveManifest);\n\t\t}\n\n\t\tawait Promise.race([\n\t\t\tloadingUiPromise,\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => reject(new Error('Timed out waiting for player loading UI.')),\n\t\t\t\t\t120_000\n\t\t\t\t);\n\t\t\t})\n\t\t]);\n\n\t\tawait Promise.race([\n\t\t\treadyUiPromise,\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => reject(new Error('Timed out waiting for player ready state.')),\n\t\t\t\t\t120_000\n\t\t\t\t);\n\t\t\t})\n\t\t]);\n\n\t\tthis.attached = true;\n\t\treturn this.createPlayerFacade();\n\t}\n\n\tasync startListening(): Promise<void> {\n\t\tthis.assertSessionStarted();\n\t\tawait this.iframeHost!.startListening();\n\t}\n\n\tasync stopListening(): Promise<UtteranceResult> {\n\t\tthis.assertSessionStarted();\n\t\treturn this.iframeHost!.stopListening();\n\t}\n\n\tasync listenOnce(options?: ListenOnceOptions): Promise<UtteranceResult> {\n\t\tthis.assertSessionStarted();\n\t\treturn this.iframeHost!.listenOnce({\n\t\t\ttimeoutMs: options?.timeoutMs\n\t\t});\n\t}\n\n\tgetConversation(): readonly ConversationMessage[] {\n\t\treturn this.conversationCache;\n\t}\n\n\t/** Parent → player chrome mode for ExperienceWidget warm/cold expand. */\n\tsetWidgetChrome(mode: 'collapsed' | 'loading' | 'expanded'): void {\n\t\tthis.iframeHost?.postWidgetSetChrome(mode);\n\t}\n\n\t/** Parent → player toggle for mic/speaker settings (ExperienceWidget toolbar). */\n\ttoggleAudioSettings(): void {\n\t\tthis.iframeHost?.postWidgetToggleAudioSettings();\n\t}\n\n\tgetLastTurn(): readonly ConversationMessage[] {\n\t\tif (this.conversationCache.length === 0) return [];\n\t\tconst lastTurnId = this.conversationCache[this.conversationCache.length - 1]!.turnId;\n\t\treturn this.conversationCache.filter((m) => m.turnId === lastTurnId);\n\t}\n\n\tasync end(): Promise<void> {\n\t\tthis.close();\n\t}\n\n\tdestroy(): void {\n\t\tif (this.closed) return;\n\t\tthis.closed = true;\n\t\tthis.processorAbortController?.abort();\n\t\tthis.processorAbortController = null;\n\t\tthis.endpointAbortController?.abort();\n\t\tthis.endpointAbortController = null;\n\t\tthis.attachInFlight = null;\n\t\tthis.iframeHost?.destroy();\n\t\tthis.iframeHost = null;\n\t\tclearExperienceEventRegistry(this.eventRegistry);\n\t\tthis.readyEvent = null;\n\t\tthis.startedEvent = null;\n\t\tthis.closeHandlers.length = 0;\n\t\tthis.attached = false;\n\t}\n\n\tprivate resolveMintInteraction(): {\n\t\treadonly mode?: ExperienceMode;\n\t\treadonly responseMode?: ResponseMode;\n\t\treadonly speechInputMode?: SpeechInputMode;\n\t} {\n\t\tif (this.launch.kind === 'manifest') {\n\t\t\treturn {};\n\t\t}\n\t\tconst hasProcessor = this.conversationProcessor !== null;\n\t\treturn {\n\t\t\tmode: this.launch.mode,\n\t\t\tresponseMode: hasProcessor ? 'custom' : this.launch.responseMode,\n\t\t\tspeechInputMode: this.launch.speechInputMode\n\t\t};\n\t}\n\n\tprivate assertBrowserCustomManifest(manifest: SessionManifest): void {\n\t\tif (!this.conversationProcessor) return;\n\t\tif (manifest.experience.responseMode !== 'custom') {\n\t\t\tthrow new Error(\n\t\t\t\t'conversationProcessor requires responseMode custom in the Session Manifest.'\n\t\t\t);\n\t\t}\n\t\tif (manifest.processorId) {\n\t\t\tthrow new Error(\n\t\t\t\t'Browser conversationProcessor cannot be used with a registered processorId.'\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate queueProcessorTurn(update: UserTranscriptUpdate): void {\n\t\tif (!update.isFinal || !update.text.trim() || !this.conversationProcessor) return;\n\n\t\tconst processor = this.conversationProcessor;\n\t\tthis.processorAbortController?.abort();\n\t\tthis.processorAbortController = new AbortController();\n\t\tconst signal = this.processorAbortController.signal;\n\n\t\tthis.processorChain = this.processorChain.then(async () => {\n\t\t\tif (signal.aborted) return;\n\t\t\ttry {\n\t\t\t\tconst dispatch = await dispatchConversationProcessor(processor, {\n\t\t\t\t\tutteranceId: update.utteranceId,\n\t\t\t\t\ttext: update.text,\n\t\t\t\t\tconversation: this.conversationCache,\n\t\t\t\t\tsignal\n\t\t\t\t});\n\t\t\t\tif (signal.aborted) return;\n\t\t\t\tif (dispatch.kind === 'complete') {\n\t\t\t\t\tconst speech = dispatch.speech;\n\t\t\t\t\tawait this.speech.speak({\n\t\t\t\t\t\ttext: speech.text,\n\t\t\t\t\t\t...(speech.characterId ? { characterId: speech.characterId } : {}),\n\t\t\t\t\t\tqueue: speech.behavior === 'interrupt' ? 'replace-active' : 'append'\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.iframeHost!.speakProcessorStream(dispatch.stream, { signal });\n\t\t\t} catch (error) {\n\t\t\t\tif (signal.aborted) return;\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'conversationProcessorError', {\n\t\t\t\t\tutteranceId: update.utteranceId,\n\t\t\t\t\tmessage\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate assertAttached(): void {\n\t\tif (!this.attached || !this.iframeHost) {\n\t\t\tthrow new Error('Call Experience.attach() before using speech APIs.');\n\t\t}\n\t}\n\n\tprivate assertSessionStarted(): void {\n\t\tthis.assertAttached();\n\t\tif (!this.startedEvent) {\n\t\t\tthrow new Error(\n\t\t\t\t'Session has not started. Wait for the player start button and the started event before using speak() or listening APIs.'\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate close(): void {\n\t\tif (this.closed) return;\n\t\tthis.closed = true;\n\t\tthis.endpointAbortController?.abort();\n\t\tthis.endpointAbortController = null;\n\t\tthis.attachInFlight = null;\n\t\tthis.iframeHost?.destroy();\n\t\tthis.iframeHost = null;\n\t\tthis.attached = false;\n\t}\n\n\tprivate createPlayerFacade(): LiformaPlayer {\n\t\treturn {\n\t\t\tclose: () => {\n\t\t\t\tthis.close();\n\t\t\t},\n\t\t\tdestroy: () => {\n\t\t\t\tthis.destroy();\n\t\t\t},\n\t\t\ton: (event, handler) => {\n\t\t\t\tif (event === 'close') {\n\t\t\t\t\tthis.closeHandlers.push(handler);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n}\n\n/** Live session handle returned by {@link Experience.startSession}. */\nexport type ExperienceSession = Experience;\n\nfunction resolveSpeechCapabilities(manifest: SessionManifest | null): SpeechCapabilities {\n\tconst caps = manifest?.capabilities ?? [];\n\tconst explicitText = caps.includes('textSpeech');\n\tconst explicitExternal = caps.includes('externalSpeechAudio');\n\t// Schema 1 manifests omit speech flags — default both on so existing experiences keep working.\n\tif (!explicitText && !explicitExternal) {\n\t\treturn { textSpeech: true, externalSpeechAudio: true };\n\t}\n\treturn {\n\t\ttextSpeech: explicitText,\n\t\texternalSpeechAudio: explicitExternal\n\t};\n}\n","import type { CloseEvent } from './protocol';\n\nfunction resolveIntegrationReturnUrl(returnUrl: string, baseOrigin: string): URL | null {\n\tconst raw = returnUrl.trim();\n\tif (!raw) return null;\n\n\tif (/^https?:\\/\\//i.test(raw)) {\n\t\ttry {\n\t\t\treturn new URL(raw);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst base = baseOrigin.replace(/\\/$/, '');\n\tconst path = raw.startsWith('/') ? raw : `/${raw}`;\n\ttry {\n\t\treturn new URL(path, `${base}/`);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction resolveFallbackReturnUrl(fallbackReturnUrl: string): string {\n\ttry {\n\t\tif (document.referrer) {\n\t\t\tconst referrer = new URL(document.referrer);\n\t\t\tif (\n\t\t\t\treferrer.origin === window.location.origin &&\n\t\t\t\treferrer.pathname !== window.location.pathname\n\t\t\t) {\n\t\t\t\treturn `${referrer.pathname}${referrer.search}${referrer.hash}`;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t/* ignore invalid referrer */\n\t}\n\treturn fallbackReturnUrl;\n}\n\n/** Navigate the host page when an iframe session closes. */\nexport function navigateOnExperienceClose(\n\tdetail: CloseEvent,\n\tfallbackReturnUrl = '/meet'\n): void {\n\tif (detail.reason !== 'user') return;\n\n\tconst target =\n\t\tdetail.returnUrl?.trim() || resolveFallbackReturnUrl(fallbackReturnUrl);\n\tconst url = resolveIntegrationReturnUrl(target, window.location.origin);\n\tif (!url?.protocol.startsWith('http')) return;\n\n\twindow.location.assign(url.toString());\n}\n","export type ExperienceLoadErrorKind =\n\t| 'not_found'\n\t| 'origin_not_allowed'\n\t| 'browser_embeds_disabled'\n\t| 'generic';\n\nexport type ExperienceLoadErrorPresentation = {\n\treadonly kind: ExperienceLoadErrorKind;\n\treadonly title: string;\n\treadonly detail: string;\n\treadonly technicalMessage: string;\n\treadonly experienceId?: string;\n\treadonly origin?: string;\n};\n\nconst EXPERIENCE_ID_IN_MESSAGE =\n\t/\\b(exp_[A-Za-z0-9][A-Za-z0-9_-]{2,127})\\b/;\n\nconst ORIGIN_IN_MESSAGE =\n\t/(?:Your origin|origin)\\s+(\\S+)\\s+is not an allowed origin/i;\n\nfunction toErrorMessage(error: unknown): string {\n\tif (error instanceof Error) return error.message;\n\treturn String(error);\n}\n\nfunction currentPageOrigin(): string | undefined {\n\ttry {\n\t\tif (typeof globalThis.location?.origin === 'string' && globalThis.location.origin) {\n\t\t\treturn globalThis.location.origin;\n\t\t}\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nexport function extractExperienceIdFromMessage(message: string): string | undefined {\n\treturn EXPERIENCE_ID_IN_MESSAGE.exec(message)?.[1];\n}\n\nexport function extractOriginFromMessage(message: string): string | undefined {\n\treturn ORIGIN_IN_MESSAGE.exec(message)?.[1];\n}\n\nexport function presentExperienceLoadError(\n\terror: unknown,\n\toptions?: { readonly experienceId?: string | null; readonly origin?: string | null }\n): ExperienceLoadErrorPresentation {\n\tconst technicalMessage = toErrorMessage(error).trim() || 'Unknown error';\n\tconst experienceId =\n\t\toptions?.experienceId?.trim() ||\n\t\textractExperienceIdFromMessage(technicalMessage) ||\n\t\tundefined;\n\tconst origin =\n\t\toptions?.origin?.trim() ||\n\t\textractOriginFromMessage(technicalMessage) ||\n\t\tcurrentPageOrigin() ||\n\t\tundefined;\n\n\tif (\n\t\t/No playable experience found/i.test(technicalMessage) ||\n\t\t/^Experience is not available\\.?$/i.test(technicalMessage) ||\n\t\t/^Unknown experience\\.?$/i.test(technicalMessage) ||\n\t\t/experience_unavailable/i.test(technicalMessage)\n\t) {\n\t\tconst idLabel = experienceId ?? 'the requested experience';\n\t\treturn {\n\t\t\tkind: 'not_found',\n\t\t\ttitle: 'The application tried to load an avatar experience that doesn’t exist.',\n\t\t\tdetail: `Experience with id ${idLabel} does not exist`,\n\t\t\ttechnicalMessage,\n\t\t\texperienceId,\n\t\t\torigin\n\t\t};\n\t}\n\n\tif (\n\t\t/origin_not_allowed/i.test(technicalMessage) ||\n\t\t/is not an allowed origin/i.test(technicalMessage) ||\n\t\t/^Origin not allowed/i.test(technicalMessage)\n\t) {\n\t\tconst originLabel = origin ?? 'this page';\n\t\tconst idLabel = experienceId ?? 'the requested experience';\n\t\treturn {\n\t\t\tkind: 'origin_not_allowed',\n\t\t\ttitle: 'The application tried to load an avatar experience from a website that isn’t allowed.',\n\t\t\tdetail: `Origin ${originLabel} is not allowed for experience ${idLabel}`,\n\t\t\ttechnicalMessage,\n\t\t\texperienceId,\n\t\t\torigin\n\t\t};\n\t}\n\n\tif (\n\t\t/browser_embeds_disabled/i.test(technicalMessage) ||\n\t\t/^Browser embeds are not enabled/i.test(technicalMessage)\n\t) {\n\t\tconst idLabel = experienceId ?? 'the requested experience';\n\t\treturn {\n\t\t\tkind: 'browser_embeds_disabled',\n\t\t\ttitle: 'The application tried to load an avatar experience that isn’t enabled for browser embeds.',\n\t\t\tdetail: `Browser embeds are not enabled for experience ${idLabel}`,\n\t\t\ttechnicalMessage,\n\t\t\texperienceId,\n\t\t\torigin\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: 'generic',\n\t\ttitle: 'This avatar experience couldn’t be started.',\n\t\tdetail: technicalMessage,\n\t\ttechnicalMessage,\n\t\texperienceId,\n\t\torigin\n\t};\n}\n","/** Subset of session loading overlay styles for pre-attach Experience load errors. */\n\nexport const EXPERIENCE_LOAD_ERROR_STYLE_ID = 'liforma-experience-load-error-styles';\n\nexport function injectExperienceLoadErrorStyles(): void {\n\tif (typeof document === 'undefined') return;\n\tif (document.getElementById(EXPERIENCE_LOAD_ERROR_STYLE_ID)) return;\n\tconst style = document.createElement('style');\n\tstyle.id = EXPERIENCE_LOAD_ERROR_STYLE_ID;\n\tstyle.textContent = EXPERIENCE_LOAD_ERROR_CSS;\n\tdocument.head.append(style);\n}\n\nexport const EXPERIENCE_LOAD_ERROR_CSS = `\n\t.liforma-loading-screen {\n\t\tinset: 0;\n\t\tz-index: 20;\n\t\tbox-sizing: border-box;\n\t\toverflow-x: clip;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tmax-width: 100vw;\n\t\tbackground:\n\t\t\tradial-gradient(circle at 50% 60%, rgba(79, 126, 196, 0.18), transparent 38%),\n\t\t\t#030508;\n\t\tfont-family: system-ui, -apple-system, sans-serif;\n\t\tcolor: #e8f0ff;\n\t\ttext-align: center;\n\t}\n\t.liforma-loading-screen-absolute {\n\t\tposition: absolute;\n\t}\n\t.liforma-loading-card {\n\t\tposition: absolute;\n\t\tleft: 50%;\n\t\ttop: 60%;\n\t\ttransform: translate(-50%, -50%);\n\t\twidth: min(22rem, calc(100% - 2.5rem));\n\t\tmax-width: calc(100% - max(1.25rem, env(safe-area-inset-left, 0px)) - max(1.25rem, env(safe-area-inset-right, 0px)));\n\t\tbox-sizing: border-box;\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tbackground: transparent;\n\t\tbox-shadow: none;\n\t}\n\t.liforma-loading-card-error {\n\t\tdisplay: block;\n\t\ttext-align: center;\n\t\tpadding: 1rem 1.05rem;\n\t\tborder-radius: 14px;\n\t\tborder: 1px solid rgba(255, 154, 154, 0.28);\n\t\tbackground:\n\t\t\tlinear-gradient(180deg, rgba(21, 29, 42, 0.92), rgba(9, 13, 20, 0.92));\n\t}\n\t.liforma-loading-kicker {\n\t\tmargin: 0 0 0.18rem;\n\t\tcolor: #8ba4c5;\n\t\tfont-size: 0.68rem;\n\t\tfont-weight: 700;\n\t\ttext-transform: uppercase;\n\t\tletter-spacing: 0.08em;\n\t}\n\t.liforma-loading-error {\n\t\tmargin: 0;\n\t\tmax-width: 28rem;\n\t\tcolor: #ffb4b4;\n\t\tfont-size: 0.92rem;\n\t\tline-height: 1.4;\n\t}\n\t.liforma-loading-error-title {\n\t\tmargin: 0;\n\t\tcolor: #f6ebe8;\n\t\tfont-size: 0.98rem;\n\t\tfont-weight: 650;\n\t\tline-height: 1.35;\n\t}\n\t.liforma-loading-error-advanced {\n\t\tmargin: 0.85rem 0 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tbackground: transparent;\n\t\tcolor: #9eb7d8;\n\t\tfont: inherit;\n\t\tfont-size: 0.78rem;\n\t\tfont-weight: 650;\n\t\tletter-spacing: 0.02em;\n\t\ttext-decoration: underline;\n\t\ttext-underline-offset: 0.18em;\n\t\tcursor: pointer;\n\t}\n\t.liforma-loading-error-advanced:hover,\n\t.liforma-loading-error-advanced:focus-visible {\n\t\tcolor: #d7e6ff;\n\t\toutline: none;\n\t}\n\t.liforma-loading-error-detail {\n\t\tmargin: 0.7rem 0 0;\n\t\tpadding: 0.65rem 0.7rem;\n\t\tborder-radius: 10px;\n\t\tborder: 1px solid rgba(158, 191, 255, 0.16);\n\t\tbackground: rgba(3, 5, 8, 0.45);\n\t\tcolor: #c6d4e8;\n\t\tfont-size: 0.78rem;\n\t\tfont-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n\t\tline-height: 1.4;\n\t\ttext-align: left;\n\t\tword-break: break-word;\n\t}\n\t.liforma-loading-error-detail[hidden] {\n\t\tdisplay: none;\n\t}\n`;\n","import type { ExperienceLoadErrorPresentation } from './experienceLoadError';\nimport { injectExperienceLoadErrorStyles } from './experienceLoadErrorStyles';\n\nexport type ExperienceLoadErrorOverlay = {\n\treadonly root: HTMLDivElement;\n\tsetPresentation(presentation: ExperienceLoadErrorPresentation): void;\n\tremove(): void;\n};\n\nexport function createExperienceLoadErrorOverlay(\n\tcontainer: HTMLElement,\n\tinitial: ExperienceLoadErrorPresentation\n): ExperienceLoadErrorOverlay {\n\tinjectExperienceLoadErrorStyles();\n\n\tlet presentation = initial;\n\tlet advancedOpen = false;\n\n\tconst root = document.createElement('div');\n\troot.className = 'liforma-loading-screen liforma-loading-screen-absolute';\n\troot.setAttribute('role', 'alert');\n\troot.setAttribute('aria-live', 'assertive');\n\n\tconst card = document.createElement('div');\n\tcard.className = 'liforma-loading-card liforma-loading-card-error';\n\n\tconst kicker = document.createElement('p');\n\tkicker.className = 'liforma-loading-kicker';\n\tkicker.textContent = 'Avatar experience';\n\n\tconst title = document.createElement('p');\n\ttitle.className = 'liforma-loading-error-title';\n\n\tconst advancedBtn = document.createElement('button');\n\tadvancedBtn.type = 'button';\n\tadvancedBtn.className = 'liforma-loading-error-advanced';\n\n\tconst detail = document.createElement('p');\n\tdetail.className = 'liforma-loading-error-detail';\n\n\tadvancedBtn.addEventListener('click', () => {\n\t\tadvancedOpen = !advancedOpen;\n\t\trender();\n\t});\n\n\tcard.append(kicker, title, advancedBtn, detail);\n\troot.append(card);\n\tcontainer.append(root);\n\n\tfunction render(): void {\n\t\ttitle.textContent = presentation.title;\n\t\tdetail.textContent = presentation.detail;\n\t\tdetail.hidden = !advancedOpen;\n\t\tadvancedBtn.textContent = advancedOpen ? 'Hide details' : 'Advanced';\n\t\tadvancedBtn.setAttribute('aria-expanded', advancedOpen ? 'true' : 'false');\n\t}\n\n\trender();\n\n\treturn {\n\t\troot,\n\t\tsetPresentation(next) {\n\t\t\tpresentation = next;\n\t\t\tadvancedOpen = false;\n\t\t\trender();\n\t\t},\n\t\tremove() {\n\t\t\troot.remove();\n\t\t}\n\t};\n}\n","import { Experience } from './experience';\nimport type { CloseEvent } from './embed/protocol';\nimport { navigateOnExperienceClose } from './embed/returnNavigation';\nimport type { ExperienceFit, ExperienceMode, SpeechInputMode } from './types/sessionInteraction';\nimport { presentExperienceLoadError } from '../svelte/experienceLoadError';\nimport {\n\tcreateExperienceLoadErrorOverlay,\n\ttype ExperienceLoadErrorOverlay\n} from '../svelte/experienceLoadErrorOverlay';\n\nconst ELEMENT_NAME = 'liforma-experience';\n\nfunction parseMode(value: string | null): ExperienceMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'conversation' || trimmed === 'presenter' ? trimmed : undefined;\n}\n\nfunction parseSpeechInputMode(value: string | null): SpeechInputMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'auto' || trimmed === 'manual' || trimmed === 'off' ? trimmed : undefined;\n}\n\nfunction parseFit(value: string | null): ExperienceFit | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'full' || trimmed === 'face' ? trimmed : undefined;\n}\n\nexport class LiformaExperienceElement extends HTMLElement {\n\tprivate host: HTMLDivElement | null = null;\n\tprivate errorHost: HTMLDivElement | null = null;\n\tprivate errorOverlay: ExperienceLoadErrorOverlay | null = null;\n\tprivate experience: Experience | null = null;\n\tprivate bootstrapGeneration = 0;\n\n\tstatic get observedAttributes(): string[] {\n\t\treturn [\n\t\t\t'experience-id',\n\t\t\t'language',\n\t\t\t'session-endpoint',\n\t\t\t'speech-only',\n\t\t\t'mode',\n\t\t\t'speech-input-mode',\n\t\t\t'fit'\n\t\t];\n\t}\n\n\tconnectedCallback(): void {\n\t\tthis.style.display = 'block';\n\t\tthis.style.position = 'relative';\n\t\tthis.style.overflow = 'hidden';\n\t\tif (!this.style.width) this.style.width = '100%';\n\t\t// Fill the host box when it has a definite height (flex/grid/explicit).\n\t\t// Do not set minHeight:inherit — that overrides host CSS such as\n\t\t// `.liforma-embed { min-height: 420px }` and collapses absolute children.\n\t\tif (!this.style.height) this.style.height = '100%';\n\t\tconst computedMinHeight = getComputedStyle(this).minHeight;\n\t\tif (\n\t\t\t!this.style.minHeight &&\n\t\t\t(computedMinHeight === '0px' || computedMinHeight === 'auto')\n\t\t) {\n\t\t\tthis.style.minHeight = '480px';\n\t\t}\n\n\t\tif (!this.errorHost) {\n\t\t\tthis.errorHost = document.createElement('div');\n\t\t\tthis.errorHost.style.cssText =\n\t\t\t\t'position:absolute;inset:0;z-index:20;pointer-events:none;';\n\t\t\tthis.append(this.errorHost);\n\t\t}\n\n\t\tif (!this.host) {\n\t\t\tthis.host = document.createElement('div');\n\t\t\t// Absolute fill avoids height:100% collapsing when size comes from flex/min-height.\n\t\t\tthis.host.style.cssText = 'position:absolute;inset:0;overflow:hidden;';\n\t\t\tthis.append(this.host);\n\t\t}\n\n\t\tvoid this.bootstrap();\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tthis.bootstrapGeneration += 1;\n\t\tthis.experience?.destroy();\n\t\tthis.experience = null;\n\t\tthis.clearError();\n\t}\n\n\tattributeChangedCallback(\n\t\tname: string,\n\t\toldValue: string | null,\n\t\tnewValue: string | null\n\t): void {\n\t\tif (\n\t\t\tname !== 'experience-id' &&\n\t\t\tname !== 'language' &&\n\t\t\tname !== 'session-endpoint' &&\n\t\t\tname !== 'speech-only' &&\n\t\t\tname !== 'mode' &&\n\t\t\tname !== 'speech-input-mode' &&\n\t\t\tname !== 'fit'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (oldValue === newValue || !this.isConnected) {\n\t\t\treturn;\n\t\t}\n\t\tthis.bootstrapGeneration += 1;\n\t\tthis.experience?.destroy();\n\t\tthis.experience = null;\n\t\tthis.clearError();\n\t\tif (this.host) {\n\t\t\tthis.host.replaceChildren();\n\t\t}\n\t\tvoid this.bootstrap();\n\t}\n\n\tprivate async bootstrap(): Promise<void> {\n\t\tconst experienceId = this.getAttribute('experience-id')?.trim();\n\t\tconst sessionEndpoint = this.getAttribute('session-endpoint')?.trim();\n\t\tconst languageAttr = this.getAttribute('language')?.trim();\n\t\tconst language = languageAttr === 'es' || languageAttr === 'en' ? languageAttr : undefined;\n\t\tconst speechOnly = this.getAttribute('speech-only') === 'true';\n\t\tconst mode = parseMode(this.getAttribute('mode'));\n\t\tconst speechInputMode = parseSpeechInputMode(this.getAttribute('speech-input-mode'));\n\t\tconst fit = parseFit(this.getAttribute('fit'));\n\t\tif (!experienceId || !this.host) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst generation = ++this.bootstrapGeneration;\n\t\tthis.clearError();\n\n\t\ttry {\n\t\t\tconst experience = await Experience.startSession(\n\t\t\t\tsessionEndpoint\n\t\t\t\t\t? {\n\t\t\t\t\t\t\texperienceId,\n\t\t\t\t\t\t\tsessionEndpoint,\n\t\t\t\t\t\t\tlanguage,\n\t\t\t\t\t\t\tspeechOnly,\n\t\t\t\t\t\t\tmode,\n\t\t\t\t\t\t\tspeechInputMode,\n\t\t\t\t\t\t\tfit\n\t\t\t\t\t\t}\n\t\t\t\t\t: { experienceId, language, speechOnly, mode, speechInputMode, fit }\n\t\t\t);\n\t\t\tif (generation !== this.bootstrapGeneration) {\n\t\t\t\texperience.destroy();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.experience = experience;\n\t\t\tconst player = await experience.attach({ container: this.host });\n\t\t\tif (generation !== this.bootstrapGeneration) {\n\t\t\t\texperience.destroy();\n\t\t\t\tthis.experience = null;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tplayer.on('close', (detail: CloseEvent) => {\n\t\t\t\tthis.dispatchEvent(new CustomEvent<CloseEvent>('close', { detail, bubbles: true }));\n\t\t\t\tnavigateOnExperienceClose(detail);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (generation !== this.bootstrapGeneration) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.showError(error, experienceId);\n\t\t\tconsole.error('[liforma-experience]', error);\n\t\t\tthis.experience?.destroy();\n\t\t\tthis.experience = null;\n\t\t}\n\t}\n\n\tprivate showError(error: unknown, experienceId?: string): void {\n\t\tthis.clearError();\n\t\tif (!this.errorHost) return;\n\t\tthis.errorHost.style.pointerEvents = 'auto';\n\t\tthis.errorOverlay = createExperienceLoadErrorOverlay(\n\t\t\tthis.errorHost,\n\t\t\tpresentExperienceLoadError(error, { experienceId })\n\t\t);\n\t}\n\n\tprivate clearError(): void {\n\t\tthis.errorOverlay?.remove();\n\t\tthis.errorOverlay = null;\n\t\tif (this.errorHost) {\n\t\t\tthis.errorHost.style.pointerEvents = 'none';\n\t\t\tthis.errorHost.replaceChildren();\n\t\t}\n\t}\n}\n\nif (typeof customElements !== 'undefined' && !customElements.get(ELEMENT_NAME)) {\n\tcustomElements.define(ELEMENT_NAME, LiformaExperienceElement);\n}\n","const AVATAR_TIER_RE = /(\\/avatars\\/[^/]+\\/)(\\d+)(\\/)/i;\nconst LOCATION_SIZE_RE = /(-)(\\d+x\\d+)(\\.webp)(\\?|$)/i;\n\n/**\n * Rewrite known Liforma CDN URLs to gallery thumb tiers.\n * Avatars: /{tier}/ → /256/; locations: -{WxH}.webp → -256x256.webp.\n * Unrecognized URLs are returned unchanged.\n */\nexport function toGalleryThumbUrl(url: string): string {\n\tconst raw = url.trim();\n\tif (!raw) return raw;\n\n\tlet next = raw.replace(AVATAR_TIER_RE, (_match, prefix: string, tier: string, slash: string) => {\n\t\tif (tier === '256') return `${prefix}${tier}${slash}`;\n\t\treturn `${prefix}256${slash}`;\n\t});\n\n\tnext = next.replace(\n\t\tLOCATION_SIZE_RE,\n\t\t(_match, dash: string, size: string, ext: string, end: string) => {\n\t\t\tif (size === '256x256') return `${dash}${size}${ext}${end}`;\n\t\t\treturn `${dash}256x256${ext}${end}`;\n\t\t}\n\t);\n\n\treturn next;\n}\n\nexport function resolveThumbnailLayers(input: {\n\treadonly galleryThumb?: {\n\t\treadonly avatarImage?: string;\n\t\treadonly backgroundImage?: string;\n\t\treadonly foregroundImage?: string;\n\t};\n\treadonly avatarImage?: string;\n\treadonly backgroundImage?: string;\n\treadonly foregroundImage?: string;\n\treadonly fallbackImage?: string;\n}): {\n\treadonly avatarImage: string;\n\treadonly backgroundImage?: string;\n\treadonly foregroundImage?: string;\n\treadonly fallbackImage?: string;\n} | null {\n\tconst avatarSource =\n\t\tinput.avatarImage?.trim() ||\n\t\tinput.galleryThumb?.avatarImage?.trim() ||\n\t\t'';\n\tif (!avatarSource) return null;\n\n\tconst backgroundSource =\n\t\tinput.backgroundImage?.trim() || input.galleryThumb?.backgroundImage?.trim() || '';\n\tconst foregroundSource =\n\t\tinput.foregroundImage?.trim() || input.galleryThumb?.foregroundImage?.trim() || '';\n\tconst fallbackSource = input.fallbackImage?.trim() || '';\n\n\treturn {\n\t\tavatarImage: toGalleryThumbUrl(avatarSource),\n\t\t...(backgroundSource ? { backgroundImage: toGalleryThumbUrl(backgroundSource) } : {}),\n\t\t...(foregroundSource ? { foregroundImage: toGalleryThumbUrl(foregroundSource) } : {}),\n\t\t...(fallbackSource ? { fallbackImage: toGalleryThumbUrl(fallbackSource) } : {})\n\t};\n}\n","import { useExplicitLocalStack } from '../shims/localStack';\nimport type { ResolveThumbnailInteractionInput, ThumbnailInteractionKind } from './types';\n\nconst PRODUCTION_PLAYER_ORIGIN = 'https://player.liforma.ai';\nconst LOCAL_PLAYER_ORIGIN = 'http://localhost:3002';\n\n/** Priority: href → click-only → hosted (experienceId) → presentational. */\nexport function resolveThumbnailInteraction(\n\tinput: ResolveThumbnailInteractionInput\n): ThumbnailInteractionKind {\n\tif (input.href?.trim()) return 'anchor';\n\tif (input.hasClickHandler) return 'button';\n\tif (input.experienceId?.trim()) return 'anchor';\n\treturn 'presentational';\n}\n\nexport function resolvePlayerBaseUrl(playerBaseUrl?: string): string {\n\tconst configured = playerBaseUrl?.trim();\n\tif (configured) return configured.replace(/\\/$/, '');\n\n\tif (useExplicitLocalStack()) {\n\t\treturn LOCAL_PLAYER_ORIGIN;\n\t}\n\n\treturn PRODUCTION_PLAYER_ORIGIN;\n}\n\n/**\n * Build hosted player launch URL: `{player}/{experienceId}?returnUrl=…`\n * When `returnUrl` is omitted, callers should assign on click (SSR-safe) or pass an explicit URL.\n */\nexport function buildHostedLaunchUrl(options: {\n\treadonly experienceId: string;\n\treadonly returnUrl?: string;\n\treadonly playerBaseUrl?: string;\n}): string {\n\tconst experienceId = options.experienceId.trim();\n\tconst base = resolvePlayerBaseUrl(options.playerBaseUrl);\n\tconst url = new URL(`${base}/${encodeURIComponent(experienceId)}`);\n\tconst returnUrl = options.returnUrl?.trim();\n\tif (returnUrl) {\n\t\turl.searchParams.set('returnUrl', returnUrl);\n\t}\n\treturn url.toString();\n}\n\n/** Resolve href for anchor mode (app link or hosted launch). */\nexport function resolveThumbnailHref(options: {\n\treadonly href?: string;\n\treadonly experienceId?: string;\n\treadonly returnUrl?: string;\n\treadonly playerBaseUrl?: string;\n\t/** When true and returnUrl omitted, use window.location.href (browser only). */\n\treadonly useCurrentPageAsReturnUrl?: boolean;\n}): string | undefined {\n\tconst href = options.href?.trim();\n\tif (href) return href;\n\n\tconst experienceId = options.experienceId?.trim();\n\tif (!experienceId) return undefined;\n\n\tlet returnUrl = options.returnUrl?.trim();\n\tif (!returnUrl && options.useCurrentPageAsReturnUrl && typeof window !== 'undefined') {\n\t\treturnUrl = window.location.href;\n\t}\n\n\treturn buildHostedLaunchUrl({\n\t\texperienceId,\n\t\t...(returnUrl ? { returnUrl } : {}),\n\t\tplayerBaseUrl: options.playerBaseUrl\n\t});\n}\n","/** Touch / coarse pointers — limit how many thumbs start loading at once. */\nexport const COARSE_THUMB_LOAD_CONCURRENCY = 4;\n/** Delay before a started thumb frees its queue slot for the next card. */\nexport const COARSE_THUMB_LOAD_STAGGER_MS = 160;\n\nexport function prefersCoarsePointer(): boolean {\n\tif (typeof window === 'undefined') return false;\n\treturn window.matchMedia('(hover: none), (pointer: coarse)').matches;\n}\n\ntype QueuedLoad = {\n\treadonly start: () => void;\n\tcancelled: boolean;\n};\n\nlet inflight = 0;\nconst waiting: QueuedLoad[] = [];\n\nfunction maxConcurrent(): number {\n\treturn prefersCoarsePointer() ? COARSE_THUMB_LOAD_CONCURRENCY : Number.POSITIVE_INFINITY;\n}\n\nfunction staggerMs(): number {\n\treturn prefersCoarsePointer() ? COARSE_THUMB_LOAD_STAGGER_MS : 0;\n}\n\nfunction pump(): void {\n\tconst limit = maxConcurrent();\n\twhile (inflight < limit && waiting.length > 0) {\n\t\tconst next = waiting.shift();\n\t\tif (!next || next.cancelled) continue;\n\t\tinflight += 1;\n\t\tnext.start();\n\t\tconst delay = staggerMs();\n\t\tif (delay <= 0) {\n\t\t\tinflight = Math.max(0, inflight - 1);\n\t\t\tcontinue;\n\t\t}\n\t\twindow.setTimeout(() => {\n\t\t\tinflight = Math.max(0, inflight - 1);\n\t\t\tpump();\n\t\t}, delay);\n\t}\n}\n\n/**\n * On coarse pointers, start thumb image loads in small waves so old devices\n * are not hit with dozens of concurrent decodes. Fine pointers start immediately.\n * Returns a cancel function (no-op after start has run).\n */\nexport function scheduleThumbLoad(start: () => void): () => void {\n\tif (!prefersCoarsePointer()) {\n\t\tstart();\n\t\treturn () => {};\n\t}\n\n\tconst item: QueuedLoad = { start, cancelled: false };\n\twaiting.push(item);\n\tpump();\n\n\treturn () => {\n\t\titem.cancelled = true;\n\t};\n}\n\n/** Test helper — clear queue state between vitest cases. */\nexport function resetThumbLoadSchedulerForTests(): void {\n\tinflight = 0;\n\twaiting.length = 0;\n}\n","import { prefersCoarsePointer, scheduleThumbLoad } from './thumbLoadScheduler';\n\nexport type LazyThumbOptions = {\n\treadonly rootMargin?: string;\n\treadonly onVisibleChange: (visible: boolean) => void;\n};\n\n/** Desktop: prefetch earlier. Coarse/touch: tighter margin to cut burst loads. */\nexport function getDefaultLazyRootMargin(): string {\n\treturn prefersCoarsePointer() ? '96px 0px' : '280px 0px';\n}\n\nfunction parseVerticalRootMarginPx(rootMargin: string): number {\n\tconst first = rootMargin.trim().split(/\\s+/)[0] ?? '0px';\n\tconst value = Number.parseFloat(first);\n\treturn Number.isFinite(value) ? Math.abs(value) : 280;\n}\n\nfunction isNearViewport(element: HTMLElement, marginPx: number): boolean {\n\tif (typeof window === 'undefined') return false;\n\tconst rect = element.getBoundingClientRect();\n\treturn rect.bottom >= -marginPx && rect.top <= window.innerHeight + marginPx;\n}\n\n/** Observe the thumb and enable image loads when near the viewport. */\nexport function attachLazyThumb(element: HTMLElement, options: LazyThumbOptions): () => void {\n\tconst { onVisibleChange } = options;\n\tconst rootMargin = options.rootMargin ?? getDefaultLazyRootMargin();\n\tconst marginPx = parseVerticalRootMarginPx(rootMargin);\n\tlet visible = false;\n\tlet loadStarted = false;\n\tlet cancelScheduled: (() => void) | null = null;\n\n\tconst requestLoad = () => {\n\t\tif (loadStarted) return;\n\t\tcancelScheduled?.();\n\t\tcancelScheduled = scheduleThumbLoad(() => {\n\t\t\tcancelScheduled = null;\n\t\t\tloadStarted = true;\n\t\t\tonVisibleChange(true);\n\t\t});\n\t};\n\n\tconst setVisible = (next: boolean) => {\n\t\tif (next === visible) return;\n\t\tvisible = next;\n\t\tif (next) {\n\t\t\trequestLoad();\n\t\t\treturn;\n\t\t}\n\t\t// Keep images once started; only cancel a queued (not-yet-started) load.\n\t\tcancelScheduled?.();\n\t\tcancelScheduled = null;\n\t\tonVisibleChange(false);\n\t};\n\n\tif (typeof IntersectionObserver === 'undefined') {\n\t\trequestLoad();\n\t\treturn () => {\n\t\t\tcancelScheduled?.();\n\t\t\tcancelScheduled = null;\n\t\t};\n\t}\n\n\tconst observer = new IntersectionObserver(\n\t\t(entries) => {\n\t\t\tsetVisible(entries.some((entry) => entry.isIntersecting));\n\t\t},\n\t\t{ root: null, rootMargin, threshold: 0 }\n\t);\n\n\tobserver.observe(element);\n\n\tif (isNearViewport(element, marginPx)) {\n\t\tsetVisible(true);\n\t}\n\n\treturn () => {\n\t\tcancelScheduled?.();\n\t\tcancelScheduled = null;\n\t\tobserver.disconnect();\n\t};\n}\n\nexport function attachImageReady(element: HTMLImageElement, onReady: () => void): () => void {\n\tconst notify = () => onReady();\n\tif (element.complete) {\n\t\tqueueMicrotask(notify);\n\t} else {\n\t\telement.addEventListener('load', notify, { once: true });\n\t\telement.addEventListener('error', notify, { once: true });\n\t}\n\treturn () => {\n\t\telement.removeEventListener('load', notify);\n\t\telement.removeEventListener('error', notify);\n\t};\n}\n","/** Touch devices without hover — drive thumbnail parallax from scroll position. */\nexport function prefersScrollLinkedParallax(): boolean {\n\tif (typeof window === 'undefined') return false;\n\tif (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return false;\n\treturn window.matchMedia('(hover: none), (pointer: coarse)').matches;\n}\n\n/**\n * Map an element's vertical centre in the viewport to horizontal parallax in [-1, 1].\n */\nexport function horizontalParallaxFromViewportY(rect: DOMRect, viewportHeight: number): number {\n\tconst centerY = rect.top + rect.height / 2;\n\tconst t = centerY / Math.max(viewportHeight, 1);\n\treturn (t - 0.5) * 2;\n}\n\nexport type ScrollLinkedParallaxOptions = {\n\treadonly onParallax: (x: number) => void;\n\treadonly pointerActive?: () => boolean;\n};\n\ntype ScrollParallaxSubscriber = {\n\treadonly element: HTMLElement;\n\treadonly onParallax: (x: number) => void;\n\treadonly pointerActive?: () => boolean;\n};\n\nconst subscribers = new Set<ScrollParallaxSubscriber>();\nlet listening = false;\nlet frame = 0;\n\nfunction syncAll(): void {\n\tframe = 0;\n\tif (subscribers.size === 0 || typeof window === 'undefined') return;\n\tconst viewportHeight = window.innerHeight;\n\tfor (const entry of subscribers) {\n\t\tif (entry.pointerActive?.()) continue;\n\t\tconst rect = entry.element.getBoundingClientRect();\n\t\t// Skip off-screen thumbs — avoids N layout reads + framework updates per scroll.\n\t\tif (rect.bottom < -64 || rect.top > viewportHeight + 64) continue;\n\t\tentry.onParallax(horizontalParallaxFromViewportY(rect, viewportHeight));\n\t}\n}\n\nfunction scheduleSync(): void {\n\tif (frame !== 0) return;\n\tframe = requestAnimationFrame(syncAll);\n}\n\nfunction ensureListening(): void {\n\tif (listening || typeof window === 'undefined') return;\n\tlistening = true;\n\twindow.addEventListener('scroll', scheduleSync, { passive: true });\n\twindow.addEventListener('resize', scheduleSync, { passive: true });\n}\n\nfunction stopListeningIfIdle(): void {\n\tif (subscribers.size > 0 || !listening || typeof window === 'undefined') return;\n\tlistening = false;\n\tif (frame !== 0) {\n\t\tcancelAnimationFrame(frame);\n\t\tframe = 0;\n\t}\n\twindow.removeEventListener('scroll', scheduleSync);\n\twindow.removeEventListener('resize', scheduleSync);\n}\n\n/**\n * Subscribe to scroll/resize and update horizontal parallax from viewport Y.\n * Uses one shared window listener for all thumbs (old iPads with large galleries).\n */\nexport function attachScrollLinkedParallax(\n\telement: HTMLElement,\n\toptions: ScrollLinkedParallaxOptions\n): () => void {\n\tif (!prefersScrollLinkedParallax()) return () => {};\n\n\tconst entry: ScrollParallaxSubscriber = {\n\t\telement,\n\t\tonParallax: options.onParallax,\n\t\tpointerActive: options.pointerActive\n\t};\n\tsubscribers.add(entry);\n\tensureListening();\n\n\tif (!entry.pointerActive?.()) {\n\t\toptions.onParallax(\n\t\t\thorizontalParallaxFromViewportY(element.getBoundingClientRect(), window.innerHeight)\n\t\t);\n\t}\n\n\treturn () => {\n\t\tsubscribers.delete(entry);\n\t\tstopListeningIfIdle();\n\t};\n}\n\n/** Test helper — clear shared scroll state between vitest cases. */\nexport function resetScrollLinkedParallaxForTests(): void {\n\tsubscribers.clear();\n\tif (typeof window !== 'undefined' && listening) {\n\t\twindow.removeEventListener('scroll', scheduleSync);\n\t\twindow.removeEventListener('resize', scheduleSync);\n\t}\n\tlistening = false;\n\tif (frame !== 0) {\n\t\tcancelAnimationFrame(frame);\n\t\tframe = 0;\n\t}\n}\n","import {\n\tattachScrollLinkedParallax,\n\thorizontalParallaxFromViewportY\n} from './scrollParallax';\n\n/**\n * Drive `--liforma-et-parallax-*` CSS vars and `liforma-et--parallax` /\n * `liforma-et--scroll-parallax` classes from pointer (desktop) or scroll (touch).\n * Matches ExperienceThumbnail / `<liforma-experience-thumbnail>` behaviour.\n */\nexport function attachThumbnailParallax(root: HTMLElement): () => void {\n\tlet parallaxX = 0;\n\tlet parallaxY = 0;\n\tlet hovering = false;\n\tlet scrollParallax = false;\n\tlet pointerDown = false;\n\n\tconst sync = () => {\n\t\tconst parallaxActive = hovering || scrollParallax;\n\t\troot.classList.toggle('liforma-et--parallax', parallaxActive);\n\t\troot.classList.toggle('liforma-et--scroll-parallax', scrollParallax);\n\t\troot.style.setProperty('--liforma-et-parallax-x', String(parallaxX));\n\t\troot.style.setProperty('--liforma-et-parallax-y', String(parallaxY));\n\t};\n\n\tconst detachScroll = attachScrollLinkedParallax(root, {\n\t\tonParallax: (x) => {\n\t\t\tscrollParallax = true;\n\t\t\tif (!pointerDown) {\n\t\t\t\tparallaxX = x;\n\t\t\t\tparallaxY = 0;\n\t\t\t\tsync();\n\t\t\t}\n\t\t},\n\t\tpointerActive: () => pointerDown\n\t});\n\n\tconst onPointerMove = (event: PointerEvent) => {\n\t\tif (scrollParallax) return;\n\t\tconst rect = root.getBoundingClientRect();\n\t\tif (rect.width <= 0 || rect.height <= 0) return;\n\t\tparallaxX = ((event.clientX - rect.left) / rect.width - 0.5) * 2;\n\t\tparallaxY = ((event.clientY - rect.top) / rect.height - 0.5) * 2;\n\t\tsync();\n\t};\n\n\tconst onPointerDown = (event: PointerEvent) => {\n\t\tpointerDown = true;\n\t\tif (event.pointerType === 'mouse') hovering = true;\n\t\tsync();\n\t};\n\n\tconst onPointerUp = () => {\n\t\tconst wasDown = pointerDown;\n\t\tpointerDown = false;\n\t\thovering = false;\n\t\tif (scrollParallax && wasDown) {\n\t\t\tparallaxX = horizontalParallaxFromViewportY(\n\t\t\t\troot.getBoundingClientRect(),\n\t\t\t\twindow.innerHeight\n\t\t\t);\n\t\t\tparallaxY = 0;\n\t\t} else if (!scrollParallax) {\n\t\t\tparallaxX = 0;\n\t\t\tparallaxY = 0;\n\t\t}\n\t\tsync();\n\t};\n\n\tconst onPointerEnter = (event: PointerEvent) => {\n\t\tif (event.pointerType === 'mouse') {\n\t\t\thovering = true;\n\t\t\tsync();\n\t\t}\n\t};\n\n\tconst onPointerLeave = () => {\n\t\tif (!pointerDown) {\n\t\t\thovering = false;\n\t\t\tif (!scrollParallax) {\n\t\t\t\tparallaxX = 0;\n\t\t\t\tparallaxY = 0;\n\t\t\t}\n\t\t\tsync();\n\t\t}\n\t};\n\n\troot.addEventListener('pointermove', onPointerMove);\n\troot.addEventListener('pointerdown', onPointerDown);\n\troot.addEventListener('pointerup', onPointerUp);\n\troot.addEventListener('pointercancel', onPointerUp);\n\troot.addEventListener('pointerenter', onPointerEnter);\n\troot.addEventListener('pointerleave', onPointerLeave);\n\n\treturn () => {\n\t\tdetachScroll();\n\t\troot.removeEventListener('pointermove', onPointerMove);\n\t\troot.removeEventListener('pointerdown', onPointerDown);\n\t\troot.removeEventListener('pointerup', onPointerUp);\n\t\troot.removeEventListener('pointercancel', onPointerUp);\n\t\troot.removeEventListener('pointerenter', onPointerEnter);\n\t\troot.removeEventListener('pointerleave', onPointerLeave);\n\t\troot.classList.remove('liforma-et--parallax', 'liforma-et--scroll-parallax');\n\t\troot.style.removeProperty('--liforma-et-parallax-x');\n\t\troot.style.removeProperty('--liforma-et-parallax-y');\n\t};\n}\n","/** Shared styles for ExperienceThumbnail (class prefix `liforma-et`). */\nexport const EXPERIENCE_THUMBNAIL_CSS = `\n.liforma-et {\n\t--liforma-et-parallax-x: 0;\n\t--liforma-et-parallax-y: 0;\n\t--liforma-et-bg-scale: 1;\n\t--liforma-et-fg-scale: 1;\n\t--liforma-et-avatar-scale: 1;\n\t--liforma-et-bg-shift: 0px;\n\t--liforma-et-fg-shift: 0px;\n\t--liforma-et-avatar-shift: 0px;\n\t--liforma-et-reveal-duration: 420ms;\n\n\tbox-sizing: border-box;\n\tposition: relative;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tmin-height: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tborder-radius: 0.65rem;\n\toverflow: hidden;\n\tbackground: #111;\n\tcolor: inherit;\n\ttext-decoration: none;\n\tcursor: inherit;\n\t-webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n\tcursor: pointer;\n}\n\nbutton.liforma-et {\n\tfont: inherit;\n\tappearance: none;\n}\n\n.liforma-et__placeholder {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 0;\n\tbackground:\n\t\tradial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n\t\tlinear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n\topacity: 1;\n\ttransition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n\topacity: 0;\n}\n\n.liforma-et__media {\n\topacity: 0;\n\ttransition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n\topacity: 1;\n}\n\n.liforma-et__background {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\twidth: 100%;\n\theight: 100%;\n\tobject-fit: cover;\n\tobject-position: center center;\n\ttransform: translate(\n\t\t\tcalc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n\t\t\tcalc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n\t\t)\n\t\tscale(var(--liforma-et-bg-scale));\n\ttransform-origin: center center;\n\ttransition:\n\t\topacity var(--liforma-et-reveal-duration) ease,\n\t\ttransform 160ms ease;\n}\n\n.liforma-et__avatar {\n\tposition: relative;\n\tz-index: 2;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tobject-fit: cover;\n\tobject-position: 50% 30%;\n\ttransform: scale(var(--liforma-et-avatar-scale))\n\t\ttranslate(\n\t\t\tcalc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n\t\t\tcalc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n\t\t);\n\ttransform-origin: center center;\n\ttransition:\n\t\topacity var(--liforma-et-reveal-duration) ease,\n\t\ttransform 160ms ease;\n}\n\n.liforma-et--scene .liforma-et__avatar {\n\tobject-fit: contain;\n\tobject-position: center bottom;\n}\n\n.liforma-et__foreground {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 3;\n\twidth: 100%;\n\theight: 100%;\n\tobject-fit: cover;\n\tobject-position: center center;\n\tpointer-events: none;\n\ttransform: translate(\n\t\t\tcalc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n\t\t\tcalc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n\t\t)\n\t\tscale(var(--liforma-et-fg-scale));\n\ttransform-origin: center center;\n\ttransition:\n\t\topacity var(--liforma-et-reveal-duration) ease,\n\t\ttransform 160ms ease;\n}\n\n.liforma-et--parallax {\n\t--liforma-et-bg-scale: 1.08;\n\t--liforma-et-fg-scale: 1.05;\n\t--liforma-et-avatar-scale: 1.08;\n\t--liforma-et-bg-shift: 10px;\n\t--liforma-et-fg-shift: 4px;\n\t--liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n\twill-change: transform;\n}\n\n.liforma-et--parallax:not(.liforma-et--scene) {\n\t--liforma-et-avatar-scale: 1.05;\n\t--liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n\ttransition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.liforma-et {\n\t\t--liforma-et-reveal-duration: 0ms;\n\t}\n\n\t.liforma-et--parallax {\n\t\t--liforma-et-bg-scale: 1;\n\t\t--liforma-et-fg-scale: 1;\n\t\t--liforma-et-avatar-scale: 1;\n\t\t--liforma-et-bg-shift: 0px;\n\t\t--liforma-et-fg-shift: 0px;\n\t\t--liforma-et-avatar-shift: 0px;\n\t}\n\n\t.liforma-et__background,\n\t.liforma-et__foreground,\n\t.liforma-et__avatar {\n\t\ttransition: none;\n\t}\n}\n`.trim();\n","let styleMounted = false;\n\n/** Inject shared thumbnail CSS once per document. */\nexport function ensureExperienceThumbnailStyles(css: string): void {\n\tif (typeof document === 'undefined' || styleMounted) return;\n\tif (document.querySelector('style[data-liforma-et]')) {\n\t\tstyleMounted = true;\n\t\treturn;\n\t}\n\tconst style = document.createElement('style');\n\tstyle.setAttribute('data-liforma-et', '');\n\tstyle.textContent = css;\n\tdocument.head.appendChild(style);\n\tstyleMounted = true;\n}\n","import {\n\tattachImageReady,\n\tattachLazyThumb,\n\tattachScrollLinkedParallax,\n\tEXPERIENCE_THUMBNAIL_CSS,\n\thorizontalParallaxFromViewportY,\n\tresolveThumbnailHref,\n\tresolveThumbnailInteraction,\n\tresolveThumbnailLayers,\n\ttype GalleryThumb\n} from '../thumbnail/index';\n\nconst ELEMENT_NAME = 'liforma-experience-thumbnail';\n\nfunction parseGalleryThumb(raw: string | null): GalleryThumb | undefined {\n\tif (!raw?.trim()) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as GalleryThumb;\n\t\tif (parsed && typeof parsed.avatarImage === 'string') return parsed;\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nclass LiformaExperienceThumbnailElement extends HTMLElement {\n\tstatic get observedAttributes(): string[] {\n\t\treturn [\n\t\t\t'experience-id',\n\t\t\t'gallery-thumb',\n\t\t\t'avatar-image',\n\t\t\t'background-image',\n\t\t\t'foreground-image',\n\t\t\t'fallback-image',\n\t\t\t'alt',\n\t\t\t'href',\n\t\t\t'target',\n\t\t\t'rel',\n\t\t\t'return-url',\n\t\t\t'player-base-url',\n\t\t\t'parallax',\n\t\t\t'lazy'\n\t\t];\n\t}\n\n\t#root: HTMLElement | null = null;\n\t#cleanup: (() => void)[] = [];\n\t#shouldLoad = false;\n\t#hovering = false;\n\t#pointerDown = false;\n\t#scrollParallax = false;\n\t#parallaxX = 0;\n\t#parallaxY = 0;\n\t#avatarLoadFailed = false;\n\t#backgroundReady = false;\n\t#avatarReady = false;\n\t#foregroundReady = false;\n\n\tconnectedCallback(): void {\n\t\tthis.#render();\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tthis.#teardown();\n\t}\n\n\tattributeChangedCallback(): void {\n\t\tif (this.isConnected) this.#render();\n\t}\n\n\t#teardown(): void {\n\t\tfor (const fn of this.#cleanup) fn();\n\t\tthis.#cleanup = [];\n\t\tthis.#root = null;\n\t}\n\n\t#boolAttr(name: string, defaultValue: boolean): boolean {\n\t\tif (!this.hasAttribute(name)) return defaultValue;\n\t\tconst value = this.getAttribute(name);\n\t\tif (value === null || value === '' || value === 'true') return true;\n\t\tif (value === 'false') return false;\n\t\treturn defaultValue;\n\t}\n\n\t#render(): void {\n\t\tthis.#teardown();\n\n\t\tconst shadow = this.shadowRoot ?? this.attachShadow({ mode: 'open' });\n\t\tconst style = document.createElement('style');\n\t\tstyle.textContent = EXPERIENCE_THUMBNAIL_CSS;\n\t\tshadow.replaceChildren(style);\n\n\t\tconst alt = this.getAttribute('alt')?.trim() || 'Experience';\n\t\tconst hrefAttr = this.getAttribute('href');\n\t\tconst experienceId = this.getAttribute('experience-id');\n\t\tconst hasClickHandler = this.hasAttribute('onclick') || typeof this.onclick === 'function';\n\t\tconst interaction = resolveThumbnailInteraction({\n\t\t\thref: hrefAttr,\n\t\t\thasClickHandler,\n\t\t\texperienceId\n\t\t});\n\n\t\tconst layers = resolveThumbnailLayers({\n\t\t\tgalleryThumb: parseGalleryThumb(this.getAttribute('gallery-thumb')),\n\t\t\tavatarImage: this.getAttribute('avatar-image') ?? undefined,\n\t\t\tbackgroundImage: this.getAttribute('background-image') ?? undefined,\n\t\t\tforegroundImage: this.getAttribute('foreground-image') ?? undefined,\n\t\t\tfallbackImage: this.getAttribute('fallback-image') ?? undefined\n\t\t});\n\t\tif (!layers) return;\n\n\t\tconst parallaxEnabled = this.#boolAttr('parallax', true);\n\t\tconst lazy = this.#boolAttr('lazy', true);\n\t\tthis.#shouldLoad = !lazy;\n\n\t\tconst isHostedLaunch =\n\t\t\tinteraction === 'anchor' && !hrefAttr?.trim() && Boolean(experienceId?.trim());\n\t\tconst resolvedHref = resolveThumbnailHref({\n\t\t\thref: hrefAttr ?? undefined,\n\t\t\texperienceId: experienceId ?? undefined,\n\t\t\treturnUrl: this.getAttribute('return-url') ?? undefined,\n\t\t\tplayerBaseUrl: this.getAttribute('player-base-url') ?? undefined,\n\t\t\tuseCurrentPageAsReturnUrl:\n\t\t\t\tisHostedLaunch && !this.getAttribute('return-url')?.trim()\n\t\t});\n\n\t\tlet root: HTMLElement;\n\t\tif (interaction === 'anchor' && resolvedHref) {\n\t\t\tconst a = document.createElement('a');\n\t\t\ta.href = resolvedHref;\n\t\t\tconst target = this.getAttribute('target');\n\t\t\tconst rel = this.getAttribute('rel');\n\t\t\tif (target) a.target = target;\n\t\t\tif (rel) a.rel = rel;\n\t\t\troot = a;\n\t\t} else if (interaction === 'button') {\n\t\t\tconst button = document.createElement('button');\n\t\t\tbutton.type = 'button';\n\t\t\troot = button;\n\t\t} else {\n\t\t\troot = document.createElement('div');\n\t\t\troot.setAttribute('role', 'img');\n\t\t}\n\n\t\troot.className = 'liforma-et';\n\t\troot.setAttribute('aria-label', alt);\n\t\tthis.#root = root;\n\t\tshadow.appendChild(root);\n\n\t\tconst syncClass = () => {\n\t\t\tconst hasScene = Boolean(layers.backgroundImage);\n\t\t\tconst parallaxActive = parallaxEnabled && (this.#hovering || this.#scrollParallax);\n\t\t\t// Fade placeholder as soon as any layer can paint — don't wait for the slowest plate.\n\t\t\tconst reveal =\n\t\t\t\tthis.#shouldLoad &&\n\t\t\t\t(this.#avatarReady || this.#backgroundReady || this.#foregroundReady);\n\t\t\troot.className = [\n\t\t\t\t'liforma-et',\n\t\t\t\thasScene ? 'liforma-et--scene' : '',\n\t\t\t\tparallaxActive ? 'liforma-et--parallax' : '',\n\t\t\t\tthis.#scrollParallax ? 'liforma-et--scroll-parallax' : '',\n\t\t\t\tthis.#shouldLoad && !reveal ? 'liforma-et--loading' : '',\n\t\t\t\treveal ? 'liforma-et--revealed' : ''\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ');\n\t\t\troot.style.setProperty('--liforma-et-parallax-x', String(this.#parallaxX));\n\t\t\troot.style.setProperty('--liforma-et-parallax-y', String(this.#parallaxY));\n\t\t};\n\n\t\tconst placeholder = document.createElement('span');\n\t\tplaceholder.className = 'liforma-et__placeholder';\n\t\tplaceholder.setAttribute('aria-hidden', 'true');\n\t\troot.appendChild(placeholder);\n\n\t\tconst paintImages = () => {\n\t\t\tif (!this.#shouldLoad) return;\n\t\t\tconst avatarSrc =\n\t\t\t\tthis.#avatarLoadFailed && layers.fallbackImage\n\t\t\t\t\t? layers.fallbackImage\n\t\t\t\t\t: layers.avatarImage;\n\n\t\t\tif (layers.backgroundImage && !root.querySelector('.liforma-et__background')) {\n\t\t\t\tconst img = document.createElement('img');\n\t\t\t\timg.className = 'liforma-et__background liforma-et__media';\n\t\t\t\timg.alt = '';\n\t\t\t\timg.decoding = 'async';\n\t\t\t\timg.src = layers.backgroundImage;\n\t\t\t\tthis.#cleanup.push(\n\t\t\t\t\tattachImageReady(img, () => {\n\t\t\t\t\t\tthis.#backgroundReady = true;\n\t\t\t\t\t\timg.classList.add('liforma-et__media--ready');\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\troot.appendChild(img);\n\t\t\t}\n\n\t\t\tlet avatar = root.querySelector('.liforma-et__avatar') as HTMLImageElement | null;\n\t\t\tif (!avatar) {\n\t\t\t\tavatar = document.createElement('img');\n\t\t\t\tavatar.className = 'liforma-et__avatar liforma-et__media';\n\t\t\t\tavatar.alt = '';\n\t\t\t\tavatar.decoding = 'async';\n\t\t\t\tavatar.addEventListener('error', () => {\n\t\t\t\t\tif (layers.fallbackImage && !this.#avatarLoadFailed) {\n\t\t\t\t\t\tthis.#avatarLoadFailed = true;\n\t\t\t\t\t\tavatar!.src = layers.fallbackImage;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#avatarReady = true;\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis.#cleanup.push(\n\t\t\t\t\tattachImageReady(avatar, () => {\n\t\t\t\t\t\tthis.#avatarReady = true;\n\t\t\t\t\t\tavatar!.classList.add('liforma-et__media--ready');\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\troot.appendChild(avatar);\n\t\t\t}\n\t\t\tif (avatar.src !== avatarSrc) avatar.src = avatarSrc;\n\n\t\t\tif (layers.foregroundImage && !root.querySelector('.liforma-et__foreground')) {\n\t\t\t\tconst img = document.createElement('img');\n\t\t\t\timg.className = 'liforma-et__foreground liforma-et__media';\n\t\t\t\timg.alt = '';\n\t\t\t\timg.decoding = 'async';\n\t\t\t\timg.src = layers.foregroundImage;\n\t\t\t\tthis.#cleanup.push(\n\t\t\t\t\tattachImageReady(img, () => {\n\t\t\t\t\t\tthis.#foregroundReady = true;\n\t\t\t\t\t\timg.classList.add('liforma-et__media--ready');\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\troot.appendChild(img);\n\t\t\t}\n\t\t\tsyncClass();\n\t\t};\n\n\t\tif (lazy) {\n\t\t\tthis.#cleanup.push(\n\t\t\t\tattachLazyThumb(root, {\n\t\t\t\t\tonVisibleChange: (visible) => {\n\t\t\t\t\t\tif (!visible) return;\n\t\t\t\t\t\tthis.#shouldLoad = true;\n\t\t\t\t\t\tpaintImages();\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t);\n\t\t} else {\n\t\t\tpaintImages();\n\t\t}\n\n\t\tif (parallaxEnabled) {\n\t\t\tthis.#cleanup.push(\n\t\t\t\tattachScrollLinkedParallax(root, {\n\t\t\t\t\tonParallax: (x) => {\n\t\t\t\t\t\tthis.#scrollParallax = true;\n\t\t\t\t\t\tif (!this.#pointerDown) {\n\t\t\t\t\t\t\tthis.#parallaxX = x;\n\t\t\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tpointerActive: () => this.#pointerDown\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tconst onPointerMove = (event: PointerEvent) => {\n\t\t\t\tif (this.#scrollParallax) return;\n\t\t\t\tconst rect = root.getBoundingClientRect();\n\t\t\t\tif (rect.width <= 0 || rect.height <= 0) return;\n\t\t\t\tthis.#parallaxX = ((event.clientX - rect.left) / rect.width - 0.5) * 2;\n\t\t\t\tthis.#parallaxY = ((event.clientY - rect.top) / rect.height - 0.5) * 2;\n\t\t\t\tsyncClass();\n\t\t\t};\n\t\t\tconst onPointerDown = (event: PointerEvent) => {\n\t\t\t\tthis.#pointerDown = true;\n\t\t\t\tif (event.pointerType === 'mouse') this.#hovering = true;\n\t\t\t\tsyncClass();\n\t\t\t};\n\t\t\tconst onPointerUp = () => {\n\t\t\t\tconst wasDown = this.#pointerDown;\n\t\t\t\tthis.#pointerDown = false;\n\t\t\t\tthis.#hovering = false;\n\t\t\t\tif (this.#scrollParallax && wasDown) {\n\t\t\t\t\tthis.#parallaxX = horizontalParallaxFromViewportY(\n\t\t\t\t\t\troot.getBoundingClientRect(),\n\t\t\t\t\t\twindow.innerHeight\n\t\t\t\t\t);\n\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t} else if (!this.#scrollParallax) {\n\t\t\t\t\tthis.#parallaxX = 0;\n\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t}\n\t\t\t\tsyncClass();\n\t\t\t};\n\t\t\troot.addEventListener('pointermove', onPointerMove);\n\t\t\troot.addEventListener('pointerdown', onPointerDown);\n\t\t\troot.addEventListener('pointerup', onPointerUp);\n\t\t\troot.addEventListener('pointercancel', onPointerUp);\n\t\t\troot.addEventListener('pointerenter', (event: PointerEvent) => {\n\t\t\t\tif (event.pointerType === 'mouse') {\n\t\t\t\t\tthis.#hovering = true;\n\t\t\t\t\tsyncClass();\n\t\t\t\t}\n\t\t\t});\n\t\t\troot.addEventListener('pointerleave', () => {\n\t\t\t\tif (!this.#pointerDown) {\n\t\t\t\t\tthis.#hovering = false;\n\t\t\t\t\tif (!this.#scrollParallax) {\n\t\t\t\t\t\tthis.#parallaxX = 0;\n\t\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tsyncClass();\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.#cleanup.push(() => {\n\t\t\t\troot.removeEventListener('pointermove', onPointerMove);\n\t\t\t\troot.removeEventListener('pointerdown', onPointerDown);\n\t\t\t\troot.removeEventListener('pointerup', onPointerUp);\n\t\t\t\troot.removeEventListener('pointercancel', onPointerUp);\n\t\t\t});\n\t\t}\n\n\t\troot.addEventListener('click', (event: MouseEvent) => {\n\t\t\tif (isHostedLaunch && !this.getAttribute('return-url')?.trim()) {\n\t\t\t\tconst next = resolveThumbnailHref({\n\t\t\t\t\texperienceId: experienceId ?? undefined,\n\t\t\t\t\tplayerBaseUrl: this.getAttribute('player-base-url') ?? undefined,\n\t\t\t\t\tuseCurrentPageAsReturnUrl: true\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tnext &&\n\t\t\t\t\tevent.button === 0 &&\n\t\t\t\t\t!event.metaKey &&\n\t\t\t\t\t!event.ctrlKey &&\n\t\t\t\t\t!event.shiftKey\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\twindow.location.assign(next);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tsyncClass();\n\t}\n}\n\nif (!customElements.get(ELEMENT_NAME)) {\n\tcustomElements.define(ELEMENT_NAME, LiformaExperienceThumbnailElement);\n}\n\nexport { LiformaExperienceThumbnailElement };\n","import { resolvePublicApiBaseUrl } from '../../shims/apiBaseUrl';\nimport type { GalleryThumb } from '../../thumbnail/types';\n\nexport type ExperiencePreview = {\n\treadonly experienceId: string;\n\treadonly title: string;\n\treadonly galleryThumb: GalleryThumb;\n};\n\nfunction parseGalleryThumb(raw: unknown): GalleryThumb | null {\n\tif (!raw || typeof raw !== 'object') return null;\n\tconst thumb = raw as Record<string, unknown>;\n\tconst avatarImage = typeof thumb.avatarImage === 'string' ? thumb.avatarImage.trim() : '';\n\tif (!avatarImage) return null;\n\treturn {\n\t\tavatarImage,\n\t\t...(typeof thumb.backgroundImage === 'string' && thumb.backgroundImage.trim()\n\t\t\t? { backgroundImage: thumb.backgroundImage.trim() }\n\t\t\t: {}),\n\t\t...(typeof thumb.foregroundImage === 'string' && thumb.foregroundImage.trim()\n\t\t\t? { foregroundImage: thumb.foregroundImage.trim() }\n\t\t\t: {})\n\t};\n}\n\n/**\n * Fetch public widget preview (title + gallery thumb plates) by experience id.\n * No API key / origin allowlist — safe for collapsed FAB paint before mint.\n */\nexport async function fetchExperiencePreview(\n\texperienceId: string,\n\toptions?: {\n\t\treadonly apiBaseUrl?: string;\n\t\treadonly signal?: AbortSignal;\n\t}\n): Promise<ExperiencePreview> {\n\tconst trimmed = experienceId.trim();\n\tif (!trimmed) {\n\t\tthrow new Error('Experience preview requires experienceId.');\n\t}\n\n\tconst apiBaseUrl = (options?.apiBaseUrl ?? resolvePublicApiBaseUrl()).replace(/\\/$/, '');\n\tconst res = await fetch(\n\t\t`${apiBaseUrl}/v1/experiences/${encodeURIComponent(trimmed)}/preview`,\n\t\t{\n\t\t\tmethod: 'GET',\n\t\t\theaders: { Accept: 'application/json' },\n\t\t\tsignal: options?.signal\n\t\t}\n\t);\n\n\tif (!res.ok) {\n\t\tlet message = `Experience preview failed (${res.status})`;\n\t\ttry {\n\t\t\tconst body = (await res.json()) as { message?: string };\n\t\t\tif (body.message?.trim()) message = body.message.trim();\n\t\t} catch {\n\t\t\t/* keep */\n\t\t}\n\t\tthrow new Error(message);\n\t}\n\n\tlet raw: unknown;\n\ttry {\n\t\traw = await res.json();\n\t} catch {\n\t\tthrow new Error('Experience preview returned invalid JSON.');\n\t}\n\n\tif (!raw || typeof raw !== 'object') {\n\t\tthrow new Error('Experience preview returned an invalid payload.');\n\t}\n\tconst payload = raw as Record<string, unknown>;\n\tconst id =\n\t\ttypeof payload.experienceId === 'string' ? payload.experienceId.trim() : trimmed;\n\tconst title = typeof payload.title === 'string' ? payload.title.trim() : '';\n\tconst galleryThumb = parseGalleryThumb(payload.galleryThumb);\n\tif (!galleryThumb) {\n\t\tthrow new Error('Experience preview is missing gallery thumb images.');\n\t}\n\n\treturn {\n\t\texperienceId: id || trimmed,\n\t\ttitle: title || id || trimmed,\n\t\tgalleryThumb\n\t};\n}\n","/** Desktop breakpoint for reduce / dock chrome (matches CSS). */\nexport const WIDGET_DESKTOP_MEDIA = '(min-width: 768px)';\n\nconst DOCK_MARGIN = 24;\n/** Fraction of the device screen height (not the browser chrome box). */\nexport const DOCK_HEIGHT_FRAC = 0.5;\nexport const DOCK_HEIGHT_MAX = 1200;\n/** Never taller than this share of the browser viewport (keeps margins). */\nconst DOCK_VIEWPORT_FRAC = 0.85;\n/** Portrait width / height. */\nexport const DOCK_ASPECT = 9 / 16;\n\nexport type DockSize = {\n\treadonly width: number;\n\treadonly height: number;\n};\n\nexport type DockPoint = {\n\treadonly left: number;\n\treadonly top: number;\n};\n\nfunction readScreenHeight(): number {\n\tif (typeof window === 'undefined') return 800;\n\tconst avail = window.screen?.availHeight;\n\treturn typeof avail === 'number' && avail > 0 ? avail : window.innerHeight;\n}\n\n/**\n * Docked panel size: ~50% of device screen height (cap 1200), 9:16 portrait,\n * then clamped to fit the browser viewport with margin.\n */\nexport function computeDockSize(\n\tviewportWidth = typeof window !== 'undefined' ? window.innerWidth : 1280,\n\tviewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800,\n\tmargin = DOCK_MARGIN,\n\tscreenHeight = typeof window !== 'undefined' ? readScreenHeight() : 800\n): DockSize {\n\tconst maxH = Math.max(\n\t\t160,\n\t\tMath.min(viewportHeight - margin * 2, viewportHeight * DOCK_VIEWPORT_FRAC)\n\t);\n\tconst maxW = Math.max(120, viewportWidth - margin * 2);\n\tlet height = Math.min(screenHeight * DOCK_HEIGHT_FRAC, DOCK_HEIGHT_MAX, maxH);\n\tlet width = height * DOCK_ASPECT;\n\tif (width > maxW) {\n\t\twidth = maxW;\n\t\theight = width / DOCK_ASPECT;\n\t\tif (height > maxH) {\n\t\t\theight = maxH;\n\t\t\twidth = height * DOCK_ASPECT;\n\t\t}\n\t}\n\treturn {\n\t\twidth: Math.round(width),\n\t\theight: Math.round(height)\n\t};\n}\n\n/** Default bottom-right placement for a docked panel. */\nexport function defaultDockOrigin(\n\tsize: DockSize,\n\tviewportWidth = typeof window !== 'undefined' ? window.innerWidth : 1280,\n\tviewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800,\n\tmargin = DOCK_MARGIN\n): DockPoint {\n\treturn {\n\t\tleft: Math.max(margin, viewportWidth - size.width - margin),\n\t\ttop: Math.max(margin, viewportHeight - size.height - margin)\n\t};\n}\n\n/** Keep a docked panel fully inside the viewport. */\nexport function clampDockOrigin(\n\tleft: number,\n\ttop: number,\n\tsize: DockSize,\n\tviewportWidth = typeof window !== 'undefined' ? window.innerWidth : 1280,\n\tviewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800,\n\tmargin = DOCK_MARGIN\n): DockPoint {\n\tconst maxLeft = Math.max(margin, viewportWidth - size.width - margin);\n\tconst maxTop = Math.max(margin, viewportHeight - size.height - margin);\n\treturn {\n\t\tleft: Math.min(Math.max(margin, left), maxLeft),\n\t\ttop: Math.min(Math.max(margin, top), maxTop)\n\t};\n}\n\nexport function isDesktopViewport(\n\tmatchMediaFn: (query: string) => MediaQueryList = typeof window !== 'undefined'\n\t\t? window.matchMedia.bind(window)\n\t\t: () => ({ matches: true }) as MediaQueryList\n): boolean {\n\treturn matchMediaFn(WIDGET_DESKTOP_MEDIA).matches;\n}\n","/** Styles for ExperienceWidget (class prefix `liforma-ew`). */\nexport const EXPERIENCE_WIDGET_CSS = `\n.liforma-ew {\n\tbox-sizing: border-box;\n\tposition: relative;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tmin-height: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n\tposition: fixed;\n\twidth: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n\theight: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n\tbottom: var(--liforma-ew-offset, 16px);\n\tz-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n\tright: var(--liforma-ew-offset, 16px);\n\tleft: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n\tleft: var(--liforma-ew-offset, 16px);\n\tright: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n\twidth: 0;\n\theight: 0;\n\tmin-width: 0;\n\tmin-height: 0;\n\toverflow: visible;\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n\tpointer-events: auto;\n}\n\n.liforma-ew__hit {\n\tbox-sizing: border-box;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tbackground: transparent;\n\tcursor: pointer;\n\tfont: inherit;\n\tappearance: none;\n\t-webkit-tap-highlight-color: transparent;\n\ttransform: scale(1);\n\ttransform-origin: center center;\n\ttransition:\n\t\ttransform 180ms ease,\n\t\tfilter 180ms ease;\n\twill-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n\toutline: 2px solid #5b8def;\n\toutline-offset: 3px;\n\tborder-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n\t/* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n\t.liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n\t.liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n\t\ttransform: scale(1.06);\n\t}\n\n\t.liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n\t.liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n\t\tbox-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n\t}\n}\n\n.liforma-ew__face {\n\twidth: 100%;\n\theight: 100%;\n\tmin-height: 0;\n\tposition: relative;\n}\n\n.liforma-ew__face-status {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\tdisplay: grid;\n\tplace-items: center;\n\tpadding: 0.5rem;\n\ttext-align: center;\n\tfont: 600 0.75rem/1.3 system-ui, sans-serif;\n\tcolor: #e8ecf4;\n\tbackground: rgba(10, 12, 18, 0.72);\n\tborder-radius: 0.75rem;\n\tpointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__hit:disabled {\n\tcursor: default;\n\topacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n\tborder-radius: 0.75rem;\n\tbox-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n\ttransition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n\tbox-sizing: border-box;\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 2;\n\tborder-radius: 0.75rem;\n\toverflow: hidden;\n\tbackground: transparent;\n\tpointer-events: none;\n\topacity: 1;\n\ttransition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n\topacity: 0;\n\ttransition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n\tpointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n\t/* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n\topacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n\topacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n\ttransition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n\topacity: 0 !important;\n\ttransition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n\t/* Keep the live iframe under the thumb; FAB click resumes the shell. */\n\tpointer-events: none;\n\topacity: 0;\n\t/* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n\ttransition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n\tposition: fixed;\n\t/* Match overlay panel inset so the warm iframe fills the conversation shell. */\n\tinset: clamp(12px, 3vw, 28px);\n\tz-index: 2147483001;\n\twidth: auto;\n\theight: auto;\n\tborder-radius: 16px;\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n\tposition: fixed;\n\tinset: auto;\n\tz-index: 2147483001;\n\tborder-radius: 16px;\n\tpointer-events: auto;\n\t/* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n\tdisplay: none;\n\tposition: fixed;\n\tz-index: 2147483002;\n\tpointer-events: auto;\n\tbox-sizing: border-box;\n\talign-items: center;\n\tgap: 0.35rem;\n\tpadding: 0.35rem 0.4rem;\n\tborder-radius: 999px;\n\tbackground: rgba(12, 14, 20, 0.72);\n\tbackdrop-filter: blur(8px);\n\t-webkit-backdrop-filter: blur(8px);\n\tbox-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n\tdisplay: flex;\n\ttop: calc(clamp(12px, 3vw, 28px) + 10px);\n\tright: calc(clamp(12px, 3vw, 28px) + 10px);\n\tleft: auto;\n\tcursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n\tdisplay: flex;\n\t/* left/top set inline to track the panel; strip is the drag handle */\n\tcursor: grab;\n\ttouch-action: none;\n\tuser-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging {\n\tcursor: grabbing;\n}\n\n.liforma-ew__toolbar[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__icon-btn {\n\tappearance: none;\n\tbox-sizing: border-box;\n\tdisplay: inline-grid;\n\tplace-items: center;\n\twidth: 2rem;\n\theight: 2rem;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tborder-radius: 999px;\n\tcolor: #f5f7fb;\n\tbackground: transparent;\n\tcursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n\tbackground: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n\tbackground: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n\toutline: 2px solid #5b8def;\n\toutline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n\twidth: 1.05rem;\n\theight: 1.05rem;\n\tdisplay: block;\n}\n\n.liforma-ew__drag-grip {\n\tdisplay: none;\n\twidth: 0.85rem;\n\theight: 1.25rem;\n\tmargin: 0 0.15rem 0 0.25rem;\n\tbackground:\n\t\tradial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n\t\tradial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n\tbackground-repeat: repeat-y;\n\topacity: 0.55;\n\tcolor: #f5f7fb;\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n\tdisplay: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__overlay {\n\tposition: fixed;\n\tinset: 0;\n\tz-index: 2147483000;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: clamp(12px, 3vw, 28px);\n\tbox-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n\tpadding: 0;\n\talign-items: stretch;\n\tjustify-content: stretch;\n\tpointer-events: none;\n\tbackground: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__backdrop {\n\tposition: absolute;\n\tinset: 0;\n\tborder: 0;\n\tpadding: 0;\n\tmargin: 0;\n\tbackground: rgba(6, 8, 14, 0.62);\n\tcursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n\tdisplay: none !important;\n}\n\n.liforma-ew__panel {\n\tposition: relative;\n\tz-index: 1;\n\tdisplay: flex;\n\tflex-direction: column;\n\t/* Fill the overlay so player loading / start UI centers in the visible window. */\n\twidth: var(--liforma-ew-max-w, 100%);\n\theight: var(--liforma-ew-max-h, 100%);\n\tmax-width: 100%;\n\tmax-height: 100%;\n\tborder-radius: 16px;\n\toverflow: hidden;\n\tbackground: #030508;\n\tbox-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n\t/* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n\tposition: fixed;\n\tinset: auto;\n\tmax-width: none;\n\tmax-height: none;\n\tpointer-events: auto;\n\t/* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n\tpointer-events: auto;\n}\n\n.liforma-ew__stage {\n\tposition: relative;\n\tflex: 1;\n\tmin-height: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbackground: #030508;\n\topacity: 1;\n\ttransition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\tdisplay: grid;\n\tplace-items: center;\n\tpadding: 1.5rem;\n\ttext-align: center;\n\tcolor: #d7dde8;\n\tfont: 500 0.9375rem/1.45 system-ui, sans-serif;\n\tbackground: rgba(3, 5, 8, 0.92);\n\tpointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n\tdisplay: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n\t.liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n\t\tpadding: 5vh 5vw;\n\t}\n\n\t.liforma-ew[data-state='expanded'] .liforma-ew__panel {\n\t\twidth: 90vw;\n\t\theight: 90vh;\n\t\tmax-width: 90vw;\n\t\tmax-height: 90vh;\n\t}\n\n\t.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n\t\tinset: 5vh 5vw;\n\t}\n\n\t.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n\t\ttop: calc(5vh + 10px);\n\t\tright: calc(5vw + 10px);\n\t}\n\n\t.liforma-ew__dock-toggle {\n\t\tdisplay: none !important;\n\t}\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.liforma-ew__hit {\n\t\ttransition: none;\n\t\twill-change: auto;\n\t}\n\n\t.liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n\t.liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n\t\ttransform: none;\n\t}\n\n\t.liforma-ew__face .liforma-et {\n\t\tbox-shadow: none;\n\t\ttransition: none;\n\t}\n\n\t.liforma-ew__warm,\n\t.liforma-ew__stage {\n\t\ttransition: none;\n\t}\n}\n`;\n\nconst STYLE_ID = 'liforma-experience-widget-styles';\n\nexport function ensureExperienceWidgetStyles(css: string = EXPERIENCE_WIDGET_CSS): void {\n\tif (typeof document === 'undefined') return;\n\tconst existing = document.getElementById(STYLE_ID);\n\tif (existing) {\n\t\t/* Keep injected CSS current across local HMR / preview reloads. */\n\t\texisting.textContent = css;\n\t\treturn;\n\t}\n\tconst style = document.createElement('style');\n\tstyle.id = STYLE_ID;\n\tstyle.textContent = css;\n\tdocument.head.append(style);\n}\n","import { fetchExperiencePreview } from '../v2/api/fetchExperiencePreview';\nimport { Experience } from '../v2/experience';\nimport type { StartButtonOptions } from '../v2/types/sessionInteraction';\nimport {\n\tattachThumbnailParallax,\n\tensureExperienceThumbnailStyles,\n\tEXPERIENCE_THUMBNAIL_CSS,\n\tresolveThumbnailLayers\n} from '../thumbnail/index';\nimport type { GalleryThumb } from '../thumbnail/types';\nimport {\n\tclampDockOrigin,\n\tcomputeDockSize,\n\tdefaultDockOrigin,\n\tisDesktopViewport,\n\tWIDGET_DESKTOP_MEDIA\n} from './dockGeometry';\nimport { ensureExperienceWidgetStyles, EXPERIENCE_WIDGET_CSS } from './styles';\nimport type {\n\tExperienceWidgetController,\n\tExperienceWidgetOptions,\n\tExperienceWidgetPosition,\n\tExperienceWidgetPrefetch\n} from './types';\n\nfunction resolvePosition(value: ExperienceWidgetPosition | undefined): ExperienceWidgetPosition {\n\treturn value === 'bottom-right' || value === 'bottom-left' ? value : 'static';\n}\n\n/** Normalize offset to a CSS length (default 16px). */\nexport function resolveWidgetOffsetCss(offset?: number | string): string {\n\tif (typeof offset === 'number' && Number.isFinite(offset)) {\n\t\treturn `${offset}px`;\n\t}\n\tconst raw = typeof offset === 'string' ? offset.trim() : '';\n\tif (!raw) return '16px';\n\tif (/^\\d+(\\.\\d+)?$/.test(raw)) return `${raw}px`;\n\treturn raw;\n}\n\ntype FaceLayers = {\n\treadonly galleryThumb?: GalleryThumb;\n\treadonly avatarImage?: string;\n\treadonly backgroundImage?: string;\n\treadonly foregroundImage?: string;\n\treadonly fallbackImage?: string;\n};\n\ntype ShellState = 'collapsed' | 'expanded' | 'docked';\n\nfunction isOpenShell(state: string | undefined): state is 'expanded' | 'docked' {\n\treturn state === 'expanded' || state === 'docked';\n}\n\n/** Tabler `settings` — audio device panel. */\nconst ICON_SETTINGS = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>`;\n\nconst ICON_CLOSE = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>`;\n\n/** Tabler `arrows-diagonal-minimize-2` — reduce / dock. */\nconst ICON_REDUCE = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>`;\n\n/** Tabler `arrows-diagonal` — maximize (pair for minimize-2). */\nconst ICON_MAXIMIZE = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>`;\n\nfunction renderFace(\n\tcontainer: HTMLElement,\n\tlayersInput: FaceLayers,\n\toptions?: { readonly parallax?: boolean }\n): (() => void) | null {\n\tensureExperienceThumbnailStyles(EXPERIENCE_THUMBNAIL_CSS);\n\tconst layers = resolveThumbnailLayers({\n\t\tgalleryThumb: layersInput.galleryThumb,\n\t\tavatarImage: layersInput.avatarImage,\n\t\tbackgroundImage: layersInput.backgroundImage,\n\t\tforegroundImage: layersInput.foregroundImage,\n\t\tfallbackImage: layersInput.fallbackImage\n\t});\n\tif (!layers) {\n\t\tcontainer.replaceChildren();\n\t\treturn null;\n\t}\n\n\tconst root = document.createElement('div');\n\troot.className = `liforma-et${layers.backgroundImage ? ' liforma-et--scene' : ''} liforma-et--revealed`;\n\troot.setAttribute('aria-hidden', 'true');\n\n\tconst placeholder = document.createElement('span');\n\tplaceholder.className = 'liforma-et__placeholder';\n\tplaceholder.setAttribute('aria-hidden', 'true');\n\troot.append(placeholder);\n\n\tconst markReady = (img: HTMLImageElement) => {\n\t\timg.classList.add('liforma-et__media--ready');\n\t};\n\n\tif (layers.backgroundImage) {\n\t\tconst bg = document.createElement('img');\n\t\tbg.className = 'liforma-et__background liforma-et__media';\n\t\tbg.alt = '';\n\t\tbg.decoding = 'async';\n\t\tbg.src = layers.backgroundImage;\n\t\tbg.addEventListener('load', () => markReady(bg), { once: true });\n\t\troot.append(bg);\n\t}\n\n\tconst avatar = document.createElement('img');\n\tavatar.className = 'liforma-et__avatar liforma-et__media';\n\tavatar.alt = '';\n\tavatar.decoding = 'async';\n\tavatar.src = layers.avatarImage;\n\tavatar.addEventListener('load', () => markReady(avatar), { once: true });\n\tavatar.addEventListener(\n\t\t'error',\n\t\t() => {\n\t\t\tif (layers.fallbackImage) {\n\t\t\t\tavatar.src = layers.fallbackImage;\n\t\t\t}\n\t\t},\n\t\t{ once: true }\n\t);\n\troot.append(avatar);\n\n\tif (layers.foregroundImage) {\n\t\tconst fg = document.createElement('img');\n\t\tfg.className = 'liforma-et__foreground liforma-et__media';\n\t\tfg.alt = '';\n\t\tfg.decoding = 'async';\n\t\tfg.src = layers.foregroundImage;\n\t\tfg.addEventListener('load', () => markReady(fg), { once: true });\n\t\troot.append(fg);\n\t}\n\n\tcontainer.replaceChildren(root);\n\n\tif (options?.parallax === false) return () => {};\n\treturn attachThumbnailParallax(root);\n}\n\nfunction resolveStartButton(options: ExperienceWidgetOptions): StartButtonOptions {\n\tif (options.startButton) {\n\t\treturn {\n\t\t\t...options.startButton,\n\t\t\tlabel: options.startButton.label ?? options.startButtonLabel ?? 'Tap to talk',\n\t\t\tplacement: options.startButton.placement ?? 'bottom-center',\n\t\t\tvariant: options.startButton.variant ?? 'primary'\n\t\t};\n\t}\n\treturn {\n\t\tlabel: options.startButtonLabel ?? 'Tap to talk',\n\t\tplacement: 'bottom-center',\n\t\tvariant: 'primary'\n\t};\n}\n\nfunction scheduleIdle(callback: () => void): () => void {\n\tlet cancelled = false;\n\tconst run = () => {\n\t\tif (cancelled) return;\n\t\tcallback();\n\t};\n\n\tconst onLoad = () => {\n\t\tif (cancelled) return;\n\t\tconst ric = (\n\t\t\twindow as Window & {\n\t\t\t\trequestIdleCallback?: (cb: () => void, opts?: { timeout: number }) => number;\n\t\t\t\tcancelIdleCallback?: (id: number) => void;\n\t\t\t}\n\t\t).requestIdleCallback;\n\t\tif (typeof ric === 'function') {\n\t\t\tconst id = ric(run, { timeout: 3000 });\n\t\t\tcancelIdle = () => {\n\t\t\t\t(\n\t\t\t\t\twindow as Window & { cancelIdleCallback?: (id: number) => void }\n\t\t\t\t).cancelIdleCallback?.(id);\n\t\t\t};\n\t\t\treturn;\n\t\t}\n\t\tconst t = window.setTimeout(run, 1);\n\t\tcancelIdle = () => window.clearTimeout(t);\n\t};\n\n\tlet cancelIdle: (() => void) | null = null;\n\tif (document.readyState === 'complete') {\n\t\tonLoad();\n\t} else {\n\t\twindow.addEventListener('load', onLoad, { once: true });\n\t}\n\n\treturn () => {\n\t\tcancelled = true;\n\t\twindow.removeEventListener('load', onLoad);\n\t\tcancelIdle?.();\n\t};\n}\n\n/**\n * Mount a light collapsed widget that expands an Experience overlay on click.\n * Default `prefetch=\"onExpand\"` is cold (second tap unlocks audio).\n * `idle` / `eager` warm a transparent iframe so one in-iframe click unlocks + expands.\n *\n * When gallery thumb layers are not provided, fetches\n * `GET /v1/experiences/{id}/preview` (no auth / allowlist).\n */\nexport function mountExperienceWidget(\n\thost: HTMLElement,\n\toptions: ExperienceWidgetOptions\n): ExperienceWidgetController {\n\tensureExperienceWidgetStyles(EXPERIENCE_WIDGET_CSS);\n\n\tconst experienceId = options.experienceId?.trim();\n\tif (!experienceId) {\n\t\tthrow new Error('ExperienceWidget requires experienceId.');\n\t}\n\n\tconst prefetchMode: ExperienceWidgetPrefetch = options.prefetch ?? 'onExpand';\n\tconst position = resolvePosition(options.position);\n\n\tconst root = document.createElement('div');\n\troot.className = 'liforma-ew';\n\troot.dataset.state = 'collapsed';\n\troot.dataset.prefetch = prefetchMode;\n\troot.dataset.position = position;\n\troot.style.setProperty('--liforma-ew-max-w', options.expandedMaxWidth ?? '100%');\n\troot.style.setProperty('--liforma-ew-max-h', options.expandedMaxHeight ?? '100%');\n\tif (position !== 'static') {\n\t\troot.style.setProperty('--liforma-ew-offset', resolveWidgetOffsetCss(options.offset));\n\t}\n\n\tconst hit = document.createElement('button');\n\thit.type = 'button';\n\thit.className = 'liforma-ew__hit';\n\thit.setAttribute('aria-label', options.alt);\n\thit.disabled = true;\n\n\tconst face = document.createElement('div');\n\tface.className = 'liforma-ew__face';\n\thit.append(face);\n\n\tconst faceLoading = document.createElement('div');\n\tfaceLoading.className = 'liforma-ew__face-status';\n\tfaceLoading.textContent = 'Loading…';\n\tface.append(faceLoading);\n\n\tconst warmStage = document.createElement('div');\n\twarmStage.className = 'liforma-ew__warm';\n\twarmStage.hidden = true;\n\twarmStage.setAttribute('aria-hidden', 'true');\n\n\tconst overlay = document.createElement('div');\n\toverlay.className = 'liforma-ew__overlay';\n\toverlay.hidden = true;\n\toverlay.setAttribute('role', 'dialog');\n\toverlay.setAttribute('aria-modal', 'true');\n\toverlay.setAttribute('aria-label', options.alt);\n\n\tconst backdrop = document.createElement('button');\n\tbackdrop.type = 'button';\n\tbackdrop.className = 'liforma-ew__backdrop';\n\tbackdrop.setAttribute('aria-label', 'Close experience');\n\n\tconst panel = document.createElement('div');\n\tpanel.className = 'liforma-ew__panel';\n\n\tconst toolbar = document.createElement('div');\n\ttoolbar.className = 'liforma-ew__toolbar';\n\ttoolbar.hidden = true;\n\n\tconst dragGrip = document.createElement('span');\n\tdragGrip.className = 'liforma-ew__drag-grip';\n\tdragGrip.setAttribute('aria-hidden', 'true');\n\n\tconst dockToggleBtn = document.createElement('button');\n\tdockToggleBtn.type = 'button';\n\tdockToggleBtn.className = 'liforma-ew__icon-btn liforma-ew__dock-toggle';\n\tdockToggleBtn.innerHTML = ICON_REDUCE;\n\tdockToggleBtn.setAttribute('aria-label', 'Reduce');\n\n\tconst settingsBtn = document.createElement('button');\n\tsettingsBtn.type = 'button';\n\tsettingsBtn.className = 'liforma-ew__icon-btn liforma-ew__settings';\n\tsettingsBtn.innerHTML = ICON_SETTINGS;\n\tsettingsBtn.setAttribute('aria-label', 'Audio settings');\n\tsettingsBtn.setAttribute('aria-pressed', 'false');\n\n\tconst closeBtn = document.createElement('button');\n\tcloseBtn.type = 'button';\n\tcloseBtn.className = 'liforma-ew__icon-btn liforma-ew__close';\n\tcloseBtn.innerHTML = ICON_CLOSE;\n\tcloseBtn.setAttribute('aria-label', 'Close');\n\n\ttoolbar.append(dragGrip, dockToggleBtn, settingsBtn, closeBtn);\n\n\tconst stage = document.createElement('div');\n\tstage.className = 'liforma-ew__stage';\n\n\tconst status = document.createElement('div');\n\tstatus.className = 'liforma-ew__status';\n\tstatus.hidden = true;\n\n\tpanel.append(stage, status);\n\toverlay.append(backdrop, panel);\n\t/* Toolbar must be a root sibling above the warm iframe stacking context. */\n\troot.append(hit, warmStage, overlay, toolbar);\n\thost.replaceChildren(root);\n\n\tlet experience: Experience | null = null;\n\tlet expanding = false;\n\tlet destroyed = false;\n\tlet previewReady = false;\n\tlet warmReady = false;\n\tlet warmInFlight = false;\n\t/** True after iframe attach (warm or cold); retain across collapse until hard teardown. */\n\tlet shellMounted = false;\n\t/** True after the player has unlocked audio / started conversation. */\n\tlet sessionStarted = false;\n\t/** Bumped on hard teardown so in-flight expand/warm work is discarded. */\n\tlet expandEpoch = 0;\n\tlet previousOverflow = '';\n\tlet detachFaceParallax: (() => void) | null = null;\n\tlet cancelWarmSchedule: (() => void) | null = null;\n\tlet collapseRevealTimer: ReturnType<typeof setTimeout> | null = null;\n\tlet layoutSettleTimer: ReturnType<typeof setTimeout> | null = null;\n\t/** Last docked origin; null means use default bottom-right for current size. */\n\tlet dockLeft: number | null = null;\n\tlet dockTop: number | null = null;\n\tlet dragPointerId: number | null = null;\n\tlet dragOffsetX = 0;\n\tlet dragOffsetY = 0;\n\tconst previewAbort = new AbortController();\n\tconst parallaxEnabled = options.parallax !== false;\n\tconst SESSION_CONCEAL_MS = 280;\n\t/**\n\t * Past FaceSessionView resize debounce (160ms) + morph restart so dock/maximize\n\t * never flashes a wrong-aspect canvas stretched into the new box.\n\t */\n\tconst LAYOUT_SETTLE_MS = 220;\n\tconst TOOLBAR_GAP = 10;\n\n\tconst shellState = (): ShellState => {\n\t\tconst state = root.dataset.state;\n\t\tif (state === 'expanded' || state === 'docked' || state === 'collapsed') return state;\n\t\treturn 'collapsed';\n\t};\n\n\tconst clearCollapseRevealTimer = () => {\n\t\tif (collapseRevealTimer !== null) {\n\t\t\tclearTimeout(collapseRevealTimer);\n\t\t\tcollapseRevealTimer = null;\n\t\t}\n\t};\n\n\tconst clearLayoutSettleTimer = () => {\n\t\tif (layoutSettleTimer !== null) {\n\t\t\tclearTimeout(layoutSettleTimer);\n\t\t\tlayoutSettleTimer = null;\n\t\t}\n\t\troot.classList.remove('liforma-ew--layout-settling');\n\t};\n\n\tconst clearExpandedLayoutInline = () => {\n\t\tfor (const el of [panel, warmStage, toolbar]) {\n\t\t\tel.style.removeProperty('left');\n\t\t\tel.style.removeProperty('top');\n\t\t\tel.style.removeProperty('width');\n\t\t\tel.style.removeProperty('height');\n\t\t\tel.style.removeProperty('right');\n\t\t\tel.style.removeProperty('bottom');\n\t\t}\n\t\ttoolbar.classList.remove('liforma-ew__toolbar--dragging');\n\t};\n\n\tconst applyDockedGeometry = (left: number, top: number, width: number, height: number) => {\n\t\tconst box = (el: HTMLElement) => {\n\t\t\tel.style.left = `${left}px`;\n\t\t\tel.style.top = `${top}px`;\n\t\t\tel.style.width = `${width}px`;\n\t\t\tel.style.height = `${height}px`;\n\t\t\tel.style.right = 'auto';\n\t\t\tel.style.bottom = 'auto';\n\t\t};\n\t\tbox(panel);\n\t\tbox(warmStage);\n\t\tconst toolbarWidth = toolbar.offsetWidth || 120;\n\t\ttoolbar.style.left = `${left + width - toolbarWidth - TOOLBAR_GAP}px`;\n\t\ttoolbar.style.top = `${top + TOOLBAR_GAP}px`;\n\t\ttoolbar.style.right = 'auto';\n\t\ttoolbar.style.bottom = 'auto';\n\t\ttoolbar.style.width = 'auto';\n\t\ttoolbar.style.height = 'auto';\n\t};\n\n\tconst syncDockToggleChrome = () => {\n\t\tconst desktop = isDesktopViewport();\n\t\tconst state = shellState();\n\t\tif (!desktop || (state !== 'expanded' && state !== 'docked')) {\n\t\t\tdockToggleBtn.hidden = true;\n\t\t\treturn;\n\t\t}\n\t\tdockToggleBtn.hidden = false;\n\t\tif (state === 'docked') {\n\t\t\tdockToggleBtn.innerHTML = ICON_MAXIMIZE;\n\t\t\tdockToggleBtn.setAttribute('aria-label', 'Maximize');\n\t\t} else {\n\t\t\tdockToggleBtn.innerHTML = ICON_REDUCE;\n\t\t\tdockToggleBtn.setAttribute('aria-label', 'Reduce');\n\t\t}\n\t};\n\n\tconst layoutDockedShell = (preserveOrigin: boolean) => {\n\t\tconst size = computeDockSize();\n\t\tlet origin =\n\t\t\tpreserveOrigin && dockLeft !== null && dockTop !== null\n\t\t\t\t? clampDockOrigin(dockLeft, dockTop, size)\n\t\t\t\t: defaultDockOrigin(size);\n\t\torigin = clampDockOrigin(origin.left, origin.top, size);\n\t\tdockLeft = origin.left;\n\t\tdockTop = origin.top;\n\t\tapplyDockedGeometry(origin.left, origin.top, size.width, size.height);\n\t\tsyncDockToggleChrome();\n\t};\n\n\t/** Fade the live session in after layout/resize has settled (matches cold avatar reveal). */\n\tconst revealLiveSession = () => {\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tif (destroyed || !isOpenShell(root.dataset.state)) return;\n\t\t\t\troot.classList.add('liforma-ew--session-revealed');\n\t\t\t});\n\t\t});\n\t};\n\n\t/**\n\t * Hide the live surface instantly, apply a layout change, then reveal after the\n\t * player has had time to rebuild the morph canvas for the new aspect.\n\t */\n\tconst settleLayoutThenReveal = (applyLayout: () => void) => {\n\t\tclearLayoutSettleTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\troot.classList.add('liforma-ew--layout-settling');\n\t\tapplyLayout();\n\t\tif (!sessionStarted) {\n\t\t\troot.classList.remove('liforma-ew--layout-settling');\n\t\t\treturn;\n\t\t}\n\t\tlayoutSettleTimer = setTimeout(() => {\n\t\t\tlayoutSettleTimer = null;\n\t\t\tif (destroyed || !isOpenShell(root.dataset.state)) {\n\t\t\t\troot.classList.remove('liforma-ew--layout-settling');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\troot.classList.remove('liforma-ew--layout-settling');\n\t\t\trevealLiveSession();\n\t\t}, LAYOUT_SETTLE_MS);\n\t};\n\n\tconst concealLiveSession = (): Promise<void> => {\n\t\troot.classList.add('liforma-ew--session-concealing');\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\treturn new Promise((resolve) => {\n\t\t\tclearCollapseRevealTimer();\n\t\t\tcollapseRevealTimer = setTimeout(() => {\n\t\t\t\tcollapseRevealTimer = null;\n\t\t\t\troot.classList.remove('liforma-ew--session-concealing');\n\t\t\t\tresolve();\n\t\t\t}, SESSION_CONCEAL_MS);\n\t\t});\n\t};\n\n\tconst initialLayers: FaceLayers = {\n\t\tgalleryThumb: options.galleryThumb,\n\t\tavatarImage: options.avatarImage,\n\t\tbackgroundImage: options.backgroundImage,\n\t\tforegroundImage: options.foregroundImage,\n\t\tfallbackImage: options.fallbackImage\n\t};\n\n\tconst setStatus = (text: string | null) => {\n\t\tif (!text) {\n\t\t\tstatus.hidden = true;\n\t\t\tstatus.textContent = '';\n\t\t\treturn;\n\t\t}\n\t\tstatus.hidden = false;\n\t\tstatus.textContent = text;\n\t};\n\n\tconst setFaceStatus = (text: string | null) => {\n\t\tif (!text) {\n\t\t\tfaceLoading.hidden = true;\n\t\t\tfaceLoading.textContent = '';\n\t\t\treturn;\n\t\t}\n\t\tfaceLoading.hidden = false;\n\t\tfaceLoading.textContent = text;\n\t\tif (!face.contains(faceLoading)) {\n\t\t\tface.append(faceLoading);\n\t\t}\n\t};\n\n\tconst markPreviewReady = () => {\n\t\tpreviewReady = true;\n\t\thit.disabled = false;\n\t\tsetFaceStatus(null);\n\t\tif (prefetchMode === 'onExpand') {\n\t\t\toptions.onPrefetchReady?.();\n\t\t}\n\t};\n\n\tconst armWarmHit = () => {\n\t\twarmReady = true;\n\t\troot.dataset.warm = 'true';\n\t\twarmStage.hidden = false;\n\t\tif (!sessionStarted) {\n\t\t\thit.tabIndex = -1;\n\t\t\thit.setAttribute('aria-hidden', 'true');\n\t\t}\n\t\toptions.onPrefetchReady?.();\n\t};\n\n\tconst paintFace = (layers: FaceLayers): boolean => {\n\t\tdetachFaceParallax?.();\n\t\tdetachFaceParallax = null;\n\t\tconst detach = renderFace(face, layers, { parallax: parallaxEnabled });\n\t\tif (!detach) return false;\n\t\tdetachFaceParallax = detach;\n\t\treturn true;\n\t};\n\n\tconst paintOrFetchPreview = () => {\n\t\tif (paintFace(initialLayers)) {\n\t\t\tmarkPreviewReady();\n\t\t\treturn;\n\t\t}\n\n\t\tsetFaceStatus('Loading…');\n\t\tvoid fetchExperiencePreview(experienceId, { signal: previewAbort.signal })\n\t\t\t.then((preview) => {\n\t\t\t\tif (destroyed) return;\n\t\t\t\tif (!paintFace({ galleryThumb: preview.galleryThumb })) {\n\t\t\t\t\tthrow new Error('Experience preview is missing gallery thumb images.');\n\t\t\t\t}\n\t\t\t\tmarkPreviewReady();\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tif (destroyed || previewAbort.signal.aborted) return;\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tsetFaceStatus('Preview unavailable');\n\t\t\t\thit.disabled = true;\n\t\t\t\toptions.onError?.(err);\n\t\t\t\tconsole.error('[ExperienceWidget]', err);\n\t\t\t});\n\t};\n\n\tconst sessionLaunchOptions = () => ({\n\t\texperienceId,\n\t\t...(options.sessionEndpoint ? { sessionEndpoint: options.sessionEndpoint } : {}),\n\t\t...(options.language ? { language: options.language } : {}),\n\t\t...(options.mode ? { mode: options.mode } : {}),\n\t\t...(options.speechInputMode ? { speechInputMode: options.speechInputMode } : {}),\n\t\t...(options.speechOnly !== undefined ? { speechOnly: options.speechOnly } : {}),\n\t\t...(options.fit ? { fit: options.fit } : {}),\n\t\t...(options.embedBaseUrl ? { embedBaseUrl: options.embedBaseUrl } : {}),\n\t\tstartButton: resolveStartButton(options)\n\t});\n\n\tconst showExpandedShell = (announce = true) => {\n\t\thit.hidden = true;\n\t\toverlay.hidden = false;\n\t\ttoolbar.hidden = false;\n\t\toverlay.setAttribute('aria-modal', 'true');\n\t\tclearExpandedLayoutInline();\n\t\troot.dataset.state = 'expanded';\n\t\tsetStatus(null);\n\t\tif (typeof document !== 'undefined') {\n\t\t\tpreviousOverflow = document.body.style.overflow;\n\t\t\tdocument.body.style.overflow = 'hidden';\n\t\t}\n\t\tsyncDockToggleChrome();\n\t\tif (announce) {\n\t\t\toptions.onExpanded?.();\n\t\t}\n\t};\n\n\tconst showDockedShell = () => {\n\t\thit.hidden = true;\n\t\toverlay.hidden = false;\n\t\ttoolbar.hidden = false;\n\t\toverlay.setAttribute('aria-modal', 'false');\n\t\troot.dataset.state = 'docked';\n\t\tsetStatus(null);\n\t\tif (typeof document !== 'undefined') {\n\t\t\tdocument.body.style.overflow = previousOverflow;\n\t\t}\n\t\tlayoutDockedShell(true);\n\t\tsyncDockToggleChrome();\n\t};\n\n\tconst bindSessionLifecycle = (session: Experience) => {\n\t\tsession.on('started', () => {\n\t\t\tif (destroyed) return;\n\t\t\tsessionStarted = true;\n\t\t\troot.dataset.live = 'true';\n\t\t\tsetStatus(null);\n\t\t\toptions.onStarted?.();\n\t\t\tif (isOpenShell(root.dataset.state)) {\n\t\t\t\trevealLiveSession();\n\t\t\t}\n\t\t});\n\t};\n\n\tconst restoreCollapsedChrome = () => {\n\t\tclearLayoutSettleTimer();\n\t\toverlay.hidden = true;\n\t\ttoolbar.hidden = true;\n\t\tclearExpandedLayoutInline();\n\t\troot.dataset.state = 'collapsed';\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\troot.classList.remove('liforma-ew--session-concealing');\n\t\tsettingsBtn.setAttribute('aria-pressed', 'false');\n\t\thit.hidden = false;\n\t\thit.tabIndex = 0;\n\t\thit.removeAttribute('aria-hidden');\n\t\tif (previewReady) hit.disabled = false;\n\t\tsetStatus(null);\n\t\tif (typeof document !== 'undefined') {\n\t\t\tdocument.body.style.overflow = previousOverflow;\n\t\t}\n\t\tsyncDockToggleChrome();\n\t};\n\n\tconst hardTeardownSession = () => {\n\t\tclearCollapseRevealTimer();\n\t\tclearLayoutSettleTimer();\n\t\texpandEpoch += 1;\n\t\texpanding = false;\n\t\twarmReady = false;\n\t\twarmInFlight = false;\n\t\tshellMounted = false;\n\t\tsessionStarted = false;\n\t\tconst session = experience;\n\t\texperience = null;\n\t\tsession?.destroy();\n\t\tstage.replaceChildren();\n\t\twarmStage.replaceChildren();\n\t\twarmStage.hidden = true;\n\t\tdelete root.dataset.warm;\n\t\tdelete root.dataset.live;\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t};\n\n\tconst collapse = () => {\n\t\tif (destroyed) return;\n\t\tif (!isOpenShell(root.dataset.state)) return;\n\t\texpanding = false;\n\n\t\t/*\n\t\t * Keep any attached session (warm or cold, started or waiting on Tap to talk).\n\t\t * Only CSS-collapse / pause — never remint on the next open.\n\t\t */\n\t\tif (experience && shellMounted) {\n\t\t\tconst session = experience;\n\t\t\tvoid (async () => {\n\t\t\t\tif (sessionStarted) {\n\t\t\t\t\tawait concealLiveSession();\n\t\t\t\t\tif (destroyed || experience !== session) return;\n\t\t\t\t}\n\t\t\t\tif (warmReady) {\n\t\t\t\t\tsession.setWidgetChrome('collapsed');\n\t\t\t\t}\n\t\t\t\trestoreCollapsedChrome();\n\t\t\t\tif (sessionStarted) {\n\t\t\t\t\troot.dataset.live = 'true';\n\t\t\t\t\t/* Face receives the next click; warm iframe stays hidden under the thumb. */\n\t\t\t\t\thit.tabIndex = 0;\n\t\t\t\t\thit.removeAttribute('aria-hidden');\n\t\t\t\t\thit.disabled = false;\n\t\t\t\t} else if (warmReady) {\n\t\t\t\t\tarmWarmHit();\n\t\t\t\t}\n\t\t\t\toptions.onCollapsed?.();\n\t\t\t\toptions.onClose?.();\n\t\t\t})();\n\t\t\treturn;\n\t\t}\n\n\t\thardTeardownSession();\n\t\trestoreCollapsedChrome();\n\t\toptions.onCollapsed?.();\n\t\toptions.onClose?.();\n\t};\n\n\tconst dock = () => {\n\t\tif (destroyed) return;\n\t\tif (!isDesktopViewport()) return;\n\t\tif (shellState() !== 'expanded') return;\n\t\tsettleLayoutThenReveal(() => {\n\t\t\tshowDockedShell();\n\t\t});\n\t};\n\n\tconst maximize = () => {\n\t\tif (destroyed) return;\n\t\tif (shellState() !== 'docked') return;\n\t\tsettleLayoutThenReveal(() => {\n\t\t\tclearExpandedLayoutInline();\n\t\t\tshowExpandedShell(false);\n\t\t\texperience?.setWidgetChrome('expanded');\n\t\t});\n\t};\n\n\tconst resumeLiveSession = () => {\n\t\tif (!experience || !sessionStarted) return;\n\t\tclearCollapseRevealTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\tshowExpandedShell();\n\t\texperience.setWidgetChrome('expanded');\n\t\texpanding = false;\n\t\trevealLiveSession();\n\t};\n\n\t/** Re-open an attached session that has not unlocked yet (warm or cold Tap to talk). */\n\tconst resumeMountedSession = () => {\n\t\tif (!experience || !shellMounted || sessionStarted) return;\n\t\tclearCollapseRevealTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\tshowExpandedShell();\n\t\texpanding = false;\n\t\tif (warmReady) {\n\t\t\texperience.setWidgetChrome('expanded');\n\t\t}\n\t};\n\n\tconst onWarmExpand = (epoch: number) => {\n\t\tif (destroyed) return;\n\t\tif (epoch !== expandEpoch && !sessionStarted) return;\n\t\tclearCollapseRevealTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\tshowExpandedShell();\n\t\texpanding = false;\n\t\texperience?.setWidgetChrome('expanded');\n\t\tif (sessionStarted) {\n\t\t\trevealLiveSession();\n\t\t}\n\t};\n\n\tconst beginWarm = () => {\n\t\tif (\n\t\t\tdestroyed ||\n\t\t\twarmInFlight ||\n\t\t\twarmReady ||\n\t\t\texperience ||\n\t\t\tisOpenShell(root.dataset.state)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\twarmInFlight = true;\n\t\tconst epoch = expandEpoch;\n\t\twarmStage.hidden = false;\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tconst session = await Experience.startSession({\n\t\t\t\t\t...sessionLaunchOptions(),\n\t\t\t\t\tui: 'widget'\n\t\t\t\t});\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\texperience = session;\n\t\t\t\tbindSessionLifecycle(session);\n\t\t\t\tconst player = await session.attach({\n\t\t\t\t\tcontainer: warmStage,\n\t\t\t\t\tonWidgetReady: () => {\n\t\t\t\t\t\tif (destroyed || epoch !== expandEpoch) return;\n\t\t\t\t\t\twarmInFlight = false;\n\t\t\t\t\t\tshellMounted = true;\n\t\t\t\t\t\tarmWarmHit();\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetExpand: () => {\n\t\t\t\t\t\tonWarmExpand(epoch);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetAudioSettings: (open) => {\n\t\t\t\t\t\tif (!destroyed) syncSettingsPressed(open);\n\t\t\t\t\t},\n\t\t\t\t\tonStateUpdate: (state) => {\n\t\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\t\tif (state === 'error' && isOpenShell(root.dataset.state)) {\n\t\t\t\t\t\t\tsetStatus('Could not load the experience.');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\tif (experience === session) experience = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tshellMounted = true;\n\t\t\t\tplayer.on('close', () => {\n\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\tcollapse();\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (destroyed || epoch !== expandEpoch) return;\n\t\t\t\twarmInFlight = false;\n\t\t\t\twarmStage.hidden = true;\n\t\t\t\twarmStage.replaceChildren();\n\t\t\t\texperience = null;\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\toptions.onError?.(err);\n\t\t\t\tconsole.error('[ExperienceWidget] warm prefetch failed', err);\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst expandCold = () => {\n\t\tif (destroyed || expanding || !previewReady || isOpenShell(root.dataset.state)) return;\n\t\tif (experience && sessionStarted) {\n\t\t\tresumeLiveSession();\n\t\t\treturn;\n\t\t}\n\t\tif (experience && shellMounted) {\n\t\t\tresumeMountedSession();\n\t\t\treturn;\n\t\t}\n\t\tconst epoch = ++expandEpoch;\n\t\texpanding = true;\n\t\twarmReady = false;\n\t\twarmInFlight = false;\n\t\tshellMounted = false;\n\t\tsessionStarted = false;\n\t\tdelete root.dataset.warm;\n\t\tdelete root.dataset.live;\n\t\twarmStage.hidden = true;\n\t\twarmStage.replaceChildren();\n\t\tif (experience) {\n\t\t\texperience.destroy();\n\t\t\texperience = null;\n\t\t}\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tshowExpandedShell();\n\t\t\t\tconst session = await Experience.startSession(sessionLaunchOptions());\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\texperience = session;\n\t\t\t\tbindSessionLifecycle(session);\n\t\t\t\tconst player = await session.attach({\n\t\t\t\t\tcontainer: stage,\n\t\t\t\t\tonWidgetAudioSettings: (open) => {\n\t\t\t\t\t\tif (!destroyed) syncSettingsPressed(open);\n\t\t\t\t\t},\n\t\t\t\t\tonStateUpdate: (state) => {\n\t\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\t\tif (state === 'error') {\n\t\t\t\t\t\t\tsetStatus('Could not load the experience.');\n\t\t\t\t\t\t} else if (isOpenShell(root.dataset.state)) {\n\t\t\t\t\t\t\tsetStatus(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\tif (experience === session) experience = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tshellMounted = true;\n\t\t\t\tplayer.on('close', () => {\n\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\tcollapse();\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (destroyed || epoch !== expandEpoch) return;\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tsetStatus(err.message);\n\t\t\t\toptions.onError?.(err);\n\t\t\t\tconsole.error('[ExperienceWidget]', err);\n\t\t\t} finally {\n\t\t\t\tif (epoch === expandEpoch) {\n\t\t\t\t\texpanding = false;\n\t\t\t\t}\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst expand = () => {\n\t\tif (destroyed || isOpenShell(root.dataset.state)) return;\n\t\tif (experience && sessionStarted) {\n\t\t\tresumeLiveSession();\n\t\t\treturn;\n\t\t}\n\t\tif (experience && shellMounted) {\n\t\t\t/*\n\t\t\t * Warm path: prefer the iframe hit (audio unlock). If the FAB receives the click\n\t\t\t * instead, still restore the open shell without reminting.\n\t\t\t */\n\t\t\tresumeMountedSession();\n\t\t\treturn;\n\t\t}\n\t\texpandCold();\n\t};\n\n\tconst onDockToggleClick = (event: MouseEvent) => {\n\t\tevent.stopPropagation();\n\t\tif (shellState() === 'expanded') {\n\t\t\tdock();\n\t\t\treturn;\n\t\t}\n\t\tif (shellState() === 'docked') {\n\t\t\tmaximize();\n\t\t}\n\t};\n\n\tconst syncSettingsPressed = (open: boolean) => {\n\t\tsettingsBtn.setAttribute('aria-pressed', open ? 'true' : 'false');\n\t};\n\n\tconst onSettingsClick = (event: MouseEvent) => {\n\t\tevent.stopPropagation();\n\t\tif (!isOpenShell(root.dataset.state)) return;\n\t\texperience?.toggleAudioSettings();\n\t};\n\n\tconst onToolbarPointerDown = (event: PointerEvent) => {\n\t\tif (shellState() !== 'docked') return;\n\t\tif (!isDesktopViewport()) return;\n\t\tconst target = event.target as HTMLElement | null;\n\t\tif (target?.closest('button')) return;\n\t\tevent.preventDefault();\n\t\tdragPointerId = event.pointerId;\n\t\ttoolbar.classList.add('liforma-ew__toolbar--dragging');\n\t\ttoolbar.setPointerCapture(event.pointerId);\n\t\tconst panelRect = panel.getBoundingClientRect();\n\t\tdragOffsetX = event.clientX - panelRect.left;\n\t\tdragOffsetY = event.clientY - panelRect.top;\n\t};\n\n\tconst onToolbarPointerMove = (event: PointerEvent) => {\n\t\tif (dragPointerId === null || event.pointerId !== dragPointerId) return;\n\t\tif (shellState() !== 'docked') return;\n\t\tconst size = computeDockSize();\n\t\tconst origin = clampDockOrigin(\n\t\t\tevent.clientX - dragOffsetX,\n\t\t\tevent.clientY - dragOffsetY,\n\t\t\tsize\n\t\t);\n\t\tdockLeft = origin.left;\n\t\tdockTop = origin.top;\n\t\tapplyDockedGeometry(origin.left, origin.top, size.width, size.height);\n\t};\n\n\tconst endToolbarDrag = (event: PointerEvent) => {\n\t\tif (dragPointerId === null || event.pointerId !== dragPointerId) return;\n\t\tdragPointerId = null;\n\t\ttoolbar.classList.remove('liforma-ew__toolbar--dragging');\n\t\ttry {\n\t\t\ttoolbar.releasePointerCapture(event.pointerId);\n\t\t} catch {\n\t\t\t/* already released */\n\t\t}\n\t};\n\n\tconst onKeyDown = (event: KeyboardEvent) => {\n\t\tif (event.key === 'Escape' && isOpenShell(root.dataset.state)) {\n\t\t\tevent.preventDefault();\n\t\t\tcollapse();\n\t\t}\n\t};\n\n\tconst onWindowResize = () => {\n\t\tif (destroyed) return;\n\t\tif (shellState() === 'docked') {\n\t\t\tif (!isDesktopViewport()) {\n\t\t\t\tmaximize();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (sessionStarted) {\n\t\t\t\tsettleLayoutThenReveal(() => {\n\t\t\t\t\tlayoutDockedShell(true);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlayoutDockedShell(true);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsyncDockToggleChrome();\n\t};\n\n\tconst desktopMq =\n\t\ttypeof window !== 'undefined' ? window.matchMedia(WIDGET_DESKTOP_MEDIA) : null;\n\tconst onDesktopMqChange = () => {\n\t\tif (destroyed) return;\n\t\tif (shellState() === 'docked' && !isDesktopViewport()) {\n\t\t\tmaximize();\n\t\t\treturn;\n\t\t}\n\t\tsyncDockToggleChrome();\n\t};\n\n\thit.addEventListener('click', expand);\n\tbackdrop.addEventListener('click', collapse);\n\tcloseBtn.addEventListener('click', (event) => {\n\t\tevent.stopPropagation();\n\t\tcollapse();\n\t});\n\tdockToggleBtn.addEventListener('click', onDockToggleClick);\n\tsettingsBtn.addEventListener('click', onSettingsClick);\n\ttoolbar.addEventListener('pointerdown', onToolbarPointerDown);\n\ttoolbar.addEventListener('pointermove', onToolbarPointerMove);\n\ttoolbar.addEventListener('pointerup', endToolbarDrag);\n\ttoolbar.addEventListener('pointercancel', endToolbarDrag);\n\twindow.addEventListener('keydown', onKeyDown);\n\twindow.addEventListener('resize', onWindowResize);\n\tdesktopMq?.addEventListener('change', onDesktopMqChange);\n\n\tpaintOrFetchPreview();\n\tsyncDockToggleChrome();\n\n\tif (prefetchMode === 'eager') {\n\t\tqueueMicrotask(() => {\n\t\t\tif (!destroyed) beginWarm();\n\t\t});\n\t} else if (prefetchMode === 'idle') {\n\t\tcancelWarmSchedule = scheduleIdle(() => {\n\t\t\tif (!destroyed) beginWarm();\n\t\t});\n\t}\n\n\treturn {\n\t\troot,\n\t\texpand,\n\t\tcollapse,\n\t\tdock,\n\t\tmaximize,\n\t\tprefetch() {\n\t\t\tif (prefetchMode === 'onExpand') {\n\t\t\t\tbeginWarm();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbeginWarm();\n\t\t},\n\t\tdestroy() {\n\t\t\tif (destroyed) return;\n\t\t\tdestroyed = true;\n\t\t\tcancelWarmSchedule?.();\n\t\t\tcancelWarmSchedule = null;\n\t\t\tpreviewAbort.abort();\n\t\t\tdetachFaceParallax?.();\n\t\t\tdetachFaceParallax = null;\n\t\t\twindow.removeEventListener('keydown', onKeyDown);\n\t\t\twindow.removeEventListener('resize', onWindowResize);\n\t\t\tdesktopMq?.removeEventListener('change', onDesktopMqChange);\n\t\t\thardTeardownSession();\n\t\t\trestoreCollapsedChrome();\n\t\t\thost.replaceChildren();\n\t\t}\n\t};\n}\n","import { mountExperienceWidget } from '../widget/mountExperienceWidget';\nimport type {\n\tExperienceWidgetController,\n\tExperienceWidgetPosition\n} from '../widget/types';\nimport type { GalleryThumb } from '../thumbnail/types';\nimport type {\n\tExperienceFit,\n\tExperienceMode,\n\tSpeechInputMode\n} from './types/sessionInteraction';\n\nconst ELEMENT_NAME = 'liforma-experience-widget';\n\nfunction parseGalleryThumb(raw: string | null): GalleryThumb | undefined {\n\tif (!raw?.trim()) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\tif (parsed && typeof parsed === 'object' && typeof (parsed as GalleryThumb).avatarImage === 'string') {\n\t\t\treturn parsed as GalleryThumb;\n\t\t}\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nfunction parseMode(value: string | null): ExperienceMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'conversation' || trimmed === 'presenter' ? trimmed : undefined;\n}\n\nfunction parseSpeechInputMode(value: string | null): SpeechInputMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'auto' || trimmed === 'manual' || trimmed === 'off' ? trimmed : undefined;\n}\n\nfunction parseFit(value: string | null): ExperienceFit | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'full' || trimmed === 'face' ? trimmed : undefined;\n}\n\nfunction parseLanguage(value: string | null): 'en' | 'es' | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'en' || trimmed === 'es' ? trimmed : undefined;\n}\n\nfunction parsePosition(value: string | null): ExperienceWidgetPosition {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'bottom-right' || trimmed === 'bottom-left' ? trimmed : 'static';\n}\n\nexport class LiformaExperienceWidgetElement extends HTMLElement {\n\tstatic get observedAttributes() {\n\t\treturn [\n\t\t\t'experience-id',\n\t\t\t'alt',\n\t\t\t'gallery-thumb',\n\t\t\t'avatar-image',\n\t\t\t'background-image',\n\t\t\t'foreground-image',\n\t\t\t'fallback-image',\n\t\t\t'prefetch',\n\t\t\t'parallax',\n\t\t\t'position',\n\t\t\t'offset',\n\t\t\t'session-endpoint',\n\t\t\t'language',\n\t\t\t'mode',\n\t\t\t'speech-input-mode',\n\t\t\t'speech-only',\n\t\t\t'fit',\n\t\t\t'expanded-max-width',\n\t\t\t'expanded-max-height',\n\t\t\t'start-button-label'\n\t\t];\n\t}\n\n\t#controller: ExperienceWidgetController | null = null;\n\t#host: HTMLDivElement | null = null;\n\n\tconnectedCallback() {\n\t\tthis.#applyHostBox();\n\t\tthis.#mount();\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#controller?.destroy();\n\t\tthis.#controller = null;\n\t}\n\n\tattributeChangedCallback() {\n\t\tif (!this.isConnected) return;\n\t\tthis.#applyHostBox();\n\t\tthis.#mount();\n\t}\n\n\t#applyHostBox() {\n\t\tconst position = parsePosition(this.getAttribute('position'));\n\t\tif (position !== 'static') {\n\t\t\t// Fixed FAB lives on `.liforma-ew`; collapse CE + host so they leave no layout hole.\n\t\t\tthis.style.display = 'contents';\n\t\t\tthis.style.removeProperty('width');\n\t\t\tthis.style.removeProperty('height');\n\t\t\tthis.style.removeProperty('min-height');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.style.display = 'block';\n\t\tthis.style.width ||= '100%';\n\t\tthis.style.height ||= '100%';\n\t\tif (!this.style.minHeight) {\n\t\t\tconst min = getComputedStyle(this).minHeight;\n\t\t\tif (min === '0px' || min === 'auto') {\n\t\t\t\tthis.style.minHeight = '224px';\n\t\t\t}\n\t\t}\n\t}\n\n\t#mount() {\n\t\tthis.#controller?.destroy();\n\t\tthis.#controller = null;\n\n\t\tconst experienceId = this.getAttribute('experience-id')?.trim();\n\t\tconst alt = this.getAttribute('alt')?.trim() || 'Open experience';\n\t\tif (!experienceId) return;\n\n\t\tconst position = parsePosition(this.getAttribute('position'));\n\n\t\tif (!this.#host) {\n\t\t\tthis.#host = document.createElement('div');\n\t\t\tthis.replaceChildren(this.#host);\n\t\t}\n\t\tthis.#host.style.cssText =\n\t\t\tposition === 'static'\n\t\t\t\t? 'width:100%;height:100%;min-height:inherit;'\n\t\t\t\t: 'display:contents;';\n\n\t\tconst prefetchAttr = this.getAttribute('prefetch')?.trim();\n\t\tconst prefetch =\n\t\t\tprefetchAttr === 'idle' || prefetchAttr === 'eager' || prefetchAttr === 'onExpand'\n\t\t\t\t? prefetchAttr\n\t\t\t\t: 'onExpand';\n\n\t\tconst speechOnlyAttr = this.getAttribute('speech-only');\n\t\tconst offsetAttr = this.getAttribute('offset');\n\n\t\ttry {\n\t\t\tthis.#controller = mountExperienceWidget(this.#host, {\n\t\t\t\texperienceId,\n\t\t\t\talt,\n\t\t\t\tgalleryThumb: parseGalleryThumb(this.getAttribute('gallery-thumb')),\n\t\t\t\tavatarImage: this.getAttribute('avatar-image') ?? undefined,\n\t\t\t\tbackgroundImage: this.getAttribute('background-image') ?? undefined,\n\t\t\t\tforegroundImage: this.getAttribute('foreground-image') ?? undefined,\n\t\t\t\tfallbackImage: this.getAttribute('fallback-image') ?? undefined,\n\t\t\t\tprefetch,\n\t\t\t\tparallax: this.getAttribute('parallax') !== 'false',\n\t\t\t\tposition,\n\t\t\t\toffset: offsetAttr === null ? undefined : offsetAttr,\n\t\t\t\tsessionEndpoint: this.getAttribute('session-endpoint') ?? undefined,\n\t\t\t\tlanguage: parseLanguage(this.getAttribute('language')),\n\t\t\t\tmode: parseMode(this.getAttribute('mode')),\n\t\t\t\tspeechInputMode: parseSpeechInputMode(this.getAttribute('speech-input-mode')),\n\t\t\t\tspeechOnly:\n\t\t\t\t\tspeechOnlyAttr === null\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: speechOnlyAttr === '' || speechOnlyAttr === 'true',\n\t\t\t\tfit: parseFit(this.getAttribute('fit')),\n\t\t\t\texpandedMaxWidth: this.getAttribute('expanded-max-width') ?? undefined,\n\t\t\t\texpandedMaxHeight: this.getAttribute('expanded-max-height') ?? undefined,\n\t\t\t\tstartButtonLabel: this.getAttribute('start-button-label') ?? undefined,\n\t\t\t\tonExpanded: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('expanded', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonCollapsed: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('collapsed', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonStarted: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('started', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonClose: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('close', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent('error', { detail: error, bubbles: true })\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error('[liforma-experience-widget]', error);\n\t\t}\n\t}\n}\n\nif (typeof customElements !== 'undefined' && !customElements.get(ELEMENT_NAME)) {\n\tcustomElements.define(ELEMENT_NAME, LiformaExperienceWidgetElement);\n}\n","import './liforma-experience';\nimport './liforma-experience-thumbnail';\nimport './liforma-experience-widget';\n\nexport { Experience, type ExperienceSession } from './experience';\nexport type {\n\tAttachOptions,\n\tCloseEvent,\n\tEmbedState,\n\tLiformaPlayer,\n\tReadyEvent,\n\tStartSessionOptions\n} from './experience';\nexport type { SessionManifest, SessionManifestCharacter } from './types/sessionManifest';\nexport type { ExperienceEventName, ExperienceEvents } from './experienceEvents';\nexport type {\n\tCharacterSpeechEvent,\n\tCharacterSpeechSource,\n\tCharacterSpeechTerminalReason,\n\tConversationMessage,\n\tSpeakOptions,\n\tTextSpeakResult,\n\tSpeechResult as LegacySpeakResult,\n\tUserTranscriptUpdate,\n\tUtteranceResult,\n\tExperienceFit,\n\tExperienceMode,\n\tResponseMode,\n\tSpeechInputMode,\n\tStartButtonAppearance,\n\tStartButtonOptions,\n\tStartButtonPlacement,\n\tStartButtonShadow,\n\tStartButtonSize,\n\tStartButtonVariant,\n\tStartedEvent,\n} from './types/sessionInteraction';\nexport type {\n\tSpeechAudioFormat,\n\tSpeechController,\n\tSpeechCreateUtteranceOptions,\n\tSpeechInterruptOptions,\n\tSpeechPlayAudio,\n\tSpeechPlayEncodedAudio,\n\tSpeechPlayOptions,\n\tSpeechPlayPcmAudio,\n\tSpeechPlayUrlAudio,\n\tSpeechResult,\n\tSpeechSpeakOptions,\n\tSpeechUtterance\n} from './speech';\nexport {\n\tSPEECH_LIMITS,\n\tSpeechBufferTimeoutError,\n\tSpeechRuntimeError,\n\tSpeechUtteranceClosedError,\n\tUnsupportedSpeechOperationError\n} from './speech';\n\nimport { Experience } from './experience';\n\ndeclare global {\n\tinterface Window {\n\t\tLiforma?: {\n\t\t\tExperience: typeof Experience;\n\t\t\tsdkVersion: 'v2';\n\t\t\treadonly features: {\n\t\t\t\treadonly speakApi: boolean;\n\t\t\t\treadonly speechAudioApi: boolean;\n\t\t\t};\n\t\t};\n\t}\n}\n\nwindow.Liforma = {\n\tExperience,\n\tsdkVersion: 'v2',\n\tfeatures: {\n\t\tspeakApi: true,\n\t\tspeechAudioApi: true\n\t}\n};\n"],"x_google_ignoreList":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],"mappings":"sFAIA,SAAgB,GAAiC,CAChD,GAAK,WAA4C,kBAAoB,QACpE,MAAO,GAGR,GAAI,OAAO,SAAa,IACvB,MAAO,GAGR,GAAI,CACH,OAAO,IAAI,gBAAgB,SAAS,MAAM,EAAE,IAAI,OAAO,IAAM,OAC9D,MAAQ,CACP,MAAO,EACR,CACD,CChBA,IAAM,EAA0B,yBAC1B,EAAqB,wBAE3B,SAAS,GAA0C,CA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C5C,WACA,OAAQ,IAAe,KAAO,IAAA,GAAY,EAC1C,gBAAiB,KAAK,aAAa,kBAAkB,GAAK,IAAA,GAC1D,SAAU,GAAc,KAAK,aAAa,UAAU,CAAC,EACrD,KAAM,GAAU,KAAK,aAAa,MAAM,CAAC,EACzC,gBAAiB,GAAqB,KAAK,aAAa,mBAAmB,CAAC,EAC5E,WACC,IAAmB,KAChB,IAAA,GACA,IAAmB,IAAM,IAAmB,OAChD,IAAK,GAAS,KAAK,aAAa,KAAK,CAAC,EACtC,iBAAkB,KAAK,aAAa,oBAAoB,GAAK,IAAA,GAC7D,kBAAmB,KAAK,aAAa,qBAAqB,GAAK,IAAA,GAC/D,iBAAkB,KAAK,aAAa,oBAAoB,GAAK,IAAA,GAC7D,eAAkB,CACjB,KAAK,cAAc,IAAI,YAAY,WAAY,CAAE,QAAS,EAAK,CAAC,CAAC,CAClE,EACA,gBAAmB,CAClB,KAAK,cAAc,IAAI,YAAY,YAAa,CAAE,QAAS,EAAK,CAAC,CAAC,CACnE,EACA,cAAiB,CAChB,KAAK,cAAc,IAAI,YAAY,UAAW,CAAE,QAAS,EAAK,CAAC,CAAC,CACjE,EACA,YAAe,CACd,KAAK,cAAc,IAAI,YAAY,QAAS,CAAE,QAAS,EAAK,CAAC,CAAC,CAC/D,EACA,QAAU,GAAU,CACnB,KAAK,cACJ,IAAI,YAAY,QAAS,CAAE,OAAQ,EAAO,QAAS,EAAK,CAAC,CAC1D,CACD,CACD,CAAC,CACF,OAAS,EAAO,CACf,QAAQ,MAAM,8BAA+B,CAAK,CACnD,CACD,CACD,SAEI,OAAO,eAAmB,KAAe,CAAC,eAAe,IAAI,EAAY,GAC5E,eAAe,OAAO,GAAc,EAA8B,EC3HnE,OAAO,QAAU,CAChB,cACA,WAAY,KACZ,SAAU,CACT,SAAU,GACV,eAAgB,EACjB,CACD"}
1
+ {"version":3,"file":"client.js","names":["_a","F","initializer","util.jsonStringifyReplacer","core.$ZodAsyncError","util.finalizeIssue","core.config","errors.$ZodError","safeParse","errors.$ZodRealError","safeParseAsync","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","content","util.aborted","util.explicitlyAborted","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","isObject","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","core._isoDateTime","core._isoDate","core._isoTime","core._isoDuration","core.formatError","core.flattenError","util.jsonStringifyReplacer","parse.parse","parse.safeParse","parse.parseAsync","parse.safeParseAsync","parse.encode","parse.decode","parse.encodeAsync","parse.decodeAsync","parse.safeEncode","parse.safeDecode","parse.safeEncodeAsync","parse.safeDecodeAsync","util.mergeDefs","core.clone","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","core._number","core._int","processors.booleanProcessor","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","#render","#teardown","#cleanup","#root","#boolAttr","#shouldLoad","#hovering","#scrollParallax","#avatarReady","#backgroundReady","#foregroundReady","#parallaxX","#parallaxY","#avatarLoadFailed","#pointerDown","#applyHostBox","#mount","#controller","#host"],"sources":["../../../src/shims/localStack.ts","../../../src/shims/apiBaseUrl.ts","../../../src/v2/api/sessionEndpointRequest.ts","../../../node_modules/zod/v4/core/core.js","../../../node_modules/zod/v4/core/util.js","../../../node_modules/zod/v4/core/errors.js","../../../node_modules/zod/v4/core/parse.js","../../../node_modules/zod/v4/core/regexes.js","../../../node_modules/zod/v4/core/checks.js","../../../node_modules/zod/v4/core/doc.js","../../../node_modules/zod/v4/core/versions.js","../../../node_modules/zod/v4/core/schemas.js","../../../node_modules/zod/v4/core/registries.js","../../../node_modules/zod/v4/core/api.js","../../../node_modules/zod/v4/core/to-json-schema.js","../../../node_modules/zod/v4/core/json-schema-processors.js","../../../node_modules/zod/v4/classic/iso.js","../../../node_modules/zod/v4/classic/errors.js","../../../node_modules/zod/v4/classic/parse.js","../../../node_modules/zod/v4/classic/schemas.js","../../../src/v2/types/sessionManifestSchema.ts","../../../src/v2/api/mintPublicSession.ts","../../../src/v2/conversationProcessor.ts","../../../src/v2/embed/playerReachability.ts","../../../src/v2/embed/protocol.ts","../../../src/v2/embed/iframeHost.ts","../../../src/v2/embed/readyGate.ts","../../../src/v2/shims/embedBaseUrl.ts","../../../src/v2/speechOnlyManifest.ts","../../../src/v2/experienceEvents.ts","../../../src/v2/speech/types.ts","../../../src/byo/pcm.ts","../../../src/byo/resample.ts","../../../src/byo/audioCapture.ts","../../../src/v2/speech/captureMediaStreamTrack.ts","../../../src/v2/speech/speechController.ts","../../../src/v2/experience.ts","../../../src/v2/embed/returnNavigation.ts","../../../src/svelte/experienceLoadError.ts","../../../src/svelte/experienceLoadErrorStyles.ts","../../../src/svelte/experienceLoadErrorOverlay.ts","../../../src/v2/liforma-experience.ts","../../../src/thumbnail/toGalleryThumbUrl.ts","../../../src/thumbnail/hostedLaunchUrl.ts","../../../src/thumbnail/thumbLoadScheduler.ts","../../../src/thumbnail/lazyLoad.ts","../../../src/thumbnail/scrollParallax.ts","../../../src/thumbnail/attachThumbnailParallax.ts","../../../src/thumbnail/styles.ts","../../../src/thumbnail/ensureStyles.ts","../../../src/v2/liforma-experience-thumbnail.ts","../../../src/v2/api/fetchExperiencePreview.ts","../../../src/widget/dockGeometry.ts","../../../src/widget/styles.ts","../../../src/widget/mountExperienceWidget.ts","../../../src/v2/liforma-experience-widget.ts","../../../src/v2/index.ts"],"sourcesContent":["/**\n * Opt-in local monorepo stack (api :3001, player :3002).\n * Never inferred from hostname alone — third-party demos run on localhost against production.\n */\nexport function useExplicitLocalStack(): boolean {\n\tif ((globalThis as { __LIFORMA_STACK?: string }).__LIFORMA_STACK === 'local') {\n\t\treturn true;\n\t}\n\n\tif (typeof location === 'undefined') {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\treturn new URLSearchParams(location.search).get('stack') === 'local';\n\t} catch {\n\t\treturn false;\n\t}\n}\n","import { useExplicitLocalStack } from './localStack';\n\nconst PRODUCTION_API_BASE_URL = 'https://api.liforma.ai';\nconst LOCAL_API_BASE_URL = 'http://localhost:3001';\n\nfunction readConfiguredApiBaseUrl(): string | null {\n\tconst globalValue = (globalThis as { __LIFORMA_API_BASE_URL?: string }).__LIFORMA_API_BASE_URL;\n\tif (globalValue?.trim()) {\n\t\treturn globalValue.trim().replace(/\\/$/, '');\n\t}\n\n\tif (typeof document === 'undefined') {\n\t\treturn null;\n\t}\n\n\tconst script =\n\t\tdocument.querySelector('script[data-liforma-sdk][src*=\"client.js\"]') ??\n\t\tdocument.querySelector('script[src*=\"/sdk/v2/client.js\"]');\n\tconst fromScript = script?.getAttribute('data-api-base-url')?.trim();\n\tif (fromScript) {\n\t\treturn fromScript.replace(/\\/$/, '');\n\t}\n\n\treturn null;\n}\n\n/**\n * Browser-visible API origin for Liforma HTTP calls from the CDN SDK.\n *\n * Defaults to production. Local stack is opt-in only — never inferred from\n * `localhost` hostname (third-party demos run on localhost against production).\n *\n * Override order:\n * 1. `window.__LIFORMA_API_BASE_URL`\n * 2. `data-api-base-url` on the SDK script tag\n * 3. `window.__LIFORMA_STACK === 'local'` or host `?stack=local` → http://localhost:3001\n * 4. production default → https://api.liforma.ai\n */\nexport function resolvePublicApiBaseUrl(): string {\n\tconst configured = readConfiguredApiBaseUrl();\n\tif (configured) {\n\t\treturn configured;\n\t}\n\n\tif (useExplicitLocalStack()) {\n\t\treturn LOCAL_API_BASE_URL;\n\t}\n\n\treturn PRODUCTION_API_BASE_URL;\n}\n","import type { StartButtonOptions } from '../types/sessionInteraction';\n\nexport type SessionEndpointRequestOptions = {\n\treadonly experienceId: string;\n\treadonly language?: 'en' | 'es';\n\treadonly mode?: 'conversation' | 'presenter';\n\t/** @deprecated Response ownership is derived from mode. */\n\treadonly responseMode?: 'managed' | 'custom' | 'manual';\n\treadonly speechInputMode?: 'auto' | 'manual' | 'off';\n\treadonly startButton?: StartButtonOptions;\n\treadonly speechOnly?: boolean;\n};\n\nexport function createSessionEndpointRequest(\n\tsessionEndpoint: string,\n\toptions: SessionEndpointRequestOptions\n): { readonly url: string; readonly init: RequestInit } {\n\tconst endpoint = sessionEndpoint.trim();\n\tif (!endpoint) {\n\t\tthrow new Error('sessionEndpoint must not be empty.');\n\t}\n\tif (typeof location === 'undefined') {\n\t\tthrow new Error('sessionEndpoint is only available in a browser.');\n\t}\n\n\tconst url = new URL(endpoint, location.href);\n\tif (url.origin !== location.origin) {\n\t\tthrow new Error('sessionEndpoint must be same-origin.');\n\t}\n\n\tconst experienceId = options.experienceId.trim();\n\tif (!experienceId) {\n\t\tthrow new Error('sessionEndpoint requires experienceId.');\n\t}\n\n\treturn {\n\t\turl: url.toString(),\n\t\tinit: {\n\t\t\tmethod: 'POST',\n\t\t\tcredentials: 'same-origin',\n\t\t\theaders: {\n\t\t\t\tAccept: 'application/json',\n\t\t\t\t'Content-Type': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\texperienceId,\n\t\t\t\t...(options.language ? { language: options.language } : {}),\n\t\t\t\t...(options.mode ? { mode: options.mode } : {}),\n\t\t\t\t...(options.responseMode ? { responseMode: options.responseMode } : {}),\n\t\t\t\t...(options.speechInputMode ? { speechInputMode: options.speechInputMode } : {}),\n\t\t\t\t...(options.startButton ? { startButton: options.startButton } : {}),\n\t\t\t\t...(options.speechOnly !== undefined ? { speechOnly: options.speechOnly } : {})\n\t\t\t})\n\t\t}\n\t};\n}\n","var _a;\n/** A special constant with type `never` */\nexport const NEVER = /*@__PURE__*/ 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}\n(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});\nexport const globalConfig = globalThis.__zod_globalConfig;\nexport function config(newConfig) {\n if (newConfig)\n Object.assign(globalConfig, newConfig);\n return globalConfig;\n}\n","import { globalConfig } from \"./core.js\";\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 ratio = val / step;\n const roundedRatio = Math.round(ratio);\n // Use a relative epsilon scaled to the magnitude of the result\n const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);\n if (Math.abs(ratio - roundedRatio) < tolerance)\n return 0;\n return ratio - roundedRatio;\n}\nconst EVALUATING = /* @__PURE__*/ 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 = /* @__PURE__*/ cached(() => {\n // Skip the probe under `jitless`: strict CSPs report the caught `new Function`\n // as a `securitypolicyviolation` even though the throw is swallowed.\n if (globalConfig.jitless) {\n return false;\n }\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 if (o instanceof Map)\n return new Map(o);\n if (o instanceof Set)\n return new Set(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 = /* @__PURE__*/ new Set([\"string\", \"number\", \"symbol\"]);\nexport const primitiveTypes = /* @__PURE__*/ new Set([\n \"string\",\n \"number\",\n \"bigint\",\n \"boolean\",\n \"symbol\",\n \"undefined\",\n]);\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 if (a._zod.def.checks?.length) {\n throw new Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");\n }\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: b._zod.def.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}\n// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).\n// Used to respect `abort: true` in .refine() even for checks that have a `when` function.\nexport function explicitlyAborted(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 === false) {\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 message = iss.message\n ? iss.message\n : (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 const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;\n rest.path ?? (rest.path = []);\n rest.message = message;\n if (ctx?.reportInput) {\n rest.input = _input;\n }\n return rest;\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, path = []) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\" && issue.errors.length) {\n issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues }, [...path, ...issue.path]);\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues }, [...path, ...issue.path]);\n }\n else {\n const fullpath = [...path, ...issue.path];\n if (fullpath.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < fullpath.length) {\n const el = fullpath[i];\n const terminal = i === fullpath.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 };\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 }, [...path, ...issue.path]));\n }\n else if (issue.code === \"invalid_key\") {\n processError({ issues: issue.issues }, [...path, ...issue.path]);\n }\n else if (issue.code === \"invalid_element\") {\n processError({ issues: issue.issues }, [...path, ...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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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 ? { ..._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\";\n/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link cuid2} instead.\n * See https://github.com/paralleldrive/cuid.\n */\nexport const cuid = /^[cC][0-9a-z]{6,}$/;\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,}$/;\nexport const httpProtocol = /^https?$/;\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: 4,\n patch: 3,\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 if (util.explicitlyAborted(payload))\n continue;\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 // When normalize is off, require :// for http/https URLs\n // This prevents strings like \"http:example.com\" or \"https:/path\" from being silently accepted\n if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {\n if (!/^https?:\\/\\//i.test(trimmed)) {\n payload.issues.push({\n code: \"invalid_format\",\n format: \"url\",\n note: \"Invalid URL format\",\n input: payload.value,\n inst,\n continue: !def.abort,\n });\n return;\n }\n }\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});\n/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.\n * See https://github.com/paralleldrive/cuid.\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 // atob ignores whitespace, so reject it up front.\n if (/\\s/.test(data))\n return false;\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.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, isOptionalIn, isOptionalOut) {\n const isPresent = key in input;\n if (result.issues.length) {\n // For optional-in/out schemas, ignore errors on absent keys.\n if (isOptionalIn && isOptionalOut && !isPresent) {\n return;\n }\n final.issues.push(...util.prefixIssues(key, result.issues));\n }\n if (!isPresent && !isOptionalIn) {\n if (!result.issues.length) {\n final.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [key],\n });\n }\n return;\n }\n if (result.value === undefined) {\n if (isPresent) {\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 const keySet = def.keySet;\n const _catchall = def.catchall._zod;\n const t = _catchall.def.type;\n const isOptionalIn = _catchall.optin === \"optional\";\n const isOptionalOut = _catchall.optout === \"optional\";\n for (const key in input) {\n // skip __proto__ so it can't replace the result prototype via the\n // assignment setter on the plain {} we build into\n if (key === \"__proto__\")\n continue;\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, isOptionalIn, isOptionalOut)));\n }\n else {\n handlePropertyResult(r, payload, key, input, isOptionalIn, 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 isOptionalIn = el._zod.optin === \"optional\";\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, isOptionalIn, isOptionalOut)));\n }\n else {\n handlePropertyResult(r, payload, key, input, isOptionalIn, 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 isOptionalIn = schema?._zod?.optin === \"optional\";\n const isOptionalOut = schema?._zod?.optout === \"optional\";\n doc.write(`const ${id} = ${parseStr(key)};`);\n if (isOptionalIn && isOptionalOut) {\n // For optional-in/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 if (!isOptionalIn) {\n doc.write(`\n const ${id}_present = ${k} in input;\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 if (!${id}_present && !${id}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${k}]\n });\n }\n\n if (${id}_present) {\n if (${id}.value === undefined) {\n newResult[${k}] = undefined;\n } else {\n newResult[${k}] = ${id}.value;\n }\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 first = def.options.length === 1 ? def.options[0]._zod.run : null;\n inst._zod.parse = (payload, ctx) => {\n if (first) {\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 first = def.options.length === 1 ? def.options[0]._zod.run : null;\n inst._zod.parse = (payload, ctx) => {\n if (first) {\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 // Fall back to union matching when the fast discriminator path fails:\n // - explicitly enabled via unionFallback, or\n // - during backward direction (encode), since codec-based discriminators\n // have different values in forward vs backward directions\n if (def.unionFallback || ctx.direction === \"backward\") {\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 options: Array.from(disc.value.keys()),\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 optinStart = getTupleOptStart(items, \"optin\");\n const optoutStart = getTupleOptStart(items, \"optout\");\n if (!def.rest) {\n if (input.length < optinStart) {\n payload.issues.push({\n code: \"too_small\",\n minimum: optinStart,\n inclusive: true,\n input,\n inst,\n origin: \"array\",\n });\n return payload;\n }\n if (input.length > items.length) {\n payload.issues.push({\n code: \"too_big\",\n maximum: items.length,\n inclusive: true,\n input,\n inst,\n origin: \"array\",\n });\n }\n }\n // Run every item in parallel, collecting results into an indexed\n // array. The post-processing in `handleTupleResults` walks them in\n // order so it can decide whether an absent optional-output error can\n // truncate the tail or must be reported to preserve required output.\n const itemResults = new Array(items.length);\n for (let i = 0; i < items.length; i++) {\n const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);\n if (r instanceof Promise) {\n proms.push(r.then((rr) => {\n itemResults[i] = rr;\n }));\n }\n else {\n itemResults[i] = r;\n }\n }\n if (def.rest) {\n let i = items.length - 1;\n const rest = input.slice(items.length);\n for (const el of rest) {\n i++;\n const result = def.rest._zod.run({ value: el, issues: [] }, ctx);\n if (result instanceof Promise) {\n proms.push(result.then((r) => handleTupleResult(r, payload, i)));\n }\n else {\n handleTupleResult(result, payload, i);\n }\n }\n }\n if (proms.length) {\n return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));\n }\n return handleTupleResults(itemResults, payload, items, input, optoutStart);\n };\n});\nfunction getTupleOptStart(items, key) {\n for (let i = items.length - 1; i >= 0; i--) {\n if (items[i]._zod[key] !== \"optional\")\n return i + 1;\n }\n return 0;\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}\nfunction handleTupleResults(itemResults, final, items, input, optoutStart) {\n // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional\n // rule, but only after `optoutStart`: the first index where the output\n // tuple tail can be absent.\n for (let i = 0; i < items.length; i++) {\n const r = itemResults[i];\n const isPresent = i < input.length;\n if (r.issues.length) {\n if (!isPresent && i >= optoutStart) {\n final.value.length = i;\n break;\n }\n final.issues.push(...util.prefixIssues(i, r.issues));\n }\n final.value[i] = r.value;\n }\n // Drop trailing slots that produced `undefined` for absent input\n // (the array analog of an absent optional key on an object). The\n // `i >= input.length` floor is critical: an explicit `undefined`\n // *inside* the input must be preserved even when the schema is\n // optional-out (e.g. `z.string().or(z.undefined())` accepting an\n // explicit undefined value).\n for (let i = final.value.length - 1; i >= input.length; i--) {\n if (items[i]._zod.optout === \"optional\" && final.value[i] === undefined) {\n final.value.length = i;\n }\n else {\n break;\n }\n }\n return final;\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 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 if (keyResult.issues.length) {\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 continue;\n }\n const outKey = keyResult.value;\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[outKey] = result.value;\n }));\n }\n else {\n if (result.issues.length) {\n payload.issues.push(...util.prefixIssues(key, result.issues));\n }\n payload.value[outKey] = 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 // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()\n for (const key of Reflect.ownKeys(input)) {\n if (key === \"__proto__\")\n continue;\n if (!Object.prototype.propertyIsEnumerable.call(input, key))\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.optin = \"optional\";\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 payload.fallback = true;\n return payload;\n });\n }\n if (_out instanceof Promise) {\n throw new core.$ZodAsyncError();\n }\n payload.value = _out;\n payload.fallback = true;\n return payload;\n };\n});\nfunction handleOptionalResult(result, input) {\n if (input === undefined && (result.issues.length || result.fallback)) {\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 input = payload.value;\n const result = def.innerType._zod.run(payload, ctx);\n if (result instanceof Promise)\n return result.then((r) => handleOptionalResult(r, input));\n return handleOptionalResult(result, input);\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 inst._zod.optin = \"optional\";\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 payload.fallback = true;\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 payload.fallback = true;\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, fallback: left.fallback }, 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 $ZodPreprocess = /*@__PURE__*/ core.$constructor(\"$ZodPreprocess\", (inst, def) => {\n $ZodPipe.init(inst, def);\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 // Cache the resolved inner type on the shared `def` so all clones of this\n // lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,\n // preserving identity for cycle detection on recursive schemas.\n util.defineLazy(inst._zod, \"innerType\", () => {\n const d = def;\n if (!d._cachedInner)\n d._cachedInner = def.getter();\n return d._cachedInner;\n });\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/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link _cuid2} instead.\n * See https://github.com/paralleldrive/cuid.\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, params) {\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 }, params);\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\" && \"_prefault\" in result.schema)\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 // The `id` in `.meta()` is a Zod-specific registration tag used to extract\n // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it\n // from the output body where it would otherwise leak. The id is preserved\n // implicitly via the $defs key (and via $ref paths).\n const rootMetaId = ctx.metadataRegistry.get(schema)?.id;\n if (rootMetaId !== undefined && result.id === rootMetaId)\n delete result.id;\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 if (seen.def.id === seen.defId)\n delete seen.def.id;\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 if (_schema._zod.traits.has(\"$ZodCodec\"))\n return true;\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 // when both minimum and exclusiveMinimum exist, pick the more restrictive one\n const exMin = typeof exclusiveMinimum === \"number\" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);\n const exMax = typeof exclusiveMaximum === \"number\" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);\n const legacy = ctx.target === \"draft-04\" || ctx.target === \"openapi-3.0\";\n if (exMin) {\n if (legacy) {\n json.minimum = exclusiveMinimum;\n json.exclusiveMinimum = true;\n }\n else {\n json.exclusiveMinimum = exclusiveMinimum;\n }\n }\n else if (typeof minimum === \"number\") {\n json.minimum = minimum;\n }\n if (exMax) {\n if (legacy) {\n json.maximum = exclusiveMaximum;\n json.exclusiveMaximum = true;\n }\n else {\n json.exclusiveMaximum = exclusiveMaximum;\n }\n }\n else if (typeof maximum === \"number\") {\n json.maximum = maximum;\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, {\n ...params,\n path: [...params.path, \"items\"],\n });\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 inIsTransform = def.in._zod.traits.has(\"$ZodTransform\");\n const innerType = ctx.io === \"input\" ? (inIsTransform ? 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 = /*@__PURE__*/ core.$constructor(\"ZodError\", initializer);\nexport const ZodRealError = /*@__PURE__*/ 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\";\n// Lazy-bind builder methods.\n//\n// Builder methods (`.optional`, `.array`, `.refine`, ...) live as\n// non-enumerable getters on each concrete schema constructor's\n// prototype. On first access from an instance the getter allocates\n// `fn.bind(this)` and caches it as an own property on that instance,\n// so detached usage (`const m = schema.optional; m()`) still works\n// and the per-instance allocation only happens for methods actually\n// touched.\n//\n// One install per (prototype, group), memoized by `_installedGroups`.\nconst _installedGroups = /* @__PURE__ */ new WeakMap();\nfunction _installLazyMethods(inst, group, methods) {\n const proto = Object.getPrototypeOf(inst);\n let installed = _installedGroups.get(proto);\n if (!installed) {\n installed = new Set();\n _installedGroups.set(proto, installed);\n }\n if (installed.has(group))\n return;\n installed.add(group);\n for (const key in methods) {\n const fn = methods[key];\n Object.defineProperty(proto, key, {\n configurable: true,\n enumerable: false,\n get() {\n const bound = fn.bind(this);\n Object.defineProperty(this, key, {\n configurable: true,\n writable: true,\n enumerable: true,\n value: bound,\n });\n return bound;\n },\n set(v) {\n Object.defineProperty(this, key, {\n configurable: true,\n writable: true,\n enumerable: true,\n value: v,\n });\n },\n });\n }\n}\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 // Parse-family is intentionally kept as per-instance closures: these are\n // the hot path AND the most-detached methods (`arr.map(schema.parse)`,\n // `const { parse } = schema`, etc.). Eager closures here mean callers pay\n // ~12 closure allocations per schema but get monomorphic call sites and\n // detached usage that \"just works\".\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 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 // All builder methods are placed on the internal prototype as lazy-bind\n // getters. On first access per-instance, a bound thunk is allocated and\n // cached as an own property; subsequent accesses skip the getter. This\n // means: no per-instance allocation for unused methods, full\n // detachability preserved (`const m = schema.optional; m()` works), and\n // shared underlying function references across all instances.\n _installLazyMethods(inst, \"ZodType\", {\n check(...chks) {\n const def = this.def;\n return this.clone(util.mergeDefs(def, {\n checks: [\n ...(def.checks ?? []),\n ...chks.map((ch) => typeof ch === \"function\" ? { _zod: { check: ch, def: { check: \"custom\" }, onattach: [] } } : ch),\n ],\n }), { parent: true });\n },\n with(...chks) {\n return this.check(...chks);\n },\n clone(def, params) {\n return core.clone(this, def, params);\n },\n brand() {\n return this;\n },\n register(reg, meta) {\n reg.add(this, meta);\n return this;\n },\n refine(check, params) {\n return this.check(refine(check, params));\n },\n superRefine(refinement, params) {\n return this.check(superRefine(refinement, params));\n },\n overwrite(fn) {\n return this.check(checks.overwrite(fn));\n },\n optional() {\n return optional(this);\n },\n exactOptional() {\n return exactOptional(this);\n },\n nullable() {\n return nullable(this);\n },\n nullish() {\n return optional(nullable(this));\n },\n nonoptional(params) {\n return nonoptional(this, params);\n },\n array() {\n return array(this);\n },\n or(arg) {\n return union([this, arg]);\n },\n and(arg) {\n return intersection(this, arg);\n },\n transform(tx) {\n return pipe(this, transform(tx));\n },\n default(d) {\n return _default(this, d);\n },\n prefault(d) {\n return prefault(this, d);\n },\n catch(params) {\n return _catch(this, params);\n },\n pipe(target) {\n return pipe(this, target);\n },\n readonly() {\n return readonly(this);\n },\n describe(description) {\n const cl = this.clone();\n core.globalRegistry.add(cl, { description });\n return cl;\n },\n meta(...args) {\n // overloaded: meta() returns the registered metadata, meta(data)\n // returns a clone with `data` registered. The mapped type picks\n // up the second overload, so we accept variadic any-args and\n // return `any` to satisfy both at runtime.\n if (args.length === 0)\n return core.globalRegistry.get(this);\n const cl = this.clone();\n core.globalRegistry.add(cl, args[0]);\n return cl;\n },\n isOptional() {\n return this.safeParse(undefined).success;\n },\n isNullable() {\n return this.safeParse(null).success;\n },\n apply(fn) {\n return fn(this);\n },\n });\n Object.defineProperty(inst, \"description\", {\n get() {\n return core.globalRegistry.get(inst)?.description;\n },\n configurable: true,\n });\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 _installLazyMethods(inst, \"_ZodString\", {\n regex(...args) {\n return this.check(checks.regex(...args));\n },\n includes(...args) {\n return this.check(checks.includes(...args));\n },\n startsWith(...args) {\n return this.check(checks.startsWith(...args));\n },\n endsWith(...args) {\n return this.check(checks.endsWith(...args));\n },\n min(...args) {\n return this.check(checks.minLength(...args));\n },\n max(...args) {\n return this.check(checks.maxLength(...args));\n },\n length(...args) {\n return this.check(checks.length(...args));\n },\n nonempty(...args) {\n return this.check(checks.minLength(1, ...args));\n },\n lowercase(params) {\n return this.check(checks.lowercase(params));\n },\n uppercase(params) {\n return this.check(checks.uppercase(params));\n },\n trim() {\n return this.check(checks.trim());\n },\n normalize(...args) {\n return this.check(checks.normalize(...args));\n },\n toLowerCase() {\n return this.check(checks.toLowerCase());\n },\n toUpperCase() {\n return this.check(checks.toUpperCase());\n },\n slugify() {\n return this.check(checks.slugify());\n },\n });\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: core.regexes.httpProtocol,\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}\n/**\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link ZodCUID2} instead.\n * See https://github.com/paralleldrive/cuid.\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});\n/**\n * Validates a CUID v1 string.\n *\n * @deprecated CUID v1 is deprecated by its authors due to information leakage\n * (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.\n * See https://github.com/paralleldrive/cuid.\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 _installLazyMethods(inst, \"ZodNumber\", {\n gt(value, params) {\n return this.check(checks.gt(value, params));\n },\n gte(value, params) {\n return this.check(checks.gte(value, params));\n },\n min(value, params) {\n return this.check(checks.gte(value, params));\n },\n lt(value, params) {\n return this.check(checks.lt(value, params));\n },\n lte(value, params) {\n return this.check(checks.lte(value, params));\n },\n max(value, params) {\n return this.check(checks.lte(value, params));\n },\n int(params) {\n return this.check(int(params));\n },\n safe(params) {\n return this.check(int(params));\n },\n positive(params) {\n return this.check(checks.gt(0, params));\n },\n nonnegative(params) {\n return this.check(checks.gte(0, params));\n },\n negative(params) {\n return this.check(checks.lt(0, params));\n },\n nonpositive(params) {\n return this.check(checks.lte(0, params));\n },\n multipleOf(value, params) {\n return this.check(checks.multipleOf(value, params));\n },\n step(value, params) {\n return this.check(checks.multipleOf(value, params));\n },\n finite() {\n return this;\n },\n });\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 _installLazyMethods(inst, \"ZodArray\", {\n min(n, params) {\n return this.check(checks.minLength(n, params));\n },\n nonempty(params) {\n return this.check(checks.minLength(1, params));\n },\n max(n, params) {\n return this.check(checks.maxLength(n, params));\n },\n length(n, params) {\n return this.check(checks.length(n, params));\n },\n unwrap() {\n return this.element;\n },\n });\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 _installLazyMethods(inst, \"ZodObject\", {\n keyof() {\n return _enum(Object.keys(this._zod.def.shape));\n },\n catchall(catchall) {\n return this.clone({ ...this._zod.def, catchall: catchall });\n },\n passthrough() {\n return this.clone({ ...this._zod.def, catchall: unknown() });\n },\n loose() {\n return this.clone({ ...this._zod.def, catchall: unknown() });\n },\n strict() {\n return this.clone({ ...this._zod.def, catchall: never() });\n },\n strip() {\n return this.clone({ ...this._zod.def, catchall: undefined });\n },\n extend(incoming) {\n return util.extend(this, incoming);\n },\n safeExtend(incoming) {\n return util.safeExtend(this, incoming);\n },\n merge(other) {\n return util.merge(this, other);\n },\n pick(mask) {\n return util.pick(this, mask);\n },\n omit(mask) {\n return util.omit(this, mask);\n },\n partial(...args) {\n return util.partial(ZodOptional, this, args[0]);\n },\n required(...args) {\n return util.required(ZodNonOptional, this, args[0]);\n },\n });\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 // v3-compat: z.record(valueType, params?) — defaults keyType to z.string()\n if (!valueType || !valueType._zod) {\n return new ZodRecord({\n type: \"record\",\n keyType: string(),\n valueType: keyType,\n ...util.normalizeParams(valueType),\n });\n }\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 payload.fallback = true;\n return payload;\n });\n }\n payload.value = output;\n payload.fallback = true;\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 function invertCodec(codec) {\n const def = codec._zod.def;\n return new ZodCodec({\n type: \"pipe\",\n in: def.out,\n out: def.in,\n transform: def.reverseTransform,\n reverseTransform: def.transform,\n });\n}\nexport const ZodPreprocess = /*@__PURE__*/ core.$constructor(\"ZodPreprocess\", (inst, def) => {\n ZodPipe.init(inst, def);\n core.$ZodPreprocess.init(inst, def);\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, params) {\n return core._superRefine(fn, params);\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\nexport function preprocess(fn, schema) {\n return new ZodPreprocess({\n type: \"pipe\",\n in: transform(fn),\n out: schema,\n });\n}\n","import { z } from 'zod';\n\nimport type { SessionManifest } from './sessionManifest';\n\nconst closeButtonSchema = z\n\t.object({\n\t\tvisible: z.boolean().optional(),\n\t\tstyle: z.enum(['icon', 'text']).optional(),\n\t\tlabel: z.string().nullable().optional(),\n\t\tposition: z.string().optional()\n\t})\n\t.nullable()\n\t.optional();\n\nconst integrationSchema = z\n\t.object({\n\t\treturnUrl: z.string().optional(),\n\t\tnavigateOnClose: z.boolean().optional()\n\t})\n\t.optional();\n\nconst startButtonSchema = z.object({\n\tlabel: z.string().min(1).max(80).optional(),\n\tariaLabel: z.string().min(1).max(120).optional(),\n\tplacement: z.enum(['center', 'bottom-center', 'bottom-left', 'bottom-right']).optional(),\n\tvariant: z.enum(['primary', 'secondary', 'minimal']).optional(),\n\tappearance: z\n\t\t.object({\n\t\t\tbackgroundColor: z.string().min(1).max(64).optional(),\n\t\t\ttextColor: z.string().min(1).max(64).optional(),\n\t\t\tborderColor: z.string().min(1).max(64).optional(),\n\t\t\tborderRadiusPx: z.number().min(0).max(999).optional(),\n\t\t\tsize: z.enum(['small', 'medium', 'large']).optional(),\n\t\t\tshadow: z.enum(['none', 'soft', 'strong']).optional()\n\t\t})\n\t\t.optional()\n});\n\nconst characterSchema = z.object({\n\tcharacterId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tavatarId: z.string().min(1),\n\tvoiceId: z.string().min(1),\n\tsttLang: z.string().min(1),\n\tagentId: z.string().min(1),\n\tappearance: z\n\t\t.object({\n\t\t\tcostume: z.string().optional(),\n\t\t\tcostumeClothes: z.string().optional(),\n\t\t\thair: z.string().optional()\n\t\t})\n\t\t.optional()\n});\n\nconst locationPlacementSchema = z.object({\n\tcx: z.number(),\n\tcy: z.number(),\n\tscale: z.number(),\n\tdistanceM: z.number()\n});\n\nconst locationSceneSchema = z.object({\n\ttype: z.literal('image'),\n\tlayers: z.array(z.string()),\n\tassets: z.record(z.string(), z.record(z.string(), z.string()))\n});\n\nconst pipelinePlacementSchema = z.enum(['browser', 'cloud']);\n\nconst pipelineStageSchema = z.object({\n\tplacement: pipelinePlacementSchema,\n\tprovider: z.string().min(1),\n\tmodel: z.string().min(1).optional(),\n\tconfig: z.record(z.string(), z.unknown()).default({})\n});\n\nconst pipelineAnimationSchema = z.object({\n\tenabled: z.boolean(),\n\tplacement: pipelinePlacementSchema.optional(),\n\tsource: z.enum(['azureViseme', 'speechToAnimation', 'none']),\n\tprovider: z.string().min(1).optional(),\n\tmodel: z.string().min(1).optional(),\n\tconfig: z.record(z.string(), z.unknown()).default({})\n});\n\nconst pipelineSchema = z.object({\n\tstt: pipelineStageSchema,\n\tllm: pipelineStageSchema,\n\ttts: pipelineStageSchema,\n\tanimation: pipelineAnimationSchema\n});\n\nexport const sessionManifestSchema = z.object({\n\tschemaVersion: z.literal(1),\n\tsessionId: z.string().min(1),\n\texperienceId: z.string().min(1),\n\texpiresAt: z.string().min(1),\n\tsessionToken: z.string().min(1),\n\texperience: z.object({\n\t\ttitle: z.string(),\n\t\tslug: z.string(),\n\t\tmode: z.enum(['conversation', 'presenter']),\n\t\tresponseMode: z.enum(['managed', 'custom', 'manual']),\n\t\tspeechInputMode: z.enum(['auto', 'manual', 'off']),\n\t\tstartButton: startButtonSchema.optional(),\n\t\topeningMessage: z.string().optional()\n\t}),\n\ttransport: z.object({\n\t\ttype: z.literal('http'),\n\t\tconfig: z.object({\n\t\t\tapiBaseUrl: z.string().min(1)\n\t\t})\n\t}),\n\truntime: z.object({\n\t\tcdnBaseUrl: z.string().min(1),\n\t\tinput: z.literal('browserStt'),\n\t\trenderer: z.literal('morph2d')\n\t}),\n\tpipeline: pipelineSchema.optional(),\n\tcapabilities: z.array(z.string()),\n\tcharacters: z.array(characterSchema).min(1),\n\tactiveCharacterId: z.string().min(1),\n\tlocation: z\n\t\t.object({\n\t\t\tlocationId: z.string(),\n\t\t\ttitle: z.string(),\n\t\t\tscene: locationSceneSchema.optional(),\n\t\t\tplacement: locationPlacementSchema.optional(),\n\t\t\tmetersPerDepth: z.number().positive().optional(),\n\t\t\thasZoomVariant: z.boolean().optional()\n\t\t})\n\t\t.optional(),\n\tworld: z\n\t\t.object({\n\t\t\tworldId: z.string(),\n\t\t\trulesetVersion: z.number()\n\t\t})\n\t\t.optional(),\n\tstate: z.object({\n\t\tschemaVersion: z.literal(1),\n\t\tvalues: z.record(z.string(), z.unknown())\n\t}),\n\ttools: z.array(z.unknown()),\n\tintegration: integrationSchema,\n\tcloseButton: closeButtonSchema,\n\tbilling: z\n\t\t.object({\n\t\t\tpayer: z.literal('creator'),\n\t\t\tmeterId: z.string()\n\t\t})\n\t\t.optional(),\n\tlanguage: z.enum(['en', 'es']).optional(),\n\tlanguagePackRevision: z.string().optional(),\n\tprocessorId: z.string().optional()\n}).superRefine((manifest, ctx) => {\n\tconst active = manifest.activeCharacterId;\n\tconst found = manifest.characters.some((c) => c.characterId === active);\n\tif (!found) {\n\t\tctx.addIssue({\n\t\t\tcode: 'custom',\n\t\t\tmessage: 'activeCharacterId must reference a character in characters[]',\n\t\t\tpath: ['activeCharacterId']\n\t\t});\n\t}\n});\n\n/** Apply API defaults for interaction modes omitted by older mint paths. */\nexport function normalizeSessionManifestInput(data: unknown): unknown {\n\tif (!data || typeof data !== 'object') return data;\n\tconst record = { ...(data as Record<string, unknown>) };\n\tconst experience = record.experience;\n\tif (!experience || typeof experience !== 'object') return record;\n\n\tconst exp = { ...(experience as Record<string, unknown>) };\n\tconst mode = exp.mode === 'presenter' ? 'presenter' : 'conversation';\n\tif (exp.responseMode === undefined) {\n\t\texp.responseMode = mode === 'presenter' ? 'manual' : 'managed';\n\t}\n\tif (exp.speechInputMode === undefined) {\n\t\texp.speechInputMode = mode === 'presenter' ? 'manual' : 'auto';\n\t}\n\trecord.experience = exp;\n\treturn record;\n}\n\nfunction formatZodIssues(error: z.ZodError): string {\n\treturn error.issues\n\t\t.map((issue) => {\n\t\t\tconst path = issue.path.length > 0 ? issue.path.join('.') : '(root)';\n\t\t\treturn `${path}: ${issue.message}`;\n\t\t})\n\t\t.join('; ');\n}\n\nexport function parseSessionManifest(data: unknown): SessionManifest {\n\tconst result = sessionManifestSchema.safeParse(normalizeSessionManifestInput(data));\n\tif (!result.success) {\n\t\tthrow new Error(`Invalid Session Manifest from Liforma API — ${formatZodIssues(result.error)}`);\n\t}\n\treturn result.data as SessionManifest;\n}\n\nexport function manifestHasSessionCredential(manifest: SessionManifest): boolean {\n\treturn manifest.sessionToken.trim().length > 0;\n}\n","import { resolvePublicApiBaseUrl } from '../../shims/apiBaseUrl';\nimport { createSessionEndpointRequest } from './sessionEndpointRequest';\nimport { parseSessionManifest } from '../types/sessionManifestSchema';\nimport type { SessionManifest } from '../types/sessionManifest';\nimport type { StartButtonOptions } from '../types/sessionInteraction';\n\ntype MintErrorPayload = {\n\treadonly code?: string;\n\treadonly message?: string;\n\treadonly origin?: string;\n\treadonly experienceId?: string;\n};\n\nfunction currentPageOrigin(): string | undefined {\n\ttry {\n\t\tif (typeof globalThis.location?.origin === 'string' && globalThis.location.origin) {\n\t\t\treturn globalThis.location.origin;\n\t\t}\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nfunction formatPublicMintError(experienceId: string, status: number, text: string): string {\n\tlet payload: MintErrorPayload | undefined;\n\ttry {\n\t\tpayload = JSON.parse(text) as MintErrorPayload;\n\t} catch {\n\t\t/* keep */\n\t}\n\n\tconst pageOrigin = currentPageOrigin();\n\tconst apiMessage = payload?.message?.trim();\n\tconst code = payload?.code;\n\n\tif (\n\t\tcode === 'origin_not_allowed' ||\n\t\t(/^Origin not allowed/i.test(apiMessage ?? '') && pageOrigin)\n\t) {\n\t\tif (apiMessage && apiMessage.includes(experienceId) && apiMessage.includes('allowed origin')) {\n\t\t\treturn apiMessage;\n\t\t}\n\t\tconst origin = payload?.origin ?? pageOrigin ?? '(unknown origin)';\n\t\treturn (\n\t\t\t`Your origin ${origin} is not an allowed origin for experience ${experienceId}. ` +\n\t\t\t`If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), ` +\n\t\t\t`open Workspace → Settings → Origins, add ${origin} to the list of allowed origins, ` +\n\t\t\t`and ensure “Allow public client-only embeds” is enabled.`\n\t\t);\n\t}\n\n\tif (code === 'browser_embeds_disabled' || /^Browser embeds are not enabled/i.test(apiMessage ?? '')) {\n\t\tif (apiMessage && apiMessage.includes('Allow public client-only embeds')) {\n\t\t\treturn apiMessage;\n\t\t}\n\t\treturn (\n\t\t\t`Browser embeds are not enabled for experience ${experienceId}. ` +\n\t\t\t`If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), ` +\n\t\t\t`open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`\n\t\t);\n\t}\n\n\tif (\n\t\tcode === 'experience_unavailable' ||\n\t\t/^Experience is not available\\.?$/i.test(apiMessage ?? '') ||\n\t\t/^Unknown experience\\.?$/i.test(apiMessage ?? '')\n\t) {\n\t\tif (apiMessage && apiMessage.includes('No playable experience found')) {\n\t\t\treturn apiMessage;\n\t\t}\n\t\treturn (\n\t\t\t`No playable experience found for “${experienceId}”. ` +\n\t\t\t`Check that the experience id is correct (it should look like exp_…), ` +\n\t\t\t`and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). ` +\n\t\t\t`Deleted, archived, and unpublished experiences cannot be started from a browser embed.`\n\t\t);\n\t}\n\n\tif (apiMessage) return apiMessage;\n\tconst trimmed = text.trim().slice(0, 500);\n\treturn trimmed || `Public session mint failed (${status})`;\n}\n\nexport async function mintPublicSession(\n\texperienceId: string,\n\toptions?: {\n\t\treadonly language?: 'en' | 'es';\n\t\treadonly mode?: 'conversation' | 'presenter';\n\t\t/** @deprecated Response ownership is derived from mode. */\n\t\treadonly responseMode?: 'managed' | 'custom' | 'manual';\n\t\treadonly speechInputMode?: 'auto' | 'manual' | 'off';\n\t\treadonly startButton?: StartButtonOptions;\n\t\treadonly speechOnly?: boolean;\n\t}\n): Promise<SessionManifest> {\n\tconst apiBaseUrl = resolvePublicApiBaseUrl();\n\tconst body: Record<string, unknown> = { experienceId };\n\tif (options?.language) body.language = options.language;\n\tif (options?.mode) body.mode = options.mode;\n\tif (options?.responseMode) body.responseMode = options.responseMode;\n\tif (options?.speechInputMode) body.speechInputMode = options.speechInputMode;\n\tif (options?.startButton) body.startButton = options.startButton;\n\tif (options?.speechOnly !== undefined) body.speechOnly = options.speechOnly;\n\tconst res = await fetch(`${apiBaseUrl}/v1/public-sessions`, {\n\t\tmethod: 'POST',\n\t\theaders: { 'Content-Type': 'application/json' },\n\t\tbody: JSON.stringify(body)\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text();\n\t\tthrow new Error(formatPublicMintError(experienceId, res.status, text));\n\t}\n\tlet raw: unknown;\n\ttry {\n\t\traw = await res.json();\n\t} catch {\n\t\tthrow new Error('Public session mint returned invalid JSON.');\n\t}\n\n\treturn parseSessionManifest(raw);\n}\n\nexport type FetchSessionManifestOptions = {\n\treadonly experienceId: string;\n\treadonly language?: 'en' | 'es';\n\treadonly mode?: 'conversation' | 'presenter';\n\t/** @deprecated Response ownership is derived from mode. */\n\treadonly responseMode?: 'managed' | 'custom' | 'manual';\n\treadonly speechInputMode?: 'auto' | 'manual' | 'off';\n\treadonly startButton?: StartButtonOptions;\n\treadonly speechOnly?: boolean;\n\treadonly signal?: AbortSignal;\n\treadonly timeoutMs?: number;\n};\n\nexport async function fetchSessionManifest(\n\tsessionEndpoint: string,\n\toptions: FetchSessionManifestOptions\n): Promise<SessionManifest> {\n\tconst request = createSessionEndpointRequest(sessionEndpoint, options);\n\n\tconst controller = new AbortController();\n\tconst abortFromCaller = () => controller.abort(options.signal?.reason);\n\tif (options.signal?.aborted) {\n\t\tabortFromCaller();\n\t} else {\n\t\toptions.signal?.addEventListener('abort', abortFromCaller, { once: true });\n\t}\n\tconst timeoutId = globalThis.setTimeout(\n\t\t() => controller.abort(new DOMException('Session endpoint timed out.', 'TimeoutError')),\n\t\toptions.timeoutMs ?? 30_000\n\t);\n\n\tlet res: Response;\n\ttry {\n\t\tres = await fetch(request.url, {\n\t\t\t...request.init,\n\t\t\tsignal: controller.signal\n\t\t});\n\t} finally {\n\t\tglobalThis.clearTimeout(timeoutId);\n\t\toptions.signal?.removeEventListener('abort', abortFromCaller);\n\t}\n\n\tif (!res.ok) {\n\t\tconst text = await res.text();\n\t\tlet message = text.slice(0, 500) || `Session endpoint failed (${res.status})`;\n\t\ttry {\n\t\t\tconst j = JSON.parse(text) as { message?: string };\n\t\t\tif (j.message) message = j.message;\n\t\t} catch {\n\t\t\t/* keep */\n\t\t}\n\t\tthrow new Error(message);\n\t}\n\tif (!res.headers.get('content-type')?.toLowerCase().includes('application/json')) {\n\t\tthrow new Error('Session endpoint must return a JSON Session Manifest.');\n\t}\n\n\tlet raw: unknown;\n\ttry {\n\t\traw = await res.json();\n\t} catch {\n\t\tthrow new Error('Session endpoint returned invalid JSON.');\n\t}\n\n\treturn parseSessionManifest(raw);\n}\n","import type {\n\tConversationProcessorContext,\n\tConversationProcessorFn,\n\tConversationProcessorResult,\n\tNormalizedProcessorSpeech,\n\tProcessorDispatchResult,\n\tSpeakBehavior\n} from './types/sessionInteraction';\n\nexport function isAsyncIterableString(value: unknown): value is AsyncIterable<string> {\n\tif (value == null || typeof value !== 'object') return false;\n\treturn typeof (value as AsyncIterable<string>)[Symbol.asyncIterator] === 'function';\n}\n\nexport function normalizeConversationProcessorResult(\n\tresult: ConversationProcessorResult\n): NormalizedProcessorSpeech {\n\tif (typeof result === 'string') {\n\t\tconst text = result.trim();\n\t\tif (!text) {\n\t\t\tthrow new Error('conversationProcessor returned empty text.');\n\t\t}\n\t\treturn { text };\n\t}\n\n\tconst text = result.text.trim();\n\tif (!text) {\n\t\tthrow new Error('conversationProcessor returned empty text.');\n\t}\n\n\treturn {\n\t\ttext,\n\t\t...(result.characterId ? { characterId: result.characterId } : {}),\n\t\t...(result.behavior ? { behavior: result.behavior } : {})\n\t};\n}\n\nexport async function runConversationProcessor(\n\tprocessor: ConversationProcessorFn,\n\tcontext: ConversationProcessorContext\n): Promise<NormalizedProcessorSpeech> {\n\tconst dispatch = await dispatchConversationProcessor(processor, context);\n\tif (dispatch.kind !== 'complete') {\n\t\tthrow new Error('conversationProcessor returned a stream; use dispatchConversationProcessor.');\n\t}\n\treturn dispatch.speech;\n}\n\nexport async function dispatchConversationProcessor(\n\tprocessor: ConversationProcessorFn,\n\tcontext: ConversationProcessorContext\n): Promise<ProcessorDispatchResult> {\n\tconst result = await processor(context);\n\tif (isAsyncIterableString(result)) {\n\t\treturn { kind: 'stream', stream: result };\n\t}\n\treturn {\n\t\tkind: 'complete',\n\t\tspeech: normalizeConversationProcessorResult(result)\n\t};\n}\n","const LOCAL_PLAYER_DEV_PORT = '3002';\n\nexport function formatPlayerUnreachableMessage(playerOrigin: string): string {\n\tconst url = new URL(playerOrigin);\n\tconst isLocalHost = url.hostname === 'localhost' || url.hostname === '127.0.0.1';\n\n\tif (isLocalHost) {\n\t\tconst devPort = url.port || LOCAL_PLAYER_DEV_PORT;\n\t\treturn (\n\t\t\t`Cannot connect to the Liforma player at ${playerOrigin} — nothing is listening on port ${devPort}. ` +\n\t\t\t`Start the player dev server in player.liforma.ai (npm run dev).`\n\t\t);\n\t}\n\n\treturn (\n\t\t`Cannot connect to the Liforma player at ${playerOrigin}. ` +\n\t\t`The embed did not load; check your network connection and player URL configuration.`\n\t);\n}\n\nexport async function assertPlayerReachable(\n\tembedUrl: string,\n\tplayerOrigin: string\n): Promise<void> {\n\ttry {\n\t\tawait fetch(embedUrl, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t\tsignal: AbortSignal.timeout(8_000)\n\t\t});\n\t} catch {\n\t\tthrow new Error(formatPlayerUnreachableMessage(playerOrigin));\n\t}\n}\n\nexport function postMessageToPlayer(\n\ttarget: Window,\n\tmessage: unknown,\n\tplayerOrigin: string,\n\ttransfer?: Transferable[]\n): void {\n\ttry {\n\t\tif (transfer && transfer.length > 0) {\n\t\t\ttarget.postMessage(message, playerOrigin, transfer);\n\t\t} else {\n\t\t\ttarget.postMessage(message, playerOrigin);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof DOMException && error.name === 'SecurityError') {\n\t\t\tthrow new Error(formatPlayerUnreachableMessage(playerOrigin), { cause: error });\n\t\t}\n\t\tthrow error;\n\t}\n}\n","import type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tSpeakBehavior,\n\tSessionModeChange,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from '../types/sessionInteraction';\nimport type {\n\tCompleteSpeechQueuePolicy,\n\tSpeechAudioFormat,\n\tSpeechInterruptOptions,\n\tSpeechPlayEmbedSource,\n\tStreamingSpeechQueuePolicy\n} from '../speech/types';\n\nexport const EMBED_MESSAGE_SCHEMA_VERSION = 2 as const;\n\n/** Outbound postMessage versions accepted from the player embed. */\nexport const SUPPORTED_EMBED_MESSAGE_SCHEMA_VERSIONS: ReadonlySet<number> = new Set([1, 2]);\n\nexport function isSupportedEmbedMessageSchemaVersion(version: unknown): boolean {\n\treturn typeof version === 'number' && SUPPORTED_EMBED_MESSAGE_SCHEMA_VERSIONS.has(version);\n}\n\nexport type CloseEvent = {\n\treadonly sessionId?: string;\n\treadonly reason: 'user' | 'destroy';\n\treadonly returnUrl?: string;\n};\n\nexport type EmbedOutboundMessage =\n\t| {\n\t\t\treadonly type: 'close';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: CloseEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'stateUpdate';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly state: 'loading' | 'scene' | 'ready' | 'error' };\n\t }\n\t| {\n\t\t\treadonly type: 'commandResult';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly ok: boolean;\n\t\t\t\treadonly error?: string;\n\t\t\t\treadonly result?: unknown;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'userTranscript';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: UserTranscriptUpdate;\n\t }\n\t| {\n\t\t\treadonly type: 'characterSpeechStarted';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: CharacterSpeechEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'characterSpeechEnded';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: CharacterSpeechEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'conversationUpdate';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly conversation: readonly ConversationMessage[] };\n\t }\n\t| {\n\t\t\treadonly type: 'listeningState';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly listening: boolean };\n\t }\n\t| {\n\t\t\treadonly type: 'userSpeechStarted';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: UserSpeechBoundaryEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'userSpeechEnded';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: UserSpeechBoundaryEvent;\n\t }\n\t| {\n\t\t\treadonly type: 'modeChange';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly mode: SessionModeChange };\n\t }\n\t| {\n\t\t\treadonly type: 'message';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: ConversationMessage;\n\t }\n\t| {\n\t\t\treadonly type: 'started';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly mode: 'conversation' | 'presenter' };\n\t }\n\t| {\n\t\t\treadonly type: 'widgetReady';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'widgetExpand';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'widgetCollapse';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'widgetAudioSettings';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly open: boolean };\n\t }\n\t| {\n\t\t\treadonly type: 'widgetDragStart';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly pointerId: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'widgetDragMove';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly pointerId: number;\n\t\t\t\t/** Pointer deltas in CSS pixels (not iframe-local coordinates). */\n\t\t\t\treadonly dx: number;\n\t\t\t\treadonly dy: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'widgetDragEnd';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly pointerId: number;\n\t\t\t};\n\t };\n\nexport type WidgetChromeMode = 'collapsed' | 'loading' | 'expanded' | 'docked';\n\nexport type WidgetDragStartEvent = {\n\treadonly pointerId: number;\n};\n\nexport type WidgetDragMoveEvent = {\n\treadonly pointerId: number;\n\treadonly dx: number;\n\treadonly dy: number;\n};\n\n/** @deprecated Prefer WidgetDragStartEvent / WidgetDragMoveEvent */\nexport type WidgetDragPointerEvent = WidgetDragMoveEvent;\n\nexport type EmbedInboundMessage =\n\t| {\n\t\t\treadonly type: 'manifest';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly manifest: unknown };\n\t }\n\t| {\n\t\t\treadonly type: 'parentHello';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t }\n\t| {\n\t\t\treadonly type: 'speak';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly text: string;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly behavior?: SpeakBehavior;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'startListening';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly correlationId: string };\n\t }\n\t| {\n\t\t\treadonly type: 'stopListening';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly correlationId: string };\n\t }\n\t| {\n\t\t\treadonly type: 'getConversation';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly correlationId: string };\n\t }\n\t| {\n\t\t\treadonly type: 'listenOnce';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly timeoutMs?: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speakStreamStart';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly behavior?: SpeakBehavior;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speakStreamChunk';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly streamId: string;\n\t\t\t\treadonly text: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speakStreamEnd';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly streamId: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'widgetSetChrome';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: { readonly mode: WidgetChromeMode };\n\t }\n\t| {\n\t\t\treadonly type: 'widgetToggleAudioSettings';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: Record<string, never>;\n\t }\n\t| {\n\t\t\treadonly type: 'speechPlay';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly source: SpeechPlayEmbedSource;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly transcript?: string;\n\t\t\t\treadonly history?: 'none' | 'commit';\n\t\t\t\treadonly queue?: CompleteSpeechQueuePolicy;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceBegin';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly format: SpeechAudioFormat;\n\t\t\t\treadonly characterId?: string;\n\t\t\t\treadonly queue: StreamingSpeechQueuePolicy;\n\t\t\t\treadonly transcript?: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceWrite';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly audio: ArrayBuffer;\n\t\t\t\treadonly byteLength: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceSetTranscript';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly transcript: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceClose';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t\treadonly transcript?: string;\n\t\t\t\treadonly history?: 'none' | 'commit';\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechUtteranceCancel';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t\treadonly utteranceId: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly type: 'speechInterrupt';\n\t\t\treadonly schemaVersion: typeof EMBED_MESSAGE_SCHEMA_VERSION;\n\t\t\treadonly payload: {\n\t\t\t\treadonly correlationId: string;\n\t\t\t} & SpeechInterruptOptions;\n\t };\n\nexport type EmbedState = 'loading' | 'scene' | 'ready' | 'error';\n\nconst OUTBOUND_TYPES = new Set([\n\t'close',\n\t'stateUpdate',\n\t'commandResult',\n\t'userTranscript',\n\t'characterSpeechStarted',\n\t'characterSpeechEnded',\n\t'conversationUpdate',\n\t'listeningState',\n\t'userSpeechStarted',\n\t'userSpeechEnded',\n\t'modeChange',\n\t'message',\n\t'started',\n\t'widgetReady',\n\t'widgetExpand',\n\t'widgetCollapse',\n\t'widgetAudioSettings',\n\t'widgetDragStart',\n\t'widgetDragMove',\n\t'widgetDragEnd'\n]);\n\nfunction isWidgetChromeMode(value: unknown): value is WidgetChromeMode {\n\treturn (\n\t\tvalue === 'collapsed' ||\n\t\tvalue === 'loading' ||\n\t\tvalue === 'expanded' ||\n\t\tvalue === 'docked'\n\t);\n}\n\nexport function parseOutboundMessage(data: unknown): EmbedOutboundMessage | null {\n\tif (!data || typeof data !== 'object') return null;\n\tconst msg = data as Partial<EmbedOutboundMessage>;\n\tif (!isSupportedEmbedMessageSchemaVersion(msg.schemaVersion)) return null;\n\tif (!msg.type || !OUTBOUND_TYPES.has(msg.type)) return null;\n\tif (\n\t\tmsg.type === 'widgetReady' ||\n\t\tmsg.type === 'widgetExpand' ||\n\t\tmsg.type === 'widgetCollapse'\n\t) {\n\t\treturn msg as EmbedOutboundMessage;\n\t}\n\tif (msg.type === 'widgetAudioSettings') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tif (typeof (payload as { open?: unknown }).open !== 'boolean') return null;\n\t\treturn msg as EmbedOutboundMessage;\n\t}\n\tif (msg.type === 'widgetDragStart' || msg.type === 'widgetDragEnd') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tif (typeof (payload as { pointerId?: unknown }).pointerId !== 'number') return null;\n\t\tif (!Number.isFinite((payload as { pointerId: number }).pointerId)) return null;\n\t\treturn msg as EmbedOutboundMessage;\n\t}\n\tif (msg.type === 'widgetDragMove') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tconst { pointerId, dx, dy } = payload as {\n\t\t\tpointerId?: unknown;\n\t\t\tdx?: unknown;\n\t\t\tdy?: unknown;\n\t\t};\n\t\tif (typeof pointerId !== 'number' || !Number.isFinite(pointerId)) return null;\n\t\tif (typeof dx !== 'number' || !Number.isFinite(dx)) return null;\n\t\tif (typeof dy !== 'number' || !Number.isFinite(dy)) return null;\n\t\treturn msg as EmbedOutboundMessage;\n\t}\n\tif (!msg.payload || typeof msg.payload !== 'object') return null;\n\treturn msg as EmbedOutboundMessage;\n}\n\nconst INBOUND_TYPES = new Set([\n\t'manifest',\n\t'parentHello',\n\t'speak',\n\t'startListening',\n\t'stopListening',\n\t'getConversation',\n\t'listenOnce',\n\t'speakStreamStart',\n\t'speakStreamChunk',\n\t'speakStreamEnd',\n\t'widgetSetChrome',\n\t'widgetToggleAudioSettings',\n\t'speechPlay',\n\t'speechUtteranceBegin',\n\t'speechUtteranceWrite',\n\t'speechUtteranceSetTranscript',\n\t'speechUtteranceClose',\n\t'speechUtteranceCancel',\n\t'speechInterrupt'\n]);\n\nexport function parseInboundMessage(data: unknown): EmbedInboundMessage | null {\n\tif (!data || typeof data !== 'object') return null;\n\tconst msg = data as Partial<EmbedInboundMessage>;\n\tif (!isSupportedEmbedMessageSchemaVersion(msg.schemaVersion)) return null;\n\tif (!msg.type || !INBOUND_TYPES.has(msg.type)) return null;\n\tif (msg.type === 'parentHello') return msg as EmbedInboundMessage;\n\tif (msg.type === 'widgetToggleAudioSettings') return msg as EmbedInboundMessage;\n\tif (msg.type === 'widgetSetChrome') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tconst mode = (payload as { mode?: unknown }).mode;\n\t\tif (!isWidgetChromeMode(mode)) return null;\n\t\treturn msg as EmbedInboundMessage;\n\t}\n\tif (msg.type === 'speakStreamChunk') {\n\t\tconst payload = (msg as { payload?: unknown }).payload;\n\t\tif (!payload || typeof payload !== 'object') return null;\n\t\tconst streamId = (payload as { streamId?: unknown }).streamId;\n\t\tconst text = (payload as { text?: unknown }).text;\n\t\tif (typeof streamId !== 'string' || !streamId.trim()) return null;\n\t\tif (typeof text !== 'string') return null;\n\t\treturn msg as EmbedInboundMessage;\n\t}\n\tconst payload = (msg as { payload?: unknown }).payload;\n\tif (!payload || typeof payload !== 'object') return null;\n\treturn msg as EmbedInboundMessage;\n}\n\nexport function createManifestMessage(manifest: unknown): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'manifest',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\tpayload: { manifest }\n\t};\n}\n\nexport function createParentHelloMessage(): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'parentHello',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION\n\t};\n}\n\nexport function createWidgetSetChromeMessage(mode: WidgetChromeMode): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'widgetSetChrome',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\tpayload: { mode }\n\t};\n}\n\nexport function createWidgetToggleAudioSettingsMessage(): EmbedInboundMessage {\n\treturn {\n\t\ttype: 'widgetToggleAudioSettings',\n\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\tpayload: {}\n\t};\n}\n","import {\n\tassertPlayerReachable,\n\tformatPlayerUnreachableMessage,\n\tpostMessageToPlayer\n} from './playerReachability';\nimport type { CloseEvent, EmbedInboundMessage, EmbedOutboundMessage, EmbedState } from './protocol';\nimport {\n\tcreateManifestMessage,\n\tcreateParentHelloMessage,\n\tcreateWidgetSetChromeMessage,\n\tcreateWidgetToggleAudioSettingsMessage,\n\tEMBED_MESSAGE_SCHEMA_VERSION,\n\tparseOutboundMessage,\n\ttype WidgetChromeMode,\n\ttype WidgetDragMoveEvent,\n\ttype WidgetDragStartEvent\n} from './protocol';\nimport type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tSpeakBehavior,\n\tSessionModeChange,\n\tSpeechResult as LegacySpeakResult,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from '../types/sessionInteraction';\nimport type {\n\tCompleteSpeechQueuePolicy,\n\tSpeechAudioFormat,\n\tSpeechInterruptOptions,\n\tSpeechPlayEmbedSource,\n\tSpeechResult,\n\tStreamingSpeechQueuePolicy\n} from '../speech/types';\n\nexport type IframeHostEventMap = {\n\tclose: CloseEvent;\n\tstateUpdate: EmbedState;\n\tuserTranscript: UserTranscriptUpdate;\n\tcharacterSpeechStarted: CharacterSpeechEvent;\n\tcharacterSpeechEnded: CharacterSpeechEvent;\n\tconversationUpdate: readonly ConversationMessage[];\n\tlisteningState: boolean;\n\tstarted: { readonly mode: 'conversation' | 'presenter' };\n\twidgetReady: void;\n\twidgetExpand: void;\n\twidgetCollapse: void;\n\twidgetAudioSettings: boolean;\n\twidgetDragStart: WidgetDragStartEvent;\n\twidgetDragMove: WidgetDragMoveEvent;\n\twidgetDragEnd: { readonly pointerId: number };\n};\n\nexport type IframeHostOptions = {\n\treadonly container: HTMLElement;\n\treadonly src: string;\n\treadonly playerOrigin: string;\n\t/** Transparent iframe for ExperienceWidget warm overlay over a thumb. */\n\treadonly transparent?: boolean;\n\treadonly onClose?: (event: CloseEvent) => void;\n\treadonly onStateUpdate?: (state: EmbedState) => void;\n\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void;\n\treadonly onUserSpeechStarted?: (event: UserSpeechBoundaryEvent) => void;\n\treadonly onUserSpeechEnded?: (event: UserSpeechBoundaryEvent) => void;\n\treadonly onCharacterSpeechStarted?: (event: CharacterSpeechEvent) => void;\n\treadonly onCharacterSpeechEnded?: (event: CharacterSpeechEvent) => void;\n\treadonly onConversationUpdate?: (conversation: readonly ConversationMessage[]) => void;\n\treadonly onMessage?: (message: ConversationMessage) => void;\n\treadonly onListeningState?: (listening: boolean) => void;\n\treadonly onModeChange?: (mode: SessionModeChange) => void;\n\treadonly onStarted?: (event: { readonly mode: 'conversation' | 'presenter' }) => void;\n\treadonly onWidgetReady?: () => void;\n\treadonly onWidgetExpand?: () => void;\n\treadonly onWidgetCollapse?: () => void;\n\treadonly onWidgetAudioSettings?: (open: boolean) => void;\n\treadonly onWidgetDragStart?: (event: WidgetDragStartEvent) => void;\n\treadonly onWidgetDragMove?: (event: WidgetDragMoveEvent) => void;\n\treadonly onWidgetDragEnd?: (event: { readonly pointerId: number }) => void;\n};\n\nexport type IframeHost = {\n\twaitForLoad(): Promise<void>;\n\tpostParentHello(): void;\n\tpostManifest(manifest: unknown): void;\n\tpostWidgetSetChrome(mode: WidgetChromeMode): void;\n\tpostWidgetToggleAudioSettings(): void;\n\tspeak(options: {\n\t\ttext: string;\n\t\tcharacterId?: string;\n\t\tbehavior?: SpeakBehavior;\n\t}): Promise<LegacySpeakResult>;\n\tstartListening(): Promise<void>;\n\tstopListening(): Promise<UtteranceResult>;\n\tlistenOnce(options?: { readonly timeoutMs?: number }): Promise<UtteranceResult>;\n\tspeakProcessorStream(\n\t\tstream: AsyncIterable<string>,\n\t\toptions?: {\n\t\t\treadonly characterId?: string;\n\t\t\treadonly behavior?: SpeakBehavior;\n\t\t\treadonly signal?: AbortSignal;\n\t\t}\n\t): Promise<LegacySpeakResult>;\n\tspeechPlay(options: {\n\t\tsource: SpeechPlayEmbedSource;\n\t\tcharacterId?: string;\n\t\ttranscript?: string;\n\t\thistory?: 'none' | 'commit';\n\t\tqueue?: CompleteSpeechQueuePolicy;\n\t\tsignal?: AbortSignal;\n\t}): Promise<SpeechResult>;\n\tspeechUtteranceBegin(options: {\n\t\tutteranceId: string;\n\t\tformat: SpeechAudioFormat;\n\t\tcharacterId?: string;\n\t\tqueue: StreamingSpeechQueuePolicy;\n\t\ttranscript?: string;\n\t}): Promise<void>;\n\tspeechUtteranceWrite(options: {\n\t\tutteranceId: string;\n\t\taudio: ArrayBuffer;\n\t\tbyteLength: number;\n\t}): Promise<{ readonly bufferedMs: number }>;\n\tspeechUtteranceSetTranscript(options: {\n\t\tutteranceId: string;\n\t\ttranscript: string;\n\t}): Promise<void>;\n\tspeechUtteranceClose(options: {\n\t\tutteranceId: string;\n\t\ttranscript?: string;\n\t\thistory?: 'none' | 'commit';\n\t}): Promise<SpeechResult>;\n\tspeechUtteranceCancel(options: { utteranceId: string }): Promise<SpeechResult>;\n\tspeechInterrupt(options: SpeechInterruptOptions): Promise<readonly SpeechResult[]>;\n\tgetConversation(): Promise<readonly ConversationMessage[]>;\n\tdestroy(): void;\n};\n\nfunction newCorrelationId(): string {\n\tif (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n\t\treturn `cmd_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`;\n\t}\n\treturn `cmd_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;\n}\n\nconst SPEECH_WRITE_COMMAND_TIMEOUT_MS = 30_000;\n\nexport function createIframeHost(options: IframeHostOptions): IframeHost {\n\tconst container = options.container;\n\tconst containerPosition = getComputedStyle(container).position;\n\tif (containerPosition === 'static') {\n\t\tcontainer.style.position = 'relative';\n\t}\n\n\tconst iframe = document.createElement('iframe');\n\tiframe.src = options.src;\n\tiframe.title = 'Liforma experience';\n\tiframe.setAttribute(\n\t\t'allow',\n\t\t'microphone; autoplay; clipboard-read; clipboard-write'\n\t);\n\t// Absolute fill so the player viewport matches the host box even when the host\n\t// height comes from flex or min-height (percentage height:100% often collapses).\n\tiframe.style.cssText = options.transparent\n\t\t? 'display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;'\n\t\t: 'display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;';\n\tif (options.transparent) {\n\t\tiframe.setAttribute('allowtransparency', 'true');\n\t}\n\n\tlet destroyed = false;\n\tconst pendingCommands = new Map<\n\t\tstring,\n\t\t{\n\t\t\tresolve: (value: unknown) => void;\n\t\t\treject: (error: Error) => void;\n\t\t}\n\t>();\n\n\tconst loadPromise = new Promise<void>((resolve, reject) => {\n\t\tconst onLoad = () => {\n\t\t\tcleanup();\n\t\t\tvoid assertPlayerReachable(options.src, options.playerOrigin).then(resolve, reject);\n\t\t};\n\t\tconst onError = () => {\n\t\t\tcleanup();\n\t\t\treject(new Error(formatPlayerUnreachableMessage(options.playerOrigin)));\n\t\t};\n\t\tconst cleanup = () => {\n\t\t\tiframe.removeEventListener('load', onLoad);\n\t\t\tiframe.removeEventListener('error', onError);\n\t\t};\n\t\tiframe.addEventListener('load', onLoad);\n\t\tiframe.addEventListener('error', onError);\n\t});\n\n\tconst onMessage = (event: MessageEvent) => {\n\t\tif (destroyed) return;\n\t\tif (event.source !== iframe.contentWindow) return;\n\t\tif (event.origin !== options.playerOrigin) return;\n\n\t\tconst message = parseOutboundMessage(event.data);\n\t\tif (!message) return;\n\n\t\tswitch (message.type) {\n\t\t\tcase 'close':\n\t\t\t\toptions.onClose?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'stateUpdate':\n\t\t\t\toptions.onStateUpdate?.(message.payload.state);\n\t\t\t\tbreak;\n\t\t\tcase 'commandResult': {\n\t\t\t\tconst pending = pendingCommands.get(message.payload.correlationId);\n\t\t\t\tif (!pending) return;\n\t\t\t\tpendingCommands.delete(message.payload.correlationId);\n\t\t\t\tif (message.payload.ok) {\n\t\t\t\t\tpending.resolve(message.payload.result);\n\t\t\t\t} else {\n\t\t\t\t\tpending.reject(new Error(message.payload.error ?? 'Command failed.'));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'userTranscript':\n\t\t\t\toptions.onUserTranscript?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'characterSpeechStarted':\n\t\t\t\toptions.onCharacterSpeechStarted?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'characterSpeechEnded':\n\t\t\t\toptions.onCharacterSpeechEnded?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'conversationUpdate':\n\t\t\t\toptions.onConversationUpdate?.(message.payload.conversation);\n\t\t\t\tbreak;\n\t\t\tcase 'listeningState':\n\t\t\t\toptions.onListeningState?.(message.payload.listening);\n\t\t\t\tbreak;\n\t\t\tcase 'userSpeechStarted':\n\t\t\t\toptions.onUserSpeechStarted?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'userSpeechEnded':\n\t\t\t\toptions.onUserSpeechEnded?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'modeChange':\n\t\t\t\toptions.onModeChange?.(message.payload.mode);\n\t\t\t\tbreak;\n\t\t\tcase 'message':\n\t\t\t\toptions.onMessage?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'started':\n\t\t\t\toptions.onStarted?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'widgetReady':\n\t\t\t\toptions.onWidgetReady?.();\n\t\t\t\tbreak;\n\t\t\tcase 'widgetExpand':\n\t\t\t\toptions.onWidgetExpand?.();\n\t\t\t\tbreak;\n\t\t\tcase 'widgetCollapse':\n\t\t\t\toptions.onWidgetCollapse?.();\n\t\t\t\tbreak;\n\t\t\tcase 'widgetAudioSettings':\n\t\t\t\toptions.onWidgetAudioSettings?.(message.payload.open);\n\t\t\t\tbreak;\n\t\t\tcase 'widgetDragStart':\n\t\t\t\toptions.onWidgetDragStart?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'widgetDragMove':\n\t\t\t\toptions.onWidgetDragMove?.(message.payload);\n\t\t\t\tbreak;\n\t\t\tcase 'widgetDragEnd':\n\t\t\t\toptions.onWidgetDragEnd?.(message.payload);\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\twindow.addEventListener('message', onMessage);\n\tcontainer.replaceChildren(iframe);\n\t// Absolute iframe does not contribute to parent height — keep a usable floor when\n\t// the host only sized itself from previous in-flow content.\n\tif (container.clientHeight < 2 && !container.style.minHeight) {\n\t\tconst computedMin = getComputedStyle(container).minHeight;\n\t\tif (computedMin === '0px' || computedMin === 'auto') {\n\t\t\tcontainer.style.minHeight = '480px';\n\t\t}\n\t}\n\n\tconst postToIframe = (message: EmbedInboundMessage, transfer?: Transferable[]) => {\n\t\tif (destroyed) return;\n\t\tconst target = iframe.contentWindow;\n\t\tif (!target) {\n\t\t\tthrow new Error(formatPlayerUnreachableMessage(options.playerOrigin));\n\t\t}\n\t\tpostMessageToPlayer(target, message, options.playerOrigin, transfer);\n\t};\n\n\tconst postCommand = <T>(\n\t\tmessage: EmbedInboundMessage,\n\t\ttimeoutMs = 120_000,\n\t\ttransfer?: Transferable[]\n\t): Promise<T> => {\n\t\tconst correlationId =\n\t\t\tmessage.type !== 'parentHello' && message.payload && 'correlationId' in message.payload\n\t\t\t\t? (message.payload.correlationId as string)\n\t\t\t\t: newCorrelationId();\n\n\t\tif (message.type !== 'parentHello' && message.payload && 'correlationId' in message.payload) {\n\t\t\t// correlationId already set\n\t\t} else if (message.type !== 'parentHello' && message.payload) {\n\t\t\t(message.payload as { correlationId: string }).correlationId = correlationId;\n\t\t}\n\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tpendingCommands.set(correlationId, {\n\t\t\t\tresolve: (value) => resolve(value as T),\n\t\t\t\treject\n\t\t\t});\n\t\t\tpostToIframe(message, transfer);\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (!pendingCommands.has(correlationId)) return;\n\t\t\t\tpendingCommands.delete(correlationId);\n\t\t\t\treject(new Error('Timed out waiting for player command result.'));\n\t\t\t}, timeoutMs);\n\t\t});\n\t};\n\n\treturn {\n\t\twaitForLoad() {\n\t\t\treturn loadPromise;\n\t\t},\n\t\tpostParentHello() {\n\t\t\tpostToIframe(createParentHelloMessage());\n\t\t},\n\t\tpostManifest(manifest) {\n\t\t\tif (destroyed) return;\n\t\t\tconst target = iframe.contentWindow;\n\t\t\tif (!target) {\n\t\t\t\tthrow new Error('Liforma embed iframe is not ready.');\n\t\t\t}\n\t\t\tconst message = createManifestMessage(manifest);\n\t\t\tconst postOnce = () => {\n\t\t\t\tif (destroyed) return;\n\t\t\t\tpostMessageToPlayer(target, message, options.playerOrigin);\n\t\t\t};\n\t\t\tpostOnce();\n\t\t\tfor (let attempt = 1; attempt <= 12; attempt += 1) {\n\t\t\t\twindow.setTimeout(postOnce, attempt * 75);\n\t\t\t}\n\t\t},\n\t\tpostWidgetSetChrome(mode) {\n\t\t\tpostToIframe(createWidgetSetChromeMessage(mode));\n\t\t},\n\t\tpostWidgetToggleAudioSettings() {\n\t\t\tpostToIframe(createWidgetToggleAudioSettingsMessage());\n\t\t},\n\t\tspeak(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<LegacySpeakResult>({\n\t\t\t\ttype: 'speak',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\ttext: options.text,\n\t\t\t\t\t...(options.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t...(options.behavior ? { behavior: options.behavior } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tstartListening() {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<void>({\n\t\t\t\ttype: 'startListening',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: { correlationId }\n\t\t\t});\n\t\t},\n\t\tstopListening() {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<UtteranceResult>({\n\t\t\t\ttype: 'stopListening',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: { correlationId }\n\t\t\t});\n\t\t},\n\t\tlistenOnce(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<UtteranceResult>({\n\t\t\t\ttype: 'listenOnce',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\t...(options?.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tasync speakProcessorStream(stream, options) {\n\t\t\tconst startCorrelationId = newCorrelationId();\n\t\t\tconst endCorrelationId = newCorrelationId();\n\t\t\tconst started = await postCommand<{ streamId: string }>({\n\t\t\t\ttype: 'speakStreamStart',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId: startCorrelationId,\n\t\t\t\t\t...(options?.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t...(options?.behavior ? { behavior: options.behavior } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst streamId = started.streamId;\n\t\t\ttry {\n\t\t\t\tfor await (const chunk of stream) {\n\t\t\t\t\tif (options?.signal?.aborted) {\n\t\t\t\t\t\tthrow new DOMException('Processor stream aborted.', 'AbortError');\n\t\t\t\t\t}\n\t\t\t\t\tif (!chunk) continue;\n\t\t\t\t\tpostToIframe({\n\t\t\t\t\t\ttype: 'speakStreamChunk',\n\t\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\t\tpayload: { streamId, text: chunk }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (options?.signal?.aborted) {\n\t\t\t\t\tthrow new DOMException('Processor stream aborted.', 'AbortError');\n\t\t\t\t}\n\t\t\t\treturn await postCommand<LegacySpeakResult>({\n\t\t\t\t\ttype: 'speakStreamEnd',\n\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\tpayload: { correlationId: endCorrelationId, streamId }\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait postCommand<LegacySpeakResult>({\n\t\t\t\t\t\ttype: 'speakStreamEnd',\n\t\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\t\tpayload: { correlationId: endCorrelationId, streamId }\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t/* stream may already be torn down */\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tspeechPlay(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\tconst transfer: Transferable[] = [];\n\t\t\tif (options.source.kind === 'pcm' || options.source.kind === 'encoded') {\n\t\t\t\ttransfer.push(options.source.data);\n\t\t\t}\n\t\t\treturn postCommand<SpeechResult>(\n\t\t\t\t{\n\t\t\t\t\ttype: 'speechPlay',\n\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\tpayload: {\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tsource: options.source,\n\t\t\t\t\t\t...(options.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {}),\n\t\t\t\t\t\t...(options.history ? { history: options.history } : {}),\n\t\t\t\t\t\t...(options.queue ? { queue: options.queue } : {})\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t120_000,\n\t\t\t\ttransfer\n\t\t\t);\n\t\t},\n\t\tspeechUtteranceBegin(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<void>({\n\t\t\t\ttype: 'speechUtteranceBegin',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\tformat: options.format,\n\t\t\t\t\tqueue: options.queue,\n\t\t\t\t\t...(options.characterId ? { characterId: options.characterId } : {}),\n\t\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechUtteranceWrite(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<{ bufferedMs: number }>(\n\t\t\t\t{\n\t\t\t\t\ttype: 'speechUtteranceWrite',\n\t\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\t\tpayload: {\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\t\taudio: options.audio,\n\t\t\t\t\t\tbyteLength: options.byteLength\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tSPEECH_WRITE_COMMAND_TIMEOUT_MS,\n\t\t\t\t[options.audio]\n\t\t\t);\n\t\t},\n\t\tspeechUtteranceSetTranscript(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<void>({\n\t\t\t\ttype: 'speechUtteranceSetTranscript',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\ttranscript: options.transcript\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechUtteranceClose(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<SpeechResult>({\n\t\t\t\ttype: 'speechUtteranceClose',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId,\n\t\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {}),\n\t\t\t\t\t...(options.history ? { history: options.history } : {})\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechUtteranceCancel(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<SpeechResult>({\n\t\t\t\ttype: 'speechUtteranceCancel',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tutteranceId: options.utteranceId\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tspeechInterrupt(options) {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<readonly SpeechResult[]>({\n\t\t\t\ttype: 'speechInterrupt',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: {\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\t...options\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tgetConversation() {\n\t\t\tconst correlationId = newCorrelationId();\n\t\t\treturn postCommand<readonly ConversationMessage[]>({\n\t\t\t\ttype: 'getConversation',\n\t\t\t\tschemaVersion: EMBED_MESSAGE_SCHEMA_VERSION,\n\t\t\t\tpayload: { correlationId }\n\t\t\t});\n\t\t},\n\t\tdestroy() {\n\t\t\tif (destroyed) return;\n\t\t\tdestroyed = true;\n\t\t\tfor (const pending of pendingCommands.values()) {\n\t\t\t\tpending.reject(new Error('Iframe host destroyed.'));\n\t\t\t}\n\t\t\tpendingCommands.clear();\n\t\t\twindow.removeEventListener('message', onMessage);\n\t\t\tiframe.remove();\n\t\t}\n\t};\n}\n\n","export type ReadyGate<T> = {\n\tsetValue(value: T): void;\n\tmarkReady(): void;\n};\n\n/** Emits once after both an asynchronous value and readiness signal are available. */\nexport function createReadyGate<T>(onReady: (value: T) => void): ReadyGate<T> {\n\tlet value: T | undefined;\n\tlet ready = false;\n\tlet emitted = false;\n\n\tconst emitIfPossible = (): void => {\n\t\tif (emitted || !ready || value === undefined) return;\n\t\temitted = true;\n\t\tonReady(value);\n\t};\n\n\treturn {\n\t\tsetValue(nextValue) {\n\t\t\tvalue = nextValue;\n\t\t\temitIfPossible();\n\t\t},\n\t\tmarkReady() {\n\t\t\tready = true;\n\t\t\temitIfPossible();\n\t\t}\n\t};\n}\n","import { useExplicitLocalStack } from '../../shims/localStack';\n\nconst PRODUCTION_PLAYER_EMBED_URL = 'https://player.liforma.ai/embed';\nconst LOCAL_PLAYER_EMBED_URL = 'http://localhost:3002/embed';\n\nfunction readConfiguredEmbedUrl(): string | null {\n\tconst globalValue = (globalThis as { __LIFORMA_PLAYER_EMBED_URL?: string })\n\t\t.__LIFORMA_PLAYER_EMBED_URL;\n\tif (globalValue?.trim()) {\n\t\treturn globalValue.trim().replace(/\\/$/, '');\n\t}\n\n\tif (typeof document === 'undefined') {\n\t\treturn null;\n\t}\n\n\tconst script =\n\t\tdocument.querySelector('script[data-liforma-sdk][src*=\"client.js\"]') ??\n\t\tdocument.querySelector('script[src*=\"/sdk/v2/client.js\"]');\n\tconst fromScript = script?.getAttribute('data-player-embed-url')?.trim();\n\tif (fromScript) {\n\t\treturn fromScript.replace(/\\/$/, '');\n\t}\n\n\treturn null;\n}\n\n/**\n * Hosted player embed document URL (iframe `src` base).\n *\n * Defaults to production. Local stack is opt-in only — never inferred from\n * `localhost` hostname (third-party demos run on localhost against production).\n *\n * Override order:\n * 1. `window.__LIFORMA_PLAYER_EMBED_URL`\n * 2. `data-player-embed-url` on the SDK script tag\n * 3. `window.__LIFORMA_STACK === 'local'` or host `?stack=local` → http://localhost:3002/embed\n * 4. production → https://player.liforma.ai/embed\n */\nexport function resolvePublicPlayerEmbedUrl(): string {\n\tconst configured = readConfiguredEmbedUrl();\n\tif (configured) {\n\t\treturn configured.endsWith('/embed') ? configured : `${configured}/embed`;\n\t}\n\n\tif (useExplicitLocalStack()) {\n\t\treturn LOCAL_PLAYER_EMBED_URL;\n\t}\n\n\treturn PRODUCTION_PLAYER_EMBED_URL;\n}\n\nexport function buildManifestEmbedUrl(\n\tembedBaseUrl?: string,\n\tdebug?: boolean,\n\tlocationId?: string,\n\tavatarId?: string,\n\tfit?: 'full' | 'face',\n\tui?: 'widget',\n\tshowClose?: boolean\n): string {\n\tconst base = (embedBaseUrl ?? resolvePublicPlayerEmbedUrl()).replace(/\\/$/, '');\n\tconst embedRoot = base.endsWith('/embed') ? base : `${base}/embed`;\n\tconst url = new URL(embedRoot);\n\tconst loc = locationId?.trim();\n\tif (loc) {\n\t\turl.searchParams.set('locationId', loc);\n\t}\n\tconst avatar = avatarId?.trim();\n\tif (avatar) {\n\t\turl.searchParams.set('avatarId', avatar);\n\t}\n\tif (fit === 'face') {\n\t\turl.searchParams.set('fit', 'face');\n\t}\n\tif (ui === 'widget') {\n\t\turl.searchParams.set('ui', 'widget');\n\t}\n\tif (showClose) {\n\t\turl.searchParams.set('close', '1');\n\t}\n\tif (debug) {\n\t\turl.searchParams.set('debug', 'true');\n\t}\n\treturn withEmbedParentOrigin(url.toString());\n}\n\nexport function buildPublicEmbedUrl(\n\texperienceId: string,\n\tembedBaseUrl?: string,\n\tlanguage?: 'en' | 'es',\n\tlocationId?: string,\n\tavatarId?: string,\n\tdebug?: boolean\n): string {\n\tconst base = (embedBaseUrl ?? resolvePublicPlayerEmbedUrl()).replace(/\\/$/, '');\n\tconst embedRoot = base.endsWith('/embed') ? base : `${base}/embed`;\n\tconst url = new URL(embedRoot);\n\turl.searchParams.set('experienceId', experienceId);\n\tif (language && language !== 'en') {\n\t\turl.searchParams.set('language', language);\n\t}\n\tconst loc = locationId?.trim();\n\tif (loc) {\n\t\turl.searchParams.set('locationId', loc);\n\t}\n\tconst avatar = avatarId?.trim();\n\tif (avatar) {\n\t\turl.searchParams.set('avatarId', avatar);\n\t}\n\tif (debug) {\n\t\turl.searchParams.set('debug', 'true');\n\t}\n\treturn withEmbedParentOrigin(url.toString());\n}\n\n/** Tell the player embed which origin may receive postMessage events (SDK parent page). */\nexport function withEmbedParentOrigin(embedUrl: string): string {\n\tif (typeof location === 'undefined') return embedUrl;\n\tconst url = new URL(embedUrl);\n\turl.searchParams.set('parentOrigin', location.origin);\n\treturn url.toString();\n}\n\nexport function resolvePlayerOrigin(embedUrl: string): string {\n\treturn new URL(embedUrl).origin;\n}\n","import { parseSessionManifest } from './types/sessionManifestSchema';\nimport type { SessionManifest } from './types/sessionManifest';\n\nfunction speechOnlyCapabilities(capabilities: readonly string[]): readonly string[] {\n\tconst withoutAvatar = capabilities.filter((capability) => capability !== 'avatar');\n\tif (withoutAvatar.includes('voice')) {\n\t\treturn withoutAvatar;\n\t}\n\treturn ['voice', ...withoutAvatar];\n}\n\n/**\n * Strip avatar rendering and location scene assets from a Session Manifest.\n * Used when integrators request voice-only mode without authoring a separate experience.\n */\nexport function applySpeechOnlyManifest(manifest: SessionManifest): SessionManifest {\n\treturn parseSessionManifest({\n\t\t...manifest,\n\t\tcapabilities: speechOnlyCapabilities(manifest.capabilities),\n\t\tpipeline: {\n\t\t\t...manifest.pipeline,\n\t\t\tanimation: {\n\t\t\t\tenabled: false,\n\t\t\t\tsource: 'none',\n\t\t\t\tconfig: {}\n\t\t\t}\n\t\t},\n\t\tlocation: {\n\t\t\tlocationId: manifest.location?.locationId?.trim() || 'speech-only',\n\t\t\ttitle: manifest.location?.title?.trim() || ''\n\t\t}\n\t});\n}\n","import type { ReadyEvent } from './experience';\nimport type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tConversationProcessorErrorEvent,\n\tStartedEvent,\n\tSessionModeChange,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate\n} from './types/sessionInteraction';\n\nexport type ExperienceEvents = {\n\treadonly ready: ReadyEvent;\n\treadonly started: StartedEvent;\n\treadonly userTranscript: UserTranscriptUpdate;\n\treadonly userSpeechStarted: UserSpeechBoundaryEvent;\n\treadonly userSpeechEnded: UserSpeechBoundaryEvent;\n\treadonly characterSpeechStarted: CharacterSpeechEvent;\n\treadonly characterSpeechEnded: CharacterSpeechEvent;\n\treadonly conversationUpdate: readonly ConversationMessage[];\n\treadonly message: ConversationMessage;\n\treadonly listeningState: boolean;\n\treadonly modeChange: SessionModeChange;\n\treadonly conversationProcessorError: ConversationProcessorErrorEvent;\n};\n\nexport type ExperienceEventName = keyof ExperienceEvents;\n\ntype HandlerSet<K extends ExperienceEventName> = Set<(event: ExperienceEvents[K]) => void>;\n\nexport type ExperienceEventRegistry = {\n\treadonly [K in ExperienceEventName]: HandlerSet<K>;\n};\n\nexport function createExperienceEventRegistry(): ExperienceEventRegistry {\n\treturn {\n\t\tready: new Set(),\n\t\tstarted: new Set(),\n\t\tuserTranscript: new Set(),\n\t\tuserSpeechStarted: new Set(),\n\t\tuserSpeechEnded: new Set(),\n\t\tcharacterSpeechStarted: new Set(),\n\t\tcharacterSpeechEnded: new Set(),\n\t\tconversationUpdate: new Set(),\n\t\tmessage: new Set(),\n\t\tlisteningState: new Set(),\n\t\tmodeChange: new Set(),\n\t\tconversationProcessorError: new Set()\n\t};\n}\n\nexport function subscribeExperienceEvent<K extends ExperienceEventName>(\n\tregistry: ExperienceEventRegistry,\n\tevent: K,\n\thandler: (payload: ExperienceEvents[K]) => void\n): () => void {\n\tregistry[event].add(handler);\n\treturn () => registry[event].delete(handler);\n}\n\nexport function emitExperienceEvent<K extends ExperienceEventName>(\n\tregistry: ExperienceEventRegistry,\n\tevent: K,\n\tpayload: ExperienceEvents[K]\n): void {\n\tfor (const handler of registry[event]) {\n\t\thandler(payload);\n\t}\n}\n\nexport function clearExperienceEventRegistry(registry: ExperienceEventRegistry): void {\n\tfor (const key of Object.keys(registry) as ExperienceEventName[]) {\n\t\tregistry[key].clear();\n\t}\n}\n","/**\n * Phase A public speech contract for Experience.speech\n * (docs/plans/2026/08/experience-play-audio-api.plan.md).\n */\n\nexport type SpeechAudioFormat = {\n\treadonly encoding: 'pcm_s16le';\n\treadonly sampleRate: number;\n\treadonly channels: 1;\n};\n\n/** Complete one-shot ops only (`speak` / `play`). */\nexport type CompleteSpeechQueuePolicy = 'append' | 'replace-active' | 'replace-all';\n\n/** Live streams only — `append` is forbidden. */\nexport type StreamingSpeechQueuePolicy = 'replace-active' | 'replace-all';\n\nexport type SpeechTerminalStatus = 'completed' | 'interrupted' | 'cancelled' | 'destroyed';\n\nexport type SpeechAnimationMode = 'tracked' | 'partially-tracked' | 'energy-fallback' | 'none';\n\nexport type SpeechResult = {\n\treadonly utteranceId: string;\n\treadonly characterId: string;\n\treadonly status: SpeechTerminalStatus;\n\treadonly durationMs: number;\n\treadonly transcript?: string;\n\treadonly animation: {\n\t\treadonly mode: SpeechAnimationMode;\n\t\treadonly trackedDurationMs: number;\n\t\treadonly fallbackDurationMs: number;\n\t\treadonly warningCodes?: readonly string[];\n\t};\n};\n\nexport type SpeechInterruptOptions =\n\t| { readonly utteranceId: string }\n\t| { readonly characterId: string }\n\t| { readonly scope?: 'active' | 'all' };\n\nexport type SpeechSpeakOptions = {\n\treadonly text: string;\n\treadonly characterId?: string;\n\treadonly queue?: CompleteSpeechQueuePolicy;\n\treadonly signal?: AbortSignal;\n};\n\n/** Raw PCM one-shot (Phase A). */\nexport type SpeechPlayPcmAudio = {\n\treadonly data: ArrayBuffer | Uint8Array;\n\treadonly format: SpeechAudioFormat;\n};\n\n/**\n * Encoded media bytes (wav/mp3/…). Player decodes via Web Audio — not api/models.\n * `encoding` is a MIME type such as `audio/mpeg` or `audio/wav`.\n */\nexport type SpeechPlayEncodedAudio = {\n\treadonly data: ArrayBuffer | Uint8Array | Blob;\n\treadonly encoding: string;\n\t/** Preferred pcm sample rate after decode (default 24000 when decoded rate is unsupported). */\n\treadonly sampleRate?: number;\n};\n\n/** Fetch + decode in the player (URL must allow CORS from player.liforma.ai). */\nexport type SpeechPlayUrlAudio = {\n\treadonly url: string;\n\treadonly sampleRate?: number;\n};\n\n/**\n * Live audio track. Captured to PCM in the **host** SDK (not transferable across the embed).\n * Prefer `createUtterance({ track })` for long streams; `play({ audio: { track } })` runs until\n * the track ends then closes the utterance.\n */\nexport type SpeechPlayMediaStreamAudio = {\n\treadonly track: MediaStreamTrack;\n\t/** Target pcm sample rate after capture (default 24000). */\n\treadonly sampleRate?: number;\n};\n\nexport type SpeechPlayAudio =\n\t| SpeechPlayPcmAudio\n\t| SpeechPlayEncodedAudio\n\t| SpeechPlayUrlAudio\n\t| SpeechPlayMediaStreamAudio;\n\nexport type SpeechPlayOptions = {\n\treadonly audio: SpeechPlayAudio;\n\treadonly characterId?: string;\n\treadonly transcript?: string;\n\treadonly history?: 'none' | 'commit';\n\treadonly queue?: CompleteSpeechQueuePolicy;\n\treadonly signal?: AbortSignal;\n};\n\n/** Embed / player wire format for {@link SpeechPlayOptions.audio}. */\nexport type SpeechPlayEmbedSource =\n\t| {\n\t\t\treadonly kind: 'pcm';\n\t\t\treadonly data: ArrayBuffer;\n\t\t\treadonly format: SpeechAudioFormat;\n\t }\n\t| {\n\t\t\treadonly kind: 'encoded';\n\t\t\treadonly data: ArrayBuffer;\n\t\t\treadonly encoding: string;\n\t\t\treadonly sampleRate?: number;\n\t }\n\t| {\n\t\t\treadonly kind: 'url';\n\t\t\treadonly url: string;\n\t\t\treadonly sampleRate?: number;\n\t };\n\nexport function isSpeechPlayPcmAudio(audio: SpeechPlayAudio): audio is SpeechPlayPcmAudio {\n\treturn (\n\t\t'data' in audio &&\n\t\t'format' in audio &&\n\t\t(audio as SpeechPlayPcmAudio).format != null &&\n\t\t!('track' in audio)\n\t);\n}\n\nexport function isSpeechPlayUrlAudio(audio: SpeechPlayAudio): audio is SpeechPlayUrlAudio {\n\treturn 'url' in audio && typeof (audio as SpeechPlayUrlAudio).url === 'string';\n}\n\nexport function isSpeechPlayMediaStreamAudio(\n\taudio: SpeechPlayAudio\n): audio is SpeechPlayMediaStreamAudio {\n\tif (!('track' in audio)) return false;\n\tconst track = (audio as SpeechPlayMediaStreamAudio).track as unknown;\n\tif (track == null || typeof track !== 'object') return false;\n\tif (typeof MediaStreamTrack !== 'undefined' && track instanceof MediaStreamTrack) {\n\t\treturn true;\n\t}\n\t// Duck-type for non-DOM / test environments.\n\treturn 'kind' in track && 'readyState' in track;\n}\n\nexport function isSpeechPlayEncodedAudio(audio: SpeechPlayAudio): audio is SpeechPlayEncodedAudio {\n\treturn (\n\t\t!isSpeechPlayPcmAudio(audio) &&\n\t\t!isSpeechPlayUrlAudio(audio) &&\n\t\t!isSpeechPlayMediaStreamAudio(audio) &&\n\t\t'encoding' in audio &&\n\t\ttypeof (audio as SpeechPlayEncodedAudio).encoding === 'string'\n\t);\n}\n\nexport type SpeechCreateUtteranceOptions = {\n\t/**\n\t * Required unless `track` is set. When `track` is provided without `format`, defaults to\n\t * pcm_s16le mono at `sampleRate` (or 24000).\n\t */\n\treadonly format?: SpeechAudioFormat;\n\t/** Optional live track — host captures and writes until the track ends. */\n\treadonly track?: MediaStreamTrack;\n\t/** Used with `track` when `format` is omitted (default 24000). */\n\treadonly sampleRate?: number;\n\treadonly characterId?: string;\n\treadonly queue?: StreamingSpeechQueuePolicy;\n\t/**\n\t * Optional spoken text seed for force-aligned STA (lip sync).\n\t * Non-empty transcript enables force-align for this utterance; omit / whitespace → free CTC.\n\t * May be updated mid-turn via {@link SpeechUtterance.setTranscript} or finalized on\n\t * {@link SpeechUtterance.close} `{ transcript }`.\n\t */\n\treadonly transcript?: string;\n\treadonly signal?: AbortSignal;\n};\n\nexport type SpeechUtteranceCloseOptions = {\n\treadonly transcript?: string;\n\treadonly history?: 'none' | 'commit';\n};\n\nexport type SpeechWriteOptions = {\n\treadonly timeoutMs?: number;\n};\n\nexport type SpeechUtterance = {\n\treadonly id: string;\n\treadonly characterId: string;\n\treadonly result: Promise<SpeechResult>;\n\twrite(audio: ArrayBuffer | Uint8Array, options?: SpeechWriteOptions): Promise<void>;\n\t/**\n\t * Replace / set spoken text mid-turn for force-aligned STA.\n\t * Non-empty text upgrades free decode → force-align (full-utterance on close).\n\t * Empty / whitespace is a no-op.\n\t */\n\tsetTranscript(text: string): Promise<void>;\n\tclose(options?: SpeechUtteranceCloseOptions): Promise<SpeechResult>;\n\tcancel(): Promise<SpeechResult>;\n};\n\nexport type SpeechController = {\n\tspeak(options: SpeechSpeakOptions): Promise<SpeechResult>;\n\tplay(options: SpeechPlayOptions): Promise<SpeechResult>;\n\tcreateUtterance(options: SpeechCreateUtteranceOptions): SpeechUtterance;\n\tinterrupt(options?: SpeechInterruptOptions): Promise<readonly SpeechResult[]>;\n};\n\n/** Accepted PCM sample rates (Phase A). */\nexport const SPEECH_ACCEPTED_SAMPLE_RATES = [\n\t8000, 16000, 22050, 24000, 44100, 48000\n] as const;\n\nexport const SPEECH_LIMITS = {\n\tMAX_CHUNK_BYTES: 64 * 1024,\n\tRECOMMENDED_CHUNK_MS_MIN: 20,\n\tRECOMMENDED_CHUNK_MS_MAX: 200,\n\tMAX_BUFFERED_AUDIO_MS: 8_000,\n\tPLAYBACK_JITTER_BUFFER_MS: 150,\n\tPLAYBACK_JITTER_BUFFER_MS_MIN: 80,\n\tPLAYBACK_JITTER_BUFFER_MS_MAX: 250,\n\tMAX_UTTERANCE_DURATION_MS: 90_000,\n\tMAX_PENDING_WRITES: 8,\n\tDEFAULT_WRITE_TIMEOUT_MS: 5_000\n} as const;\n\nexport class UnsupportedSpeechOperationError extends Error {\n\treadonly name = 'UnsupportedSpeechOperationError';\n\tconstructor(\n\t\treadonly operation: string,\n\t\treadonly requiredCapability: string\n\t) {\n\t\tsuper(`Speech operation \"${operation}\" requires capability \"${requiredCapability}\".`);\n\t}\n}\n\nexport class SpeechUtteranceClosedError extends Error {\n\treadonly name = 'SpeechUtteranceClosedError';\n\tconstructor(message = 'Cannot write to a closed or cancelled speech utterance.') {\n\t\tsuper(message);\n\t}\n}\n\nexport class SpeechRuntimeError extends Error {\n\treadonly name = 'SpeechRuntimeError';\n\tconstructor(message: string, options?: { cause?: unknown }) {\n\t\tsuper(message, options);\n\t}\n}\n\nexport class SpeechBufferTimeoutError extends Error {\n\treadonly name = 'SpeechBufferTimeoutError';\n\tconstructor(message = 'Timed out waiting for speech buffer capacity.') {\n\t\tsuper(message);\n\t}\n}\n\nexport function emptyAnimationResult(\n\tmode: SpeechAnimationMode = 'none'\n): SpeechResult['animation'] {\n\treturn {\n\t\tmode,\n\t\ttrackedDurationMs: 0,\n\t\tfallbackDurationMs: 0\n\t};\n}\n\nexport function isAcceptedSampleRate(rate: number): boolean {\n\treturn (SPEECH_ACCEPTED_SAMPLE_RATES as readonly number[]).includes(rate);\n}\n\nexport function assertPcmFormat(format: SpeechAudioFormat): void {\n\tif (format.encoding !== 'pcm_s16le') {\n\t\tthrow new SpeechRuntimeError(`Unsupported audio encoding: ${format.encoding}`);\n\t}\n\tif (format.channels !== 1) {\n\t\tthrow new SpeechRuntimeError(`Unsupported channel count: ${format.channels}`);\n\t}\n\tif (!isAcceptedSampleRate(format.sampleRate)) {\n\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${format.sampleRate}`);\n\t}\n}\n\nexport function assertSpeechPlayAudio(audio: SpeechPlayAudio): void {\n\tif (isSpeechPlayPcmAudio(audio)) {\n\t\tassertPcmFormat(audio.format);\n\t\treturn;\n\t}\n\tif (isSpeechPlayUrlAudio(audio)) {\n\t\tconst url = audio.url.trim();\n\t\tif (!url) throw new SpeechRuntimeError('Audio URL must be non-empty.');\n\t\tif (audio.sampleRate !== undefined && !isAcceptedSampleRate(audio.sampleRate)) {\n\t\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${audio.sampleRate}`);\n\t\t}\n\t\treturn;\n\t}\n\tif (isSpeechPlayMediaStreamAudio(audio)) {\n\t\tif (audio.track.kind !== 'audio') {\n\t\t\tthrow new SpeechRuntimeError('speech.play track must be an audio MediaStreamTrack.');\n\t\t}\n\t\tif (audio.sampleRate !== undefined && !isAcceptedSampleRate(audio.sampleRate)) {\n\t\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${audio.sampleRate}`);\n\t\t}\n\t\treturn;\n\t}\n\tif (isSpeechPlayEncodedAudio(audio)) {\n\t\tconst encoding = audio.encoding.trim().toLowerCase();\n\t\tif (!encoding) throw new SpeechRuntimeError('Encoded audio MIME type is required.');\n\t\tif (encoding === 'pcm_s16le') {\n\t\t\tthrow new SpeechRuntimeError('Use format: { encoding: \"pcm_s16le\", … } for raw PCM.');\n\t\t}\n\t\tif (audio.sampleRate !== undefined && !isAcceptedSampleRate(audio.sampleRate)) {\n\t\t\tthrow new SpeechRuntimeError(`Unsupported sample rate: ${audio.sampleRate}`);\n\t\t}\n\t\treturn;\n\t}\n\tthrow new SpeechRuntimeError('Unsupported speech.play audio shape.');\n}\n\nexport function resolveCreateUtteranceFormat(\n\toptions: SpeechCreateUtteranceOptions\n): SpeechAudioFormat {\n\tif (options.format) {\n\t\tassertPcmFormat(options.format);\n\t\treturn options.format;\n\t}\n\tif (options.track) {\n\t\tconst sampleRate = options.sampleRate ?? 24_000;\n\t\tconst format: SpeechAudioFormat = {\n\t\t\tencoding: 'pcm_s16le',\n\t\t\tsampleRate,\n\t\t\tchannels: 1\n\t\t};\n\t\tassertPcmFormat(format);\n\t\treturn format;\n\t}\n\tthrow new SpeechRuntimeError('createUtterance requires format or track.');\n}\n\nexport function toUint8Array(data: ArrayBuffer | Uint8Array): Uint8Array {\n\treturn data instanceof Uint8Array ? data : new Uint8Array(data);\n}\n\nexport function queuePolicyToEmbedBehavior(\n\tqueue: CompleteSpeechQueuePolicy | StreamingSpeechQueuePolicy | undefined\n): 'enqueue' | 'interrupt' {\n\tif (queue === 'replace-active' || queue === 'replace-all') return 'interrupt';\n\treturn 'enqueue';\n}\n","/** Liforma `speech.write` rejects chunks larger than 64 KiB. */\nexport const MAX_PCM_CHUNK_BYTES = 64 * 1024;\n\n/**\n * Playback / chunk guidance for custom BYO bridges (mirrors speech controller limits).\n * Prefer ~20–200 ms PCM frames; the player starts after an adaptive ~80–250 ms jitter\n * buffer (default 150 ms) based on chunk arrival variance.\n */\nexport const BYO_PLAYBACK_GUIDANCE = {\n\tRECOMMENDED_CHUNK_MS_MIN: 20,\n\tRECOMMENDED_CHUNK_MS_MAX: 200,\n\tPLAYBACK_JITTER_BUFFER_MS: 150,\n\tPLAYBACK_JITTER_BUFFER_MS_MIN: 80,\n\tPLAYBACK_JITTER_BUFFER_MS_MAX: 250\n} as const;\n\nexport function base64ToPcmBytes(b64: string): Uint8Array {\n\tconst bin = atob(b64);\n\tconst out = new Uint8Array(bin.length);\n\tfor (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n\treturn out;\n}\n\nexport function pcmBytesToBase64(bytes: Uint8Array): string {\n\tlet bin = '';\n\tconst chunk = 0x8000;\n\tfor (let i = 0; i < bytes.length; i += chunk) {\n\t\tbin += String.fromCharCode(...bytes.subarray(i, i + chunk));\n\t}\n\treturn btoa(bin);\n}\n\nexport function floatToPcm16Le(input: Float32Array): Uint8Array {\n\tconst out = new Uint8Array(input.length * 2);\n\tconst view = new DataView(out.buffer);\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst s = Math.max(-1, Math.min(1, input[i]!));\n\t\tview.setInt16(i * 2, s < 0 ? s * 0x8000 : s * 0x7fff, true);\n\t}\n\treturn out;\n}\n\n/** Naive linear resample Float32 → target rate. */\nexport function resampleFloat32(input: Float32Array, fromRate: number, toRate: number): Float32Array {\n\tif (fromRate === toRate || input.length === 0) return input;\n\tconst ratio = fromRate / toRate;\n\tconst outLen = Math.max(1, Math.round(input.length / ratio));\n\tconst out = new Float32Array(outLen);\n\tfor (let i = 0; i < outLen; i++) {\n\t\tconst src = i * ratio;\n\t\tconst i0 = Math.floor(src);\n\t\tconst i1 = Math.min(i0 + 1, input.length - 1);\n\t\tconst t = src - i0;\n\t\tout[i] = input[i0]! * (1 - t) + input[i1]! * t;\n\t}\n\treturn out;\n}\n\n/**\n * Parse vendor format strings like `pcm_16000` / `pcm_24000`.\n * Returns null when the format is missing or not PCM.\n */\nexport function parsePcmSampleRate(format: string | null | undefined): number | null {\n\tconst m = /^pcm_(\\d+)$/.exec(format ?? '');\n\tif (!m) return null;\n\tconst rate = Number(m[1]);\n\treturn Number.isFinite(rate) && rate > 0 ? rate : null;\n}\n\n/**\n * Write even-length PCM, splitting at MAX_PCM_CHUNK_BYTES on even boundaries.\n * Callers that may receive odd-length frames should run bytes through\n * {@link takeEvenPcmBytes} first so samples are not dropped across chunks.\n */\nexport async function writePcmInChunks(\n\tutterance: { write: (chunk: ArrayBuffer | ArrayBufferView) => Promise<unknown> },\n\tbytes: Uint8Array\n): Promise<void> {\n\tif (bytes.byteLength === 0) return;\n\tif ((bytes.byteLength & 1) !== 0) {\n\t\t// Defensive: drop trailing unpaired byte within a single call.\n\t\tbytes = bytes.subarray(0, bytes.byteLength - 1);\n\t\tif (bytes.byteLength === 0) return;\n\t}\n\tif (bytes.byteLength <= MAX_PCM_CHUNK_BYTES) {\n\t\tawait utterance.write(bytes);\n\t\treturn;\n\t}\n\tlet offset = 0;\n\twhile (offset < bytes.byteLength) {\n\t\tlet end = Math.min(offset + MAX_PCM_CHUNK_BYTES, bytes.byteLength);\n\t\tif ((end - offset) % 2 === 1) end -= 1;\n\t\tif (end <= offset) break;\n\t\tawait utterance.write(bytes.subarray(offset, end));\n\t\toffset = end;\n\t}\n}\n","/**\n * Stateful cubic (Catmull-Rom) resampler for continuous PCM capture streams.\n * Better than naive linear for uplink mic / track capture.\n */\n\nexport type FloatResampler = {\n\t/** Push a mono float buffer; returns samples at the target rate (may be empty). */\n\tpush(input: Float32Array): Float32Array;\n\t/** Flush any remaining fractional sample (usually silence). */\n\tflush(): Float32Array;\n\treadonly fromRate: number;\n\treadonly toRate: number;\n};\n\nfunction catmullRom(y0: number, y1: number, y2: number, y3: number, t: number): number {\n\tconst a0 = -0.5 * y0 + 1.5 * y1 - 1.5 * y2 + 0.5 * y3;\n\tconst a1 = y0 - 2.5 * y1 + 2 * y2 - 0.5 * y3;\n\tconst a2 = -0.5 * y0 + 0.5 * y2;\n\tconst a3 = y1;\n\treturn ((a0 * t + a1) * t + a2) * t + a3;\n}\n\n/**\n * Create a continuous resampler. When rates match, push() returns the input as-is\n * (no copy) when possible.\n */\nexport function createCubicResampler(fromRate: number, toRate: number): FloatResampler {\n\tif (!(fromRate > 0) || !(toRate > 0)) {\n\t\tthrow new Error('Resampler rates must be positive');\n\t}\n\n\tif (fromRate === toRate) {\n\t\treturn {\n\t\t\tfromRate,\n\t\t\ttoRate,\n\t\t\tpush(input) {\n\t\t\t\treturn input;\n\t\t\t},\n\t\t\tflush() {\n\t\t\t\treturn new Float32Array(0);\n\t\t\t}\n\t\t};\n\t}\n\n\tconst ratio = fromRate / toRate;\n\t/** History + pending input (keeps 3 samples of lookbehind for cubic). */\n\tlet pending = new Float32Array(0);\n\tlet pos = 0; // position in pending sample space for next output\n\n\treturn {\n\t\tfromRate,\n\t\ttoRate,\n\t\tpush(input) {\n\t\t\tif (input.length === 0) return new Float32Array(0);\n\t\t\tconst merged = new Float32Array(pending.length + input.length);\n\t\t\tmerged.set(pending);\n\t\t\tmerged.set(input, pending.length);\n\t\t\tpending = merged;\n\n\t\t\tif (pending.length < 4) return new Float32Array(0);\n\n\t\t\tconst out: number[] = [];\n\t\t\t// Need i+2 available for cubic; stop while pos+2 < length-1 equivalently floor(pos)+2 < len-?\n\t\t\twhile (pos + 2 < pending.length - 1) {\n\t\t\t\tconst i1 = Math.floor(pos);\n\t\t\t\tconst t = pos - i1;\n\t\t\t\tconst i0 = Math.max(0, i1 - 1);\n\t\t\t\tconst i2 = Math.min(pending.length - 1, i1 + 1);\n\t\t\t\tconst i3 = Math.min(pending.length - 1, i1 + 2);\n\t\t\t\tout.push(\n\t\t\t\t\tcatmullRom(pending[i0]!, pending[i1]!, pending[i2]!, pending[i3]!, t)\n\t\t\t\t);\n\t\t\t\tpos += ratio;\n\t\t\t}\n\n\t\t\t// Drop consumed samples but keep lookbehind (≥1) and unread tail.\n\t\t\tconst drop = Math.max(0, Math.floor(pos) - 1);\n\t\t\tif (drop > 0) {\n\t\t\t\tpending = pending.subarray(drop);\n\t\t\t\tpos -= drop;\n\t\t\t}\n\n\t\t\treturn out.length ? Float32Array.from(out) : new Float32Array(0);\n\t\t},\n\t\tflush() {\n\t\t\tif (pending.length === 0) return new Float32Array(0);\n\t\t\t// Emit one last sample if we have enough history; otherwise drop.\n\t\t\tpending = new Float32Array(0);\n\t\t\tpos = 0;\n\t\t\treturn new Float32Array(0);\n\t\t}\n\t};\n}\n","/**\n * Shared Web Audio capture: AudioWorklet when available, ScriptProcessor fallback.\n * Used by BYO mic uplink and MediaStreamTrack → PCM piping.\n */\n\nimport { floatToPcm16Le } from './pcm';\nimport { createCubicResampler, type FloatResampler } from './resample';\n\nexport type AudioCaptureSession = {\n\tstop(): void;\n\treadonly fromSampleRate: number;\n\treadonly usingWorklet: boolean;\n};\n\nexport type StartAudioCaptureOptions = {\n\treadonly mediaStream: MediaStream;\n\treadonly targetSampleRate: number;\n\t/** Called with pcm_s16le mono at targetSampleRate. */\n\treadonly onPcm: (bytes: Uint8Array) => void;\n\t/** When false, frames are dropped. */\n\treadonly shouldSend?: () => boolean;\n\treadonly onLog?: (line: string, kind?: 'info' | 'warn') => void;\n};\n\nconst WORKLET_NAME = 'liforma-pcm-capture';\n\nconst WORKLET_SOURCE = `\nclass LiformaPcmCaptureProcessor extends AudioWorkletProcessor {\n process(inputs) {\n const ch = inputs[0] && inputs[0][0];\n if (ch && ch.length) {\n const copy = new Float32Array(ch.length);\n copy.set(ch);\n this.port.postMessage(copy, [copy.buffer]);\n }\n return true;\n }\n}\nregisterProcessor('${WORKLET_NAME}', LiformaPcmCaptureProcessor);\n`;\n\nlet workletUrl: string | null = null;\n\nfunction getWorkletUrl(): string {\n\tif (!workletUrl) {\n\t\tworkletUrl = URL.createObjectURL(\n\t\t\tnew Blob([WORKLET_SOURCE], { type: 'application/javascript' })\n\t\t);\n\t}\n\treturn workletUrl;\n}\n\nfunction getAudioContextCtor(): typeof AudioContext | null {\n\treturn (\n\t\twindow.AudioContext ||\n\t\t(window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext ||\n\t\tnull\n\t);\n}\n\n/**\n * Capture a MediaStream as pcm_s16le at targetSampleRate.\n * Prefers AudioWorklet; falls back to ScriptProcessorNode.\n */\nexport async function startAudioCapture(\n\toptions: StartAudioCaptureOptions\n): Promise<AudioCaptureSession> {\n\tconst { mediaStream, targetSampleRate, onPcm, shouldSend, onLog } = options;\n\tconst AudioContextCtor = getAudioContextCtor();\n\tif (!AudioContextCtor) throw new Error('Web Audio is required for audio capture');\n\n\tconst audioCtx = new AudioContextCtor();\n\tconst source = audioCtx.createMediaStreamSource(mediaStream);\n\tconst silent = audioCtx.createGain();\n\tsilent.gain.value = 0;\n\tconst fromSampleRate = audioCtx.sampleRate;\n\tconst resampler: FloatResampler = createCubicResampler(fromSampleRate, targetSampleRate);\n\tlet stopped = false;\n\tlet usingWorklet = false;\n\n\tconst emitFloat = (input: Float32Array) => {\n\t\tif (stopped) return;\n\t\tif (shouldSend && !shouldSend()) return;\n\t\tconst resampled = resampler.push(input);\n\t\tif (resampled.length === 0) return;\n\t\tonPcm(floatToPcm16Le(resampled));\n\t};\n\n\tlet disconnectGraph: () => void = () => undefined;\n\n\tconst tryWorklet = async (): Promise<boolean> => {\n\t\tif (typeof audioCtx.audioWorklet?.addModule !== 'function') return false;\n\t\ttry {\n\t\t\tawait audioCtx.audioWorklet.addModule(getWorkletUrl());\n\t\t\tconst node = new AudioWorkletNode(audioCtx, WORKLET_NAME, {\n\t\t\t\tnumberOfInputs: 1,\n\t\t\t\tnumberOfOutputs: 1,\n\t\t\t\toutputChannelCount: [1]\n\t\t\t});\n\t\t\tnode.port.onmessage = (ev) => {\n\t\t\t\tif (ev.data instanceof Float32Array) emitFloat(ev.data);\n\t\t\t};\n\t\t\tsource.connect(node);\n\t\t\tnode.connect(silent);\n\t\t\tsilent.connect(audioCtx.destination);\n\t\t\tdisconnectGraph = () => {\n\t\t\t\tnode.port.onmessage = null;\n\t\t\t\ttry {\n\t\t\t\t\tnode.disconnect();\n\t\t\t\t} catch {\n\t\t\t\t\t/* ignore */\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tsource.disconnect();\n\t\t\t\t} catch {\n\t\t\t\t\t/* ignore */\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tsilent.disconnect();\n\t\t\t\t} catch {\n\t\t\t\t\t/* ignore */\n\t\t\t\t}\n\t\t\t};\n\t\t\tusingWorklet = true;\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t};\n\n\tconst useScriptProcessor = (): void => {\n\t\tconst createScriptProcessor = (\n\t\t\taudioCtx as AudioContext & {\n\t\t\t\tcreateScriptProcessor?: (\n\t\t\t\t\tbufferSize: number,\n\t\t\t\t\tinputChannels: number,\n\t\t\t\t\toutputChannels: number\n\t\t\t\t) => ScriptProcessorNode;\n\t\t\t}\n\t\t).createScriptProcessor?.bind(audioCtx);\n\n\t\tif (!createScriptProcessor) {\n\t\t\tthrow new Error('Neither AudioWorklet nor ScriptProcessor is available');\n\t\t}\n\n\t\tconst processor = createScriptProcessor(4096, 1, 1);\n\t\tprocessor.onaudioprocess = (ev) => {\n\t\t\temitFloat(ev.inputBuffer.getChannelData(0));\n\t\t};\n\t\tsource.connect(processor);\n\t\tprocessor.connect(silent);\n\t\tsilent.connect(audioCtx.destination);\n\t\tdisconnectGraph = () => {\n\t\t\tprocessor.onaudioprocess = null;\n\t\t\ttry {\n\t\t\t\tprocessor.disconnect();\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsource.disconnect();\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsilent.disconnect();\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t};\n\t\tusingWorklet = false;\n\t};\n\n\tif (!(await tryWorklet())) {\n\t\tuseScriptProcessor();\n\t\tonLog?.(\n\t\t\t`Mic/track capture via ScriptProcessor at ${fromSampleRate} Hz → ${targetSampleRate} Hz`,\n\t\t\t'warn'\n\t\t);\n\t} else {\n\t\tonLog?.(`Mic/track capture via AudioWorklet at ${fromSampleRate} Hz → ${targetSampleRate} Hz`);\n\t}\n\n\tif (audioCtx.state === 'suspended') {\n\t\tawait audioCtx.resume().catch(() => undefined);\n\t}\n\n\treturn {\n\t\tfromSampleRate,\n\t\tusingWorklet,\n\t\tstop() {\n\t\t\tif (stopped) return;\n\t\t\tstopped = true;\n\t\t\tresampler.flush();\n\t\t\tdisconnectGraph();\n\t\t\tvoid audioCtx.close().catch(() => undefined);\n\t\t}\n\t};\n}\n","/**\n * Host-side MediaStreamTrack → mono pcm_s16le capture for experience.speech.\n * Capture stays in the SDK (host page); player only receives PCM chunks.\n */\n\nimport { startAudioCapture } from '../../byo/audioCapture';\nimport { SPEECH_LIMITS, SpeechRuntimeError, toUint8Array } from './types';\nimport type { SpeechUtterance } from './types';\n\nexport type CaptureMediaStreamTrackOptions = {\n\treadonly track: MediaStreamTrack;\n\treadonly utterance: SpeechUtterance;\n\treadonly sampleRate: number;\n\treadonly signal?: AbortSignal;\n};\n\n/**\n * Capture a live audio track into an open utterance until the track ends or abort.\n * Prefers AudioWorklet + cubic resample (ScriptProcessor fallback).\n */\nexport async function pipeMediaStreamTrackToUtterance(\n\toptions: CaptureMediaStreamTrackOptions\n): Promise<void> {\n\tconst { track, utterance, sampleRate, signal } = options;\n\tif (typeof MediaStreamTrack === 'undefined' || !(track instanceof MediaStreamTrack)) {\n\t\tthrow new SpeechRuntimeError('MediaStreamTrack is not available in this environment.');\n\t}\n\tif (track.kind !== 'audio') {\n\t\tthrow new SpeechRuntimeError('speech.play track must be an audio MediaStreamTrack.');\n\t}\n\tif (track.readyState === 'ended') {\n\t\treturn;\n\t}\n\tif (signal?.aborted) {\n\t\treturn;\n\t}\n\n\tconst stream = new MediaStream([track]);\n\tlet writeChain: Promise<void> = Promise.resolve();\n\tlet stopped = false;\n\tlet capture: Awaited<ReturnType<typeof startAudioCapture>> | null = null;\n\n\tconst teardown = () => {\n\t\tif (stopped) return;\n\t\tstopped = true;\n\t\tcapture?.stop();\n\t\tcapture = null;\n\t};\n\n\ttry {\n\t\tcapture = await startAudioCapture({\n\t\t\tmediaStream: stream,\n\t\t\ttargetSampleRate: sampleRate,\n\t\t\tshouldSend: () => !stopped && !signal?.aborted,\n\t\t\tonPcm: (pcm) => {\n\t\t\t\tif (stopped || signal?.aborted) return;\n\t\t\t\tconst bytes = toUint8Array(pcm);\n\t\t\t\twriteChain = writeChain\n\t\t\t\t\t.then(async () => {\n\t\t\t\t\t\tif (stopped || signal?.aborted) return;\n\t\t\t\t\t\tlet offset = 0;\n\t\t\t\t\t\twhile (offset < bytes.byteLength) {\n\t\t\t\t\t\t\tlet end = Math.min(offset + SPEECH_LIMITS.MAX_CHUNK_BYTES, bytes.byteLength);\n\t\t\t\t\t\t\tif ((end - offset) % 2 === 1) end -= 1;\n\t\t\t\t\t\t\tif (end <= offset) break;\n\t\t\t\t\t\t\tconst slice = bytes.subarray(offset, end);\n\t\t\t\t\t\t\toffset = end;\n\t\t\t\t\t\t\tif (slice.byteLength === 0) continue;\n\t\t\t\t\t\t\tawait utterance.write(slice);\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\tteardown();\n\t\t\t\t\t});\n\t\t\t}\n\t\t});\n\t} catch (err) {\n\t\tteardown();\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow new SpeechRuntimeError(`MediaStreamTrack capture failed: ${message}`);\n\t}\n\n\tawait new Promise<void>((resolve) => {\n\t\tconst finish = () => {\n\t\t\tteardown();\n\t\t\tvoid writeChain.finally(resolve);\n\t\t};\n\t\ttrack.addEventListener('ended', finish, { once: true });\n\t\tsignal?.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\tvoid utterance.cancel().catch(() => undefined);\n\t\t\t\tfinish();\n\t\t\t},\n\t\t\t{ once: true }\n\t\t);\n\t\tif (track.readyState === 'ended' || signal?.aborted) {\n\t\t\tfinish();\n\t\t}\n\t});\n}\n","import type { IframeHost } from '../embed/iframeHost';\nimport type { SpeakBehavior } from '../types/sessionInteraction';\nimport type { SpeechResult as EmbedSpeakResult } from '../types/sessionInteraction';\nimport {\n\tSPEECH_LIMITS,\n\tSpeechBufferTimeoutError,\n\tSpeechRuntimeError,\n\tSpeechUtteranceClosedError,\n\tUnsupportedSpeechOperationError,\n\tassertSpeechPlayAudio,\n\temptyAnimationResult,\n\tisSpeechPlayEncodedAudio,\n\tisSpeechPlayMediaStreamAudio,\n\tisSpeechPlayPcmAudio,\n\tisSpeechPlayUrlAudio,\n\tqueuePolicyToEmbedBehavior,\n\tresolveCreateUtteranceFormat,\n\ttoUint8Array,\n\ttype SpeechAudioFormat,\n\ttype SpeechController,\n\ttype SpeechCreateUtteranceOptions,\n\ttype SpeechInterruptOptions,\n\ttype SpeechPlayAudio,\n\ttype SpeechPlayEmbedSource,\n\ttype SpeechPlayOptions,\n\ttype SpeechResult,\n\ttype SpeechSpeakOptions,\n\ttype SpeechTerminalStatus,\n\ttype SpeechUtterance,\n\ttype SpeechUtteranceCloseOptions,\n\ttype SpeechWriteOptions,\n\ttype StreamingSpeechQueuePolicy\n} from './types';\nimport { pipeMediaStreamTrackToUtterance } from './captureMediaStreamTrack';\n\nasync function toSpeechPlayEmbedSource(\n\taudio: SpeechPlayAudio,\n\tsignal?: AbortSignal\n): Promise<SpeechPlayEmbedSource> {\n\tif (isSpeechPlayMediaStreamAudio(audio)) {\n\t\tthrow new SpeechRuntimeError('MediaStreamTrack play is handled on the host before embed.');\n\t}\n\tif (isSpeechPlayPcmAudio(audio)) {\n\t\tconst data = toUint8Array(audio.data);\n\t\tif ((data.byteLength & 1) !== 0) {\n\t\t\tthrow new SpeechRuntimeError('PCM byte length must be even.');\n\t\t}\n\t\treturn {\n\t\t\tkind: 'pcm',\n\t\t\tdata: data.slice().buffer,\n\t\t\tformat: audio.format\n\t\t};\n\t}\n\tif (isSpeechPlayUrlAudio(audio)) {\n\t\treturn {\n\t\t\tkind: 'url',\n\t\t\turl: audio.url.trim(),\n\t\t\t...(audio.sampleRate !== undefined ? { sampleRate: audio.sampleRate } : {})\n\t\t};\n\t}\n\tif (!isSpeechPlayEncodedAudio(audio)) {\n\t\tthrow new SpeechRuntimeError('Unsupported speech.play audio shape.');\n\t}\n\tlet bytes: Uint8Array;\n\tif (typeof Blob !== 'undefined' && audio.data instanceof Blob) {\n\t\tif (signal?.aborted) throw new DOMException('Play aborted.', 'AbortError');\n\t\tbytes = new Uint8Array(await audio.data.arrayBuffer());\n\t} else {\n\t\tbytes = toUint8Array(audio.data as ArrayBuffer | Uint8Array);\n\t}\n\treturn {\n\t\tkind: 'encoded',\n\t\tdata: bytes.slice().buffer,\n\t\tencoding: audio.encoding.trim(),\n\t\t...(audio.sampleRate !== undefined ? { sampleRate: audio.sampleRate } : {})\n\t};\n}\n\nexport type {\n\tSpeechAudioFormat,\n\tSpeechController,\n\tSpeechCreateUtteranceOptions,\n\tSpeechInterruptOptions,\n\tSpeechPlayOptions,\n\tSpeechResult,\n\tSpeechSpeakOptions,\n\tSpeechUtterance,\n\tSpeechUtteranceCloseOptions,\n\tSpeechWriteOptions\n} from './types';\n\nexport type SpeechCapabilities = {\n\treadonly textSpeech: boolean;\n\treadonly externalSpeechAudio: boolean;\n};\n\nexport type SpeechControllerHost = {\n\treadonly getIframeHost: () => IframeHost | null;\n\treadonly assertSessionStarted: () => void;\n\treadonly getCapabilities: () => SpeechCapabilities;\n\treadonly getActiveCharacterId: () => string;\n\treadonly onProcessorInterrupt?: () => void;\n};\n\ntype PendingWrite = {\n\treadonly resolve: () => void;\n\treadonly reject: (error: Error) => void;\n};\n\nfunction newUtteranceId(): string {\n\tif (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n\t\treturn `utt_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`;\n\t}\n\treturn `utt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;\n}\n\nfunction mapEmbedSpeakResult(\n\tresult: EmbedSpeakResult,\n\tstatus: SpeechTerminalStatus = 'completed'\n): SpeechResult {\n\treturn {\n\t\tutteranceId: result.speechId,\n\t\tcharacterId: result.characterId,\n\t\tstatus,\n\t\tdurationMs: result.durationMs,\n\t\ttranscript: result.text,\n\t\tanimation: {\n\t\t\tmode: 'tracked',\n\t\t\ttrackedDurationMs: result.durationMs,\n\t\t\tfallbackDurationMs: 0\n\t\t}\n\t};\n}\n\nfunction settleError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\treturn new SpeechRuntimeError(String(error));\n}\n\nfunction isAbortError(error: unknown): boolean {\n\treturn (\n\t\t(error instanceof DOMException && error.name === 'AbortError') ||\n\t\t(error instanceof Error && error.name === 'AbortError')\n\t);\n}\n\nclass HostSpeechUtterance implements SpeechUtterance {\n\treadonly id: string;\n\treadonly characterId: string;\n\treadonly result: Promise<SpeechResult>;\n\n\tprivate readonly format: SpeechAudioFormat;\n\tprivate readonly host: SpeechControllerHost;\n\tprivate readonly signal?: AbortSignal;\n\tprivate settleResolve!: (value: SpeechResult) => void;\n\tprivate settleReject!: (error: Error) => void;\n\tprivate settled = false;\n\tprivate closed = false;\n\tprivate writeChain: Promise<void> = Promise.resolve();\n\tprivate pendingWriteCount = 0;\n\tprivate readonly pendingWriteWaiters: PendingWrite[] = [];\n\tprivate bufferedMs = 0;\n\tprivate readonly sampleRate: number;\n\tprivate readonly beginPromise: Promise<void>;\n\n\tconstructor(options: {\n\t\treadonly id: string;\n\t\treadonly characterId: string;\n\t\treadonly format: SpeechAudioFormat;\n\t\treadonly queue: StreamingSpeechQueuePolicy;\n\t\treadonly host: SpeechControllerHost;\n\t\treadonly transcript?: string;\n\t\treadonly signal?: AbortSignal;\n\t}) {\n\t\tthis.id = options.id;\n\t\tthis.characterId = options.characterId;\n\t\tthis.format = options.format;\n\t\tthis.host = options.host;\n\t\tthis.signal = options.signal;\n\t\tthis.sampleRate = options.format.sampleRate;\n\t\tthis.result = new Promise<SpeechResult>((resolve, reject) => {\n\t\t\tthis.settleResolve = resolve;\n\t\t\tthis.settleReject = reject;\n\t\t});\n\t\t// Prevent unhandled rejection if caller only uses close()/cancel().\n\t\tvoid this.result.catch(() => undefined);\n\n\t\tconst iframe = this.requireHost();\n\t\tthis.beginPromise = iframe\n\t\t\t.speechUtteranceBegin({\n\t\t\t\tutteranceId: this.id,\n\t\t\t\tformat: this.format,\n\t\t\t\tcharacterId: this.characterId,\n\t\t\t\tqueue: options.queue,\n\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {})\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tthis.fail(settleError(error));\n\t\t\t\tthrow settleError(error);\n\t\t\t});\n\n\t\tthis.signal?.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\tvoid this.cancel();\n\t\t\t},\n\t\t\t{ once: true }\n\t\t);\n\t}\n\n\tasync write(audio: ArrayBuffer | Uint8Array, options?: SpeechWriteOptions): Promise<void> {\n\t\tif (this.closed || this.settled) {\n\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t}\n\t\tawait this.beginPromise.catch(() => undefined);\n\t\tif (this.closed || this.settled) {\n\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t}\n\t\tconst bytes = toUint8Array(audio);\n\t\tif ((bytes.byteLength & 1) !== 0) {\n\t\t\tthrow new SpeechRuntimeError('PCM chunk byte length must be even (complete s16 samples).');\n\t\t}\n\t\tif (bytes.byteLength > SPEECH_LIMITS.MAX_CHUNK_BYTES) {\n\t\t\tthrow new SpeechRuntimeError(\n\t\t\t\t`PCM chunk exceeds MAX_CHUNK_BYTES (${SPEECH_LIMITS.MAX_CHUNK_BYTES}).`\n\t\t\t);\n\t\t}\n\t\tif (bytes.byteLength === 0) return;\n\n\t\tconst timeoutMs = options?.timeoutMs ?? SPEECH_LIMITS.DEFAULT_WRITE_TIMEOUT_MS;\n\t\tawait this.acquireWriteSlot(timeoutMs);\n\n\t\tconst chunkMs = (bytes.byteLength / 2 / this.sampleRate) * 1000;\n\t\tif (this.bufferedMs + chunkMs > SPEECH_LIMITS.MAX_UTTERANCE_DURATION_MS) {\n\t\t\tthis.releaseWriteSlot();\n\t\t\tthrow new SpeechRuntimeError('Utterance exceeds MAX_UTTERANCE_DURATION_MS.');\n\t\t}\n\n\t\tconst run = async () => {\n\t\t\tif (this.closed || this.settled) {\n\t\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t\t}\n\t\t\tconst iframe = this.requireHost();\n\t\t\tconst copy = bytes.slice();\n\t\t\tconst writePromise = iframe.speechUtteranceWrite({\n\t\t\t\tutteranceId: this.id,\n\t\t\t\taudio: copy.buffer,\n\t\t\t\tbyteLength: copy.byteLength\n\t\t\t});\n\t\t\tconst ack = await Promise.race([\n\t\t\t\twritePromise,\n\t\t\t\tnew Promise<never>((_, reject) => {\n\t\t\t\t\tsetTimeout(() => reject(new SpeechBufferTimeoutError()), timeoutMs);\n\t\t\t\t})\n\t\t\t]);\n\t\t\tthis.bufferedMs = Math.max(0, ack.bufferedMs);\n\t\t};\n\n\t\tconst tracked = this.writeChain.then(run, run);\n\t\tthis.writeChain = tracked.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined\n\t\t);\n\t\ttry {\n\t\t\tawait tracked;\n\t\t} finally {\n\t\t\tthis.releaseWriteSlot();\n\t\t}\n\t}\n\n\tasync setTranscript(text: string): Promise<void> {\n\t\tif (this.closed || this.settled) {\n\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t}\n\t\tawait this.beginPromise.catch(() => undefined);\n\t\tif (this.closed || this.settled) {\n\t\t\tthrow new SpeechUtteranceClosedError();\n\t\t}\n\t\tconst iframe = this.requireHost();\n\t\tawait iframe.speechUtteranceSetTranscript({\n\t\t\tutteranceId: this.id,\n\t\t\ttranscript: text\n\t\t});\n\t}\n\n\tasync close(options?: SpeechUtteranceCloseOptions): Promise<SpeechResult> {\n\t\tif (this.settled) return this.result;\n\t\tthis.closed = true;\n\t\tawait this.beginPromise.catch(() => undefined);\n\t\tawait this.writeChain.catch(() => undefined);\n\t\ttry {\n\t\t\tconst iframe = this.requireHost();\n\t\t\tconst result = await iframe.speechUtteranceClose({\n\t\t\t\tutteranceId: this.id,\n\t\t\t\ttranscript: options?.transcript,\n\t\t\t\thistory: options?.history ?? 'none'\n\t\t\t});\n\t\t\tthis.resolve(result);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tconst err = settleError(error);\n\t\t\tthis.fail(err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync cancel(): Promise<SpeechResult> {\n\t\tif (this.settled) return this.result;\n\t\tthis.closed = true;\n\t\ttry {\n\t\t\tconst iframe = this.host.getIframeHost();\n\t\t\tif (iframe) {\n\t\t\t\tconst result = await iframe.speechUtteranceCancel({ utteranceId: this.id });\n\t\t\t\tthis.resolve(result);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tconst cancelled: SpeechResult = {\n\t\t\t\tutteranceId: this.id,\n\t\t\t\tcharacterId: this.characterId,\n\t\t\t\tstatus: 'cancelled',\n\t\t\t\tdurationMs: 0,\n\t\t\t\tanimation: emptyAnimationResult('none')\n\t\t\t};\n\t\t\tthis.resolve(cancelled);\n\t\t\treturn cancelled;\n\t\t} catch (error) {\n\t\t\tconst err = settleError(error);\n\t\t\tthis.fail(err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/** Adopt an interrupt settlement from the player without a second cancel RPC. */\n\tadoptExternalResult(result: SpeechResult): void {\n\t\tthis.resolve(result);\n\t}\n\n\tprivate requireHost(): IframeHost {\n\t\tconst iframe = this.host.getIframeHost();\n\t\tif (!iframe) {\n\t\t\tthrow new SpeechRuntimeError('Speech session is not attached.');\n\t\t}\n\t\treturn iframe;\n\t}\n\n\tprivate resolve(result: SpeechResult): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tthis.settleResolve(Object.freeze(result));\n\t\tthis.flushWriteWaiters(new SpeechUtteranceClosedError());\n\t}\n\n\tprivate fail(error: Error): void {\n\t\tif (this.settled) return;\n\t\tthis.settled = true;\n\t\tthis.settleReject(error);\n\t\tthis.flushWriteWaiters(error);\n\t}\n\n\tprivate async acquireWriteSlot(timeoutMs: number): Promise<void> {\n\t\tif (this.pendingWriteCount < SPEECH_LIMITS.MAX_PENDING_WRITES) {\n\t\t\tthis.pendingWriteCount += 1;\n\t\t\treturn;\n\t\t}\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\treject(new SpeechBufferTimeoutError());\n\t\t\t}, timeoutMs);\n\t\t\tthis.pendingWriteWaiters.push({\n\t\t\t\tresolve: () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tthis.pendingWriteCount += 1;\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate releaseWriteSlot(): void {\n\t\tthis.pendingWriteCount = Math.max(0, this.pendingWriteCount - 1);\n\t\tconst next = this.pendingWriteWaiters.shift();\n\t\tnext?.resolve();\n\t}\n\n\tprivate flushWriteWaiters(error: Error): void {\n\t\twhile (this.pendingWriteWaiters.length > 0) {\n\t\t\tthis.pendingWriteWaiters.shift()?.reject(error);\n\t\t}\n\t}\n}\n\nexport function createSpeechController(host: SpeechControllerHost): SpeechController {\n\tlet openUtterance: HostSpeechUtterance | null = null;\n\n\tconst requireCapability = (operation: string, capability: keyof SpeechCapabilities) => {\n\t\tconst caps = host.getCapabilities();\n\t\tif (!caps[capability]) {\n\t\t\tthrow new UnsupportedSpeechOperationError(operation, capability);\n\t\t}\n\t};\n\n\tconst controller: SpeechController = {\n\t\tasync speak(options: SpeechSpeakOptions): Promise<SpeechResult> {\n\t\t\thost.assertSessionStarted();\n\t\t\trequireCapability('speak', 'textSpeech');\n\t\t\tif (options.signal?.aborted) {\n\t\t\t\tthrow new DOMException('Speak aborted.', 'AbortError');\n\t\t\t}\n\t\t\tconst queue = options.queue ?? 'append';\n\t\t\tconst behavior: SpeakBehavior = queuePolicyToEmbedBehavior(queue);\n\t\t\tif (behavior === 'interrupt') {\n\t\t\t\thost.onProcessorInterrupt?.();\n\t\t\t\tif (openUtterance) {\n\t\t\t\t\tvoid openUtterance.cancel();\n\t\t\t\t\topenUtterance = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst iframe = host.getIframeHost();\n\t\t\tif (!iframe) throw new SpeechRuntimeError('Speech session is not attached.');\n\n\t\t\tconst speakPromise = iframe.speak({\n\t\t\t\ttext: options.text,\n\t\t\t\tcharacterId: options.characterId,\n\t\t\t\tbehavior\n\t\t\t});\n\n\t\t\tif (options.signal) {\n\t\t\t\tconst signal = options.signal;\n\t\t\t\treturn await new Promise<SpeechResult>((resolve, reject) => {\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\tvoid iframe.speechInterrupt({ scope: 'active' }).catch(() => undefined);\n\t\t\t\t\t\treject(new DOMException('Speak aborted.', 'AbortError'));\n\t\t\t\t\t};\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\t\t\t\t\tspeakPromise.then(\n\t\t\t\t\t\t(legacy) => {\n\t\t\t\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\t\t\t\tresolve(mapEmbedSpeakResult(legacy, 'completed'));\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\t\t\t\tif (isAbortError(error)) {\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tutteranceId: `utt_interrupted`,\n\t\t\t\t\t\t\t\t\tcharacterId: options.characterId ?? host.getActiveCharacterId(),\n\t\t\t\t\t\t\t\t\tstatus: 'interrupted',\n\t\t\t\t\t\t\t\t\tdurationMs: 0,\n\t\t\t\t\t\t\t\t\ttranscript: options.text,\n\t\t\t\t\t\t\t\t\tanimation: emptyAnimationResult('none')\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treject(settleError(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\ttry {\n\t\t\t\tconst legacy = await speakPromise;\n\t\t\t\treturn mapEmbedSpeakResult(legacy, 'completed');\n\t\t\t} catch (error) {\n\t\t\t\tif (isAbortError(error)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tutteranceId: `utt_interrupted`,\n\t\t\t\t\t\tcharacterId: options.characterId ?? host.getActiveCharacterId(),\n\t\t\t\t\t\tstatus: 'interrupted',\n\t\t\t\t\t\tdurationMs: 0,\n\t\t\t\t\t\ttranscript: options.text,\n\t\t\t\t\t\tanimation: emptyAnimationResult('none')\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tthrow settleError(error);\n\t\t\t}\n\t\t},\n\n\t\tasync play(options: SpeechPlayOptions): Promise<SpeechResult> {\n\t\t\thost.assertSessionStarted();\n\t\t\trequireCapability('play', 'externalSpeechAudio');\n\t\t\tassertSpeechPlayAudio(options.audio);\n\t\t\tif (options.signal?.aborted) {\n\t\t\t\tthrow new DOMException('Play aborted.', 'AbortError');\n\t\t\t}\n\t\t\tconst queue = options.queue ?? 'append';\n\t\t\tif (queue === 'replace-active' || queue === 'replace-all') {\n\t\t\t\thost.onProcessorInterrupt?.();\n\t\t\t\tif (openUtterance) {\n\t\t\t\t\tvoid openUtterance.cancel();\n\t\t\t\t\topenUtterance = null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isSpeechPlayMediaStreamAudio(options.audio)) {\n\t\t\t\tconst sampleRate = options.audio.sampleRate ?? 24_000;\n\t\t\t\tconst utterance = controller.createUtterance({\n\t\t\t\t\tformat: { encoding: 'pcm_s16le', sampleRate, channels: 1 },\n\t\t\t\t\ttrack: options.audio.track,\n\t\t\t\t\tcharacterId: options.characterId,\n\t\t\t\t\tqueue: queue === 'append' ? 'replace-active' : queue,\n\t\t\t\t\tsignal: options.signal\n\t\t\t\t});\n\t\t\t\treturn utterance.result;\n\t\t\t}\n\n\t\t\tconst iframe = host.getIframeHost();\n\t\t\tif (!iframe) throw new SpeechRuntimeError('Speech session is not attached.');\n\t\t\tconst source = await toSpeechPlayEmbedSource(options.audio, options.signal);\n\t\t\treturn iframe.speechPlay({\n\t\t\t\tsource,\n\t\t\t\tcharacterId: options.characterId,\n\t\t\t\ttranscript: options.transcript,\n\t\t\t\thistory: options.history ?? 'none',\n\t\t\t\tqueue,\n\t\t\t\tsignal: options.signal\n\t\t\t});\n\t\t},\n\n\t\tcreateUtterance(options: SpeechCreateUtteranceOptions): SpeechUtterance {\n\t\t\thost.assertSessionStarted();\n\t\t\trequireCapability('createUtterance', 'externalSpeechAudio');\n\t\t\tconst format = resolveCreateUtteranceFormat(options);\n\t\t\tif (options.track && options.track.kind !== 'audio') {\n\t\t\t\tthrow new SpeechRuntimeError('createUtterance track must be an audio MediaStreamTrack.');\n\t\t\t}\n\t\t\tconst queue: StreamingSpeechQueuePolicy = options.queue ?? 'replace-active';\n\t\t\tif (queue !== 'replace-active' && queue !== 'replace-all') {\n\t\t\t\tthrow new SpeechRuntimeError('createUtterance queue must be replace-active or replace-all.');\n\t\t\t}\n\t\t\thost.onProcessorInterrupt?.();\n\t\t\tif (openUtterance) {\n\t\t\t\tvoid openUtterance.cancel();\n\t\t\t\topenUtterance = null;\n\t\t\t}\n\t\t\tconst utterance = new HostSpeechUtterance({\n\t\t\t\tid: newUtteranceId(),\n\t\t\t\tcharacterId: options.characterId ?? host.getActiveCharacterId(),\n\t\t\t\tformat,\n\t\t\t\tqueue,\n\t\t\t\thost,\n\t\t\t\t...(options.transcript !== undefined ? { transcript: options.transcript } : {}),\n\t\t\t\tsignal: options.signal\n\t\t\t});\n\t\t\topenUtterance = utterance;\n\t\t\tvoid utterance.result.finally(() => {\n\t\t\t\tif (openUtterance === utterance) openUtterance = null;\n\t\t\t});\n\t\t\tif (options.track) {\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait pipeMediaStreamTrackToUtterance({\n\t\t\t\t\t\t\ttrack: options.track!,\n\t\t\t\t\t\t\tutterance,\n\t\t\t\t\t\t\tsampleRate: format.sampleRate,\n\t\t\t\t\t\t\tsignal: options.signal\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (options.signal?.aborted) return;\n\t\t\t\t\t\tawait utterance.close({ history: 'none' });\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tawait utterance.cancel().catch(() => undefined);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\t\t\treturn utterance;\n\t\t},\n\n\t\tasync interrupt(options?: SpeechInterruptOptions): Promise<readonly SpeechResult[]> {\n\t\t\thost.assertSessionStarted();\n\t\t\thost.onProcessorInterrupt?.();\n\t\t\tconst iframe = host.getIframeHost();\n\t\t\tif (!iframe) return [];\n\t\t\tconst results = await iframe.speechInterrupt(options ?? { scope: 'active' });\n\t\t\tif (openUtterance) {\n\t\t\t\tconst match = results.find((r) => r.utteranceId === openUtterance!.id);\n\t\t\t\tif (match) openUtterance.adoptExternalResult(match);\n\t\t\t\topenUtterance = null;\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t};\n\n\treturn controller;\n}\n","import { fetchSessionManifest } from './api/mintPublicSession';\nimport { mintPublicSession } from './api/mintPublicSession';\nimport { dispatchConversationProcessor } from './conversationProcessor';\nimport { createIframeHost, type IframeHost } from './embed/iframeHost';\nimport { createReadyGate } from './embed/readyGate';\nimport type { CloseEvent, EmbedState } from './embed/protocol';\nimport {\n\tbuildManifestEmbedUrl,\n\tresolvePlayerOrigin,\n\tresolvePublicPlayerEmbedUrl\n} from './shims/embedBaseUrl';\nimport {\n\tmanifestHasSessionCredential,\n\tparseSessionManifest\n} from './types/sessionManifestSchema';\nimport type { SessionManifest } from './types/sessionManifest';\nimport { applySpeechOnlyManifest } from './speechOnlyManifest';\nimport {\n\tclearExperienceEventRegistry,\n\tcreateExperienceEventRegistry,\n\temitExperienceEvent,\n\tsubscribeExperienceEvent,\n\ttype ExperienceEventName,\n\ttype ExperienceEvents\n} from './experienceEvents';\nimport {\n\tcreateSpeechController,\n\ttype SpeechCapabilities,\n\ttype SpeechController\n} from './speech/speechController';\nimport type {\n\tCharacterSpeechEvent,\n\tConversationMessage,\n\tConversationProcessorFn,\n\tExperienceFit,\n\tExperienceMode,\n\tListenOnceOptions,\n\tResponseMode,\n\tSpeechInputMode,\n\tStartButtonOptions,\n\tStartedEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from './types/sessionInteraction';\n\nexport type { CloseEvent };\nexport type {\n\tCharacterSpeechEvent,\n\tCharacterSpeechSource,\n\tCharacterSpeechTerminalReason,\n\tConversationMessage,\n\tConversationProcessorContext,\n\tConversationProcessorErrorEvent,\n\tConversationProcessorFn,\n\tConversationProcessorResult,\n\tExperienceFit,\n\tListenOnceOptions,\n\tSpeakOptions,\n\tTextSpeakResult,\n\tSpeechResult as LegacySpeakResult,\n\tStartButtonAppearance,\n\tStartButtonOptions,\n\tStartButtonPlacement,\n\tStartButtonShadow,\n\tStartButtonSize,\n\tStartButtonVariant,\n\tSessionModeChange,\n\tUserSpeechBoundaryEvent,\n\tUserTranscriptUpdate,\n\tUtteranceResult\n} from './types/sessionInteraction';\nexport type {\n\tSpeechAudioFormat,\n\tSpeechController,\n\tSpeechCreateUtteranceOptions,\n\tSpeechInterruptOptions,\n\tSpeechPlayAudio,\n\tSpeechPlayEncodedAudio,\n\tSpeechPlayOptions,\n\tSpeechPlayPcmAudio,\n\tSpeechPlayUrlAudio,\n\tSpeechResult,\n\tSpeechSpeakOptions,\n\tSpeechUtterance\n} from './speech';\nexport {\n\tSPEECH_LIMITS,\n\tSpeechBufferTimeoutError,\n\tSpeechRuntimeError,\n\tSpeechUtteranceClosedError,\n\tUnsupportedSpeechOperationError\n} from './speech';\n\nexport type { ExperienceEventName, ExperienceEvents } from './experienceEvents';\n\nexport type StartSessionOptions =\n\t| {\n\t\t\treadonly experienceId: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\t/** @deprecated Response ownership is derived from mode. */\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\t/** Scene framing: `face` cover-zooms onto the mesh face oval. Default `full`. */\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\t/** ExperienceWidget warm embed chrome (`?ui=widget`). */\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly experienceId: string;\n\t\t\treadonly sessionEndpoint: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\t/** @deprecated Response ownership is derived from mode. */\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\t/** Scene framing: `face` cover-zooms onto the mesh face oval. Default `full`. */\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\t/** ExperienceWidget warm embed chrome (`?ui=widget`). */\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly manifest: unknown;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly acceptCredentialExposure?: boolean;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\t/** Scene framing: `face` cover-zooms onto the mesh face oval. Default `full`. */\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\t/** ExperienceWidget warm embed chrome (`?ui=widget`). */\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t };\n\nexport type AttachOptions = {\n\treadonly container: HTMLElement;\n\treadonly onStateUpdate?: (state: EmbedState) => void;\n\treadonly onWidgetReady?: () => void;\n\treadonly onWidgetExpand?: () => void;\n\treadonly onWidgetCollapse?: () => void;\n\treadonly onWidgetAudioSettings?: (open: boolean) => void;\n\t/** Docked shell: player surface drag → parent repositions the dock. */\n\treadonly onWidgetDragStart?: (event: { readonly pointerId: number }) => void;\n\treadonly onWidgetDragMove?: (event: {\n\t\treadonly pointerId: number;\n\t\treadonly dx: number;\n\t\treadonly dy: number;\n\t}) => void;\n\treadonly onWidgetDragEnd?: (event: { readonly pointerId: number }) => void;\n\t/**\n\t * Show the in-player close control. Set when the host provides `onClose`\n\t * and/or `returnUrl`. Widget chrome keeps its own toolbar close separately.\n\t */\n\treadonly showClose?: boolean;\n};\n\nexport type { EmbedState };\n\nexport type ReadyEvent = {\n\treadonly manifest: SessionManifest;\n};\n\nexport type LiformaPlayer = {\n\tclose(): void;\n\tdestroy(): void;\n\ton(event: 'close', handler: (event: CloseEvent) => void): void;\n};\n\ntype SessionLaunch =\n\t| {\n\t\t\treadonly kind: 'public';\n\t\t\treadonly experienceId: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly kind: 'manifest';\n\t\t\treadonly manifest: SessionManifest;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t }\n\t| {\n\t\t\treadonly kind: 'sessionEndpoint';\n\t\t\treadonly experienceId: string;\n\t\t\treadonly sessionEndpoint: string;\n\t\t\treadonly language?: 'en' | 'es';\n\t\t\treadonly locationId?: string;\n\t\t\treadonly avatarId?: string;\n\t\t\treadonly embedBaseUrl?: string;\n\t\t\treadonly debug?: boolean;\n\t\t\treadonly mode?: ExperienceMode;\n\t\t\treadonly responseMode?: ResponseMode;\n\t\t\treadonly speechInputMode?: SpeechInputMode;\n\t\t\treadonly startButton?: StartButtonOptions;\n\t\t\t/** Voice-only session: skip avatar renderer and location scene asset loading. */\n\t\t\treadonly speechOnly?: boolean;\n\t\t\treadonly fit?: ExperienceFit;\n\t\t\treadonly ui?: 'widget';\n\t\t\treadonly onStart?: (event: StartedEvent) => void | Promise<void>;\n\t\t\treadonly onUserTranscript?: (update: UserTranscriptUpdate) => void | Promise<void>;\n\t\t\treadonly conversationProcessor?: ConversationProcessorFn;\n\t };\n\nfunction applyStartButtonOptions(\n\tmanifest: SessionManifest,\n\tstartButton: StartButtonOptions | undefined\n): SessionManifest {\n\tif (!startButton) return manifest;\n\treturn parseSessionManifest({\n\t\t...manifest,\n\t\texperience: {\n\t\t\t...manifest.experience,\n\t\t\tstartButton\n\t\t}\n\t});\n}\n\nexport class Experience {\n\tprivate readonly launch: SessionLaunch;\n\tprivate readonly conversationProcessor: ConversationProcessorFn | null;\n\tprivate iframeHost: IframeHost | null = null;\n\tprivate attachInFlight: Promise<LiformaPlayer> | null = null;\n\tprivate endpointAbortController: AbortController | null = null;\n\tprivate processorAbortController: AbortController | null = null;\n\tprivate processorChain: Promise<void> = Promise.resolve();\n\tprivate resolvedManifest: SessionManifest | null;\n\tprivate closed = false;\n\tprivate attached = false;\n\tprivate readonly closeHandlers: ((event: CloseEvent) => void)[] = [];\n\tprivate readonly eventRegistry = createExperienceEventRegistry();\n\tprivate readyEvent: ReadyEvent | null = null;\n\tprivate startedEvent: StartedEvent | null = null;\n\tprivate conversationCache: readonly ConversationMessage[] = [];\n\t/** Public speech API — text TTS and BYO PCM (`speak` / `play` / `createUtterance` / `interrupt`). */\n\treadonly speech: SpeechController;\n\n\tprivate constructor(launch: SessionLaunch) {\n\t\tthis.launch = launch;\n\t\tthis.conversationProcessor = launch.conversationProcessor ?? null;\n\t\tthis.resolvedManifest = launch.kind === 'manifest' ? launch.manifest : null;\n\t\tthis.speech = createSpeechController({\n\t\t\tgetIframeHost: () => this.iframeHost,\n\t\t\tassertSessionStarted: () => this.assertSessionStarted(),\n\t\t\tgetCapabilities: () => resolveSpeechCapabilities(this.resolvedManifest),\n\t\t\tgetActiveCharacterId: () =>\n\t\t\t\tthis.resolvedManifest?.activeCharacterId ?? 'character_unknown',\n\t\t\tonProcessorInterrupt: () => {\n\t\t\t\tthis.processorAbortController?.abort();\n\t\t\t\tthis.processorAbortController = null;\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic async startSession(options: StartSessionOptions): Promise<Experience> {\n\t\tif ('sessionEndpoint' in options) {\n\t\t\treturn new Experience({\n\t\t\t\tkind: 'sessionEndpoint',\n\t\t\t\texperienceId: options.experienceId,\n\t\t\t\tsessionEndpoint: options.sessionEndpoint,\n\t\t\t\tlanguage: options.language,\n\t\t\t\tlocationId: options.locationId,\n\t\t\t\tavatarId: options.avatarId,\n\t\t\t\tembedBaseUrl: options.embedBaseUrl,\n\t\t\t\tdebug: options.debug,\n\t\t\t\tmode: options.mode,\n\t\t\t\tresponseMode: options.responseMode,\n\t\t\t\tspeechInputMode: options.speechInputMode,\n\t\t\t\tstartButton: options.startButton,\n\t\t\t\tspeechOnly: options.speechOnly,\n\t\t\t\tfit: options.fit,\n\t\t\t\tui: options.ui,\n\t\t\t\tonStart: options.onStart,\n\t\t\t\tonUserTranscript: options.onUserTranscript,\n\t\t\t\tconversationProcessor: options.conversationProcessor\n\t\t\t});\n\t\t}\n\n\t\tif ('experienceId' in options) {\n\t\t\treturn new Experience({\n\t\t\t\tkind: 'public',\n\t\t\t\texperienceId: options.experienceId,\n\t\t\t\tlanguage: options.language,\n\t\t\t\tlocationId: options.locationId,\n\t\t\t\tavatarId: options.avatarId,\n\t\t\t\tembedBaseUrl: options.embedBaseUrl,\n\t\t\t\tdebug: options.debug,\n\t\t\t\tmode: options.mode,\n\t\t\t\tresponseMode: options.responseMode,\n\t\t\t\tspeechInputMode: options.speechInputMode,\n\t\t\t\tstartButton: options.startButton,\n\t\t\t\tspeechOnly: options.speechOnly,\n\t\t\t\tfit: options.fit,\n\t\t\t\tui: options.ui,\n\t\t\t\tonStart: options.onStart,\n\t\t\t\tonUserTranscript: options.onUserTranscript,\n\t\t\t\tconversationProcessor: options.conversationProcessor\n\t\t\t});\n\t\t}\n\n\t\tconst manifest = parseSessionManifest(options.manifest);\n\t\tif (manifestHasSessionCredential(manifest) && !options.acceptCredentialExposure) {\n\t\t\tthrow new Error(\n\t\t\t\t'Credential-bearing Session Manifest requires acceptCredentialExposure: true. ' +\n\t\t\t\t\t'Prefer experienceId, sessionEndpoint, or client-side mint instead of SSR page data.'\n\t\t\t);\n\t\t}\n\n\t\treturn new Experience({\n\t\t\tkind: 'manifest',\n\t\t\tmanifest: options.speechOnly ? applySpeechOnlyManifest(manifest) : manifest,\n\t\t\tembedBaseUrl: options.embedBaseUrl,\n\t\t\tdebug: options.debug,\n\t\t\tstartButton: options.startButton,\n\t\t\tspeechOnly: options.speechOnly,\n\t\t\tfit: options.fit,\n\t\t\tui: options.ui,\n\t\t\tonStart: options.onStart,\n\t\t\tonUserTranscript: options.onUserTranscript,\n\t\t\tconversationProcessor: options.conversationProcessor\n\t\t});\n\t}\n\n\tgetManifest(): SessionManifest | null {\n\t\treturn this.resolvedManifest;\n\t}\n\n\ton<K extends ExperienceEventName>(\n\t\tevent: K,\n\t\thandler: (event: ExperienceEvents[K]) => void\n\t): () => void {\n\t\tconst unsubscribe = subscribeExperienceEvent(this.eventRegistry, event, handler);\n\t\tif (event === 'ready' && this.readyEvent) {\n\t\t\tqueueMicrotask(() => handler(this.readyEvent as ExperienceEvents[K]));\n\t\t}\n\t\tif (event === 'started' && this.startedEvent) {\n\t\t\tqueueMicrotask(() => handler(this.startedEvent as ExperienceEvents[K]));\n\t\t}\n\t\treturn unsubscribe;\n\t}\n\n\tasync attach(options: AttachOptions): Promise<LiformaPlayer> {\n\t\tif (this.closed) {\n\t\t\tthrow new Error('Session has ended.');\n\t\t}\n\t\tif (!options.container) {\n\t\t\tthrow new Error('Experience.attach requires a DOM container element.');\n\t\t}\n\t\tif (this.attached && this.iframeHost) {\n\t\t\treturn this.createPlayerFacade();\n\t\t}\n\t\tif (this.attachInFlight) {\n\t\t\treturn this.attachInFlight;\n\t\t}\n\n\t\tthis.attachInFlight = this.attachInternal(options).finally(() => {\n\t\t\tthis.attachInFlight = null;\n\t\t});\n\t\treturn this.attachInFlight;\n\t}\n\n\tprivate async attachInternal(options: AttachOptions): Promise<LiformaPlayer> {\n\t\tif (this.closed) {\n\t\t\tthrow new Error('Session has ended.');\n\t\t}\n\t\tif (this.attached && this.iframeHost) {\n\t\t\treturn this.createPlayerFacade();\n\t\t}\n\t\tif (this.iframeHost) {\n\t\t\tthis.iframeHost.destroy();\n\t\t\tthis.iframeHost = null;\n\t\t}\n\n\t\tconst embedBaseUrl = this.launch.embedBaseUrl ?? resolvePublicPlayerEmbedUrl();\n\t\tconst debug = this.launch.debug === true;\n\t\tconst speechOnly = this.launch.speechOnly === true;\n\t\t// The SDK owns minting for every launch kind and posts the resolved manifest.\n\t\t// Do not put experienceId in the iframe URL or the player will mint a second,\n\t\t// default-mode session before the parent manifest arrives.\n\t\tconst iframeSrc = buildManifestEmbedUrl(\n\t\t\tembedBaseUrl,\n\t\t\tdebug,\n\t\t\tspeechOnly || this.launch.kind === 'manifest' ? undefined : this.launch.locationId,\n\t\t\tspeechOnly || this.launch.kind === 'manifest' ? undefined : this.launch.avatarId,\n\t\t\tthis.launch.fit,\n\t\t\tthis.launch.ui,\n\t\t\toptions.showClose === true\n\t\t);\n\t\tconst playerOrigin = resolvePlayerOrigin(iframeSrc);\n\n\t\tlet resolveLoadingUi: (() => void) | null = null;\n\t\tconst loadingUiPromise = new Promise<void>((resolve) => {\n\t\t\tresolveLoadingUi = resolve;\n\t\t});\n\t\tlet resolveReadyUi: (() => void) | null = null;\n\t\tconst readyUiPromise = new Promise<void>((resolve) => {\n\t\t\tresolveReadyUi = resolve;\n\t\t});\n\t\tconst readyGate = createReadyGate<SessionManifest>((readyManifest) => {\n\t\t\tif (this.readyEvent) return;\n\t\t\tthis.readyEvent = { manifest: readyManifest };\n\t\t\temitExperienceEvent(this.eventRegistry, 'ready', this.readyEvent);\n\t\t});\n\n\t\tconst onUserTranscript = this.launch.onUserTranscript;\n\n\t\tconst iframeHost = createIframeHost({\n\t\t\tcontainer: options.container,\n\t\t\tsrc: iframeSrc,\n\t\t\tplayerOrigin,\n\t\t\ttransparent: this.launch.ui === 'widget',\n\t\t\tonClose: (event) => {\n\t\t\t\tfor (const handler of this.closeHandlers) {\n\t\t\t\t\thandler(event);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonStateUpdate: (state) => {\n\t\t\t\toptions.onStateUpdate?.(state);\n\t\t\t\tif (state === 'loading' && resolveLoadingUi) {\n\t\t\t\t\tresolveLoadingUi();\n\t\t\t\t\tresolveLoadingUi = null;\n\t\t\t\t}\n\t\t\t\tif (state === 'ready' && resolveReadyUi) {\n\t\t\t\t\tresolveReadyUi();\n\t\t\t\t\tresolveReadyUi = null;\n\t\t\t\t}\n\t\t\t\tif (state === 'ready') {\n\t\t\t\t\treadyGate.markReady();\n\t\t\t\t}\n\t\t\t},\n\t\t\tonUserTranscript: (update) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'userTranscript', update);\n\t\t\t\tvoid onUserTranscript?.(update);\n\t\t\t\tthis.queueProcessorTurn(update);\n\t\t\t},\n\t\t\tonUserSpeechStarted: (event) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'userSpeechStarted', event);\n\t\t\t},\n\t\t\tonUserSpeechEnded: (event) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'userSpeechEnded', event);\n\t\t\t},\n\t\t\tonCharacterSpeechStarted: (event: CharacterSpeechEvent) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'characterSpeechStarted', event);\n\t\t\t},\n\t\t\tonCharacterSpeechEnded: (event: CharacterSpeechEvent) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'characterSpeechEnded', event);\n\t\t\t},\n\t\t\tonListeningState: (listening) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'listeningState', listening);\n\t\t\t},\n\t\t\tonModeChange: (mode) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'modeChange', mode);\n\t\t\t},\n\t\t\tonMessage: (message) => {\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'message', message);\n\t\t\t},\n\t\t\tonStarted: (event) => {\n\t\t\t\tif (!this.startedEvent) {\n\t\t\t\t\tthis.startedEvent = event;\n\t\t\t\t\temitExperienceEvent(this.eventRegistry, 'started', event);\n\t\t\t\t\tvoid this.launch.onStart?.(event);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonConversationUpdate: (conversation) => {\n\t\t\t\tthis.conversationCache = conversation;\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'conversationUpdate', conversation);\n\t\t\t},\n\t\t\tonWidgetReady: () => options.onWidgetReady?.(),\n\t\t\tonWidgetExpand: () => options.onWidgetExpand?.(),\n\t\t\tonWidgetCollapse: () => options.onWidgetCollapse?.(),\n\t\t\tonWidgetAudioSettings: (open) => options.onWidgetAudioSettings?.(open),\n\t\t\tonWidgetDragStart: (event) => options.onWidgetDragStart?.(event),\n\t\t\tonWidgetDragMove: (event) => options.onWidgetDragMove?.(event),\n\t\t\tonWidgetDragEnd: (event) => options.onWidgetDragEnd?.(event)\n\t\t});\n\t\tthis.iframeHost = iframeHost;\n\n\t\tconst mintInteraction = this.resolveMintInteraction();\n\n\t\tconst manifestPromise =\n\t\t\tthis.launch.kind === 'sessionEndpoint'\n\t\t\t\t? (() => {\n\t\t\t\t\t\tthis.endpointAbortController = new AbortController();\n\t\t\t\t\t\treturn fetchSessionManifest(this.launch.sessionEndpoint, {\n\t\t\t\t\t\t\texperienceId: this.launch.experienceId,\n\t\t\t\t\t\t\tlanguage: this.launch.language,\n\t\t\t\t\t\t\tmode: mintInteraction.mode,\n\t\t\t\t\t\t\tresponseMode: mintInteraction.responseMode,\n\t\t\t\t\t\t\tspeechInputMode: mintInteraction.speechInputMode,\n\t\t\t\t\t\t\tstartButton: this.launch.startButton,\n\t\t\t\t\t\t\tspeechOnly: this.launch.speechOnly,\n\t\t\t\t\t\t\tsignal: this.endpointAbortController.signal\n\t\t\t\t\t\t});\n\t\t\t\t\t})()\n\t\t\t\t: this.launch.kind === 'public'\n\t\t\t\t\t? mintPublicSession(this.launch.experienceId, {\n\t\t\t\t\t\t\tlanguage: this.launch.language,\n\t\t\t\t\t\t\tmode: mintInteraction.mode,\n\t\t\t\t\t\t\tresponseMode: mintInteraction.responseMode,\n\t\t\t\t\t\t\tspeechInputMode: mintInteraction.speechInputMode,\n\t\t\t\t\t\t\tstartButton: this.launch.startButton,\n\t\t\t\t\t\t\tspeechOnly: this.launch.speechOnly\n\t\t\t\t\t\t})\n\t\t\t\t\t: Promise.resolve(this.launch.kind === 'manifest' ? this.launch.manifest : null);\n\n\t\tlet manifest: SessionManifest | null;\n\t\ttry {\n\t\t\t[, manifest] = await Promise.all([iframeHost.waitForLoad(), manifestPromise]);\n\t\t} catch (error) {\n\t\t\tiframeHost.destroy();\n\t\t\tif (this.iframeHost === iframeHost) {\n\t\t\t\tthis.iframeHost = null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.endpointAbortController = null;\n\t\t}\n\t\tiframeHost.postParentHello();\n\n\t\tif (manifest) {\n\t\t\tlet effectiveManifest = applyStartButtonOptions(manifest, this.launch.startButton);\n\t\t\tif (this.launch.speechOnly) {\n\t\t\t\teffectiveManifest = applySpeechOnlyManifest(effectiveManifest);\n\t\t\t}\n\t\t\tthis.assertBrowserCustomManifest(effectiveManifest);\n\t\t\tthis.resolvedManifest = effectiveManifest;\n\t\t\tiframeHost.postManifest(effectiveManifest);\n\t\t\treadyGate.setValue(effectiveManifest);\n\t\t}\n\n\t\tawait Promise.race([\n\t\t\tloadingUiPromise,\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => reject(new Error('Timed out waiting for player loading UI.')),\n\t\t\t\t\t120_000\n\t\t\t\t);\n\t\t\t})\n\t\t]);\n\n\t\tawait Promise.race([\n\t\t\treadyUiPromise,\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => reject(new Error('Timed out waiting for player ready state.')),\n\t\t\t\t\t120_000\n\t\t\t\t);\n\t\t\t})\n\t\t]);\n\n\t\tthis.attached = true;\n\t\treturn this.createPlayerFacade();\n\t}\n\n\tasync startListening(): Promise<void> {\n\t\tthis.assertSessionStarted();\n\t\tawait this.iframeHost!.startListening();\n\t}\n\n\tasync stopListening(): Promise<UtteranceResult> {\n\t\tthis.assertSessionStarted();\n\t\treturn this.iframeHost!.stopListening();\n\t}\n\n\tasync listenOnce(options?: ListenOnceOptions): Promise<UtteranceResult> {\n\t\tthis.assertSessionStarted();\n\t\treturn this.iframeHost!.listenOnce({\n\t\t\ttimeoutMs: options?.timeoutMs\n\t\t});\n\t}\n\n\tgetConversation(): readonly ConversationMessage[] {\n\t\treturn this.conversationCache;\n\t}\n\n\t/** Parent → player chrome mode for ExperienceWidget warm/cold expand / dock. */\n\tsetWidgetChrome(mode: 'collapsed' | 'loading' | 'expanded' | 'docked'): void {\n\t\tthis.iframeHost?.postWidgetSetChrome(mode);\n\t}\n\n\t/** Parent → player toggle for mic/speaker settings (ExperienceWidget toolbar). */\n\ttoggleAudioSettings(): void {\n\t\tthis.iframeHost?.postWidgetToggleAudioSettings();\n\t}\n\n\tgetLastTurn(): readonly ConversationMessage[] {\n\t\tif (this.conversationCache.length === 0) return [];\n\t\tconst lastTurnId = this.conversationCache[this.conversationCache.length - 1]!.turnId;\n\t\treturn this.conversationCache.filter((m) => m.turnId === lastTurnId);\n\t}\n\n\tasync end(): Promise<void> {\n\t\tthis.close();\n\t}\n\n\tdestroy(): void {\n\t\tif (this.closed) return;\n\t\tthis.closed = true;\n\t\tthis.processorAbortController?.abort();\n\t\tthis.processorAbortController = null;\n\t\tthis.endpointAbortController?.abort();\n\t\tthis.endpointAbortController = null;\n\t\tthis.attachInFlight = null;\n\t\tthis.iframeHost?.destroy();\n\t\tthis.iframeHost = null;\n\t\tclearExperienceEventRegistry(this.eventRegistry);\n\t\tthis.readyEvent = null;\n\t\tthis.startedEvent = null;\n\t\tthis.closeHandlers.length = 0;\n\t\tthis.attached = false;\n\t}\n\n\tprivate resolveMintInteraction(): {\n\t\treadonly mode?: ExperienceMode;\n\t\treadonly responseMode?: ResponseMode;\n\t\treadonly speechInputMode?: SpeechInputMode;\n\t} {\n\t\tif (this.launch.kind === 'manifest') {\n\t\t\treturn {};\n\t\t}\n\t\tconst hasProcessor = this.conversationProcessor !== null;\n\t\treturn {\n\t\t\tmode: this.launch.mode,\n\t\t\tresponseMode: hasProcessor ? 'custom' : this.launch.responseMode,\n\t\t\tspeechInputMode: this.launch.speechInputMode\n\t\t};\n\t}\n\n\tprivate assertBrowserCustomManifest(manifest: SessionManifest): void {\n\t\tif (!this.conversationProcessor) return;\n\t\tif (manifest.experience.responseMode !== 'custom') {\n\t\t\tthrow new Error(\n\t\t\t\t'conversationProcessor requires responseMode custom in the Session Manifest.'\n\t\t\t);\n\t\t}\n\t\tif (manifest.processorId) {\n\t\t\tthrow new Error(\n\t\t\t\t'Browser conversationProcessor cannot be used with a registered processorId.'\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate queueProcessorTurn(update: UserTranscriptUpdate): void {\n\t\tif (!update.isFinal || !update.text.trim() || !this.conversationProcessor) return;\n\n\t\tconst processor = this.conversationProcessor;\n\t\tthis.processorAbortController?.abort();\n\t\tthis.processorAbortController = new AbortController();\n\t\tconst signal = this.processorAbortController.signal;\n\n\t\tthis.processorChain = this.processorChain.then(async () => {\n\t\t\tif (signal.aborted) return;\n\t\t\ttry {\n\t\t\t\tconst dispatch = await dispatchConversationProcessor(processor, {\n\t\t\t\t\tutteranceId: update.utteranceId,\n\t\t\t\t\ttext: update.text,\n\t\t\t\t\tconversation: this.conversationCache,\n\t\t\t\t\tsignal\n\t\t\t\t});\n\t\t\t\tif (signal.aborted) return;\n\t\t\t\tif (dispatch.kind === 'complete') {\n\t\t\t\t\tconst speech = dispatch.speech;\n\t\t\t\t\tawait this.speech.speak({\n\t\t\t\t\t\ttext: speech.text,\n\t\t\t\t\t\t...(speech.characterId ? { characterId: speech.characterId } : {}),\n\t\t\t\t\t\tqueue: speech.behavior === 'interrupt' ? 'replace-active' : 'append'\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.iframeHost!.speakProcessorStream(dispatch.stream, { signal });\n\t\t\t} catch (error) {\n\t\t\t\tif (signal.aborted) return;\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\temitExperienceEvent(this.eventRegistry, 'conversationProcessorError', {\n\t\t\t\t\tutteranceId: update.utteranceId,\n\t\t\t\t\tmessage\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate assertAttached(): void {\n\t\tif (!this.attached || !this.iframeHost) {\n\t\t\tthrow new Error('Call Experience.attach() before using speech APIs.');\n\t\t}\n\t}\n\n\tprivate assertSessionStarted(): void {\n\t\tthis.assertAttached();\n\t\tif (!this.startedEvent) {\n\t\t\tthrow new Error(\n\t\t\t\t'Session has not started. Wait for the player start button and the started event before using speak() or listening APIs.'\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate close(): void {\n\t\tif (this.closed) return;\n\t\tthis.closed = true;\n\t\tthis.endpointAbortController?.abort();\n\t\tthis.endpointAbortController = null;\n\t\tthis.attachInFlight = null;\n\t\tthis.iframeHost?.destroy();\n\t\tthis.iframeHost = null;\n\t\tthis.attached = false;\n\t}\n\n\tprivate createPlayerFacade(): LiformaPlayer {\n\t\treturn {\n\t\t\tclose: () => {\n\t\t\t\tthis.close();\n\t\t\t},\n\t\t\tdestroy: () => {\n\t\t\t\tthis.destroy();\n\t\t\t},\n\t\t\ton: (event, handler) => {\n\t\t\t\tif (event === 'close') {\n\t\t\t\t\tthis.closeHandlers.push(handler);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n}\n\n/** Live session handle returned by {@link Experience.startSession}. */\nexport type ExperienceSession = Experience;\n\nfunction resolveSpeechCapabilities(manifest: SessionManifest | null): SpeechCapabilities {\n\tconst caps = manifest?.capabilities ?? [];\n\tconst explicitText = caps.includes('textSpeech');\n\tconst explicitExternal = caps.includes('externalSpeechAudio');\n\t// Schema 1 manifests omit speech flags — default both on so existing experiences keep working.\n\tif (!explicitText && !explicitExternal) {\n\t\treturn { textSpeech: true, externalSpeechAudio: true };\n\t}\n\treturn {\n\t\ttextSpeech: explicitText,\n\t\texternalSpeechAudio: explicitExternal\n\t};\n}\n","import type { CloseEvent } from './protocol';\n\nfunction resolveIntegrationReturnUrl(returnUrl: string, baseOrigin: string): URL | null {\n\tconst raw = returnUrl.trim();\n\tif (!raw) return null;\n\n\tif (/^https?:\\/\\//i.test(raw)) {\n\t\ttry {\n\t\t\treturn new URL(raw);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst base = baseOrigin.replace(/\\/$/, '');\n\tconst path = raw.startsWith('/') ? raw : `/${raw}`;\n\ttry {\n\t\treturn new URL(path, `${base}/`);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction resolveFallbackReturnUrl(fallbackReturnUrl: string): string {\n\ttry {\n\t\tif (document.referrer) {\n\t\t\tconst referrer = new URL(document.referrer);\n\t\t\tif (\n\t\t\t\treferrer.origin === window.location.origin &&\n\t\t\t\treferrer.pathname !== window.location.pathname\n\t\t\t) {\n\t\t\t\treturn `${referrer.pathname}${referrer.search}${referrer.hash}`;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t/* ignore invalid referrer */\n\t}\n\treturn fallbackReturnUrl;\n}\n\n/** Navigate the host page when an iframe session closes. */\nexport function navigateOnExperienceClose(\n\tdetail: CloseEvent,\n\tfallbackReturnUrl = '/meet'\n): void {\n\tif (detail.reason !== 'user') return;\n\n\tconst target =\n\t\tdetail.returnUrl?.trim() || resolveFallbackReturnUrl(fallbackReturnUrl);\n\tconst url = resolveIntegrationReturnUrl(target, window.location.origin);\n\tif (!url?.protocol.startsWith('http')) return;\n\n\twindow.location.assign(url.toString());\n}\n","export type ExperienceLoadErrorKind =\n\t| 'not_found'\n\t| 'origin_not_allowed'\n\t| 'browser_embeds_disabled'\n\t| 'generic';\n\nexport type ExperienceLoadErrorPresentation = {\n\treadonly kind: ExperienceLoadErrorKind;\n\treadonly title: string;\n\treadonly detail: string;\n\treadonly technicalMessage: string;\n\treadonly experienceId?: string;\n\treadonly origin?: string;\n};\n\nconst EXPERIENCE_ID_IN_MESSAGE =\n\t/\\b(exp_[A-Za-z0-9][A-Za-z0-9_-]{2,127})\\b/;\n\nconst ORIGIN_IN_MESSAGE =\n\t/(?:Your origin|origin)\\s+(\\S+)\\s+is not an allowed origin/i;\n\nfunction toErrorMessage(error: unknown): string {\n\tif (error instanceof Error) return error.message;\n\treturn String(error);\n}\n\nfunction currentPageOrigin(): string | undefined {\n\ttry {\n\t\tif (typeof globalThis.location?.origin === 'string' && globalThis.location.origin) {\n\t\t\treturn globalThis.location.origin;\n\t\t}\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nexport function extractExperienceIdFromMessage(message: string): string | undefined {\n\treturn EXPERIENCE_ID_IN_MESSAGE.exec(message)?.[1];\n}\n\nexport function extractOriginFromMessage(message: string): string | undefined {\n\treturn ORIGIN_IN_MESSAGE.exec(message)?.[1];\n}\n\nexport function presentExperienceLoadError(\n\terror: unknown,\n\toptions?: { readonly experienceId?: string | null; readonly origin?: string | null }\n): ExperienceLoadErrorPresentation {\n\tconst technicalMessage = toErrorMessage(error).trim() || 'Unknown error';\n\tconst experienceId =\n\t\toptions?.experienceId?.trim() ||\n\t\textractExperienceIdFromMessage(technicalMessage) ||\n\t\tundefined;\n\tconst origin =\n\t\toptions?.origin?.trim() ||\n\t\textractOriginFromMessage(technicalMessage) ||\n\t\tcurrentPageOrigin() ||\n\t\tundefined;\n\n\tif (\n\t\t/No playable experience found/i.test(technicalMessage) ||\n\t\t/^Experience is not available\\.?$/i.test(technicalMessage) ||\n\t\t/^Unknown experience\\.?$/i.test(technicalMessage) ||\n\t\t/experience_unavailable/i.test(technicalMessage)\n\t) {\n\t\tconst idLabel = experienceId ?? 'the requested experience';\n\t\treturn {\n\t\t\tkind: 'not_found',\n\t\t\ttitle: 'The application tried to load an avatar experience that doesn’t exist.',\n\t\t\tdetail: `Experience with id ${idLabel} does not exist`,\n\t\t\ttechnicalMessage,\n\t\t\texperienceId,\n\t\t\torigin\n\t\t};\n\t}\n\n\tif (\n\t\t/origin_not_allowed/i.test(technicalMessage) ||\n\t\t/is not an allowed origin/i.test(technicalMessage) ||\n\t\t/^Origin not allowed/i.test(technicalMessage)\n\t) {\n\t\tconst originLabel = origin ?? 'this page';\n\t\tconst idLabel = experienceId ?? 'the requested experience';\n\t\treturn {\n\t\t\tkind: 'origin_not_allowed',\n\t\t\ttitle: 'The application tried to load an avatar experience from a website that isn’t allowed.',\n\t\t\tdetail: `Origin ${originLabel} is not allowed for experience ${idLabel}`,\n\t\t\ttechnicalMessage,\n\t\t\texperienceId,\n\t\t\torigin\n\t\t};\n\t}\n\n\tif (\n\t\t/browser_embeds_disabled/i.test(technicalMessage) ||\n\t\t/^Browser embeds are not enabled/i.test(technicalMessage)\n\t) {\n\t\tconst idLabel = experienceId ?? 'the requested experience';\n\t\treturn {\n\t\t\tkind: 'browser_embeds_disabled',\n\t\t\ttitle: 'The application tried to load an avatar experience that isn’t enabled for browser embeds.',\n\t\t\tdetail: `Browser embeds are not enabled for experience ${idLabel}`,\n\t\t\ttechnicalMessage,\n\t\t\texperienceId,\n\t\t\torigin\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: 'generic',\n\t\ttitle: 'This avatar experience couldn’t be started.',\n\t\tdetail: technicalMessage,\n\t\ttechnicalMessage,\n\t\texperienceId,\n\t\torigin\n\t};\n}\n","/** Subset of session loading overlay styles for pre-attach Experience load errors. */\n\nexport const EXPERIENCE_LOAD_ERROR_STYLE_ID = 'liforma-experience-load-error-styles';\n\nexport function injectExperienceLoadErrorStyles(): void {\n\tif (typeof document === 'undefined') return;\n\tif (document.getElementById(EXPERIENCE_LOAD_ERROR_STYLE_ID)) return;\n\tconst style = document.createElement('style');\n\tstyle.id = EXPERIENCE_LOAD_ERROR_STYLE_ID;\n\tstyle.textContent = EXPERIENCE_LOAD_ERROR_CSS;\n\tdocument.head.append(style);\n}\n\nexport const EXPERIENCE_LOAD_ERROR_CSS = `\n\t.liforma-loading-screen {\n\t\tinset: 0;\n\t\tz-index: 20;\n\t\tbox-sizing: border-box;\n\t\toverflow-x: clip;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tmax-width: 100vw;\n\t\tbackground:\n\t\t\tradial-gradient(circle at 50% 60%, rgba(79, 126, 196, 0.18), transparent 38%),\n\t\t\t#030508;\n\t\tfont-family: system-ui, -apple-system, sans-serif;\n\t\tcolor: #e8f0ff;\n\t\ttext-align: center;\n\t}\n\t.liforma-loading-screen-absolute {\n\t\tposition: absolute;\n\t}\n\t.liforma-loading-card {\n\t\tposition: absolute;\n\t\tleft: 50%;\n\t\ttop: 60%;\n\t\ttransform: translate(-50%, -50%);\n\t\twidth: min(22rem, calc(100% - 2.5rem));\n\t\tmax-width: calc(100% - max(1.25rem, env(safe-area-inset-left, 0px)) - max(1.25rem, env(safe-area-inset-right, 0px)));\n\t\tbox-sizing: border-box;\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tbackground: transparent;\n\t\tbox-shadow: none;\n\t}\n\t.liforma-loading-card-error {\n\t\tdisplay: block;\n\t\ttext-align: center;\n\t\tpadding: 1rem 1.05rem;\n\t\tborder-radius: 14px;\n\t\tborder: 1px solid rgba(255, 154, 154, 0.28);\n\t\tbackground:\n\t\t\tlinear-gradient(180deg, rgba(21, 29, 42, 0.92), rgba(9, 13, 20, 0.92));\n\t}\n\t.liforma-loading-kicker {\n\t\tmargin: 0 0 0.18rem;\n\t\tcolor: #8ba4c5;\n\t\tfont-size: 0.68rem;\n\t\tfont-weight: 700;\n\t\ttext-transform: uppercase;\n\t\tletter-spacing: 0.08em;\n\t}\n\t.liforma-loading-error {\n\t\tmargin: 0;\n\t\tmax-width: 28rem;\n\t\tcolor: #ffb4b4;\n\t\tfont-size: 0.92rem;\n\t\tline-height: 1.4;\n\t}\n\t.liforma-loading-error-title {\n\t\tmargin: 0;\n\t\tcolor: #f6ebe8;\n\t\tfont-size: 0.98rem;\n\t\tfont-weight: 650;\n\t\tline-height: 1.35;\n\t}\n\t.liforma-loading-error-advanced {\n\t\tmargin: 0.85rem 0 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tbackground: transparent;\n\t\tcolor: #9eb7d8;\n\t\tfont: inherit;\n\t\tfont-size: 0.78rem;\n\t\tfont-weight: 650;\n\t\tletter-spacing: 0.02em;\n\t\ttext-decoration: underline;\n\t\ttext-underline-offset: 0.18em;\n\t\tcursor: pointer;\n\t}\n\t.liforma-loading-error-advanced:hover,\n\t.liforma-loading-error-advanced:focus-visible {\n\t\tcolor: #d7e6ff;\n\t\toutline: none;\n\t}\n\t.liforma-loading-error-detail {\n\t\tmargin: 0.7rem 0 0;\n\t\tpadding: 0.65rem 0.7rem;\n\t\tborder-radius: 10px;\n\t\tborder: 1px solid rgba(158, 191, 255, 0.16);\n\t\tbackground: rgba(3, 5, 8, 0.45);\n\t\tcolor: #c6d4e8;\n\t\tfont-size: 0.78rem;\n\t\tfont-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n\t\tline-height: 1.4;\n\t\ttext-align: left;\n\t\tword-break: break-word;\n\t}\n\t.liforma-loading-error-detail[hidden] {\n\t\tdisplay: none;\n\t}\n`;\n","import type { ExperienceLoadErrorPresentation } from './experienceLoadError';\nimport { injectExperienceLoadErrorStyles } from './experienceLoadErrorStyles';\n\nexport type ExperienceLoadErrorOverlay = {\n\treadonly root: HTMLDivElement;\n\tsetPresentation(presentation: ExperienceLoadErrorPresentation): void;\n\tremove(): void;\n};\n\nexport function createExperienceLoadErrorOverlay(\n\tcontainer: HTMLElement,\n\tinitial: ExperienceLoadErrorPresentation\n): ExperienceLoadErrorOverlay {\n\tinjectExperienceLoadErrorStyles();\n\n\tlet presentation = initial;\n\tlet advancedOpen = false;\n\n\tconst root = document.createElement('div');\n\troot.className = 'liforma-loading-screen liforma-loading-screen-absolute';\n\troot.setAttribute('role', 'alert');\n\troot.setAttribute('aria-live', 'assertive');\n\n\tconst card = document.createElement('div');\n\tcard.className = 'liforma-loading-card liforma-loading-card-error';\n\n\tconst kicker = document.createElement('p');\n\tkicker.className = 'liforma-loading-kicker';\n\tkicker.textContent = 'Avatar experience';\n\n\tconst title = document.createElement('p');\n\ttitle.className = 'liforma-loading-error-title';\n\n\tconst advancedBtn = document.createElement('button');\n\tadvancedBtn.type = 'button';\n\tadvancedBtn.className = 'liforma-loading-error-advanced';\n\n\tconst detail = document.createElement('p');\n\tdetail.className = 'liforma-loading-error-detail';\n\n\tadvancedBtn.addEventListener('click', () => {\n\t\tadvancedOpen = !advancedOpen;\n\t\trender();\n\t});\n\n\tcard.append(kicker, title, advancedBtn, detail);\n\troot.append(card);\n\tcontainer.append(root);\n\n\tfunction render(): void {\n\t\ttitle.textContent = presentation.title;\n\t\tdetail.textContent = presentation.detail;\n\t\tdetail.hidden = !advancedOpen;\n\t\tadvancedBtn.textContent = advancedOpen ? 'Hide details' : 'Advanced';\n\t\tadvancedBtn.setAttribute('aria-expanded', advancedOpen ? 'true' : 'false');\n\t}\n\n\trender();\n\n\treturn {\n\t\troot,\n\t\tsetPresentation(next) {\n\t\t\tpresentation = next;\n\t\t\tadvancedOpen = false;\n\t\t\trender();\n\t\t},\n\t\tremove() {\n\t\t\troot.remove();\n\t\t}\n\t};\n}\n","import { Experience } from './experience';\nimport type { CloseEvent } from './embed/protocol';\nimport { navigateOnExperienceClose } from './embed/returnNavigation';\nimport type { ExperienceFit, ExperienceMode, SpeechInputMode } from './types/sessionInteraction';\nimport { presentExperienceLoadError } from '../svelte/experienceLoadError';\nimport {\n\tcreateExperienceLoadErrorOverlay,\n\ttype ExperienceLoadErrorOverlay\n} from '../svelte/experienceLoadErrorOverlay';\n\nconst ELEMENT_NAME = 'liforma-experience';\n\nfunction parseMode(value: string | null): ExperienceMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'conversation' || trimmed === 'presenter' ? trimmed : undefined;\n}\n\nfunction parseSpeechInputMode(value: string | null): SpeechInputMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'auto' || trimmed === 'manual' || trimmed === 'off' ? trimmed : undefined;\n}\n\nfunction parseFit(value: string | null): ExperienceFit | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'full' || trimmed === 'face' ? trimmed : undefined;\n}\n\nexport class LiformaExperienceElement extends HTMLElement {\n\tprivate host: HTMLDivElement | null = null;\n\tprivate errorHost: HTMLDivElement | null = null;\n\tprivate errorOverlay: ExperienceLoadErrorOverlay | null = null;\n\tprivate experience: Experience | null = null;\n\tprivate bootstrapGeneration = 0;\n\n\tstatic get observedAttributes(): string[] {\n\t\treturn [\n\t\t\t'experience-id',\n\t\t\t'language',\n\t\t\t'session-endpoint',\n\t\t\t'speech-only',\n\t\t\t'mode',\n\t\t\t'speech-input-mode',\n\t\t\t'fit'\n\t\t];\n\t}\n\n\tconnectedCallback(): void {\n\t\tthis.style.display = 'block';\n\t\tthis.style.position = 'relative';\n\t\tthis.style.overflow = 'hidden';\n\t\tif (!this.style.width) this.style.width = '100%';\n\t\t// Fill the host box when it has a definite height (flex/grid/explicit).\n\t\t// Do not set minHeight:inherit — that overrides host CSS such as\n\t\t// `.liforma-embed { min-height: 420px }` and collapses absolute children.\n\t\tif (!this.style.height) this.style.height = '100%';\n\t\tconst computedMinHeight = getComputedStyle(this).minHeight;\n\t\tif (\n\t\t\t!this.style.minHeight &&\n\t\t\t(computedMinHeight === '0px' || computedMinHeight === 'auto')\n\t\t) {\n\t\t\tthis.style.minHeight = '480px';\n\t\t}\n\n\t\tif (!this.errorHost) {\n\t\t\tthis.errorHost = document.createElement('div');\n\t\t\tthis.errorHost.style.cssText =\n\t\t\t\t'position:absolute;inset:0;z-index:20;pointer-events:none;';\n\t\t\tthis.append(this.errorHost);\n\t\t}\n\n\t\tif (!this.host) {\n\t\t\tthis.host = document.createElement('div');\n\t\t\t// Absolute fill avoids height:100% collapsing when size comes from flex/min-height.\n\t\t\tthis.host.style.cssText = 'position:absolute;inset:0;overflow:hidden;';\n\t\t\tthis.append(this.host);\n\t\t}\n\n\t\tvoid this.bootstrap();\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tthis.bootstrapGeneration += 1;\n\t\tthis.experience?.destroy();\n\t\tthis.experience = null;\n\t\tthis.clearError();\n\t}\n\n\tattributeChangedCallback(\n\t\tname: string,\n\t\toldValue: string | null,\n\t\tnewValue: string | null\n\t): void {\n\t\tif (\n\t\t\tname !== 'experience-id' &&\n\t\t\tname !== 'language' &&\n\t\t\tname !== 'session-endpoint' &&\n\t\t\tname !== 'speech-only' &&\n\t\t\tname !== 'mode' &&\n\t\t\tname !== 'speech-input-mode' &&\n\t\t\tname !== 'fit'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (oldValue === newValue || !this.isConnected) {\n\t\t\treturn;\n\t\t}\n\t\tthis.bootstrapGeneration += 1;\n\t\tthis.experience?.destroy();\n\t\tthis.experience = null;\n\t\tthis.clearError();\n\t\tif (this.host) {\n\t\t\tthis.host.replaceChildren();\n\t\t}\n\t\tvoid this.bootstrap();\n\t}\n\n\tprivate async bootstrap(): Promise<void> {\n\t\tconst experienceId = this.getAttribute('experience-id')?.trim();\n\t\tconst sessionEndpoint = this.getAttribute('session-endpoint')?.trim();\n\t\tconst languageAttr = this.getAttribute('language')?.trim();\n\t\tconst language = languageAttr === 'es' || languageAttr === 'en' ? languageAttr : undefined;\n\t\tconst speechOnly = this.getAttribute('speech-only') === 'true';\n\t\tconst mode = parseMode(this.getAttribute('mode'));\n\t\tconst speechInputMode = parseSpeechInputMode(this.getAttribute('speech-input-mode'));\n\t\tconst fit = parseFit(this.getAttribute('fit'));\n\t\tif (!experienceId || !this.host) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst generation = ++this.bootstrapGeneration;\n\t\tthis.clearError();\n\n\t\ttry {\n\t\t\tconst experience = await Experience.startSession(\n\t\t\t\tsessionEndpoint\n\t\t\t\t\t? {\n\t\t\t\t\t\t\texperienceId,\n\t\t\t\t\t\t\tsessionEndpoint,\n\t\t\t\t\t\t\tlanguage,\n\t\t\t\t\t\t\tspeechOnly,\n\t\t\t\t\t\t\tmode,\n\t\t\t\t\t\t\tspeechInputMode,\n\t\t\t\t\t\t\tfit\n\t\t\t\t\t\t}\n\t\t\t\t\t: { experienceId, language, speechOnly, mode, speechInputMode, fit }\n\t\t\t);\n\t\t\tif (generation !== this.bootstrapGeneration) {\n\t\t\t\texperience.destroy();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.experience = experience;\n\t\t\tconst player = await experience.attach({ container: this.host });\n\t\t\tif (generation !== this.bootstrapGeneration) {\n\t\t\t\texperience.destroy();\n\t\t\t\tthis.experience = null;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tplayer.on('close', (detail: CloseEvent) => {\n\t\t\t\tthis.dispatchEvent(new CustomEvent<CloseEvent>('close', { detail, bubbles: true }));\n\t\t\t\tnavigateOnExperienceClose(detail);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (generation !== this.bootstrapGeneration) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.showError(error, experienceId);\n\t\t\tconsole.error('[liforma-experience]', error);\n\t\t\tthis.experience?.destroy();\n\t\t\tthis.experience = null;\n\t\t}\n\t}\n\n\tprivate showError(error: unknown, experienceId?: string): void {\n\t\tthis.clearError();\n\t\tif (!this.errorHost) return;\n\t\tthis.errorHost.style.pointerEvents = 'auto';\n\t\tthis.errorOverlay = createExperienceLoadErrorOverlay(\n\t\t\tthis.errorHost,\n\t\t\tpresentExperienceLoadError(error, { experienceId })\n\t\t);\n\t}\n\n\tprivate clearError(): void {\n\t\tthis.errorOverlay?.remove();\n\t\tthis.errorOverlay = null;\n\t\tif (this.errorHost) {\n\t\t\tthis.errorHost.style.pointerEvents = 'none';\n\t\t\tthis.errorHost.replaceChildren();\n\t\t}\n\t}\n}\n\nif (typeof customElements !== 'undefined' && !customElements.get(ELEMENT_NAME)) {\n\tcustomElements.define(ELEMENT_NAME, LiformaExperienceElement);\n}\n","const AVATAR_TIER_RE = /(\\/avatars\\/[^/]+\\/)(\\d+)(\\/)/i;\nconst LOCATION_SIZE_RE = /(-)(\\d+x\\d+)(\\.webp)(\\?|$)/i;\n\n/**\n * Rewrite known Liforma CDN URLs to gallery thumb tiers.\n * Avatars: /{tier}/ → /256/; locations: -{WxH}.webp → -256x256.webp.\n * Unrecognized URLs are returned unchanged.\n */\nexport function toGalleryThumbUrl(url: string): string {\n\tconst raw = url.trim();\n\tif (!raw) return raw;\n\n\tlet next = raw.replace(AVATAR_TIER_RE, (_match, prefix: string, tier: string, slash: string) => {\n\t\tif (tier === '256') return `${prefix}${tier}${slash}`;\n\t\treturn `${prefix}256${slash}`;\n\t});\n\n\tnext = next.replace(\n\t\tLOCATION_SIZE_RE,\n\t\t(_match, dash: string, size: string, ext: string, end: string) => {\n\t\t\tif (size === '256x256') return `${dash}${size}${ext}${end}`;\n\t\t\treturn `${dash}256x256${ext}${end}`;\n\t\t}\n\t);\n\n\treturn next;\n}\n\nexport function resolveThumbnailLayers(input: {\n\treadonly galleryThumb?: {\n\t\treadonly avatarImage?: string;\n\t\treadonly backgroundImage?: string;\n\t\treadonly foregroundImage?: string;\n\t};\n\treadonly avatarImage?: string;\n\treadonly backgroundImage?: string;\n\treadonly foregroundImage?: string;\n\treadonly fallbackImage?: string;\n}): {\n\treadonly avatarImage: string;\n\treadonly backgroundImage?: string;\n\treadonly foregroundImage?: string;\n\treadonly fallbackImage?: string;\n} | null {\n\tconst avatarSource =\n\t\tinput.avatarImage?.trim() ||\n\t\tinput.galleryThumb?.avatarImage?.trim() ||\n\t\t'';\n\tif (!avatarSource) return null;\n\n\tconst backgroundSource =\n\t\tinput.backgroundImage?.trim() || input.galleryThumb?.backgroundImage?.trim() || '';\n\tconst foregroundSource =\n\t\tinput.foregroundImage?.trim() || input.galleryThumb?.foregroundImage?.trim() || '';\n\tconst fallbackSource = input.fallbackImage?.trim() || '';\n\n\treturn {\n\t\tavatarImage: toGalleryThumbUrl(avatarSource),\n\t\t...(backgroundSource ? { backgroundImage: toGalleryThumbUrl(backgroundSource) } : {}),\n\t\t...(foregroundSource ? { foregroundImage: toGalleryThumbUrl(foregroundSource) } : {}),\n\t\t...(fallbackSource ? { fallbackImage: toGalleryThumbUrl(fallbackSource) } : {})\n\t};\n}\n","import { useExplicitLocalStack } from '../shims/localStack';\nimport type { ResolveThumbnailInteractionInput, ThumbnailInteractionKind } from './types';\n\nconst PRODUCTION_PLAYER_ORIGIN = 'https://player.liforma.ai';\nconst LOCAL_PLAYER_ORIGIN = 'http://localhost:3002';\n\n/** Priority: href → click-only → hosted (experienceId) → presentational. */\nexport function resolveThumbnailInteraction(\n\tinput: ResolveThumbnailInteractionInput\n): ThumbnailInteractionKind {\n\tif (input.href?.trim()) return 'anchor';\n\tif (input.hasClickHandler) return 'button';\n\tif (input.experienceId?.trim()) return 'anchor';\n\treturn 'presentational';\n}\n\nexport function resolvePlayerBaseUrl(playerBaseUrl?: string): string {\n\tconst configured = playerBaseUrl?.trim();\n\tif (configured) return configured.replace(/\\/$/, '');\n\n\tif (useExplicitLocalStack()) {\n\t\treturn LOCAL_PLAYER_ORIGIN;\n\t}\n\n\treturn PRODUCTION_PLAYER_ORIGIN;\n}\n\n/**\n * Build hosted player launch URL: `{player}/{experienceId}?returnUrl=…`\n * When `returnUrl` is omitted, callers should assign on click (SSR-safe) or pass an explicit URL.\n */\nexport function buildHostedLaunchUrl(options: {\n\treadonly experienceId: string;\n\treadonly returnUrl?: string;\n\treadonly playerBaseUrl?: string;\n}): string {\n\tconst experienceId = options.experienceId.trim();\n\tconst base = resolvePlayerBaseUrl(options.playerBaseUrl);\n\tconst url = new URL(`${base}/${encodeURIComponent(experienceId)}`);\n\tconst returnUrl = options.returnUrl?.trim();\n\tif (returnUrl) {\n\t\turl.searchParams.set('returnUrl', returnUrl);\n\t}\n\treturn url.toString();\n}\n\n/** Resolve href for anchor mode (app link or hosted launch). */\nexport function resolveThumbnailHref(options: {\n\treadonly href?: string;\n\treadonly experienceId?: string;\n\treadonly returnUrl?: string;\n\treadonly playerBaseUrl?: string;\n\t/** When true and returnUrl omitted, use window.location.href (browser only). */\n\treadonly useCurrentPageAsReturnUrl?: boolean;\n}): string | undefined {\n\tconst href = options.href?.trim();\n\tif (href) return href;\n\n\tconst experienceId = options.experienceId?.trim();\n\tif (!experienceId) return undefined;\n\n\tlet returnUrl = options.returnUrl?.trim();\n\tif (!returnUrl && options.useCurrentPageAsReturnUrl && typeof window !== 'undefined') {\n\t\treturnUrl = window.location.href;\n\t}\n\n\treturn buildHostedLaunchUrl({\n\t\texperienceId,\n\t\t...(returnUrl ? { returnUrl } : {}),\n\t\tplayerBaseUrl: options.playerBaseUrl\n\t});\n}\n","/** Touch / coarse pointers — limit how many thumbs start loading at once. */\nexport const COARSE_THUMB_LOAD_CONCURRENCY = 4;\n/** Delay before a started thumb frees its queue slot for the next card. */\nexport const COARSE_THUMB_LOAD_STAGGER_MS = 160;\n\nexport function prefersCoarsePointer(): boolean {\n\tif (typeof window === 'undefined') return false;\n\treturn window.matchMedia('(hover: none), (pointer: coarse)').matches;\n}\n\ntype QueuedLoad = {\n\treadonly start: () => void;\n\tcancelled: boolean;\n};\n\nlet inflight = 0;\nconst waiting: QueuedLoad[] = [];\n\nfunction maxConcurrent(): number {\n\treturn prefersCoarsePointer() ? COARSE_THUMB_LOAD_CONCURRENCY : Number.POSITIVE_INFINITY;\n}\n\nfunction staggerMs(): number {\n\treturn prefersCoarsePointer() ? COARSE_THUMB_LOAD_STAGGER_MS : 0;\n}\n\nfunction pump(): void {\n\tconst limit = maxConcurrent();\n\twhile (inflight < limit && waiting.length > 0) {\n\t\tconst next = waiting.shift();\n\t\tif (!next || next.cancelled) continue;\n\t\tinflight += 1;\n\t\tnext.start();\n\t\tconst delay = staggerMs();\n\t\tif (delay <= 0) {\n\t\t\tinflight = Math.max(0, inflight - 1);\n\t\t\tcontinue;\n\t\t}\n\t\twindow.setTimeout(() => {\n\t\t\tinflight = Math.max(0, inflight - 1);\n\t\t\tpump();\n\t\t}, delay);\n\t}\n}\n\n/**\n * On coarse pointers, start thumb image loads in small waves so old devices\n * are not hit with dozens of concurrent decodes. Fine pointers start immediately.\n * Returns a cancel function (no-op after start has run).\n */\nexport function scheduleThumbLoad(start: () => void): () => void {\n\tif (!prefersCoarsePointer()) {\n\t\tstart();\n\t\treturn () => {};\n\t}\n\n\tconst item: QueuedLoad = { start, cancelled: false };\n\twaiting.push(item);\n\tpump();\n\n\treturn () => {\n\t\titem.cancelled = true;\n\t};\n}\n\n/** Test helper — clear queue state between vitest cases. */\nexport function resetThumbLoadSchedulerForTests(): void {\n\tinflight = 0;\n\twaiting.length = 0;\n}\n","import { prefersCoarsePointer, scheduleThumbLoad } from './thumbLoadScheduler';\n\nexport type LazyThumbOptions = {\n\treadonly rootMargin?: string;\n\treadonly onVisibleChange: (visible: boolean) => void;\n};\n\n/** Desktop: prefetch earlier. Coarse/touch: tighter margin to cut burst loads. */\nexport function getDefaultLazyRootMargin(): string {\n\treturn prefersCoarsePointer() ? '96px 0px' : '280px 0px';\n}\n\nfunction parseVerticalRootMarginPx(rootMargin: string): number {\n\tconst first = rootMargin.trim().split(/\\s+/)[0] ?? '0px';\n\tconst value = Number.parseFloat(first);\n\treturn Number.isFinite(value) ? Math.abs(value) : 280;\n}\n\nfunction isNearViewport(element: HTMLElement, marginPx: number): boolean {\n\tif (typeof window === 'undefined') return false;\n\tconst rect = element.getBoundingClientRect();\n\treturn rect.bottom >= -marginPx && rect.top <= window.innerHeight + marginPx;\n}\n\n/** Observe the thumb and enable image loads when near the viewport. */\nexport function attachLazyThumb(element: HTMLElement, options: LazyThumbOptions): () => void {\n\tconst { onVisibleChange } = options;\n\tconst rootMargin = options.rootMargin ?? getDefaultLazyRootMargin();\n\tconst marginPx = parseVerticalRootMarginPx(rootMargin);\n\tlet visible = false;\n\tlet loadStarted = false;\n\tlet cancelScheduled: (() => void) | null = null;\n\n\tconst requestLoad = () => {\n\t\tif (loadStarted) return;\n\t\tcancelScheduled?.();\n\t\tcancelScheduled = scheduleThumbLoad(() => {\n\t\t\tcancelScheduled = null;\n\t\t\tloadStarted = true;\n\t\t\tonVisibleChange(true);\n\t\t});\n\t};\n\n\tconst setVisible = (next: boolean) => {\n\t\tif (next === visible) return;\n\t\tvisible = next;\n\t\tif (next) {\n\t\t\trequestLoad();\n\t\t\treturn;\n\t\t}\n\t\t// Keep images once started; only cancel a queued (not-yet-started) load.\n\t\tcancelScheduled?.();\n\t\tcancelScheduled = null;\n\t\tonVisibleChange(false);\n\t};\n\n\tif (typeof IntersectionObserver === 'undefined') {\n\t\trequestLoad();\n\t\treturn () => {\n\t\t\tcancelScheduled?.();\n\t\t\tcancelScheduled = null;\n\t\t};\n\t}\n\n\tconst observer = new IntersectionObserver(\n\t\t(entries) => {\n\t\t\tsetVisible(entries.some((entry) => entry.isIntersecting));\n\t\t},\n\t\t{ root: null, rootMargin, threshold: 0 }\n\t);\n\n\tobserver.observe(element);\n\n\tif (isNearViewport(element, marginPx)) {\n\t\tsetVisible(true);\n\t}\n\n\treturn () => {\n\t\tcancelScheduled?.();\n\t\tcancelScheduled = null;\n\t\tobserver.disconnect();\n\t};\n}\n\nexport function attachImageReady(element: HTMLImageElement, onReady: () => void): () => void {\n\tconst notify = () => onReady();\n\tif (element.complete) {\n\t\tqueueMicrotask(notify);\n\t} else {\n\t\telement.addEventListener('load', notify, { once: true });\n\t\telement.addEventListener('error', notify, { once: true });\n\t}\n\treturn () => {\n\t\telement.removeEventListener('load', notify);\n\t\telement.removeEventListener('error', notify);\n\t};\n}\n","/** Touch devices without hover — drive thumbnail parallax from scroll position. */\nexport function prefersScrollLinkedParallax(): boolean {\n\tif (typeof window === 'undefined') return false;\n\tif (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return false;\n\treturn window.matchMedia('(hover: none), (pointer: coarse)').matches;\n}\n\n/**\n * Map an element's vertical centre in the viewport to horizontal parallax in [-1, 1].\n */\nexport function horizontalParallaxFromViewportY(rect: DOMRect, viewportHeight: number): number {\n\tconst centerY = rect.top + rect.height / 2;\n\tconst t = centerY / Math.max(viewportHeight, 1);\n\treturn (t - 0.5) * 2;\n}\n\nexport type ScrollLinkedParallaxOptions = {\n\treadonly onParallax: (x: number) => void;\n\treadonly pointerActive?: () => boolean;\n};\n\ntype ScrollParallaxSubscriber = {\n\treadonly element: HTMLElement;\n\treadonly onParallax: (x: number) => void;\n\treadonly pointerActive?: () => boolean;\n};\n\nconst subscribers = new Set<ScrollParallaxSubscriber>();\nlet listening = false;\nlet frame = 0;\n\nfunction syncAll(): void {\n\tframe = 0;\n\tif (subscribers.size === 0 || typeof window === 'undefined') return;\n\tconst viewportHeight = window.innerHeight;\n\tfor (const entry of subscribers) {\n\t\tif (entry.pointerActive?.()) continue;\n\t\tconst rect = entry.element.getBoundingClientRect();\n\t\t// Skip off-screen thumbs — avoids N layout reads + framework updates per scroll.\n\t\tif (rect.bottom < -64 || rect.top > viewportHeight + 64) continue;\n\t\tentry.onParallax(horizontalParallaxFromViewportY(rect, viewportHeight));\n\t}\n}\n\nfunction scheduleSync(): void {\n\tif (frame !== 0) return;\n\tframe = requestAnimationFrame(syncAll);\n}\n\nfunction ensureListening(): void {\n\tif (listening || typeof window === 'undefined') return;\n\tlistening = true;\n\twindow.addEventListener('scroll', scheduleSync, { passive: true });\n\twindow.addEventListener('resize', scheduleSync, { passive: true });\n}\n\nfunction stopListeningIfIdle(): void {\n\tif (subscribers.size > 0 || !listening || typeof window === 'undefined') return;\n\tlistening = false;\n\tif (frame !== 0) {\n\t\tcancelAnimationFrame(frame);\n\t\tframe = 0;\n\t}\n\twindow.removeEventListener('scroll', scheduleSync);\n\twindow.removeEventListener('resize', scheduleSync);\n}\n\n/**\n * Subscribe to scroll/resize and update horizontal parallax from viewport Y.\n * Uses one shared window listener for all thumbs (old iPads with large galleries).\n */\nexport function attachScrollLinkedParallax(\n\telement: HTMLElement,\n\toptions: ScrollLinkedParallaxOptions\n): () => void {\n\tif (!prefersScrollLinkedParallax()) return () => {};\n\n\tconst entry: ScrollParallaxSubscriber = {\n\t\telement,\n\t\tonParallax: options.onParallax,\n\t\tpointerActive: options.pointerActive\n\t};\n\tsubscribers.add(entry);\n\tensureListening();\n\n\tif (!entry.pointerActive?.()) {\n\t\toptions.onParallax(\n\t\t\thorizontalParallaxFromViewportY(element.getBoundingClientRect(), window.innerHeight)\n\t\t);\n\t}\n\n\treturn () => {\n\t\tsubscribers.delete(entry);\n\t\tstopListeningIfIdle();\n\t};\n}\n\n/** Test helper — clear shared scroll state between vitest cases. */\nexport function resetScrollLinkedParallaxForTests(): void {\n\tsubscribers.clear();\n\tif (typeof window !== 'undefined' && listening) {\n\t\twindow.removeEventListener('scroll', scheduleSync);\n\t\twindow.removeEventListener('resize', scheduleSync);\n\t}\n\tlistening = false;\n\tif (frame !== 0) {\n\t\tcancelAnimationFrame(frame);\n\t\tframe = 0;\n\t}\n}\n","import {\n\tattachScrollLinkedParallax,\n\thorizontalParallaxFromViewportY\n} from './scrollParallax';\n\n/**\n * Drive `--liforma-et-parallax-*` CSS vars and `liforma-et--parallax` /\n * `liforma-et--scroll-parallax` classes from pointer (desktop) or scroll (touch).\n * Matches ExperienceThumbnail / `<liforma-experience-thumbnail>` behaviour.\n */\nexport function attachThumbnailParallax(root: HTMLElement): () => void {\n\tlet parallaxX = 0;\n\tlet parallaxY = 0;\n\tlet hovering = false;\n\tlet scrollParallax = false;\n\tlet pointerDown = false;\n\n\tconst sync = () => {\n\t\tconst parallaxActive = hovering || scrollParallax;\n\t\troot.classList.toggle('liforma-et--parallax', parallaxActive);\n\t\troot.classList.toggle('liforma-et--scroll-parallax', scrollParallax);\n\t\troot.style.setProperty('--liforma-et-parallax-x', String(parallaxX));\n\t\troot.style.setProperty('--liforma-et-parallax-y', String(parallaxY));\n\t};\n\n\tconst detachScroll = attachScrollLinkedParallax(root, {\n\t\tonParallax: (x) => {\n\t\t\tscrollParallax = true;\n\t\t\tif (!pointerDown) {\n\t\t\t\tparallaxX = x;\n\t\t\t\tparallaxY = 0;\n\t\t\t\tsync();\n\t\t\t}\n\t\t},\n\t\tpointerActive: () => pointerDown\n\t});\n\n\tconst onPointerMove = (event: PointerEvent) => {\n\t\tif (scrollParallax) return;\n\t\tconst rect = root.getBoundingClientRect();\n\t\tif (rect.width <= 0 || rect.height <= 0) return;\n\t\tparallaxX = ((event.clientX - rect.left) / rect.width - 0.5) * 2;\n\t\tparallaxY = ((event.clientY - rect.top) / rect.height - 0.5) * 2;\n\t\tsync();\n\t};\n\n\tconst onPointerDown = (event: PointerEvent) => {\n\t\tpointerDown = true;\n\t\tif (event.pointerType === 'mouse') hovering = true;\n\t\tsync();\n\t};\n\n\tconst onPointerUp = () => {\n\t\tconst wasDown = pointerDown;\n\t\tpointerDown = false;\n\t\thovering = false;\n\t\tif (scrollParallax && wasDown) {\n\t\t\tparallaxX = horizontalParallaxFromViewportY(\n\t\t\t\troot.getBoundingClientRect(),\n\t\t\t\twindow.innerHeight\n\t\t\t);\n\t\t\tparallaxY = 0;\n\t\t} else if (!scrollParallax) {\n\t\t\tparallaxX = 0;\n\t\t\tparallaxY = 0;\n\t\t}\n\t\tsync();\n\t};\n\n\tconst onPointerEnter = (event: PointerEvent) => {\n\t\tif (event.pointerType === 'mouse') {\n\t\t\thovering = true;\n\t\t\tsync();\n\t\t}\n\t};\n\n\tconst onPointerLeave = () => {\n\t\tif (!pointerDown) {\n\t\t\thovering = false;\n\t\t\tif (!scrollParallax) {\n\t\t\t\tparallaxX = 0;\n\t\t\t\tparallaxY = 0;\n\t\t\t}\n\t\t\tsync();\n\t\t}\n\t};\n\n\troot.addEventListener('pointermove', onPointerMove);\n\troot.addEventListener('pointerdown', onPointerDown);\n\troot.addEventListener('pointerup', onPointerUp);\n\troot.addEventListener('pointercancel', onPointerUp);\n\troot.addEventListener('pointerenter', onPointerEnter);\n\troot.addEventListener('pointerleave', onPointerLeave);\n\n\treturn () => {\n\t\tdetachScroll();\n\t\troot.removeEventListener('pointermove', onPointerMove);\n\t\troot.removeEventListener('pointerdown', onPointerDown);\n\t\troot.removeEventListener('pointerup', onPointerUp);\n\t\troot.removeEventListener('pointercancel', onPointerUp);\n\t\troot.removeEventListener('pointerenter', onPointerEnter);\n\t\troot.removeEventListener('pointerleave', onPointerLeave);\n\t\troot.classList.remove('liforma-et--parallax', 'liforma-et--scroll-parallax');\n\t\troot.style.removeProperty('--liforma-et-parallax-x');\n\t\troot.style.removeProperty('--liforma-et-parallax-y');\n\t};\n}\n","/** Shared styles for ExperienceThumbnail (class prefix `liforma-et`). */\nexport const EXPERIENCE_THUMBNAIL_CSS = `\n.liforma-et {\n\t--liforma-et-parallax-x: 0;\n\t--liforma-et-parallax-y: 0;\n\t--liforma-et-bg-scale: 1;\n\t--liforma-et-fg-scale: 1;\n\t--liforma-et-avatar-scale: 1;\n\t--liforma-et-bg-shift: 0px;\n\t--liforma-et-fg-shift: 0px;\n\t--liforma-et-avatar-shift: 0px;\n\t--liforma-et-reveal-duration: 420ms;\n\n\tbox-sizing: border-box;\n\tposition: relative;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tmin-height: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tborder-radius: 0.65rem;\n\toverflow: hidden;\n\tbackground: #111;\n\tcolor: inherit;\n\ttext-decoration: none;\n\tcursor: inherit;\n\t-webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n\tcursor: pointer;\n}\n\nbutton.liforma-et {\n\tfont: inherit;\n\tappearance: none;\n}\n\n.liforma-et__placeholder {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 0;\n\tbackground:\n\t\tradial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n\t\tlinear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n\topacity: 1;\n\ttransition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n\topacity: 0;\n}\n\n.liforma-et__media {\n\topacity: 0;\n\ttransition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n\topacity: 1;\n}\n\n.liforma-et__background {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\twidth: 100%;\n\theight: 100%;\n\tobject-fit: cover;\n\tobject-position: center center;\n\ttransform: translate(\n\t\t\tcalc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n\t\t\tcalc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n\t\t)\n\t\tscale(var(--liforma-et-bg-scale));\n\ttransform-origin: center center;\n\ttransition:\n\t\topacity var(--liforma-et-reveal-duration) ease,\n\t\ttransform 160ms ease;\n}\n\n.liforma-et__avatar {\n\tposition: relative;\n\tz-index: 2;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tobject-fit: cover;\n\tobject-position: 50% 30%;\n\ttransform: scale(var(--liforma-et-avatar-scale))\n\t\ttranslate(\n\t\t\tcalc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n\t\t\tcalc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n\t\t);\n\ttransform-origin: center center;\n\ttransition:\n\t\topacity var(--liforma-et-reveal-duration) ease,\n\t\ttransform 160ms ease;\n}\n\n.liforma-et--scene .liforma-et__avatar {\n\tobject-fit: contain;\n\tobject-position: center bottom;\n}\n\n.liforma-et__foreground {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 3;\n\twidth: 100%;\n\theight: 100%;\n\tobject-fit: cover;\n\tobject-position: center center;\n\tpointer-events: none;\n\ttransform: translate(\n\t\t\tcalc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n\t\t\tcalc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n\t\t)\n\t\tscale(var(--liforma-et-fg-scale));\n\ttransform-origin: center center;\n\ttransition:\n\t\topacity var(--liforma-et-reveal-duration) ease,\n\t\ttransform 160ms ease;\n}\n\n.liforma-et--parallax {\n\t--liforma-et-bg-scale: 1.08;\n\t--liforma-et-fg-scale: 1.05;\n\t--liforma-et-avatar-scale: 1.08;\n\t--liforma-et-bg-shift: 10px;\n\t--liforma-et-fg-shift: 4px;\n\t--liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n\twill-change: transform;\n}\n\n.liforma-et--parallax:not(.liforma-et--scene) {\n\t--liforma-et-avatar-scale: 1.05;\n\t--liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n\ttransition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.liforma-et {\n\t\t--liforma-et-reveal-duration: 0ms;\n\t}\n\n\t.liforma-et--parallax {\n\t\t--liforma-et-bg-scale: 1;\n\t\t--liforma-et-fg-scale: 1;\n\t\t--liforma-et-avatar-scale: 1;\n\t\t--liforma-et-bg-shift: 0px;\n\t\t--liforma-et-fg-shift: 0px;\n\t\t--liforma-et-avatar-shift: 0px;\n\t}\n\n\t.liforma-et__background,\n\t.liforma-et__foreground,\n\t.liforma-et__avatar {\n\t\ttransition: none;\n\t}\n}\n`.trim();\n","let styleMounted = false;\n\n/** Inject shared thumbnail CSS once per document. */\nexport function ensureExperienceThumbnailStyles(css: string): void {\n\tif (typeof document === 'undefined' || styleMounted) return;\n\tif (document.querySelector('style[data-liforma-et]')) {\n\t\tstyleMounted = true;\n\t\treturn;\n\t}\n\tconst style = document.createElement('style');\n\tstyle.setAttribute('data-liforma-et', '');\n\tstyle.textContent = css;\n\tdocument.head.appendChild(style);\n\tstyleMounted = true;\n}\n","import {\n\tattachImageReady,\n\tattachLazyThumb,\n\tattachScrollLinkedParallax,\n\tEXPERIENCE_THUMBNAIL_CSS,\n\thorizontalParallaxFromViewportY,\n\tresolveThumbnailHref,\n\tresolveThumbnailInteraction,\n\tresolveThumbnailLayers,\n\ttype GalleryThumb\n} from '../thumbnail/index';\n\nconst ELEMENT_NAME = 'liforma-experience-thumbnail';\n\nfunction parseGalleryThumb(raw: string | null): GalleryThumb | undefined {\n\tif (!raw?.trim()) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as GalleryThumb;\n\t\tif (parsed && typeof parsed.avatarImage === 'string') return parsed;\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nclass LiformaExperienceThumbnailElement extends HTMLElement {\n\tstatic get observedAttributes(): string[] {\n\t\treturn [\n\t\t\t'experience-id',\n\t\t\t'gallery-thumb',\n\t\t\t'avatar-image',\n\t\t\t'background-image',\n\t\t\t'foreground-image',\n\t\t\t'fallback-image',\n\t\t\t'alt',\n\t\t\t'href',\n\t\t\t'target',\n\t\t\t'rel',\n\t\t\t'return-url',\n\t\t\t'player-base-url',\n\t\t\t'parallax',\n\t\t\t'lazy'\n\t\t];\n\t}\n\n\t#root: HTMLElement | null = null;\n\t#cleanup: (() => void)[] = [];\n\t#shouldLoad = false;\n\t#hovering = false;\n\t#pointerDown = false;\n\t#scrollParallax = false;\n\t#parallaxX = 0;\n\t#parallaxY = 0;\n\t#avatarLoadFailed = false;\n\t#backgroundReady = false;\n\t#avatarReady = false;\n\t#foregroundReady = false;\n\n\tconnectedCallback(): void {\n\t\tthis.#render();\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tthis.#teardown();\n\t}\n\n\tattributeChangedCallback(): void {\n\t\tif (this.isConnected) this.#render();\n\t}\n\n\t#teardown(): void {\n\t\tfor (const fn of this.#cleanup) fn();\n\t\tthis.#cleanup = [];\n\t\tthis.#root = null;\n\t}\n\n\t#boolAttr(name: string, defaultValue: boolean): boolean {\n\t\tif (!this.hasAttribute(name)) return defaultValue;\n\t\tconst value = this.getAttribute(name);\n\t\tif (value === null || value === '' || value === 'true') return true;\n\t\tif (value === 'false') return false;\n\t\treturn defaultValue;\n\t}\n\n\t#render(): void {\n\t\tthis.#teardown();\n\n\t\tconst shadow = this.shadowRoot ?? this.attachShadow({ mode: 'open' });\n\t\tconst style = document.createElement('style');\n\t\tstyle.textContent = EXPERIENCE_THUMBNAIL_CSS;\n\t\tshadow.replaceChildren(style);\n\n\t\tconst alt = this.getAttribute('alt')?.trim() || 'Experience';\n\t\tconst hrefAttr = this.getAttribute('href');\n\t\tconst experienceId = this.getAttribute('experience-id');\n\t\tconst hasClickHandler = this.hasAttribute('onclick') || typeof this.onclick === 'function';\n\t\tconst interaction = resolveThumbnailInteraction({\n\t\t\thref: hrefAttr,\n\t\t\thasClickHandler,\n\t\t\texperienceId\n\t\t});\n\n\t\tconst layers = resolveThumbnailLayers({\n\t\t\tgalleryThumb: parseGalleryThumb(this.getAttribute('gallery-thumb')),\n\t\t\tavatarImage: this.getAttribute('avatar-image') ?? undefined,\n\t\t\tbackgroundImage: this.getAttribute('background-image') ?? undefined,\n\t\t\tforegroundImage: this.getAttribute('foreground-image') ?? undefined,\n\t\t\tfallbackImage: this.getAttribute('fallback-image') ?? undefined\n\t\t});\n\t\tif (!layers) return;\n\n\t\tconst parallaxEnabled = this.#boolAttr('parallax', true);\n\t\tconst lazy = this.#boolAttr('lazy', true);\n\t\tthis.#shouldLoad = !lazy;\n\n\t\tconst isHostedLaunch =\n\t\t\tinteraction === 'anchor' && !hrefAttr?.trim() && Boolean(experienceId?.trim());\n\t\tconst resolvedHref = resolveThumbnailHref({\n\t\t\thref: hrefAttr ?? undefined,\n\t\t\texperienceId: experienceId ?? undefined,\n\t\t\treturnUrl: this.getAttribute('return-url') ?? undefined,\n\t\t\tplayerBaseUrl: this.getAttribute('player-base-url') ?? undefined,\n\t\t\tuseCurrentPageAsReturnUrl:\n\t\t\t\tisHostedLaunch && !this.getAttribute('return-url')?.trim()\n\t\t});\n\n\t\tlet root: HTMLElement;\n\t\tif (interaction === 'anchor' && resolvedHref) {\n\t\t\tconst a = document.createElement('a');\n\t\t\ta.href = resolvedHref;\n\t\t\tconst target = this.getAttribute('target');\n\t\t\tconst rel = this.getAttribute('rel');\n\t\t\tif (target) a.target = target;\n\t\t\tif (rel) a.rel = rel;\n\t\t\troot = a;\n\t\t} else if (interaction === 'button') {\n\t\t\tconst button = document.createElement('button');\n\t\t\tbutton.type = 'button';\n\t\t\troot = button;\n\t\t} else {\n\t\t\troot = document.createElement('div');\n\t\t\troot.setAttribute('role', 'img');\n\t\t}\n\n\t\troot.className = 'liforma-et';\n\t\troot.setAttribute('aria-label', alt);\n\t\tthis.#root = root;\n\t\tshadow.appendChild(root);\n\n\t\tconst syncClass = () => {\n\t\t\tconst hasScene = Boolean(layers.backgroundImage);\n\t\t\tconst parallaxActive = parallaxEnabled && (this.#hovering || this.#scrollParallax);\n\t\t\t// Fade placeholder as soon as any layer can paint — don't wait for the slowest plate.\n\t\t\tconst reveal =\n\t\t\t\tthis.#shouldLoad &&\n\t\t\t\t(this.#avatarReady || this.#backgroundReady || this.#foregroundReady);\n\t\t\troot.className = [\n\t\t\t\t'liforma-et',\n\t\t\t\thasScene ? 'liforma-et--scene' : '',\n\t\t\t\tparallaxActive ? 'liforma-et--parallax' : '',\n\t\t\t\tthis.#scrollParallax ? 'liforma-et--scroll-parallax' : '',\n\t\t\t\tthis.#shouldLoad && !reveal ? 'liforma-et--loading' : '',\n\t\t\t\treveal ? 'liforma-et--revealed' : ''\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ');\n\t\t\troot.style.setProperty('--liforma-et-parallax-x', String(this.#parallaxX));\n\t\t\troot.style.setProperty('--liforma-et-parallax-y', String(this.#parallaxY));\n\t\t};\n\n\t\tconst placeholder = document.createElement('span');\n\t\tplaceholder.className = 'liforma-et__placeholder';\n\t\tplaceholder.setAttribute('aria-hidden', 'true');\n\t\troot.appendChild(placeholder);\n\n\t\tconst paintImages = () => {\n\t\t\tif (!this.#shouldLoad) return;\n\t\t\tconst avatarSrc =\n\t\t\t\tthis.#avatarLoadFailed && layers.fallbackImage\n\t\t\t\t\t? layers.fallbackImage\n\t\t\t\t\t: layers.avatarImage;\n\n\t\t\tif (layers.backgroundImage && !root.querySelector('.liforma-et__background')) {\n\t\t\t\tconst img = document.createElement('img');\n\t\t\t\timg.className = 'liforma-et__background liforma-et__media';\n\t\t\t\timg.alt = '';\n\t\t\t\timg.decoding = 'async';\n\t\t\t\timg.src = layers.backgroundImage;\n\t\t\t\tthis.#cleanup.push(\n\t\t\t\t\tattachImageReady(img, () => {\n\t\t\t\t\t\tthis.#backgroundReady = true;\n\t\t\t\t\t\timg.classList.add('liforma-et__media--ready');\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\troot.appendChild(img);\n\t\t\t}\n\n\t\t\tlet avatar = root.querySelector('.liforma-et__avatar') as HTMLImageElement | null;\n\t\t\tif (!avatar) {\n\t\t\t\tavatar = document.createElement('img');\n\t\t\t\tavatar.className = 'liforma-et__avatar liforma-et__media';\n\t\t\t\tavatar.alt = '';\n\t\t\t\tavatar.decoding = 'async';\n\t\t\t\tavatar.addEventListener('error', () => {\n\t\t\t\t\tif (layers.fallbackImage && !this.#avatarLoadFailed) {\n\t\t\t\t\t\tthis.#avatarLoadFailed = true;\n\t\t\t\t\t\tavatar!.src = layers.fallbackImage;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.#avatarReady = true;\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis.#cleanup.push(\n\t\t\t\t\tattachImageReady(avatar, () => {\n\t\t\t\t\t\tthis.#avatarReady = true;\n\t\t\t\t\t\tavatar!.classList.add('liforma-et__media--ready');\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\troot.appendChild(avatar);\n\t\t\t}\n\t\t\tif (avatar.src !== avatarSrc) avatar.src = avatarSrc;\n\n\t\t\tif (layers.foregroundImage && !root.querySelector('.liforma-et__foreground')) {\n\t\t\t\tconst img = document.createElement('img');\n\t\t\t\timg.className = 'liforma-et__foreground liforma-et__media';\n\t\t\t\timg.alt = '';\n\t\t\t\timg.decoding = 'async';\n\t\t\t\timg.src = layers.foregroundImage;\n\t\t\t\tthis.#cleanup.push(\n\t\t\t\t\tattachImageReady(img, () => {\n\t\t\t\t\t\tthis.#foregroundReady = true;\n\t\t\t\t\t\timg.classList.add('liforma-et__media--ready');\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\troot.appendChild(img);\n\t\t\t}\n\t\t\tsyncClass();\n\t\t};\n\n\t\tif (lazy) {\n\t\t\tthis.#cleanup.push(\n\t\t\t\tattachLazyThumb(root, {\n\t\t\t\t\tonVisibleChange: (visible) => {\n\t\t\t\t\t\tif (!visible) return;\n\t\t\t\t\t\tthis.#shouldLoad = true;\n\t\t\t\t\t\tpaintImages();\n\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t);\n\t\t} else {\n\t\t\tpaintImages();\n\t\t}\n\n\t\tif (parallaxEnabled) {\n\t\t\tthis.#cleanup.push(\n\t\t\t\tattachScrollLinkedParallax(root, {\n\t\t\t\t\tonParallax: (x) => {\n\t\t\t\t\t\tthis.#scrollParallax = true;\n\t\t\t\t\t\tif (!this.#pointerDown) {\n\t\t\t\t\t\t\tthis.#parallaxX = x;\n\t\t\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t\t\t\tsyncClass();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tpointerActive: () => this.#pointerDown\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tconst onPointerMove = (event: PointerEvent) => {\n\t\t\t\tif (this.#scrollParallax) return;\n\t\t\t\tconst rect = root.getBoundingClientRect();\n\t\t\t\tif (rect.width <= 0 || rect.height <= 0) return;\n\t\t\t\tthis.#parallaxX = ((event.clientX - rect.left) / rect.width - 0.5) * 2;\n\t\t\t\tthis.#parallaxY = ((event.clientY - rect.top) / rect.height - 0.5) * 2;\n\t\t\t\tsyncClass();\n\t\t\t};\n\t\t\tconst onPointerDown = (event: PointerEvent) => {\n\t\t\t\tthis.#pointerDown = true;\n\t\t\t\tif (event.pointerType === 'mouse') this.#hovering = true;\n\t\t\t\tsyncClass();\n\t\t\t};\n\t\t\tconst onPointerUp = () => {\n\t\t\t\tconst wasDown = this.#pointerDown;\n\t\t\t\tthis.#pointerDown = false;\n\t\t\t\tthis.#hovering = false;\n\t\t\t\tif (this.#scrollParallax && wasDown) {\n\t\t\t\t\tthis.#parallaxX = horizontalParallaxFromViewportY(\n\t\t\t\t\t\troot.getBoundingClientRect(),\n\t\t\t\t\t\twindow.innerHeight\n\t\t\t\t\t);\n\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t} else if (!this.#scrollParallax) {\n\t\t\t\t\tthis.#parallaxX = 0;\n\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t}\n\t\t\t\tsyncClass();\n\t\t\t};\n\t\t\troot.addEventListener('pointermove', onPointerMove);\n\t\t\troot.addEventListener('pointerdown', onPointerDown);\n\t\t\troot.addEventListener('pointerup', onPointerUp);\n\t\t\troot.addEventListener('pointercancel', onPointerUp);\n\t\t\troot.addEventListener('pointerenter', (event: PointerEvent) => {\n\t\t\t\tif (event.pointerType === 'mouse') {\n\t\t\t\t\tthis.#hovering = true;\n\t\t\t\t\tsyncClass();\n\t\t\t\t}\n\t\t\t});\n\t\t\troot.addEventListener('pointerleave', () => {\n\t\t\t\tif (!this.#pointerDown) {\n\t\t\t\t\tthis.#hovering = false;\n\t\t\t\t\tif (!this.#scrollParallax) {\n\t\t\t\t\t\tthis.#parallaxX = 0;\n\t\t\t\t\t\tthis.#parallaxY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tsyncClass();\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.#cleanup.push(() => {\n\t\t\t\troot.removeEventListener('pointermove', onPointerMove);\n\t\t\t\troot.removeEventListener('pointerdown', onPointerDown);\n\t\t\t\troot.removeEventListener('pointerup', onPointerUp);\n\t\t\t\troot.removeEventListener('pointercancel', onPointerUp);\n\t\t\t});\n\t\t}\n\n\t\troot.addEventListener('click', (event: MouseEvent) => {\n\t\t\tif (isHostedLaunch && !this.getAttribute('return-url')?.trim()) {\n\t\t\t\tconst next = resolveThumbnailHref({\n\t\t\t\t\texperienceId: experienceId ?? undefined,\n\t\t\t\t\tplayerBaseUrl: this.getAttribute('player-base-url') ?? undefined,\n\t\t\t\t\tuseCurrentPageAsReturnUrl: true\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tnext &&\n\t\t\t\t\tevent.button === 0 &&\n\t\t\t\t\t!event.metaKey &&\n\t\t\t\t\t!event.ctrlKey &&\n\t\t\t\t\t!event.shiftKey\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\twindow.location.assign(next);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tsyncClass();\n\t}\n}\n\nif (!customElements.get(ELEMENT_NAME)) {\n\tcustomElements.define(ELEMENT_NAME, LiformaExperienceThumbnailElement);\n}\n\nexport { LiformaExperienceThumbnailElement };\n","import { resolvePublicApiBaseUrl } from '../../shims/apiBaseUrl';\nimport type { GalleryThumb } from '../../thumbnail/types';\n\nexport type ExperiencePreview = {\n\treadonly experienceId: string;\n\treadonly title: string;\n\treadonly galleryThumb: GalleryThumb;\n};\n\nfunction parseGalleryThumb(raw: unknown): GalleryThumb | null {\n\tif (!raw || typeof raw !== 'object') return null;\n\tconst thumb = raw as Record<string, unknown>;\n\tconst avatarImage = typeof thumb.avatarImage === 'string' ? thumb.avatarImage.trim() : '';\n\tif (!avatarImage) return null;\n\treturn {\n\t\tavatarImage,\n\t\t...(typeof thumb.backgroundImage === 'string' && thumb.backgroundImage.trim()\n\t\t\t? { backgroundImage: thumb.backgroundImage.trim() }\n\t\t\t: {}),\n\t\t...(typeof thumb.foregroundImage === 'string' && thumb.foregroundImage.trim()\n\t\t\t? { foregroundImage: thumb.foregroundImage.trim() }\n\t\t\t: {})\n\t};\n}\n\n/**\n * Fetch public widget preview (title + gallery thumb plates) by experience id.\n * No API key / origin allowlist — safe for collapsed FAB paint before mint.\n */\nexport async function fetchExperiencePreview(\n\texperienceId: string,\n\toptions?: {\n\t\treadonly apiBaseUrl?: string;\n\t\treadonly signal?: AbortSignal;\n\t}\n): Promise<ExperiencePreview> {\n\tconst trimmed = experienceId.trim();\n\tif (!trimmed) {\n\t\tthrow new Error('Experience preview requires experienceId.');\n\t}\n\n\tconst apiBaseUrl = (options?.apiBaseUrl ?? resolvePublicApiBaseUrl()).replace(/\\/$/, '');\n\tconst res = await fetch(\n\t\t`${apiBaseUrl}/v1/experiences/${encodeURIComponent(trimmed)}/preview`,\n\t\t{\n\t\t\tmethod: 'GET',\n\t\t\theaders: { Accept: 'application/json' },\n\t\t\tsignal: options?.signal\n\t\t}\n\t);\n\n\tif (!res.ok) {\n\t\tlet message = `Experience preview failed (${res.status})`;\n\t\ttry {\n\t\t\tconst body = (await res.json()) as { message?: string };\n\t\t\tif (body.message?.trim()) message = body.message.trim();\n\t\t} catch {\n\t\t\t/* keep */\n\t\t}\n\t\tthrow new Error(message);\n\t}\n\n\tlet raw: unknown;\n\ttry {\n\t\traw = await res.json();\n\t} catch {\n\t\tthrow new Error('Experience preview returned invalid JSON.');\n\t}\n\n\tif (!raw || typeof raw !== 'object') {\n\t\tthrow new Error('Experience preview returned an invalid payload.');\n\t}\n\tconst payload = raw as Record<string, unknown>;\n\tconst id =\n\t\ttypeof payload.experienceId === 'string' ? payload.experienceId.trim() : trimmed;\n\tconst title = typeof payload.title === 'string' ? payload.title.trim() : '';\n\tconst galleryThumb = parseGalleryThumb(payload.galleryThumb);\n\tif (!galleryThumb) {\n\t\tthrow new Error('Experience preview is missing gallery thumb images.');\n\t}\n\n\treturn {\n\t\texperienceId: id || trimmed,\n\t\ttitle: title || id || trimmed,\n\t\tgalleryThumb\n\t};\n}\n","/** Desktop breakpoint for reduce / dock chrome (matches CSS). */\nexport const WIDGET_DESKTOP_MEDIA = '(min-width: 768px)';\n\nconst DOCK_MARGIN = 24;\n/** Fraction of the device screen height (not the browser chrome box). */\nexport const DOCK_HEIGHT_FRAC = 0.5;\nexport const DOCK_HEIGHT_MAX = 1200;\n/** Never taller than this share of the browser viewport (keeps margins). */\nconst DOCK_VIEWPORT_FRAC = 0.85;\n/** Portrait width / height. */\nexport const DOCK_ASPECT = 9 / 16;\n\nexport type DockSize = {\n\treadonly width: number;\n\treadonly height: number;\n};\n\nexport type DockPoint = {\n\treadonly left: number;\n\treadonly top: number;\n};\n\nfunction readScreenHeight(): number {\n\tif (typeof window === 'undefined') return 800;\n\tconst avail = window.screen?.availHeight;\n\treturn typeof avail === 'number' && avail > 0 ? avail : window.innerHeight;\n}\n\n/**\n * Docked panel size: ~50% of device screen height (cap 1200), 9:16 portrait,\n * then clamped to fit the browser viewport with margin.\n */\nexport function computeDockSize(\n\tviewportWidth = typeof window !== 'undefined' ? window.innerWidth : 1280,\n\tviewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800,\n\tmargin = DOCK_MARGIN,\n\tscreenHeight = typeof window !== 'undefined' ? readScreenHeight() : 800\n): DockSize {\n\tconst maxH = Math.max(\n\t\t160,\n\t\tMath.min(viewportHeight - margin * 2, viewportHeight * DOCK_VIEWPORT_FRAC)\n\t);\n\tconst maxW = Math.max(120, viewportWidth - margin * 2);\n\tlet height = Math.min(screenHeight * DOCK_HEIGHT_FRAC, DOCK_HEIGHT_MAX, maxH);\n\tlet width = height * DOCK_ASPECT;\n\tif (width > maxW) {\n\t\twidth = maxW;\n\t\theight = width / DOCK_ASPECT;\n\t\tif (height > maxH) {\n\t\t\theight = maxH;\n\t\t\twidth = height * DOCK_ASPECT;\n\t\t}\n\t}\n\treturn {\n\t\twidth: Math.round(width),\n\t\theight: Math.round(height)\n\t};\n}\n\n/** Default bottom-right placement for a docked panel. */\nexport function defaultDockOrigin(\n\tsize: DockSize,\n\tviewportWidth = typeof window !== 'undefined' ? window.innerWidth : 1280,\n\tviewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800,\n\tmargin = DOCK_MARGIN\n): DockPoint {\n\treturn {\n\t\tleft: Math.max(margin, viewportWidth - size.width - margin),\n\t\ttop: Math.max(margin, viewportHeight - size.height - margin)\n\t};\n}\n\n/** Keep a docked panel fully inside the viewport. */\nexport function clampDockOrigin(\n\tleft: number,\n\ttop: number,\n\tsize: DockSize,\n\tviewportWidth = typeof window !== 'undefined' ? window.innerWidth : 1280,\n\tviewportHeight = typeof window !== 'undefined' ? window.innerHeight : 800,\n\tmargin = DOCK_MARGIN\n): DockPoint {\n\tconst maxLeft = Math.max(margin, viewportWidth - size.width - margin);\n\tconst maxTop = Math.max(margin, viewportHeight - size.height - margin);\n\treturn {\n\t\tleft: Math.min(Math.max(margin, left), maxLeft),\n\t\ttop: Math.min(Math.max(margin, top), maxTop)\n\t};\n}\n\nexport function isDesktopViewport(\n\tmatchMediaFn: (query: string) => MediaQueryList = typeof window !== 'undefined'\n\t\t? window.matchMedia.bind(window)\n\t\t: () => ({ matches: true }) as MediaQueryList\n): boolean {\n\treturn matchMediaFn(WIDGET_DESKTOP_MEDIA).matches;\n}\n","/** Styles for ExperienceWidget (class prefix `liforma-ew`). */\nexport const EXPERIENCE_WIDGET_CSS = `\n.liforma-ew {\n\tbox-sizing: border-box;\n\tposition: relative;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tmin-height: 0;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n\tposition: fixed;\n\twidth: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n\theight: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n\tbottom: var(--liforma-ew-offset, 16px);\n\tz-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n\tright: var(--liforma-ew-offset, 16px);\n\tleft: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n\tleft: var(--liforma-ew-offset, 16px);\n\tright: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n\twidth: 0;\n\theight: 0;\n\tmin-width: 0;\n\tmin-height: 0;\n\toverflow: visible;\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n\tpointer-events: auto;\n}\n\n.liforma-ew__hit {\n\tbox-sizing: border-box;\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tbackground: transparent;\n\tcursor: pointer;\n\tfont: inherit;\n\tappearance: none;\n\t-webkit-tap-highlight-color: transparent;\n\ttransform: scale(1);\n\ttransform-origin: center center;\n\ttransition:\n\t\ttransform 180ms ease,\n\t\tfilter 180ms ease;\n\twill-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n\toutline: 2px solid #5b8def;\n\toutline-offset: 3px;\n\tborder-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n\t/* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n\t.liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n\t.liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n\t\ttransform: scale(1.06);\n\t}\n\n\t.liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n\t.liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n\t\tbox-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n\t}\n}\n\n.liforma-ew__face {\n\twidth: 100%;\n\theight: 100%;\n\tmin-height: 0;\n\tposition: relative;\n}\n\n.liforma-ew__face-status {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\tdisplay: grid;\n\tplace-items: center;\n\tpadding: 0.5rem;\n\ttext-align: center;\n\tfont: 600 0.75rem/1.3 system-ui, sans-serif;\n\tcolor: #e8ecf4;\n\tbackground: rgba(10, 12, 18, 0.72);\n\tborder-radius: 0.75rem;\n\tpointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__hit:disabled {\n\tcursor: default;\n\topacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n\tborder-radius: 0.75rem;\n\tbox-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n\ttransition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n\tbox-sizing: border-box;\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 2;\n\tborder-radius: 0.75rem;\n\toverflow: hidden;\n\tbackground: transparent;\n\tpointer-events: none;\n\topacity: 1;\n\ttransition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n\topacity: 0;\n\ttransition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n\tpointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n\t/* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n\topacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n\topacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n\ttransition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n\topacity: 0 !important;\n\ttransition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n\t/* Keep the live iframe under the thumb; FAB click resumes the shell. */\n\tpointer-events: none;\n\topacity: 0;\n\t/* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n\ttransition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n\tposition: fixed;\n\t/* Match overlay panel inset so the warm iframe fills the conversation shell. */\n\tinset: clamp(12px, 3vw, 28px);\n\tz-index: 2147483001;\n\twidth: auto;\n\theight: auto;\n\tborder-radius: 16px;\n\tpointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n\tposition: fixed;\n\tinset: auto;\n\tz-index: 2147483001;\n\tborder-radius: 16px;\n\tpointer-events: auto;\n\t/* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n\tdisplay: none;\n\tposition: fixed;\n\tz-index: 2147483002;\n\tpointer-events: auto;\n\tbox-sizing: border-box;\n\talign-items: center;\n\tgap: 0.35rem;\n\tpadding: 0.35rem 0.4rem;\n\tborder-radius: 999px;\n\tbackground: rgba(12, 14, 20, 0.72);\n\tbackdrop-filter: blur(8px);\n\t-webkit-backdrop-filter: blur(8px);\n\tbox-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n\tdisplay: flex;\n\ttop: calc(clamp(12px, 3vw, 28px) + 10px);\n\tright: calc(clamp(12px, 3vw, 28px) + 10px);\n\tleft: auto;\n\tcursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n\tdisplay: flex;\n\t/* left/top set inline to track the panel; strip remains a drag handle */\n\tcursor: grab;\n\ttouch-action: none;\n\tuser-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n\t/* Player also reports surface drags via postMessage when docked. */\n\tcursor: grab;\n\ttouch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n\tcursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__icon-btn {\n\tappearance: none;\n\tbox-sizing: border-box;\n\tdisplay: inline-grid;\n\tplace-items: center;\n\twidth: 2rem;\n\theight: 2rem;\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tborder-radius: 999px;\n\tcolor: #f5f7fb;\n\tbackground: transparent;\n\tcursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n\tbackground: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n\tbackground: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n\toutline: 2px solid #5b8def;\n\toutline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n\twidth: 1.05rem;\n\theight: 1.05rem;\n\tdisplay: block;\n}\n\n.liforma-ew__drag-grip {\n\tdisplay: none;\n\twidth: 0.85rem;\n\theight: 1.25rem;\n\tmargin: 0 0.15rem 0 0.25rem;\n\tbackground:\n\t\tradial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n\t\tradial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n\tbackground-repeat: repeat-y;\n\topacity: 0.55;\n\tcolor: #f5f7fb;\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n\tdisplay: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__overlay {\n\tposition: fixed;\n\tinset: 0;\n\tz-index: 2147483000;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpadding: clamp(12px, 3vw, 28px);\n\tbox-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n\tpadding: 0;\n\talign-items: stretch;\n\tjustify-content: stretch;\n\tpointer-events: none;\n\tbackground: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n\tdisplay: none !important;\n}\n\n.liforma-ew__backdrop {\n\tposition: absolute;\n\tinset: 0;\n\tborder: 0;\n\tpadding: 0;\n\tmargin: 0;\n\tbackground: rgba(6, 8, 14, 0.62);\n\tcursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n\tdisplay: none !important;\n}\n\n.liforma-ew__panel {\n\tposition: relative;\n\tz-index: 1;\n\tdisplay: flex;\n\tflex-direction: column;\n\t/* Fill the overlay so player loading / start UI centers in the visible window. */\n\twidth: var(--liforma-ew-max-w, 100%);\n\theight: var(--liforma-ew-max-h, 100%);\n\tmax-width: 100%;\n\tmax-height: 100%;\n\tborder-radius: 16px;\n\toverflow: hidden;\n\tbackground: #030508;\n\tbox-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n\t/* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n\tpointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n\tposition: fixed;\n\tinset: auto;\n\tmax-width: none;\n\tmax-height: none;\n\tpointer-events: auto;\n\t/* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n\tpointer-events: auto;\n}\n\n.liforma-ew__stage {\n\tposition: relative;\n\tflex: 1;\n\tmin-height: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbackground: #030508;\n\topacity: 1;\n\ttransition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n\tposition: absolute;\n\tinset: 0;\n\tz-index: 1;\n\tdisplay: grid;\n\tplace-items: center;\n\tpadding: 1.5rem;\n\ttext-align: center;\n\tcolor: #d7dde8;\n\tfont: 500 0.9375rem/1.45 system-ui, sans-serif;\n\tbackground: rgba(3, 5, 8, 0.92);\n\tpointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n\tdisplay: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n\t.liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n\t\tpadding: 5vh 5vw;\n\t}\n\n\t.liforma-ew[data-state='expanded'] .liforma-ew__panel {\n\t\twidth: 90vw;\n\t\theight: 90vh;\n\t\tmax-width: 90vw;\n\t\tmax-height: 90vh;\n\t}\n\n\t.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n\t\tinset: 5vh 5vw;\n\t}\n\n\t.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n\t\ttop: calc(5vh + 10px);\n\t\tright: calc(5vw + 10px);\n\t}\n\n\t.liforma-ew__dock-toggle {\n\t\tdisplay: none !important;\n\t}\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.liforma-ew__hit {\n\t\ttransition: none;\n\t\twill-change: auto;\n\t}\n\n\t.liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n\t.liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n\t\ttransform: none;\n\t}\n\n\t.liforma-ew__face .liforma-et {\n\t\tbox-shadow: none;\n\t\ttransition: none;\n\t}\n\n\t.liforma-ew__warm,\n\t.liforma-ew__stage {\n\t\ttransition: none;\n\t}\n}\n`;\n\nconst STYLE_ID = 'liforma-experience-widget-styles';\n\nexport function ensureExperienceWidgetStyles(css: string = EXPERIENCE_WIDGET_CSS): void {\n\tif (typeof document === 'undefined') return;\n\tconst existing = document.getElementById(STYLE_ID);\n\tif (existing) {\n\t\t/* Keep injected CSS current across local HMR / preview reloads. */\n\t\texisting.textContent = css;\n\t\treturn;\n\t}\n\tconst style = document.createElement('style');\n\tstyle.id = STYLE_ID;\n\tstyle.textContent = css;\n\tdocument.head.append(style);\n}\n","import { fetchExperiencePreview } from '../v2/api/fetchExperiencePreview';\nimport { Experience } from '../v2/experience';\nimport type { StartButtonOptions } from '../v2/types/sessionInteraction';\nimport {\n\tattachThumbnailParallax,\n\tensureExperienceThumbnailStyles,\n\tEXPERIENCE_THUMBNAIL_CSS,\n\tresolveThumbnailLayers\n} from '../thumbnail/index';\nimport type { GalleryThumb } from '../thumbnail/types';\nimport {\n\tclampDockOrigin,\n\tcomputeDockSize,\n\tdefaultDockOrigin,\n\tisDesktopViewport,\n\tWIDGET_DESKTOP_MEDIA\n} from './dockGeometry';\nimport { ensureExperienceWidgetStyles, EXPERIENCE_WIDGET_CSS } from './styles';\nimport type {\n\tExperienceWidgetController,\n\tExperienceWidgetOptions,\n\tExperienceWidgetPosition,\n\tExperienceWidgetPrefetch\n} from './types';\n\nfunction resolvePosition(value: ExperienceWidgetPosition | undefined): ExperienceWidgetPosition {\n\treturn value === 'bottom-right' || value === 'bottom-left' ? value : 'static';\n}\n\n/** Normalize offset to a CSS length (default 16px). */\nexport function resolveWidgetOffsetCss(offset?: number | string): string {\n\tif (typeof offset === 'number' && Number.isFinite(offset)) {\n\t\treturn `${offset}px`;\n\t}\n\tconst raw = typeof offset === 'string' ? offset.trim() : '';\n\tif (!raw) return '16px';\n\tif (/^\\d+(\\.\\d+)?$/.test(raw)) return `${raw}px`;\n\treturn raw;\n}\n\ntype FaceLayers = {\n\treadonly galleryThumb?: GalleryThumb;\n\treadonly avatarImage?: string;\n\treadonly backgroundImage?: string;\n\treadonly foregroundImage?: string;\n\treadonly fallbackImage?: string;\n};\n\ntype ShellState = 'collapsed' | 'expanded' | 'docked';\n\nfunction isOpenShell(state: string | undefined): state is 'expanded' | 'docked' {\n\treturn state === 'expanded' || state === 'docked';\n}\n\n/** Tabler `settings` — audio device panel. */\nconst ICON_SETTINGS = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>`;\n\nconst ICON_CLOSE = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>`;\n\n/** Tabler `arrows-diagonal-minimize-2` — reduce / dock. */\nconst ICON_REDUCE = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>`;\n\n/** Tabler `arrows-diagonal` — maximize (pair for minimize-2). */\nconst ICON_MAXIMIZE = `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>`;\n\nfunction renderFace(\n\tcontainer: HTMLElement,\n\tlayersInput: FaceLayers,\n\toptions?: { readonly parallax?: boolean }\n): (() => void) | null {\n\tensureExperienceThumbnailStyles(EXPERIENCE_THUMBNAIL_CSS);\n\tconst layers = resolveThumbnailLayers({\n\t\tgalleryThumb: layersInput.galleryThumb,\n\t\tavatarImage: layersInput.avatarImage,\n\t\tbackgroundImage: layersInput.backgroundImage,\n\t\tforegroundImage: layersInput.foregroundImage,\n\t\tfallbackImage: layersInput.fallbackImage\n\t});\n\tif (!layers) {\n\t\tcontainer.replaceChildren();\n\t\treturn null;\n\t}\n\n\tconst root = document.createElement('div');\n\troot.className = `liforma-et${layers.backgroundImage ? ' liforma-et--scene' : ''} liforma-et--revealed`;\n\troot.setAttribute('aria-hidden', 'true');\n\n\tconst placeholder = document.createElement('span');\n\tplaceholder.className = 'liforma-et__placeholder';\n\tplaceholder.setAttribute('aria-hidden', 'true');\n\troot.append(placeholder);\n\n\tconst markReady = (img: HTMLImageElement) => {\n\t\timg.classList.add('liforma-et__media--ready');\n\t};\n\n\tif (layers.backgroundImage) {\n\t\tconst bg = document.createElement('img');\n\t\tbg.className = 'liforma-et__background liforma-et__media';\n\t\tbg.alt = '';\n\t\tbg.decoding = 'async';\n\t\tbg.src = layers.backgroundImage;\n\t\tbg.addEventListener('load', () => markReady(bg), { once: true });\n\t\troot.append(bg);\n\t}\n\n\tconst avatar = document.createElement('img');\n\tavatar.className = 'liforma-et__avatar liforma-et__media';\n\tavatar.alt = '';\n\tavatar.decoding = 'async';\n\tavatar.src = layers.avatarImage;\n\tavatar.addEventListener('load', () => markReady(avatar), { once: true });\n\tavatar.addEventListener(\n\t\t'error',\n\t\t() => {\n\t\t\tif (layers.fallbackImage) {\n\t\t\t\tavatar.src = layers.fallbackImage;\n\t\t\t}\n\t\t},\n\t\t{ once: true }\n\t);\n\troot.append(avatar);\n\n\tif (layers.foregroundImage) {\n\t\tconst fg = document.createElement('img');\n\t\tfg.className = 'liforma-et__foreground liforma-et__media';\n\t\tfg.alt = '';\n\t\tfg.decoding = 'async';\n\t\tfg.src = layers.foregroundImage;\n\t\tfg.addEventListener('load', () => markReady(fg), { once: true });\n\t\troot.append(fg);\n\t}\n\n\tcontainer.replaceChildren(root);\n\n\tif (options?.parallax === false) return () => {};\n\treturn attachThumbnailParallax(root);\n}\n\nfunction resolveStartButton(options: ExperienceWidgetOptions): StartButtonOptions {\n\tif (options.startButton) {\n\t\treturn {\n\t\t\t...options.startButton,\n\t\t\tlabel: options.startButton.label ?? options.startButtonLabel ?? 'Tap to talk',\n\t\t\tplacement: options.startButton.placement ?? 'bottom-center',\n\t\t\tvariant: options.startButton.variant ?? 'primary'\n\t\t};\n\t}\n\treturn {\n\t\tlabel: options.startButtonLabel ?? 'Tap to talk',\n\t\tplacement: 'bottom-center',\n\t\tvariant: 'primary'\n\t};\n}\n\nfunction scheduleIdle(callback: () => void): () => void {\n\tlet cancelled = false;\n\tconst run = () => {\n\t\tif (cancelled) return;\n\t\tcallback();\n\t};\n\n\tconst onLoad = () => {\n\t\tif (cancelled) return;\n\t\tconst ric = (\n\t\t\twindow as Window & {\n\t\t\t\trequestIdleCallback?: (cb: () => void, opts?: { timeout: number }) => number;\n\t\t\t\tcancelIdleCallback?: (id: number) => void;\n\t\t\t}\n\t\t).requestIdleCallback;\n\t\tif (typeof ric === 'function') {\n\t\t\tconst id = ric(run, { timeout: 3000 });\n\t\t\tcancelIdle = () => {\n\t\t\t\t(\n\t\t\t\t\twindow as Window & { cancelIdleCallback?: (id: number) => void }\n\t\t\t\t).cancelIdleCallback?.(id);\n\t\t\t};\n\t\t\treturn;\n\t\t}\n\t\tconst t = window.setTimeout(run, 1);\n\t\tcancelIdle = () => window.clearTimeout(t);\n\t};\n\n\tlet cancelIdle: (() => void) | null = null;\n\tif (document.readyState === 'complete') {\n\t\tonLoad();\n\t} else {\n\t\twindow.addEventListener('load', onLoad, { once: true });\n\t}\n\n\treturn () => {\n\t\tcancelled = true;\n\t\twindow.removeEventListener('load', onLoad);\n\t\tcancelIdle?.();\n\t};\n}\n\n/**\n * Mount a light collapsed widget that expands an Experience overlay on click.\n * Default `prefetch=\"onExpand\"` is cold (second tap unlocks audio).\n * `idle` / `eager` warm a transparent iframe so one in-iframe click unlocks + expands.\n *\n * When gallery thumb layers are not provided, fetches\n * `GET /v1/experiences/{id}/preview` (no auth / allowlist).\n */\nexport function mountExperienceWidget(\n\thost: HTMLElement,\n\toptions: ExperienceWidgetOptions\n): ExperienceWidgetController {\n\tensureExperienceWidgetStyles(EXPERIENCE_WIDGET_CSS);\n\n\tconst experienceId = options.experienceId?.trim();\n\tif (!experienceId) {\n\t\tthrow new Error('ExperienceWidget requires experienceId.');\n\t}\n\n\tconst prefetchMode: ExperienceWidgetPrefetch = options.prefetch ?? 'onExpand';\n\tconst position = resolvePosition(options.position);\n\n\tconst root = document.createElement('div');\n\troot.className = 'liforma-ew';\n\troot.dataset.state = 'collapsed';\n\troot.dataset.prefetch = prefetchMode;\n\troot.dataset.position = position;\n\troot.style.setProperty('--liforma-ew-max-w', options.expandedMaxWidth ?? '100%');\n\troot.style.setProperty('--liforma-ew-max-h', options.expandedMaxHeight ?? '100%');\n\tif (position !== 'static') {\n\t\troot.style.setProperty('--liforma-ew-offset', resolveWidgetOffsetCss(options.offset));\n\t}\n\n\tconst hit = document.createElement('button');\n\thit.type = 'button';\n\thit.className = 'liforma-ew__hit';\n\thit.setAttribute('aria-label', options.alt);\n\thit.disabled = true;\n\n\tconst face = document.createElement('div');\n\tface.className = 'liforma-ew__face';\n\thit.append(face);\n\n\tconst faceLoading = document.createElement('div');\n\tfaceLoading.className = 'liforma-ew__face-status';\n\tfaceLoading.textContent = 'Loading…';\n\tface.append(faceLoading);\n\n\tconst warmStage = document.createElement('div');\n\twarmStage.className = 'liforma-ew__warm';\n\twarmStage.hidden = true;\n\twarmStage.setAttribute('aria-hidden', 'true');\n\n\tconst overlay = document.createElement('div');\n\toverlay.className = 'liforma-ew__overlay';\n\toverlay.hidden = true;\n\toverlay.setAttribute('role', 'dialog');\n\toverlay.setAttribute('aria-modal', 'true');\n\toverlay.setAttribute('aria-label', options.alt);\n\n\tconst backdrop = document.createElement('button');\n\tbackdrop.type = 'button';\n\tbackdrop.className = 'liforma-ew__backdrop';\n\tbackdrop.setAttribute('aria-label', 'Close experience');\n\n\tconst panel = document.createElement('div');\n\tpanel.className = 'liforma-ew__panel';\n\n\tconst toolbar = document.createElement('div');\n\ttoolbar.className = 'liforma-ew__toolbar';\n\ttoolbar.hidden = true;\n\n\tconst dragGrip = document.createElement('span');\n\tdragGrip.className = 'liforma-ew__drag-grip';\n\tdragGrip.setAttribute('aria-hidden', 'true');\n\n\tconst dockToggleBtn = document.createElement('button');\n\tdockToggleBtn.type = 'button';\n\tdockToggleBtn.className = 'liforma-ew__icon-btn liforma-ew__dock-toggle';\n\tdockToggleBtn.innerHTML = ICON_REDUCE;\n\tdockToggleBtn.setAttribute('aria-label', 'Reduce');\n\n\tconst settingsBtn = document.createElement('button');\n\tsettingsBtn.type = 'button';\n\tsettingsBtn.className = 'liforma-ew__icon-btn liforma-ew__settings';\n\tsettingsBtn.innerHTML = ICON_SETTINGS;\n\tsettingsBtn.setAttribute('aria-label', 'Audio settings');\n\tsettingsBtn.setAttribute('aria-pressed', 'false');\n\n\tconst closeBtn = document.createElement('button');\n\tcloseBtn.type = 'button';\n\tcloseBtn.className = 'liforma-ew__icon-btn liforma-ew__close';\n\tcloseBtn.innerHTML = ICON_CLOSE;\n\tcloseBtn.setAttribute('aria-label', 'Close');\n\n\ttoolbar.append(dragGrip, dockToggleBtn, settingsBtn, closeBtn);\n\n\tconst stage = document.createElement('div');\n\tstage.className = 'liforma-ew__stage';\n\n\tconst status = document.createElement('div');\n\tstatus.className = 'liforma-ew__status';\n\tstatus.hidden = true;\n\n\tpanel.append(stage, status);\n\toverlay.append(backdrop, panel);\n\t/* Toolbar must be a root sibling above the warm iframe stacking context. */\n\troot.append(hit, warmStage, overlay, toolbar);\n\thost.replaceChildren(root);\n\n\tlet experience: Experience | null = null;\n\tlet expanding = false;\n\tlet destroyed = false;\n\tlet previewReady = false;\n\tlet warmReady = false;\n\tlet warmInFlight = false;\n\t/** True after iframe attach (warm or cold); retain across collapse until hard teardown. */\n\tlet shellMounted = false;\n\t/** True after the player has unlocked audio / started conversation. */\n\tlet sessionStarted = false;\n\t/** Bumped on hard teardown so in-flight expand/warm work is discarded. */\n\tlet expandEpoch = 0;\n\tlet previousOverflow = '';\n\tlet detachFaceParallax: (() => void) | null = null;\n\tlet cancelWarmSchedule: (() => void) | null = null;\n\tlet collapseRevealTimer: ReturnType<typeof setTimeout> | null = null;\n\tlet layoutSettleTimer: ReturnType<typeof setTimeout> | null = null;\n\t/** Last docked origin; null means use default bottom-right for current size. */\n\tlet dockLeft: number | null = null;\n\tlet dockTop: number | null = null;\n\tlet dragPointerId: number | null = null;\n\tlet dragOffsetX = 0;\n\tlet dragOffsetY = 0;\n\t/** `toolbar` = parent pointer capture; `player` = iframe postMessage stream. */\n\tlet dockDragSource: 'toolbar' | 'player' | null = null;\n\tlet dockDragWindowBound = false;\n\tconst previewAbort = new AbortController();\n\tconst parallaxEnabled = options.parallax !== false;\n\tconst SESSION_CONCEAL_MS = 280;\n\t/**\n\t * Past FaceSessionView resize debounce (160ms) + morph restart so dock/maximize\n\t * never flashes a wrong-aspect canvas stretched into the new box.\n\t */\n\tconst LAYOUT_SETTLE_MS = 220;\n\tconst TOOLBAR_GAP = 10;\n\n\tconst shellState = (): ShellState => {\n\t\tconst state = root.dataset.state;\n\t\tif (state === 'expanded' || state === 'docked' || state === 'collapsed') return state;\n\t\treturn 'collapsed';\n\t};\n\n\tconst clearCollapseRevealTimer = () => {\n\t\tif (collapseRevealTimer !== null) {\n\t\t\tclearTimeout(collapseRevealTimer);\n\t\t\tcollapseRevealTimer = null;\n\t\t}\n\t};\n\n\tconst clearLayoutSettleTimer = () => {\n\t\tif (layoutSettleTimer !== null) {\n\t\t\tclearTimeout(layoutSettleTimer);\n\t\t\tlayoutSettleTimer = null;\n\t\t}\n\t\troot.classList.remove('liforma-ew--layout-settling');\n\t};\n\n\tconst clearExpandedLayoutInline = () => {\n\t\tfor (const el of [panel, warmStage, toolbar]) {\n\t\t\tel.style.removeProperty('left');\n\t\t\tel.style.removeProperty('top');\n\t\t\tel.style.removeProperty('width');\n\t\t\tel.style.removeProperty('height');\n\t\t\tel.style.removeProperty('right');\n\t\t\tel.style.removeProperty('bottom');\n\t\t}\n\t\ttoolbar.classList.remove('liforma-ew__toolbar--dragging');\n\t\troot.classList.remove('liforma-ew--dock-dragging');\n\t};\n\n\tconst applyDockedGeometry = (left: number, top: number, width: number, height: number) => {\n\t\tconst box = (el: HTMLElement) => {\n\t\t\tel.style.left = `${left}px`;\n\t\t\tel.style.top = `${top}px`;\n\t\t\tel.style.width = `${width}px`;\n\t\t\tel.style.height = `${height}px`;\n\t\t\tel.style.right = 'auto';\n\t\t\tel.style.bottom = 'auto';\n\t\t};\n\t\tbox(panel);\n\t\tbox(warmStage);\n\t\tconst toolbarWidth = toolbar.offsetWidth || 120;\n\t\ttoolbar.style.left = `${left + width - toolbarWidth - TOOLBAR_GAP}px`;\n\t\ttoolbar.style.top = `${top + TOOLBAR_GAP}px`;\n\t\ttoolbar.style.right = 'auto';\n\t\ttoolbar.style.bottom = 'auto';\n\t\ttoolbar.style.width = 'auto';\n\t\ttoolbar.style.height = 'auto';\n\t};\n\n\tconst applyDockDragPosition = (clientX: number, clientY: number) => {\n\t\tif (shellState() !== 'docked') return;\n\t\tconst size = computeDockSize();\n\t\tconst origin = clampDockOrigin(clientX - dragOffsetX, clientY - dragOffsetY, size);\n\t\tdockLeft = origin.left;\n\t\tdockTop = origin.top;\n\t\tapplyDockedGeometry(origin.left, origin.top, size.width, size.height);\n\t};\n\n\tconst applyDockDragDelta = (dx: number, dy: number) => {\n\t\tif (shellState() !== 'docked') return;\n\t\tif (!Number.isFinite(dx) || !Number.isFinite(dy)) return;\n\t\tif (dx === 0 && dy === 0) return;\n\t\tconst size = computeDockSize();\n\t\tconst currentLeft = dockLeft ?? panel.getBoundingClientRect().left;\n\t\tconst currentTop = dockTop ?? panel.getBoundingClientRect().top;\n\t\tconst origin = clampDockOrigin(currentLeft + dx, currentTop + dy, size);\n\t\tdockLeft = origin.left;\n\t\tdockTop = origin.top;\n\t\tapplyDockedGeometry(origin.left, origin.top, size.width, size.height);\n\t};\n\n\tconst onToolbarDockPointerMove = (event: PointerEvent) => {\n\t\tif (dockDragSource !== 'toolbar') return;\n\t\tif (dragPointerId === null || event.pointerId !== dragPointerId) return;\n\t\tevent.preventDefault();\n\t\tapplyDockDragPosition(event.clientX, event.clientY);\n\t};\n\n\tconst endDockDrag = (event?: PointerEvent) => {\n\t\tif (dragPointerId === null) return;\n\t\tif (event && event.pointerId !== dragPointerId) return;\n\t\tconst source = dockDragSource;\n\t\tdragPointerId = null;\n\t\tdockDragSource = null;\n\t\ttoolbar.classList.remove('liforma-ew__toolbar--dragging');\n\t\troot.classList.remove('liforma-ew--dock-dragging');\n\t\tif (source === 'toolbar' && dockDragWindowBound) {\n\t\t\tdockDragWindowBound = false;\n\t\t\twindow.removeEventListener('pointermove', onToolbarDockPointerMove);\n\t\t\twindow.removeEventListener('pointerup', endDockDrag);\n\t\t\twindow.removeEventListener('pointercancel', endDockDrag);\n\t\t}\n\t};\n\n\tconst beginToolbarDockDrag = (clientX: number, clientY: number, pointerId: number) => {\n\t\tif (destroyed) return;\n\t\tif (shellState() !== 'docked') return;\n\t\tif (!isDesktopViewport()) return;\n\t\tif (dragPointerId !== null) return;\n\t\tdragPointerId = pointerId;\n\t\tdockDragSource = 'toolbar';\n\t\ttoolbar.classList.add('liforma-ew__toolbar--dragging');\n\t\troot.classList.add('liforma-ew--dock-dragging');\n\t\tconst panelRect = panel.getBoundingClientRect();\n\t\tdragOffsetX = clientX - panelRect.left;\n\t\tdragOffsetY = clientY - panelRect.top;\n\t\tif (!dockDragWindowBound) {\n\t\t\tdockDragWindowBound = true;\n\t\t\twindow.addEventListener('pointermove', onToolbarDockPointerMove);\n\t\t\twindow.addEventListener('pointerup', endDockDrag);\n\t\t\twindow.addEventListener('pointercancel', endDockDrag);\n\t\t}\n\t};\n\n\tconst beginDockDragFromPlayer = (event: { readonly pointerId: number }) => {\n\t\tif (destroyed) return;\n\t\tif (shellState() !== 'docked') return;\n\t\tif (!isDesktopViewport()) return;\n\t\tif (dragPointerId !== null) return;\n\t\tdragPointerId = event.pointerId;\n\t\tdockDragSource = 'player';\n\t\ttoolbar.classList.add('liforma-ew__toolbar--dragging');\n\t\troot.classList.add('liforma-ew--dock-dragging');\n\t\t/*\n\t\t * Delta-based player drags: keep dockLeft/dockTop as the live origin.\n\t\t * Do not convert iframe client coordinates (async layout feedback jumps).\n\t\t */\n\t\tconst panelRect = panel.getBoundingClientRect();\n\t\tdockLeft = panelRect.left;\n\t\tdockTop = panelRect.top;\n\t};\n\n\tconst moveDockDragFromPlayer = (event: {\n\t\treadonly pointerId: number;\n\t\treadonly dx: number;\n\t\treadonly dy: number;\n\t}) => {\n\t\tif (dockDragSource !== 'player') return;\n\t\tif (dragPointerId === null || event.pointerId !== dragPointerId) return;\n\t\tapplyDockDragDelta(event.dx, event.dy);\n\t};\n\n\tconst endDockDragFromPlayer = (event: { readonly pointerId: number }) => {\n\t\tif (dockDragSource !== 'player') return;\n\t\tif (dragPointerId === null || event.pointerId !== dragPointerId) return;\n\t\tendDockDrag();\n\t};\n\n\tconst syncDockToggleChrome = () => {\n\t\tconst desktop = isDesktopViewport();\n\t\tconst state = shellState();\n\t\tif (!desktop || (state !== 'expanded' && state !== 'docked')) {\n\t\t\tdockToggleBtn.hidden = true;\n\t\t\treturn;\n\t\t}\n\t\tdockToggleBtn.hidden = false;\n\t\tif (state === 'docked') {\n\t\t\tdockToggleBtn.innerHTML = ICON_MAXIMIZE;\n\t\t\tdockToggleBtn.setAttribute('aria-label', 'Maximize');\n\t\t} else {\n\t\t\tdockToggleBtn.innerHTML = ICON_REDUCE;\n\t\t\tdockToggleBtn.setAttribute('aria-label', 'Reduce');\n\t\t}\n\t};\n\n\tconst layoutDockedShell = (preserveOrigin: boolean) => {\n\t\tconst size = computeDockSize();\n\t\tlet origin =\n\t\t\tpreserveOrigin && dockLeft !== null && dockTop !== null\n\t\t\t\t? clampDockOrigin(dockLeft, dockTop, size)\n\t\t\t\t: defaultDockOrigin(size);\n\t\torigin = clampDockOrigin(origin.left, origin.top, size);\n\t\tdockLeft = origin.left;\n\t\tdockTop = origin.top;\n\t\tapplyDockedGeometry(origin.left, origin.top, size.width, size.height);\n\t\tsyncDockToggleChrome();\n\t};\n\n\t/** Fade the live session in after layout/resize has settled (matches cold avatar reveal). */\n\tconst revealLiveSession = () => {\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tif (destroyed || !isOpenShell(root.dataset.state)) return;\n\t\t\t\troot.classList.add('liforma-ew--session-revealed');\n\t\t\t});\n\t\t});\n\t};\n\n\t/**\n\t * Hide the live surface instantly, apply a layout change, then reveal after the\n\t * player has had time to rebuild the morph canvas for the new aspect.\n\t */\n\tconst settleLayoutThenReveal = (applyLayout: () => void) => {\n\t\tclearLayoutSettleTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\troot.classList.add('liforma-ew--layout-settling');\n\t\tapplyLayout();\n\t\tif (!sessionStarted) {\n\t\t\troot.classList.remove('liforma-ew--layout-settling');\n\t\t\treturn;\n\t\t}\n\t\tlayoutSettleTimer = setTimeout(() => {\n\t\t\tlayoutSettleTimer = null;\n\t\t\tif (destroyed || !isOpenShell(root.dataset.state)) {\n\t\t\t\troot.classList.remove('liforma-ew--layout-settling');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\troot.classList.remove('liforma-ew--layout-settling');\n\t\t\trevealLiveSession();\n\t\t}, LAYOUT_SETTLE_MS);\n\t};\n\n\tconst concealLiveSession = (): Promise<void> => {\n\t\troot.classList.add('liforma-ew--session-concealing');\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\treturn new Promise((resolve) => {\n\t\t\tclearCollapseRevealTimer();\n\t\t\tcollapseRevealTimer = setTimeout(() => {\n\t\t\t\tcollapseRevealTimer = null;\n\t\t\t\troot.classList.remove('liforma-ew--session-concealing');\n\t\t\t\tresolve();\n\t\t\t}, SESSION_CONCEAL_MS);\n\t\t});\n\t};\n\n\tconst initialLayers: FaceLayers = {\n\t\tgalleryThumb: options.galleryThumb,\n\t\tavatarImage: options.avatarImage,\n\t\tbackgroundImage: options.backgroundImage,\n\t\tforegroundImage: options.foregroundImage,\n\t\tfallbackImage: options.fallbackImage\n\t};\n\n\tconst setStatus = (text: string | null) => {\n\t\tif (!text) {\n\t\t\tstatus.hidden = true;\n\t\t\tstatus.textContent = '';\n\t\t\treturn;\n\t\t}\n\t\tstatus.hidden = false;\n\t\tstatus.textContent = text;\n\t};\n\n\tconst setFaceStatus = (text: string | null) => {\n\t\tif (!text) {\n\t\t\tfaceLoading.hidden = true;\n\t\t\tfaceLoading.textContent = '';\n\t\t\treturn;\n\t\t}\n\t\tfaceLoading.hidden = false;\n\t\tfaceLoading.textContent = text;\n\t\tif (!face.contains(faceLoading)) {\n\t\t\tface.append(faceLoading);\n\t\t}\n\t};\n\n\tconst markPreviewReady = () => {\n\t\tpreviewReady = true;\n\t\thit.disabled = false;\n\t\tsetFaceStatus(null);\n\t\tif (prefetchMode === 'onExpand') {\n\t\t\toptions.onPrefetchReady?.();\n\t\t}\n\t};\n\n\tconst armWarmHit = () => {\n\t\twarmReady = true;\n\t\troot.dataset.warm = 'true';\n\t\twarmStage.hidden = false;\n\t\tif (!sessionStarted) {\n\t\t\thit.tabIndex = -1;\n\t\t\thit.setAttribute('aria-hidden', 'true');\n\t\t}\n\t\toptions.onPrefetchReady?.();\n\t};\n\n\tconst paintFace = (layers: FaceLayers): boolean => {\n\t\tdetachFaceParallax?.();\n\t\tdetachFaceParallax = null;\n\t\tconst detach = renderFace(face, layers, { parallax: parallaxEnabled });\n\t\tif (!detach) return false;\n\t\tdetachFaceParallax = detach;\n\t\treturn true;\n\t};\n\n\tconst paintOrFetchPreview = () => {\n\t\tif (paintFace(initialLayers)) {\n\t\t\tmarkPreviewReady();\n\t\t\treturn;\n\t\t}\n\n\t\tsetFaceStatus('Loading…');\n\t\tvoid fetchExperiencePreview(experienceId, { signal: previewAbort.signal })\n\t\t\t.then((preview) => {\n\t\t\t\tif (destroyed) return;\n\t\t\t\tif (!paintFace({ galleryThumb: preview.galleryThumb })) {\n\t\t\t\t\tthrow new Error('Experience preview is missing gallery thumb images.');\n\t\t\t\t}\n\t\t\t\tmarkPreviewReady();\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tif (destroyed || previewAbort.signal.aborted) return;\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tsetFaceStatus('Preview unavailable');\n\t\t\t\thit.disabled = true;\n\t\t\t\toptions.onError?.(err);\n\t\t\t\tconsole.error('[ExperienceWidget]', err);\n\t\t\t});\n\t};\n\n\tconst sessionLaunchOptions = () => ({\n\t\texperienceId,\n\t\tui: 'widget' as const,\n\t\t...(options.sessionEndpoint ? { sessionEndpoint: options.sessionEndpoint } : {}),\n\t\t...(options.language ? { language: options.language } : {}),\n\t\t...(options.mode ? { mode: options.mode } : {}),\n\t\t...(options.speechInputMode ? { speechInputMode: options.speechInputMode } : {}),\n\t\t...(options.speechOnly !== undefined ? { speechOnly: options.speechOnly } : {}),\n\t\t...(options.fit ? { fit: options.fit } : {}),\n\t\t...(options.embedBaseUrl ? { embedBaseUrl: options.embedBaseUrl } : {}),\n\t\tstartButton: resolveStartButton(options)\n\t});\n\n\tconst showExpandedShell = (announce = true) => {\n\t\thit.hidden = true;\n\t\toverlay.hidden = false;\n\t\ttoolbar.hidden = false;\n\t\toverlay.setAttribute('aria-modal', 'true');\n\t\tclearExpandedLayoutInline();\n\t\troot.dataset.state = 'expanded';\n\t\tsetStatus(null);\n\t\tif (typeof document !== 'undefined') {\n\t\t\tpreviousOverflow = document.body.style.overflow;\n\t\t\tdocument.body.style.overflow = 'hidden';\n\t\t}\n\t\tsyncDockToggleChrome();\n\t\tif (announce) {\n\t\t\toptions.onExpanded?.();\n\t\t}\n\t};\n\n\tconst showDockedShell = () => {\n\t\thit.hidden = true;\n\t\toverlay.hidden = false;\n\t\ttoolbar.hidden = false;\n\t\toverlay.setAttribute('aria-modal', 'false');\n\t\troot.dataset.state = 'docked';\n\t\tsetStatus(null);\n\t\tif (typeof document !== 'undefined') {\n\t\t\tdocument.body.style.overflow = previousOverflow;\n\t\t}\n\t\tlayoutDockedShell(true);\n\t\tsyncDockToggleChrome();\n\t\texperience?.setWidgetChrome('docked');\n\t};\n\n\tconst bindSessionLifecycle = (session: Experience) => {\n\t\tsession.on('started', () => {\n\t\t\tif (destroyed) return;\n\t\t\tsessionStarted = true;\n\t\t\troot.dataset.live = 'true';\n\t\t\tsetStatus(null);\n\t\t\toptions.onStarted?.();\n\t\t\tif (isOpenShell(root.dataset.state)) {\n\t\t\t\trevealLiveSession();\n\t\t\t}\n\t\t});\n\t};\n\n\tconst restoreCollapsedChrome = () => {\n\t\tclearLayoutSettleTimer();\n\t\toverlay.hidden = true;\n\t\ttoolbar.hidden = true;\n\t\tclearExpandedLayoutInline();\n\t\troot.dataset.state = 'collapsed';\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\troot.classList.remove('liforma-ew--session-concealing');\n\t\tsettingsBtn.setAttribute('aria-pressed', 'false');\n\t\thit.hidden = false;\n\t\thit.tabIndex = 0;\n\t\thit.removeAttribute('aria-hidden');\n\t\tif (previewReady) hit.disabled = false;\n\t\tsetStatus(null);\n\t\tif (typeof document !== 'undefined') {\n\t\t\tdocument.body.style.overflow = previousOverflow;\n\t\t}\n\t\tsyncDockToggleChrome();\n\t};\n\n\tconst hardTeardownSession = () => {\n\t\tclearCollapseRevealTimer();\n\t\tclearLayoutSettleTimer();\n\t\texpandEpoch += 1;\n\t\texpanding = false;\n\t\twarmReady = false;\n\t\twarmInFlight = false;\n\t\tshellMounted = false;\n\t\tsessionStarted = false;\n\t\tconst session = experience;\n\t\texperience = null;\n\t\tsession?.destroy();\n\t\tstage.replaceChildren();\n\t\twarmStage.replaceChildren();\n\t\twarmStage.hidden = true;\n\t\tdelete root.dataset.warm;\n\t\tdelete root.dataset.live;\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t};\n\n\tconst collapse = () => {\n\t\tif (destroyed) return;\n\t\tif (!isOpenShell(root.dataset.state)) return;\n\t\tendDockDrag();\n\t\texpanding = false;\n\n\t\t/*\n\t\t * Keep any attached session (warm or cold, started or waiting on Tap to talk).\n\t\t * Only CSS-collapse / pause — never remint on the next open.\n\t\t */\n\t\tif (experience && shellMounted) {\n\t\t\tconst session = experience;\n\t\t\tvoid (async () => {\n\t\t\t\tif (sessionStarted) {\n\t\t\t\t\tawait concealLiveSession();\n\t\t\t\t\tif (destroyed || experience !== session) return;\n\t\t\t\t}\n\t\t\t\tif (warmReady) {\n\t\t\t\t\tsession.setWidgetChrome('collapsed');\n\t\t\t\t}\n\t\t\t\trestoreCollapsedChrome();\n\t\t\t\tif (sessionStarted) {\n\t\t\t\t\troot.dataset.live = 'true';\n\t\t\t\t\t/* Face receives the next click; warm iframe stays hidden under the thumb. */\n\t\t\t\t\thit.tabIndex = 0;\n\t\t\t\t\thit.removeAttribute('aria-hidden');\n\t\t\t\t\thit.disabled = false;\n\t\t\t\t} else if (warmReady) {\n\t\t\t\t\tarmWarmHit();\n\t\t\t\t}\n\t\t\t\toptions.onCollapsed?.();\n\t\t\t\toptions.onClose?.();\n\t\t\t})();\n\t\t\treturn;\n\t\t}\n\n\t\thardTeardownSession();\n\t\trestoreCollapsedChrome();\n\t\toptions.onCollapsed?.();\n\t\toptions.onClose?.();\n\t};\n\n\tconst dock = () => {\n\t\tif (destroyed) return;\n\t\tif (!isDesktopViewport()) return;\n\t\tif (shellState() !== 'expanded') return;\n\t\tsettleLayoutThenReveal(() => {\n\t\t\tshowDockedShell();\n\t\t});\n\t};\n\n\tconst maximize = () => {\n\t\tif (destroyed) return;\n\t\tif (shellState() !== 'docked') return;\n\t\tendDockDrag();\n\t\tsettleLayoutThenReveal(() => {\n\t\t\tclearExpandedLayoutInline();\n\t\t\tshowExpandedShell(false);\n\t\t\texperience?.setWidgetChrome('expanded');\n\t\t});\n\t};\n\n\tconst resumeLiveSession = () => {\n\t\tif (!experience || !sessionStarted) return;\n\t\tclearCollapseRevealTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\tshowExpandedShell();\n\t\texperience.setWidgetChrome('expanded');\n\t\texpanding = false;\n\t\trevealLiveSession();\n\t};\n\n\t/** Re-open an attached session that has not unlocked yet (warm or cold Tap to talk). */\n\tconst resumeMountedSession = () => {\n\t\tif (!experience || !shellMounted || sessionStarted) return;\n\t\tclearCollapseRevealTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\tshowExpandedShell();\n\t\texpanding = false;\n\t\tif (warmReady) {\n\t\t\texperience.setWidgetChrome('expanded');\n\t\t}\n\t};\n\n\tconst onWarmExpand = (epoch: number) => {\n\t\tif (destroyed) return;\n\t\tif (epoch !== expandEpoch && !sessionStarted) return;\n\t\tclearCollapseRevealTimer();\n\t\troot.classList.remove('liforma-ew--session-revealed');\n\t\tshowExpandedShell();\n\t\texpanding = false;\n\t\texperience?.setWidgetChrome('expanded');\n\t\tif (sessionStarted) {\n\t\t\trevealLiveSession();\n\t\t}\n\t};\n\n\tconst beginWarm = () => {\n\t\tif (\n\t\t\tdestroyed ||\n\t\t\twarmInFlight ||\n\t\t\twarmReady ||\n\t\t\texperience ||\n\t\t\tisOpenShell(root.dataset.state)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\twarmInFlight = true;\n\t\tconst epoch = expandEpoch;\n\t\twarmStage.hidden = false;\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tconst session = await Experience.startSession(sessionLaunchOptions());\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\texperience = session;\n\t\t\t\tbindSessionLifecycle(session);\n\t\t\t\tconst player = await session.attach({\n\t\t\t\t\tcontainer: warmStage,\n\t\t\t\t\tonWidgetReady: () => {\n\t\t\t\t\t\tif (destroyed || epoch !== expandEpoch) return;\n\t\t\t\t\t\twarmInFlight = false;\n\t\t\t\t\t\tshellMounted = true;\n\t\t\t\t\t\tarmWarmHit();\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetExpand: () => {\n\t\t\t\t\t\tonWarmExpand(epoch);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetAudioSettings: (open) => {\n\t\t\t\t\t\tif (!destroyed) syncSettingsPressed(open);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetDragStart: (event) => {\n\t\t\t\t\t\tif (!destroyed) beginDockDragFromPlayer(event);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetDragMove: (event) => {\n\t\t\t\t\t\tif (!destroyed) moveDockDragFromPlayer(event);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetDragEnd: (event) => {\n\t\t\t\t\t\tif (!destroyed) endDockDragFromPlayer(event);\n\t\t\t\t\t},\n\t\t\t\t\tonStateUpdate: (state) => {\n\t\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\t\tif (state === 'error' && isOpenShell(root.dataset.state)) {\n\t\t\t\t\t\t\tsetStatus('Could not load the experience.');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\tif (experience === session) experience = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tshellMounted = true;\n\t\t\t\tplayer.on('close', () => {\n\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\tcollapse();\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (destroyed || epoch !== expandEpoch) return;\n\t\t\t\twarmInFlight = false;\n\t\t\t\twarmStage.hidden = true;\n\t\t\t\twarmStage.replaceChildren();\n\t\t\t\texperience = null;\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\toptions.onError?.(err);\n\t\t\t\tconsole.error('[ExperienceWidget] warm prefetch failed', err);\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst expandCold = () => {\n\t\tif (destroyed || expanding || !previewReady || isOpenShell(root.dataset.state)) return;\n\t\tif (experience && sessionStarted) {\n\t\t\tresumeLiveSession();\n\t\t\treturn;\n\t\t}\n\t\tif (experience && shellMounted) {\n\t\t\tresumeMountedSession();\n\t\t\treturn;\n\t\t}\n\t\tconst epoch = ++expandEpoch;\n\t\texpanding = true;\n\t\twarmReady = false;\n\t\twarmInFlight = false;\n\t\tshellMounted = false;\n\t\tsessionStarted = false;\n\t\tdelete root.dataset.warm;\n\t\tdelete root.dataset.live;\n\t\twarmStage.hidden = true;\n\t\twarmStage.replaceChildren();\n\t\tif (experience) {\n\t\t\texperience.destroy();\n\t\t\texperience = null;\n\t\t}\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tshowExpandedShell();\n\t\t\t\tconst session = await Experience.startSession(sessionLaunchOptions());\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\texperience = session;\n\t\t\t\tbindSessionLifecycle(session);\n\t\t\t\tconst player = await session.attach({\n\t\t\t\t\tcontainer: stage,\n\t\t\t\t\tonWidgetAudioSettings: (open) => {\n\t\t\t\t\t\tif (!destroyed) syncSettingsPressed(open);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetDragStart: (event) => {\n\t\t\t\t\t\tif (!destroyed) beginDockDragFromPlayer(event);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetDragMove: (event) => {\n\t\t\t\t\t\tif (!destroyed) moveDockDragFromPlayer(event);\n\t\t\t\t\t},\n\t\t\t\t\tonWidgetDragEnd: (event) => {\n\t\t\t\t\t\tif (!destroyed) endDockDragFromPlayer(event);\n\t\t\t\t\t},\n\t\t\t\t\tonStateUpdate: (state) => {\n\t\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\t\tif (state === 'error') {\n\t\t\t\t\t\t\tsetStatus('Could not load the experience.');\n\t\t\t\t\t\t} else if (isOpenShell(root.dataset.state)) {\n\t\t\t\t\t\t\tsetStatus(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (destroyed || epoch !== expandEpoch) {\n\t\t\t\t\tsession.destroy();\n\t\t\t\t\tif (experience === session) experience = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tshellMounted = true;\n\t\t\t\tplayer.on('close', () => {\n\t\t\t\t\tif (destroyed) return;\n\t\t\t\t\tcollapse();\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (destroyed || epoch !== expandEpoch) return;\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tsetStatus(err.message);\n\t\t\t\toptions.onError?.(err);\n\t\t\t\tconsole.error('[ExperienceWidget]', err);\n\t\t\t} finally {\n\t\t\t\tif (epoch === expandEpoch) {\n\t\t\t\t\texpanding = false;\n\t\t\t\t}\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst expand = () => {\n\t\tif (destroyed || isOpenShell(root.dataset.state)) return;\n\t\tif (experience && sessionStarted) {\n\t\t\tresumeLiveSession();\n\t\t\treturn;\n\t\t}\n\t\tif (experience && shellMounted) {\n\t\t\t/*\n\t\t\t * Warm path: prefer the iframe hit (audio unlock). If the FAB receives the click\n\t\t\t * instead, still restore the open shell without reminting.\n\t\t\t */\n\t\t\tresumeMountedSession();\n\t\t\treturn;\n\t\t}\n\t\texpandCold();\n\t};\n\n\tconst onDockToggleClick = (event: MouseEvent) => {\n\t\tevent.stopPropagation();\n\t\tif (shellState() === 'expanded') {\n\t\t\tdock();\n\t\t\treturn;\n\t\t}\n\t\tif (shellState() === 'docked') {\n\t\t\tmaximize();\n\t\t}\n\t};\n\n\tconst syncSettingsPressed = (open: boolean) => {\n\t\tsettingsBtn.setAttribute('aria-pressed', open ? 'true' : 'false');\n\t};\n\n\tconst onSettingsClick = (event: MouseEvent) => {\n\t\tevent.stopPropagation();\n\t\tif (!isOpenShell(root.dataset.state)) return;\n\t\texperience?.toggleAudioSettings();\n\t};\n\n\tconst onToolbarPointerDown = (event: PointerEvent) => {\n\t\tif (shellState() !== 'docked') return;\n\t\tif (!isDesktopViewport()) return;\n\t\tconst target = event.target as HTMLElement | null;\n\t\tif (target?.closest('button')) return;\n\t\tevent.preventDefault();\n\t\tbeginToolbarDockDrag(event.clientX, event.clientY, event.pointerId);\n\t};\n\n\tconst onKeyDown = (event: KeyboardEvent) => {\n\t\tif (event.key === 'Escape' && isOpenShell(root.dataset.state)) {\n\t\t\tevent.preventDefault();\n\t\t\tcollapse();\n\t\t}\n\t};\n\n\tconst onWindowResize = () => {\n\t\tif (destroyed) return;\n\t\tif (shellState() === 'docked') {\n\t\t\tif (!isDesktopViewport()) {\n\t\t\t\tmaximize();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (sessionStarted) {\n\t\t\t\tsettleLayoutThenReveal(() => {\n\t\t\t\t\tlayoutDockedShell(true);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tlayoutDockedShell(true);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsyncDockToggleChrome();\n\t};\n\n\tconst desktopMq =\n\t\ttypeof window !== 'undefined' ? window.matchMedia(WIDGET_DESKTOP_MEDIA) : null;\n\tconst onDesktopMqChange = () => {\n\t\tif (destroyed) return;\n\t\tif (shellState() === 'docked' && !isDesktopViewport()) {\n\t\t\tmaximize();\n\t\t\treturn;\n\t\t}\n\t\tsyncDockToggleChrome();\n\t};\n\n\thit.addEventListener('click', expand);\n\tbackdrop.addEventListener('click', collapse);\n\tcloseBtn.addEventListener('click', (event) => {\n\t\tevent.stopPropagation();\n\t\tcollapse();\n\t});\n\tdockToggleBtn.addEventListener('click', onDockToggleClick);\n\tsettingsBtn.addEventListener('click', onSettingsClick);\n\ttoolbar.addEventListener('pointerdown', onToolbarPointerDown);\n\twindow.addEventListener('keydown', onKeyDown);\n\twindow.addEventListener('resize', onWindowResize);\n\tdesktopMq?.addEventListener('change', onDesktopMqChange);\n\n\tpaintOrFetchPreview();\n\tsyncDockToggleChrome();\n\n\tif (prefetchMode === 'eager') {\n\t\tqueueMicrotask(() => {\n\t\t\tif (!destroyed) beginWarm();\n\t\t});\n\t} else if (prefetchMode === 'idle') {\n\t\tcancelWarmSchedule = scheduleIdle(() => {\n\t\t\tif (!destroyed) beginWarm();\n\t\t});\n\t}\n\n\treturn {\n\t\troot,\n\t\texpand,\n\t\tcollapse,\n\t\tdock,\n\t\tmaximize,\n\t\tprefetch() {\n\t\t\tif (prefetchMode === 'onExpand') {\n\t\t\t\tbeginWarm();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbeginWarm();\n\t\t},\n\t\tdestroy() {\n\t\t\tif (destroyed) return;\n\t\t\tdestroyed = true;\n\t\t\tendDockDrag();\n\t\t\tcancelWarmSchedule?.();\n\t\t\tcancelWarmSchedule = null;\n\t\t\tpreviewAbort.abort();\n\t\t\tdetachFaceParallax?.();\n\t\t\tdetachFaceParallax = null;\n\t\t\twindow.removeEventListener('keydown', onKeyDown);\n\t\t\twindow.removeEventListener('resize', onWindowResize);\n\t\t\tdesktopMq?.removeEventListener('change', onDesktopMqChange);\n\t\t\thardTeardownSession();\n\t\t\trestoreCollapsedChrome();\n\t\t\thost.replaceChildren();\n\t\t}\n\t};\n}\n","import { mountExperienceWidget } from '../widget/mountExperienceWidget';\nimport type {\n\tExperienceWidgetController,\n\tExperienceWidgetPosition\n} from '../widget/types';\nimport type { GalleryThumb } from '../thumbnail/types';\nimport type {\n\tExperienceFit,\n\tExperienceMode,\n\tSpeechInputMode\n} from './types/sessionInteraction';\n\nconst ELEMENT_NAME = 'liforma-experience-widget';\n\nfunction parseGalleryThumb(raw: string | null): GalleryThumb | undefined {\n\tif (!raw?.trim()) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\tif (parsed && typeof parsed === 'object' && typeof (parsed as GalleryThumb).avatarImage === 'string') {\n\t\t\treturn parsed as GalleryThumb;\n\t\t}\n\t} catch {\n\t\t/* ignore */\n\t}\n\treturn undefined;\n}\n\nfunction parseMode(value: string | null): ExperienceMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'conversation' || trimmed === 'presenter' ? trimmed : undefined;\n}\n\nfunction parseSpeechInputMode(value: string | null): SpeechInputMode | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'auto' || trimmed === 'manual' || trimmed === 'off' ? trimmed : undefined;\n}\n\nfunction parseFit(value: string | null): ExperienceFit | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'full' || trimmed === 'face' ? trimmed : undefined;\n}\n\nfunction parseLanguage(value: string | null): 'en' | 'es' | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'en' || trimmed === 'es' ? trimmed : undefined;\n}\n\nfunction parsePosition(value: string | null): ExperienceWidgetPosition {\n\tconst trimmed = value?.trim();\n\treturn trimmed === 'bottom-right' || trimmed === 'bottom-left' ? trimmed : 'static';\n}\n\nexport class LiformaExperienceWidgetElement extends HTMLElement {\n\tstatic get observedAttributes() {\n\t\treturn [\n\t\t\t'experience-id',\n\t\t\t'alt',\n\t\t\t'gallery-thumb',\n\t\t\t'avatar-image',\n\t\t\t'background-image',\n\t\t\t'foreground-image',\n\t\t\t'fallback-image',\n\t\t\t'prefetch',\n\t\t\t'parallax',\n\t\t\t'position',\n\t\t\t'offset',\n\t\t\t'session-endpoint',\n\t\t\t'language',\n\t\t\t'mode',\n\t\t\t'speech-input-mode',\n\t\t\t'speech-only',\n\t\t\t'fit',\n\t\t\t'expanded-max-width',\n\t\t\t'expanded-max-height',\n\t\t\t'start-button-label'\n\t\t];\n\t}\n\n\t#controller: ExperienceWidgetController | null = null;\n\t#host: HTMLDivElement | null = null;\n\n\tconnectedCallback() {\n\t\tthis.#applyHostBox();\n\t\tthis.#mount();\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#controller?.destroy();\n\t\tthis.#controller = null;\n\t}\n\n\tattributeChangedCallback() {\n\t\tif (!this.isConnected) return;\n\t\tthis.#applyHostBox();\n\t\tthis.#mount();\n\t}\n\n\t#applyHostBox() {\n\t\tconst position = parsePosition(this.getAttribute('position'));\n\t\tif (position !== 'static') {\n\t\t\t// Fixed FAB lives on `.liforma-ew`; collapse CE + host so they leave no layout hole.\n\t\t\tthis.style.display = 'contents';\n\t\t\tthis.style.removeProperty('width');\n\t\t\tthis.style.removeProperty('height');\n\t\t\tthis.style.removeProperty('min-height');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.style.display = 'block';\n\t\tthis.style.width ||= '100%';\n\t\tthis.style.height ||= '100%';\n\t\tif (!this.style.minHeight) {\n\t\t\tconst min = getComputedStyle(this).minHeight;\n\t\t\tif (min === '0px' || min === 'auto') {\n\t\t\t\tthis.style.minHeight = '224px';\n\t\t\t}\n\t\t}\n\t}\n\n\t#mount() {\n\t\tthis.#controller?.destroy();\n\t\tthis.#controller = null;\n\n\t\tconst experienceId = this.getAttribute('experience-id')?.trim();\n\t\tconst alt = this.getAttribute('alt')?.trim() || 'Open experience';\n\t\tif (!experienceId) return;\n\n\t\tconst position = parsePosition(this.getAttribute('position'));\n\n\t\tif (!this.#host) {\n\t\t\tthis.#host = document.createElement('div');\n\t\t\tthis.replaceChildren(this.#host);\n\t\t}\n\t\tthis.#host.style.cssText =\n\t\t\tposition === 'static'\n\t\t\t\t? 'width:100%;height:100%;min-height:inherit;'\n\t\t\t\t: 'display:contents;';\n\n\t\tconst prefetchAttr = this.getAttribute('prefetch')?.trim();\n\t\tconst prefetch =\n\t\t\tprefetchAttr === 'idle' || prefetchAttr === 'eager' || prefetchAttr === 'onExpand'\n\t\t\t\t? prefetchAttr\n\t\t\t\t: 'onExpand';\n\n\t\tconst speechOnlyAttr = this.getAttribute('speech-only');\n\t\tconst offsetAttr = this.getAttribute('offset');\n\n\t\ttry {\n\t\t\tthis.#controller = mountExperienceWidget(this.#host, {\n\t\t\t\texperienceId,\n\t\t\t\talt,\n\t\t\t\tgalleryThumb: parseGalleryThumb(this.getAttribute('gallery-thumb')),\n\t\t\t\tavatarImage: this.getAttribute('avatar-image') ?? undefined,\n\t\t\t\tbackgroundImage: this.getAttribute('background-image') ?? undefined,\n\t\t\t\tforegroundImage: this.getAttribute('foreground-image') ?? undefined,\n\t\t\t\tfallbackImage: this.getAttribute('fallback-image') ?? undefined,\n\t\t\t\tprefetch,\n\t\t\t\tparallax: this.getAttribute('parallax') !== 'false',\n\t\t\t\tposition,\n\t\t\t\toffset: offsetAttr === null ? undefined : offsetAttr,\n\t\t\t\tsessionEndpoint: this.getAttribute('session-endpoint') ?? undefined,\n\t\t\t\tlanguage: parseLanguage(this.getAttribute('language')),\n\t\t\t\tmode: parseMode(this.getAttribute('mode')),\n\t\t\t\tspeechInputMode: parseSpeechInputMode(this.getAttribute('speech-input-mode')),\n\t\t\t\tspeechOnly:\n\t\t\t\t\tspeechOnlyAttr === null\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: speechOnlyAttr === '' || speechOnlyAttr === 'true',\n\t\t\t\tfit: parseFit(this.getAttribute('fit')),\n\t\t\t\texpandedMaxWidth: this.getAttribute('expanded-max-width') ?? undefined,\n\t\t\t\texpandedMaxHeight: this.getAttribute('expanded-max-height') ?? undefined,\n\t\t\t\tstartButtonLabel: this.getAttribute('start-button-label') ?? undefined,\n\t\t\t\tonExpanded: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('expanded', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonCollapsed: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('collapsed', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonStarted: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('started', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonClose: () => {\n\t\t\t\t\tthis.dispatchEvent(new CustomEvent('close', { bubbles: true }));\n\t\t\t\t},\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent('error', { detail: error, bubbles: true })\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error('[liforma-experience-widget]', error);\n\t\t}\n\t}\n}\n\nif (typeof customElements !== 'undefined' && !customElements.get(ELEMENT_NAME)) {\n\tcustomElements.define(ELEMENT_NAME, LiformaExperienceWidgetElement);\n}\n","import './liforma-experience';\nimport './liforma-experience-thumbnail';\nimport './liforma-experience-widget';\n\nexport { Experience, type ExperienceSession } from './experience';\nexport type {\n\tAttachOptions,\n\tCloseEvent,\n\tEmbedState,\n\tLiformaPlayer,\n\tReadyEvent,\n\tStartSessionOptions\n} from './experience';\nexport type { SessionManifest, SessionManifestCharacter } from './types/sessionManifest';\nexport type { ExperienceEventName, ExperienceEvents } from './experienceEvents';\nexport type {\n\tCharacterSpeechEvent,\n\tCharacterSpeechSource,\n\tCharacterSpeechTerminalReason,\n\tConversationMessage,\n\tSpeakOptions,\n\tTextSpeakResult,\n\tSpeechResult as LegacySpeakResult,\n\tUserTranscriptUpdate,\n\tUtteranceResult,\n\tExperienceFit,\n\tExperienceMode,\n\tResponseMode,\n\tSpeechInputMode,\n\tStartButtonAppearance,\n\tStartButtonOptions,\n\tStartButtonPlacement,\n\tStartButtonShadow,\n\tStartButtonSize,\n\tStartButtonVariant,\n\tStartedEvent,\n} from './types/sessionInteraction';\nexport type {\n\tSpeechAudioFormat,\n\tSpeechController,\n\tSpeechCreateUtteranceOptions,\n\tSpeechInterruptOptions,\n\tSpeechPlayAudio,\n\tSpeechPlayEncodedAudio,\n\tSpeechPlayOptions,\n\tSpeechPlayPcmAudio,\n\tSpeechPlayUrlAudio,\n\tSpeechResult,\n\tSpeechSpeakOptions,\n\tSpeechUtterance\n} from './speech';\nexport {\n\tSPEECH_LIMITS,\n\tSpeechBufferTimeoutError,\n\tSpeechRuntimeError,\n\tSpeechUtteranceClosedError,\n\tUnsupportedSpeechOperationError\n} from './speech';\n\nimport { Experience } from './experience';\n\ndeclare global {\n\tinterface Window {\n\t\tLiforma?: {\n\t\t\tExperience: typeof Experience;\n\t\t\tsdkVersion: 'v2';\n\t\t\treadonly features: {\n\t\t\t\treadonly speakApi: boolean;\n\t\t\t\treadonly speechAudioApi: boolean;\n\t\t\t};\n\t\t};\n\t}\n}\n\nwindow.Liforma = {\n\tExperience,\n\tsdkVersion: 'v2',\n\tfeatures: {\n\t\tspeakApi: true,\n\t\tspeechAudioApi: true\n\t}\n};\n"],"x_google_ignoreList":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],"mappings":"sFAIA,SAAgB,GAAiC,CAChD,GAAK,WAA4C,kBAAoB,QACpE,MAAO,GAGR,GAAI,OAAO,SAAa,IACvB,MAAO,GAGR,GAAI,CACH,OAAO,IAAI,gBAAgB,SAAS,MAAM,EAAE,IAAI,OAAO,IAAM,OAC9D,MAAQ,CACP,MAAO,EACR,CACD,CChBA,IAAM,EAA0B,yBAC1B,EAAqB,wBAE3B,SAAS,GAA0C,CAClD,IAAM,EAAe,WAAmD,uBACxE,GAAI,GAAa,KAAK,EACrB,OAAO,EAAY,KAAK,EAAE,QAAQ,MAAO,EAAE,EAG5C,GAAI,OAAO,SAAa,IACvB,OAAO,KAMR,IAAM,GAFL,SAAS,cAAc,4CAA4C,GACnE,SAAS,cAAc,kCAAkC,IAC/B,aAAa,mBAAmB,GAAG,KAAK,EAKnE,OAJI,EACI,EAAW,QAAQ,MAAO,EAAE,EAG7B,IACR,CAcA,SAAgB,GAAkC,CAUjD,OATmB,EACf,IAIA,EAAsB,EAClB,EAGD,EACR,CCpCA,SAAgB,EACf,EACA,EACuD,CACvD,IAAM,EAAW,EAAgB,KAAK,EACtC,GAAI,CAAC,E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