{"version":3,"file":"index.cjs","names":["floatSafeRemainder","F","_a","util.jsonStringifyReplacer","initializer","_parse","core.$ZodAsyncError","util.finalizeIssue","core.config","validateAsync","_emoji","number","boolean","_null","util.nullish","util.floatSafeRemainder","util.NUMBER_FORMAT_RANGES","util.codePointLength","util.getLengthableOrigin","regexes.lowercase","regexes.uppercase","util.escapeRegex","util.prefixIssues","content","util.aborted","util.explicitlyAborted","core.$ZodAsyncError","util.hide","util.finalizeIssue","core.config","regexes.anyString","regexes.guid","regexes.uuid","regexes.email","regexes.emoji","regexes.nanoid","regexes.nanoidOfLength","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.e164","isValidJWT","regexes.number","regexes.boolean","regexes.null","util.sizeCaps","util.prefixIssues","util.optionalKeys","util.cached","isObject","util.isObject","util.esc","allowsEval","util.allowsEval","util.cleanRegex","util.rawShape","mergeValues","util.isPlainObject","util.getEnumValues","util.escapeRegex","core.$ZodEncodeError","util.issue","util.rawShape","util.parsedType","util.stringifyPrimitive","util.joinValues","_a","util.normalizeParams","_null","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.$ZodCheckProperties","checks.$ZodCheckOverwrite","util.slugify","issue","util.issue","checks.$ZodCheck","addPattern","regexes.base64","regexes.base64url","regexes.number","regexes.integer","core.formatError","core.flattenError","util.jsonStringifyReplacer","en","core.memoizer","ZodType","util.mergeDefs","core.clone","checks.overwrite","array","util.hide","core.standardProps","parse.parse","parse.parseAsync","parse.safeParse","parse.safeParseAsync","parse.validate","parse.validateAsync","parse.encode","parse.decode","parse.encodeAsync","parse.decodeAsync","parse.safeEncode","parse.safeDecode","parse.safeEncodeAsync","parse.safeDecodeAsync","processors.stringProcessor","processors.aggregateChecks","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","ZodString","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","core._isoDateTime","core._isoDate","core._isoTime","core._isoDuration","core._string","ZodNumber","processors.numberProcessor","checks.gt","checks.gte","checks.lt","checks.lte","checks.multipleOf","core._number","core._int","ZodBoolean","processors.booleanProcessor","core._boolean","ZodNull","processors.nullProcessor","core._null","ZodUnknown","processors.unknownProcessor","core._unknown","ZodNever","processors.neverProcessor","core._never","ZodArray","processors.arrayProcessor","core._array","ZodObject","processors.objectProcessor","util.extend","util.safeExtend","util.merge","util.pick","util.omit","util.partial","ZodOptional","util.required","object","util.normalizeParams","ZodUnion","processors.unionProcessor","ZodDiscriminatedUnion","ZodIntersection","processors.intersectionProcessor","ZodRecord","processors.recordProcessor","ZodEnum","processors.enumProcessor","ZodLiteral","processors.literalProcessor","processors.transformProcessor","core.$ZodEncodeError","issue","util.issue","processors.optionalProcessor","ZodNullable","processors.nullableProcessor","ZodDefault","processors.defaultProcessor","util.shallowClone","processors.prefaultProcessor","processors.nonoptionalProcessor","ZodCatch","processors.catchProcessor","core.util.constantCatch","processors.pipeProcessor","ZodReadonly","processors.readonlyProcessor","ZodLazy","processors.lazyProcessor","processors.customProcessor","core._custom","core._refine","core._superRefine","core._properties","defaultErrorMap","defaultErrorMap","emojiRegex","regex","defaultErrorMap","marker$1","symbol$1","_a$1","_b$1","AISDKError","name$1","marker2","symbol2","_a2","_b2","APICallError","name2","marker3","symbol3","_a3","_b3","EmptyResponseBodyError","getErrorMessage$1","name3","marker4","symbol4","_a4","_b4","InvalidArgumentError","name4","marker5","symbol5","_a5","_b5","InvalidPromptError","name5","marker6","symbol6","_a6","_b6","InvalidResponseDataError","name6","marker7","symbol7","_a7","_b7","JSONParseError","name7","marker8","symbol8","_a8","_b8","LoadAPIKeyError","name8","marker9","symbol9","_a9","_b9","LoadSettingError","name9","marker10","symbol10","_a10","_b10","NoContentGeneratedError","name10","marker11","symbol11","_a11","_b11","NoSuchModelError","name11","marker12","symbol12","_a12","_b12","TooManyEmbeddingValuesForCallError","name12","marker13","symbol13","_a13","_b13","TypeValidationError","name13","marker14","symbol14","_a14","_b14","UnsupportedFunctionalityError","ParseError","LF","CR","SPACE","noop","createParser","isDataPrefix","isEventPrefix","EventSourceParserStream","name","marker","symbol","_a","_b","DownloadError","cancelResponseBody","isBrowserRuntime","isSameOrigin","validateDownloadUrl","isPrivateIPv6","isIPv4","isPrivateIPv4","validateDownloadAddress","parseIPv6","createSafeLookup","safeNodeFetchPromise","isNodeRuntime","getDefaultDownloadFetch","createSafeNodeFetch","loadNodeModule","getCurrentModulePath","MAX_DOWNLOAD_REDIRECTS","getValidatedFetch","fetchWithValidatedRedirects","DEFAULT_MAX_DOWNLOAD_SIZE","readResponseWithSizeLimit","createIdGenerator","generateId","getRuntimeEnvironmentUserAgent","normalizeHeaders","withUserAgentSuffix","suspectProtoRx","suspectConstructorRx","_parse","filter","secureJsonParse","validatorSymbol","validator","isValidator","asValidator","safeValidateTypes","safeParseJSON","textDecoder","schemaSymbol","jsonSchema","addAdditionalPropertiesToJsonSchema","ignoreOverride","defaultOptions","getDefaultOptions","parseAnyDef","parseArrayDef","parseDef","parseBigintDef","parseBooleanDef","parseBrandedDef","parseCatchDef","parseDateDef","integerDateParser","parseDefaultDef","parseEffectsDef","parseEnumDef","isJsonSchema7AllOfType","parseIntersectionDef","parseLiteralDef","emojiRegex","zodPatterns","parseStringDef","escapeLiteralCheckValue","escapeNonAlphaNumeric","ALPHA_NUMERIC","addFormat","addPattern","stringifyRegExpWithFlags","parseRecordDef","parseMapDef","parseNativeEnumDef","parseNeverDef","parseNullDef","primitiveMappings","parseUnionDef","asAnyOf","parseNullableDef","parseNumberDef","parseObjectDef","safeIsOptional","decideAdditionalProperties","parseOptionalDef","parsePipelineDef","parsePromiseDef","parseSetDef","parseTupleDef","parseUndefinedDef","parseUnknownDef","parseReadonlyDef","selectParser","getRelativePath","get$ref","addMeta","getRefs","zodToJsonSchema","zod3Schema","zod4Schema","z4.toJSONSchema","z4.safeParseAsync","isZod4Schema","zodSchema","isSchema","asSchema","_globalThis","VERSION$1","re","_makeCompatibilityCheck","isCompatible","major","GLOBAL_OPENTELEMETRY_API_KEY","_global","registerGlobal","getGlobal","unregisterGlobal","__read$3","__spreadArray$3","DiagComponentLogger","logProxy","DiagLogLevel","createLogLevelDiagLogger","__read$2","__spreadArray$2","API_NAME$2","DiagAPI","createContextKey","ROOT_CONTEXT","__read$1","__spreadArray$1","NoopContextManager","__read","__spreadArray","API_NAME$1","NOOP_CONTEXT_MANAGER","ContextAPI","TraceFlags","INVALID_SPAN_CONTEXT","NonRecordingSpan","SPAN_KEY","getSpan","getActiveSpan","setSpan","deleteSpan","setSpanContext","getSpanContext","VALID_TRACEID_REGEX","VALID_SPANID_REGEX","isValidTraceId","isValidSpanId","isSpanContextValid","wrapSpanContext","contextApi","NoopTracer","isSpanContext","NOOP_TRACER","ProxyTracer","NOOP_TRACER_PROVIDER","ProxyTracerProvider","SpanStatusCode","API_NAME","trace","__defProp","__export","name","marker","symbol","_a","name2","marker2","symbol2","_a2","name3","marker3","symbol3","_a3","name4","marker4","symbol4","_a4","name5","marker5","symbol5","_a5","name6","marker6","symbol6","_a6","NoObjectGeneratedError","AISDKError","name7","marker7","symbol7","_a7","name8","marker8","symbol8","_a8","name9","marker9","symbol9","_a9","name10","marker10","symbol10","_a10","name11","marker11","symbol11","_a11","name12","marker12","symbol12","_a12","name13","marker13","symbol13","_a13","name14","marker14","symbol14","_a14","VERSION","download","withUserAgentSuffix","getRuntimeEnvironmentUserAgent","fetchWithValidatedRedirects","cancelResponseBody","readResponseWithSizeLimit","DEFAULT_MAX_DOWNLOAD_SIZE","dataContentSchema","z.union","z.string","z.instanceof","z.custom","jsonValueSchema","z.lazy","z.null","z.number","z.boolean","z.record","z.array","providerMetadataSchema","textPartSchema","z.object","z.literal","imagePartSchema","filePartSchema","reasoningPartSchema","toolCallPartSchema","z.unknown","outputSchema","z.discriminatedUnion","toolResultPartSchema","systemModelMessageSchema","userModelMessageSchema","assistantModelMessageSchema","toolModelMessageSchema","modelMessageSchema","originalGenerateId","createIdGenerator","JsonToSseTransformStream","uiMessageChunkSchema","zodSchema","z.looseObject","z.enum","fixJson","parsePartialJson","safeParseJSON","originalGenerateId2","textEncoder","originalGenerateId3","createDownload","originalGenerateId4","output_exports","object","text","asSchema","safeValidateTypes","customProvider","NoSuchModelError","name15","marker15","symbol15","_a15","defaultDownload","uiMessagesSchema","z.never","marker","symbol","_a","AISDKError","name","marker2","symbol2","_a2","name2","marker3","symbol3","_a3","name3","marker4","symbol4","_a4","InvalidArgumentError","name4","marker5","symbol5","_a5","name5","marker6","symbol6","_a6","name6","marker7","symbol7","_a7","JSONParseError","name7","marker8","symbol8","_a8","name9","marker10","symbol10","_a10","name10","marker11","symbol11","_a11","NoSuchModelError","name12","marker13","symbol13","_a13","TypeValidationError","name13","marker14","symbol14","_a14","createIdGenerator","generateId","safeValidateTypes","TypeValidationError","safeParseJSON","JSONParseError","ignoreOverride","defaultOptions","getDefaultOptions","getRefs","getRelativePath","parseAnyDef","parseArrayDef","parseDef","parseBigintDef","parseBooleanDef","parseBrandedDef","parseCatchDef","parseDateDef","integerDateParser","parseDefaultDef","parseEffectsDef","parseEnumDef","isJsonSchema7AllOfType","parseIntersectionDef","parseLiteralDef","emojiRegex","zodPatterns","parseStringDef","escapeLiteralCheckValue","escapeNonAlphaNumeric","ALPHA_NUMERIC","addFormat","addPattern","stringifyRegExpWithFlags","parseRecordDef","parseMapDef","parseNativeEnumDef","parseNeverDef","parseNullDef","primitiveMappings","parseUnionDef","asAnyOf","parseNullableDef","parseNumberDef","parseObjectDef","safeIsOptional","decideAdditionalProperties","parseOptionalDef","parsePipelineDef","parsePromiseDef","parseSetDef","parseTupleDef","parseUndefinedDef","parseUnknownDef","parseReadonlyDef","selectParser","get$ref","addMeta","fixJson","parsePartialJson","zodSchema","jsonSchema","schemaSymbol","isSchema","asSchema","VERSION","re","_makeCompatibilityCheck","isCompatible","major","GLOBAL_OPENTELEMETRY_API_KEY","_global","registerGlobal","getGlobal","unregisterGlobal","DiagComponentLogger","logProxy","DiagLogLevel","createLogLevelDiagLogger","API_NAME$2","DiagAPI","createContextKey","ROOT_CONTEXT","NoopContextManager","API_NAME$1","NOOP_CONTEXT_MANAGER","ContextAPI","TraceFlags","INVALID_SPAN_CONTEXT","NonRecordingSpan","SPAN_KEY","getSpan","getActiveSpan","setSpan","deleteSpan","setSpanContext","getSpanContext","isValidTraceId","isValidSpanId","isSpanContextValid","wrapSpanContext","contextApi","NoopTracer","isSpanContext","NOOP_TRACER","ProxyTracer","NOOP_TRACER_PROVIDER","ProxyTracerProvider","SpanStatusCode","API_NAME","trace","__defProp","__export","name","marker","symbol","_a","name2","marker2","symbol2","_a2","name3","marker3","symbol3","_a3","name4","marker4","symbol4","_a4","NoObjectGeneratedError","AISDKError","name5","marker5","symbol5","_a5","name6","marker6","symbol6","_a6","dataContentSchema","z.union","z.string","z.instanceof","z.custom","name7","marker7","symbol7","_a7","name8","marker8","symbol8","_a8","jsonValueSchema","z.lazy","z.null","z.number","z.boolean","z.record","z.array","providerMetadataSchema","z.object","z.literal","textPartSchema","imagePartSchema","filePartSchema","reasoningPartSchema","toolCallPartSchema","z.unknown","toolResultPartSchema","originalGenerateId","originalGenerateId2","name9","marker9","symbol9","_a9","name10","marker10","symbol10","_a10","name11","marker11","symbol11","_a11","name12","marker12","symbol12","_a12","name13","marker13","symbol13","_a13","originalGenerateId3","output_exports","object","text","name14","marker14","symbol14","_a14","marker15","symbol15","_a15","originalGenerateId4","customProvider","NoSuchModelError","name16","marker16","symbol16","_a16","z.optional","marker2","symbol2","_a2","name2","marker3","symbol3","_a3","name3","marker4","symbol4","_a4","name4","marker5","symbol5","_a5","name5","marker6","symbol6","_a6","name6","marker7","symbol7","_a7","name7","marker8","symbol8","_a8","name8","marker9","symbol9","_a9","name9","marker10","symbol10","_a10","name10","marker11","symbol11","_a11","name11","marker12","symbol12","_a12","name12","marker13","symbol13","_a13","name13","marker14","symbol14","_a14","name","marker","symbol","_a","z4.toJSONSchema","z4.safeParseAsync","z.union","z.string","z.instanceof","z.custom","z.lazy","z.null","z.number","z.boolean","z.record","z.array","z.object","z.literal","z.unknown","z.discriminatedUnion","z.looseObject","z.enum","z.never","Tokenizer","AddedToken","ort","downloadFile","pipeline","Readable","fsp","customProviderLegacy","customProviderV2","customProviderV3","allowsEval$1"],"sources":["../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/util.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/core.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/errors.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/parse.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/regexes.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/checks.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/doc.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/versions.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/schemas.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/memoizer.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/locales/en.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/registries.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/api.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/to-json-schema.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/core/json-schema-processors.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/classic/errors.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/classic/parse.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v4/classic/schemas.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/helpers/util.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/ZodError.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/locales/en.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/errors.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/helpers/parseUtil.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/helpers/errorUtil.js","../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.7/4c9f15c99caaca8b83ba8ab68f247a75121c86fb7e498876ed36daccd0f3d3ce/node_modules/zod/v3/types.js","../../_vendored/ai_v5/dist/dist-OCi48HWi.js","../../_vendored/ai_v5/dist/index.js","../../_vendored/ai_v4/dist/dist-Cm5DZgxA.js","../../_vendored/ai_v4/dist/index.js","../../_vendored/ai_v6/dist/dist-B3lfSiDN.js","../../_vendored/ai_v6/dist/index.js","../src/fastembed.ts","../src/model-cache.ts","../src/index.ts"],"sourcesContent":["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 toZod() {\n    return (schema) => schema;\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}\n// the accessor lives on a shared prototype: an own accessor makes every box a dictionary-mode object (~360 B and a slow load per read against ~100 B and an inlined getter here)\nclass Cached {\n    constructor(getter) {\n        this._getter = getter;\n        this._value = undefined;\n    }\n    get value() {\n        const getter = this._getter;\n        if (getter !== undefined) {\n            this._value = getter();\n            this._getter = undefined;\n        }\n        return this._value;\n    }\n}\nexport function cached(getter) {\n    return new Cached(getter);\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    // `val` and `step` each round to a double before the division rounds again, so a true decimal multiple's quotient can sit up to 1.5 of these scaled epsilons from the integer. A 1x tolerance therefore rejected 2.03 as a multiple of 0.07; 4x covers the worst case with margin.\n    const tolerance = 4 * 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}\n/**\n * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.\n *\n * Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.\n */\nexport function rawShape(def) {\n    const desc = Object.getOwnPropertyDescriptor(def, \"shape\");\n    return desc?.get ? desc.get.raw : desc?.value;\n}\n// where a builder reads its source's keys and descriptors, resolving only a shape a def answers for itself. A shape resolves by object spread, so only its enumerable keys are ever part of it.\nfunction sourceShape(schema) {\n    return rawShape(schema._zod.def) ?? schema._zod.def.shape;\n}\n// a key whose value is not settled yet, self-caching so every read after the first gets the same one\nfunction deferProp(target, key, getter) {\n    Object.defineProperty(target, key, {\n        get() {\n            const value = getter();\n            assignProp(this, key, value);\n            return value;\n        },\n        enumerable: true,\n        configurable: true,\n    });\n}\n// Writes a settled key. A plain assignment is much cheaper than `defineProperty` and produces the same descriptor, but it runs whatever setter already answers to the key — an accessor this shape deferred, or an inherited one, which `__proto__` has on every object and prototype pollution can add for any name.\nfunction putProp(target, key, value) {\n    if (key in target)\n        assignProp(target, key, value);\n    else\n        target[key] = value;\n}\n/**\n * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.\n *\n * A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.\n */\nfunction mirrorShape(target, source, keys, wrap) {\n    const raw = sourceShape(source);\n    for (const key of keys) {\n        const desc = Object.getOwnPropertyDescriptor(raw, key);\n        if (!desc.enumerable)\n            continue;\n        if (desc.get) {\n            deferProp(target, key, () => {\n                const value = source._zod.def.shape[key];\n                return wrap ? wrap(value, key) : value;\n            });\n        }\n        else\n            putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);\n    }\n}\n// same, for a plain shape a caller passed rather than a schema's\nfunction mirrorProps(target, source) {\n    for (const key of Reflect.ownKeys(source)) {\n        const desc = Object.getOwnPropertyDescriptor(source, key);\n        if (!desc.enumerable)\n            continue;\n        if (desc.get)\n            deferProp(target, key, () => source[key]);\n        else\n            putProp(target, key, desc.value);\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` 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 !== undefined && shape[k]._zod.optout === \"optional\";\n    });\n}\n// Wrapped in a `@__PURE__` IIFE: esbuild never tree-shakes a top-level initializer that contains a member access on `Number`, so the bare object literal survived into every bundle.\nexport const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({\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 newShape = {};\n    mirrorShape(newShape, schema, maskedKeys(schema, mask));\n    return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));\n}\n// the mask keys that select something, checked against the source's shape without resolving it\nfunction maskedKeys(schema, mask) {\n    const raw = sourceShape(schema);\n    const keys = [];\n    // `for...in` skips symbols, so a symbol in the mask would select nothing\n    for (const key of Reflect.ownKeys(mask)) {\n        if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {\n            throw new Error(`Unrecognized key: \"${String(key)}\"`);\n        }\n        if (mask[key])\n            keys.push(key);\n    }\n    return keys;\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 omitted = new Set(maskedKeys(schema, mask));\n    const newShape = {};\n    mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));\n    return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));\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. Use getOwnPropertyDescriptor to check key existence without accessing values\n        const existingShape = sourceShape(schema);\n        for (const key of Reflect.ownKeys(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    return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));\n}\n// the source's keys, then the caller's overlaid on top\nfunction extended(schema, shape) {\n    const newShape = {};\n    mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));\n    mirrorProps(newShape, shape);\n    return newShape;\n}\nexport function safeExtend(schema, shape) {\n    if (!isPlainObject(shape)) {\n        throw new Error(\"Invalid input to safeExtend: expected a plain object\");\n    }\n    return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));\n}\nexport function merge(a, b) {\n    if (!b?._zod?.def) {\n        throw new Error(\"Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.\");\n    }\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 newShape = {};\n    mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));\n    mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));\n    const def = mergeDefs(a._zod.def, {\n        shape: newShape,\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, name = \"partial\") {\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(`.${name}() cannot be used on object schemas containing refinements`);\n    }\n    const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;\n    const newShape = {};\n    mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class &&\n        ((value, key) => (selected && !selected.has(key) ? value : new Class({ type: \"optional\", innerType: value }))));\n    return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));\n}\nexport function required(Class, schema, mask) {\n    const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;\n    const newShape = {};\n    mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => \n    // overwrite with non-optional\n    selected && !selected.has(key) ? value : new Class({ type: \"nonoptional\", innerType: value }));\n    return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));\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). 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}\n/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */\n/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */\nexport function sizeCaps(defChecks) {\n    const caps = [];\n    for (const ch of defChecks ?? []) {\n        const d = ch._zod.def;\n        // a later check may rewrite the value\n        if (!/_(length|size)$|_equals$/.test(d.check))\n            break;\n        const max = d.maximum ?? d.length ?? d.size;\n        if (max >= 0)\n            caps.push([max, ch]);\n    }\n    return caps;\n}\nexport function attachSchema(issues, start, inst) {\n    var _a;\n    for (let i = start; i < issues.length; i++) {\n        (_a = issues[i]).schema ?? (_a.schema = inst);\n    }\n}\nexport function finalizeIssue(iss, ctx, config) {\n    var _a;\n    // A schema that raised an issue itself owns it outright, and outranks any stamp an enclosing check left in `attachSchema`. String formats and z.custom() are schema and check at once, so when they act as a check they defer to that stamp instead.\n    const traits = iss.inst?._zod?.traits;\n    if (traits?.has(\"$ZodType\")) {\n        if (traits.has(\"$ZodCheck\"))\n            (_a = iss).schema ?? (_a.schema = iss.inst);\n        else\n            iss.schema = iss.inst;\n    }\n    // Decreasing specificity, first map to return a message wins. `inst` is whatever raised the issue, so a check's own map outranks the owning schema's.\n    const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : undefined;\n    const message = iss.message\n        ? iss.message\n        : (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??\n            unwrapMessage(schemaError?.(iss)) ??\n            unwrapMessage(ctx?.error?.(iss)) ??\n            unwrapMessage(config.customError?.(iss)) ??\n            unwrapMessage(config.localeError?.(iss)) ??\n            \"Invalid input\");\n    // an explicit own-key copy beats object rest with excluded keys, which v8 routes through a generic runtime call; Object.keys rather than for-in so an issue pushed with a prototype does not leak inherited keys, and an own __proto__ key is dropped rather than assigned through the setter\n    const full = {};\n    for (const k of Object.keys(iss)) {\n        if (k === \"inst\" || k === \"schema\" || k === \"continue\" || k === \"input\" || k === \"__proto__\")\n            continue;\n        full[k] = iss[k];\n    }\n    full.path ?? (full.path = []);\n    full.message = message;\n    if (ctx?.reportInput) {\n        full.input = iss.input;\n    }\n    return full;\n}\nexport function getSizableOrigin(input) {\n    if (input instanceof Set)\n        return \"set\";\n    if (input instanceof Map)\n        return \"map\";\n    // @ts-ignore\n    if (input instanceof File)\n        return \"file\";\n    return \"unknown\";\n}\nconst highSurrogate = /[\\uD800-\\uDBFF]/;\n// Code points in `str`: a surrogate pair counts once, a lone surrogate as itself. Hand-rolled because the string iterator allocates and runs ~250x slower on this path; the regex probe exits ~50x quicker for a string with no astral characters.\nexport function codePointLength(str) {\n    const units = str.length;\n    if (!highSurrogate.test(str))\n        return units;\n    let count = units;\n    for (let i = 0; i < units - 1; i++) {\n        if ((str.charCodeAt(i) & 0xfc00) === 0xd800 && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {\n            count--;\n            i++;\n        }\n    }\n    return count;\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//////////    PROTOTYPE INSTALLERS     //////////\n//\n// Members live on the prototype and materialize per instance on first read, which keeps own-property count under the step where V8 stops using inline slots. Changing anything here means re-measuring runtime, memory and bundle size together — see \"The three axes\" in AGENTS.md.\n/**\n * Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.\n *\n * Call this from a `proto` initializer, which runs once per prototype — never per instance.\n */\nexport function members(proto, table) {\n    for (const key in table) {\n        const desc = Object.getOwnPropertyDescriptor(table, key);\n        // a getter installs as written, so it stays live: `description` reads through to the registry on every access. not enumerable: an object literal's is, and a prototype member never was\n        if (desc.get)\n            Object.defineProperty(proto, key, { ...desc, enumerable: false });\n        // a method materializes bound on first read, which is what keeps a detached member working: `const opt = schema.optional; opt()`\n        else\n            defineBound(proto, key, desc.value);\n    }\n}\n/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */\nexport function own(inst, key, value, enumerable = true) {\n    Object.defineProperty(inst, key, { configurable: true, writable: true, enumerable, value });\n    return value;\n}\n/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */\nexport function hide(inst, key, value) {\n    return own(inst, key, value, false);\n}\n/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */\nexport /*@__NO_SIDE_EFFECTS__*/ function derived(computes, table) {\n    for (const key in computes) {\n        const compute = computes[key];\n        // an object literal's accessor is configurable and enumerable, and `members` copies the descriptor as written\n        Object.defineProperty(table, key, {\n            configurable: true,\n            enumerable: true,\n            get() {\n                return own(this, key, compute(this));\n            },\n            set(value) {\n                own(this, key, value);\n            },\n        });\n    }\n    return table;\n}\nfunction defineBound(proto, key, fn) {\n    Object.defineProperty(proto, key, {\n        configurable: true,\n        get() {\n            // vitest's spyOn calls a prototype getter bare to find the function it wraps, so a nullish receiver answers the raw method\n            return this == null ? fn : own(this, key, fn.bind(this));\n        },\n        set(value) {\n            own(this, key, value);\n        },\n    });\n}\n/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */\nfunction claim(inst, sentinel) {\n    const proto = Object.getPrototypeOf(inst);\n    // Runs on every construction, so `in` rather than the costlier `hasOwnProperty.call`. Sentinels are keys the group itself defines.\n    return sentinel in proto ? undefined : proto;\n}\n// The internals whose init chain is installing. A second call for the same one is a derived constructor overriding its base, so it must not construct another schema in between or the override is dropped.\nlet installing;\n// Set while a getter is running, so a value that resolved through a recursion break is not memoized. One shared descriptor shadows the key for the duration, which costs no per-key allocation.\nlet broke = false;\nconst breaker = {\n    configurable: true,\n    get() {\n        broke = true;\n        return undefined;\n    },\n};\n/**\n * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s\n * constructor, computed from the internals object itself and cached there on\n * first read. One accessor per constructor rather than one per instance.\n */\nexport function defineLazyInternal(inst, key, compute) {\n    const proto = Object.getPrototypeOf(inst._zod);\n    if (key in proto && installing !== inst._zod) {\n        // A repeat construction: everything is installed already. Cleared here so the reference is not held past the first construction of every type.\n        installing = undefined;\n        return;\n    }\n    installing = inst._zod;\n    Object.defineProperty(proto, key, {\n        configurable: true,\n        get() {\n            // Shadowed before computing so a re-entrant read from a recursive schema resolves to undefined instead of running the getter again.\n            Object.defineProperty(this, key, breaker);\n            const outer = broke;\n            broke = false;\n            try {\n                const value = compute(this);\n                // A result that resolved through a recursion break is recomputed once the graph is complete; everything else memoizes, undefined included.\n                if (broke)\n                    delete this[key];\n                else\n                    Object.defineProperty(this, key, { configurable: true, writable: true, value });\n                broke = broke || outer;\n                return value;\n            }\n            catch (err) {\n                // A compute that threw memoizes nothing, so a later read runs it again and fails the same way. The shadow goes with it, since leaving it installed would answer undefined for every later read.\n                delete this[key];\n                broke = broke || outer;\n                throw err;\n            }\n        },\n        set(value) {\n            Object.defineProperty(this, key, { configurable: true, writable: true, value });\n        },\n    });\n}\n/**\n * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own\n * data property. One accessor per constructor rather than one per instance, because an own accessor\n * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.\n */\nexport function installLazyProp(inst, key, make, enumerable) {\n    const proto = claim(inst, key);\n    if (!proto)\n        return;\n    Object.defineProperty(proto, key, {\n        configurable: true,\n        get() {\n            // Shadowed before computing, so a re-entrant read from a self-referential shape resolves to undefined instead of running the getter again. A data property rather than an accessor: an own accessor is the dictionary-mode transition this exists to avoid.\n            const desc = { configurable: true, writable: true, enumerable, value: undefined };\n            Object.defineProperty(this, key, desc);\n            // a compute that throws leaves the shadow behind, so later reads answer undefined instead of re-throwing; `defineLazy` did the same, and `defineLazyInternal`'s delete-on-catch would cost bytes in every bundle for a case only a throwing user getter reaches\n            desc.value = make(this);\n            Object.defineProperty(this, key, desc);\n            return desc.value;\n        },\n        set(value) {\n            Object.defineProperty(this, key, { configurable: true, writable: true, enumerable, value });\n        },\n    });\n}\n/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */\nexport const CONSTANT_CATCH = \"~constantCatch\";\n/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */\nexport function constantCatch(value) {\n    const fn = () => value;\n    fn[CONSTANT_CATCH] = true;\n    return fn;\n}\n","var _a;\nimport { members as installMembers } from \"./util.js\";\n/** A special constant with type `never` */\nexport const NEVER = /*@__PURE__*/ Object.freeze({\n    status: \"aborted\",\n});\n/* Shared descriptor for installing `_zod`; defineProperty reads it\n * synchronously, so reusing one object avoids a per-instance allocation. */\nconst _zodDesc = { value: undefined, enumerable: false };\n// null where suppressing the capture would be unrecoverable: `parse()` puts the frames back with `captureStackTrace`, so without it the throw would lose its stack. also latched to null once `stackTraceLimit` proves unassignable, which a realm can do at any point by hardening Error\nlet _E = \"captureStackTrace\" in Error ? Error : null;\n// v8 captures a stack trace inside the Error constructor, which dominates a failed parse; costs only the frames, and parse() restores those. the constructor must RUN: Object.create is cheaper and passes instanceof, but Error.isError and util.types.isNativeError check an internal slot\nfunction newError(Definition) {\n    const E = _E;\n    if (E) {\n        const saved = E.stackTraceLimit;\n        if (typeof saved === \"number\") {\n            try {\n                E.stackTraceLimit = 0;\n            }\n            catch {\n                _E = null;\n                return new Definition();\n            }\n            try {\n                return new Definition();\n            }\n            finally {\n                E.stackTraceLimit = saved;\n            }\n        }\n    }\n    return new Definition();\n}\nexport /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, \n/** This trait's members, installed once on every prototype that composes it. They cannot be declared in the initializer above: that runs per instance, and the prototype is shared. */\nproto, params) {\n    // Prototype for this constructor's `_zod` internals. Lazily-derived fields (`values`, `pattern`, `optin`, …) install here once rather than as an accessor on every instance.\n    const zodProto = {};\n    // Assigning the fields in the constructor body is what gives instances in-object slots; building the object literally and reparenting it costs a second allocation and a generic property copy.\n    function Internals(def) {\n        this.def = def;\n        this.constr = _;\n        this.traits = new Set();\n    }\n    Internals.prototype = zodProto;\n    const protoMembers = proto;\n    // One trait's members land on every prototype whose chain composes it, so the answer is per prototype rather than per trait.\n    const initialized = protoMembers && new WeakSet();\n    function init(inst, def) {\n        if (!inst._zod) {\n            _zodDesc.value = new Internals(def);\n            try {\n                Object.defineProperty(inst, \"_zod\", _zodDesc);\n            }\n            finally {\n                // Cleared even on throw, so the shared descriptor never leaks one instance's internals into the next.\n                _zodDesc.value = undefined;\n            }\n        }\n        else if (inst._zod.traits.has(name)) {\n            return;\n        }\n        inst._zod.traits.add(name);\n        initializer(inst, def);\n        if (initialized) {\n            // `super(def)` from a user subclass gives `this` a prototype the subclass owns, and installing there would overwrite whatever the subclass declared. `constr` built the instance, so its prototype is the one below the subclass's that should carry the members. A receiver whose chain never reaches that prototype installs on its own, which for a plain object handed straight to `init` means `Object.prototype` — unchanged from before.\n            const own = Object.getPrototypeOf(inst);\n            const ctorProto = inst._zod.constr.prototype;\n            let up = own;\n            while (up && up !== ctorProto)\n                up = Object.getPrototypeOf(up);\n            const target = up ?? own;\n            if (!initialized.has(target)) {\n                initialized.add(target);\n                installMembers(target, protoMembers);\n            }\n        }\n        // support prototype modifications; for-in avoids the array allocation of Object.keys on the (usually empty) prototype\n        const proto = _.prototype;\n        for (const k in proto) {\n            if (!Object.prototype.hasOwnProperty.call(proto, k))\n                continue;\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        const inst = params?.Parent ? newError(Definition) : this;\n        init(inst, def);\n        const deferred = inst._zod.deferred;\n        if (deferred) {\n            for (const fn of deferred) {\n                fn();\n            }\n            // Released: initializers run once, and the list would otherwise be retained for the schema's lifetime.\n            inst._zod.deferred = undefined;\n        }\n        // Global post-processor hook. Internal: installed by `import \"zod/compile\"` to enable AOT compilation for every constructed schema. Runs last, once the instance is fully built, because it hands the instance to compile(). The post-processor is expected to be reentrancy-guarded by its own implementation.\n        const pp = globalThis.__zod_globalConfig?.postProcessor;\n        if (pp)\n            pp(inst);\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 = /*@__PURE__*/ 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 { $constructor } from \"./core.js\";\nimport * as util from \"./util.js\";\n/* Computing the message eagerly is expensive (pretty-printed JSON of all\n * issues), so defer it until first read. The accessor functions and\n * descriptors are shared across instances to keep error construction\n * cheap; the computed message is cached on the internals object. The\n * setter preserves plain assignment semantics for consumers that\n * overwrite `message`. */\nfunction _getMessage() {\n    const internals = this._zod;\n    internals.message ?? (internals.message = JSON.stringify(internals.def, util.jsonStringifyReplacer, 2));\n    return internals.message;\n}\nfunction _setMessage(value) {\n    this._zod.message = value;\n}\nconst _messageDesc = {\n    get: _getMessage,\n    set: _setMessage,\n    enumerable: true,\n    configurable: true,\n};\nconst _issuesDesc = { value: undefined, enumerable: false };\n/* Prototypes that already carry the lazy `toString`. Seeded with the\n * intrinsics so that `init` on a foreign object — it accepts any object —\n * can never install an accessor onto a prototype we do not own. */\nconst _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);\nconst initializer = (inst, def) => {\n    inst.name = \"$ZodError\";\n    // `_zod` is already non-enumerable: $constructor's init defined it with this same descriptor\n    _issuesDesc.value = def;\n    Object.defineProperty(inst, \"issues\", _issuesDesc);\n    // Clear the shared slot; a retained `value` pins the last error's issues.\n    _issuesDesc.value = undefined;\n    Object.defineProperty(inst, \"message\", _messageDesc);\n    /* `toString` lives as a non-enumerable lazy getter on the shared\n     * prototype; on first access it caches a per-instance closure so\n     * detached usage still works. */\n    const proto = Object.getPrototypeOf(inst);\n    if (!_installedToString.has(proto)) {\n        _installedToString.add(proto);\n        Object.defineProperty(proto, \"toString\", {\n            configurable: true,\n            enumerable: false,\n            get() {\n                const value = () => this.message;\n                Object.defineProperty(this, \"toString\", { value, configurable: true, writable: true });\n                return value;\n            },\n            set(value) {\n                Object.defineProperty(this, \"toString\", { value, configurable: true, writable: true });\n            },\n        });\n    }\n};\nexport const $ZodError = $constructor(\"$ZodError\", initializer);\nexport const $ZodRealError = $constructor(\"$ZodError\", initializer, undefined, {\n    Parent: Error,\n});\n/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member\n * (\"toString\", \"constructor\") would otherwise read through to the prototype, and assigning\n * \"__proto__\" would hit the setter instead of creating a key. */\nfunction node(obj, key, make) {\n    if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n        if (key === \"__proto__\") {\n            Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });\n        }\n        else {\n            obj[key] = make();\n        }\n    }\n    return obj[key];\n}\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            node(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                        // `_errors` is reserved by this legacy format, so merge a matching path segment into the current node instead of treating its array as a child.\n                        if (el === \"_errors\") {\n                            if (terminal)\n                                curr._errors.push(mapper(issue));\n                            i++;\n                            continue;\n                        }\n                        // A path element may collide with an inherited property name such as\n                        // \"__proto__\" or \"constructor\". Truthiness checks read the prototype\n                        // (so no node is created, then ._errors.push throws), and bracket\n                        // assignment of \"__proto__\" hits the setter instead of creating an\n                        // own key. Guard the read with hasOwnProperty and create the node\n                        // with defineProperty so any path element becomes a real own key.\n                        if (!Object.prototype.hasOwnProperty.call(curr, el)) {\n                            Object.defineProperty(curr, el, {\n                                value: { _errors: [] },\n                                enumerable: true,\n                                writable: true,\n                                configurable: true,\n                            });\n                        }\n                        const node = curr[el];\n                        if (terminal) {\n                            node._errors.push(mapper(issue));\n                        }\n                        curr = node;\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;\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                        // el may collide with an inherited property name (\"__proto__\",\n                        // \"constructor\", ...); ??= reads the prototype so the node is never\n                        // created and curr.errors.push throws. Guard with hasOwnProperty and\n                        // create the node with defineProperty so \"__proto__\" becomes a real\n                        // own key rather than invoking the prototype setter.\n                        if (!Object.prototype.hasOwnProperty.call(curr.properties, el)) {\n                            Object.defineProperty(curr.properties, el, {\n                                value: { errors: [] },\n                                enumerable: true,\n                                writable: true,\n                                configurable: true,\n                            });\n                        }\n                        curr = curr.properties[el];\n                    }\n                    else {\n                        curr.items ?? (curr.items = []);\n                        (_a = curr.items)[el] ?? (_a[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\";\n// Always both keys, so the `_params` read site in `_parse` sees one object shape rather than two.\nfunction finalizeParams(callee, params) {\n    return { callee: params?.callee ?? callee, Err: params?.Err };\n}\nexport const _parse = (_Err) => {\n    const fn = (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 ?? fn);\n            throw e;\n        }\n        return result.value;\n    };\n    return fn;\n};\nexport const parse = /* @__PURE__*/ _parse(errors.$ZodRealError);\nexport const _parseAsync = (_Err) => {\n    const fn = 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 ?? fn);\n            throw e;\n        }\n        return result.value;\n    };\n    return fn;\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 ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };\n};\nexport const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);\n// the error is built on the first read of `error`: finalizing the issues and constructing the instance is most of a failing parse, and a caller that only branches on `success` never pays it. a getter in the literal keeps this small; the alternative, one shared accessor descriptor plus a hidden state slot, reads ~15% faster but costs ~75 B gzipped in every bundle\nfunction failure(Err, issues, ctx) {\n    let error;\n    return {\n        success: false,\n        get error() {\n            if (!error) {\n                error = new Err(issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));\n                // finalizeIssue drops `input`, so the built error holds nothing; keeping the raw issues past this point pins the parsed value for the life of the result\n                issues = undefined;\n                ctx = undefined;\n            }\n            return error;\n        },\n        set error(e) {\n            error = e;\n            // a replacement makes the getter's branch unreachable, so the captures have to go here too\n            issues = undefined;\n            ctx = undefined;\n        },\n    };\n}\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 ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };\n};\nexport const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);\n// registry mirrors of the compiler's sentinels, so this module never imports the compiler\nconst COMPILE_INVALID = /* @__PURE__ */ Symbol.for(\"zod.compile.invalid\");\nconst COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for(\"zod.compile.fallback\");\n// Deliberately tiny, because v8 will not inline a body carrying the fallback's object literals and throw. Everything that is not the compiled happy path lives in validateFallback, and that split is worth ~35% on a compiled schema.\nexport const validate = ((schema, value, _ctx) => {\n    const validator = schema._zod.bag.validator;\n    if (validator !== undefined) {\n        if (validator(value) !== COMPILE_INVALID)\n            return true;\n        // a definite sentinel means the runtime would reject, so skip the re-parse; a ctx can still change the answer\n        if (validator.definite === true && _ctx === undefined)\n            return false;\n    }\n    return validateFallback(schema, value, _ctx);\n});\nfunction validateFallback(schema, value, _ctx) {\n    const ctx = _ctx\n        ? { ..._ctx, async: false, abortEarly: true }\n        : { async: false, abortEarly: true };\n    const fallbackRun = schema._zod.bag.fallbackRun;\n    let result;\n    if (fallbackRun) {\n        // skip nested fast paths on the fallback, so user callbacks keep the at-most-twice bound\n        ctx[COMPILE_FALLBACK] = true;\n        result = fallbackRun({ value, issues: [] }, ctx);\n    }\n    else {\n        result = schema._zod.run({ value, issues: [] }, ctx);\n    }\n    if (result instanceof Promise) {\n        throw new core.$ZodAsyncError();\n    }\n    return result.issues.length === 0;\n}\n// no fast path: the compiler keeps async parses on the runtime, because a promise-returning callback that is not declared async compiles to a throw\nexport const validateAsync = async (schema, value, _ctx) => {\n    const ctx = _ctx\n        ? { ..._ctx, async: true, abortEarly: true }\n        : { async: true, abortEarly: true };\n    let result = schema._zod.run({ value, issues: [] }, ctx);\n    if (result instanceof Promise)\n        result = await result;\n    return result.issues.length === 0;\n};\nexport const _encode = (_Err) => {\n    const parse = _parse(_Err);\n    const fn = (schema, value, _ctx, _params) => {\n        const ctx = _ctx ? { ..._ctx, direction: \"backward\" } : { direction: \"backward\" };\n        return parse(schema, value, ctx, finalizeParams(fn, _params));\n    };\n    return fn;\n};\nexport const encode = /* @__PURE__*/ _encode(errors.$ZodRealError);\nexport const _decode = (_Err) => {\n    const parse = _parse(_Err);\n    const fn = (schema, value, _ctx, _params) => {\n        return parse(schema, value, _ctx, finalizeParams(fn, _params));\n    };\n    return fn;\n};\nexport const decode = /* @__PURE__*/ _decode(errors.$ZodRealError);\nexport const _encodeAsync = (_Err) => {\n    const parseAsync = _parseAsync(_Err);\n    const fn = async (schema, value, _ctx, _params) => {\n        const ctx = _ctx ? { ..._ctx, direction: \"backward\" } : { direction: \"backward\" };\n        return (await parseAsync(schema, value, ctx, finalizeParams(fn, _params)));\n    };\n    return fn;\n};\nexport const encodeAsync = /* @__PURE__*/ _encodeAsync(errors.$ZodRealError);\nexport const _decodeAsync = (_Err) => {\n    const parseAsync = _parseAsync(_Err);\n    const fn = async (schema, value, _ctx, _params) => {\n        return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));\n    };\n    return fn;\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-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;\nexport const xid = /^[0-9a-vA-V]{20}$/;\nexport const ksuid = /^[A-Za-z0-9]{27}$/;\nexport const nanoid = /^[a-zA-Z0-9_-]{21}$/;\nexport function nanoidOfLength(length) {\n    return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);\n}\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-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\n// Single character class, not an alternation: the two properties overlap (U+1F9B0-U+1F9B3), so `(A|B)+` backtracks exponentially on a failed match. The leading lookahead then demands one anchor — a pictograph, a regional indicator, or the enclosing keycap — because `\\p{Emoji_Component}` on its own covers ASCII digits, `#`, `*`, ZWJ, variation selectors and skin tone modifiers, none of which is an emoji without a base.\nconst _emoji = `^(?=[\\\\s\\\\S]*[\\\\p{Extended_Pictographic}\\\\p{Regional_Indicator}\\\\u20E3])[\\\\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}:){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}|:))\\/(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_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;\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 = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,63}$/;\nexport const httpProtocol = /^https?$/;\n// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces) E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15\nexport const e164 = /^\\+[1-9]\\d{6,14}$/;\n// Credit card shape: 12–19 digits, optionally separated by single spaces or single hyphens. ISO/IEC 7812 caps the PAN at 19 digits; 12 is the shortest issued length (Maestro).\nexport const creditCard = /^\\d(?:[ -]?\\d){11,18}$/;\n// ISO 4217 alpha codes from the SIX list, regenerated by scripts/update-iso-4217.ts\nexport const currencyCode = /^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/;\n// iban electronic format: 2-letter country, check digits 02-98 (the only values `98 - remainder` can produce), 11-30 bban characters\nexport const iban = /^[A-Z]{2}(?!00|01|99)\\d{2}[A-Z0-9]{11,30}$/;\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])))`;\n/** Anchors a pattern source. The interpolation lives here rather than at the call site because\n * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it\n * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */\nfunction anchor(source) {\n    return new RegExp(`^${source}$`);\n}\nexport const date = /*@__PURE__*/ anchor(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        : args.seconds\n            ? `${hhmm}:[0-5]\\\\d(?:\\\\.\\\\d+)?`\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 opts = [\"Z\"];\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    // RFC 3339 mandates seconds wherever the time carries a `Z` or an offset, so only the unqualified form `local` adds may omit them\n    const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join(\"|\")})`;\n    const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;\n    return new RegExp(`^${dateSource}T(?:${timeRegex})$`);\n}\n// the unbounded form of `string()` as a literal, so every plain string shares one instance instead of building its own\nexport const anyString = /^[\\s\\S]{0,}$/;\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});\n/** Default `when` for size-based checks: run only on non-nullish values with a `size`. */\nconst _whenHasSize = (payload) => {\n    const val = payload.value;\n    return !util.nullish(val) && val.size !== undefined;\n};\n/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */\nconst _whenHasLength = (payload) => {\n    const val = payload.value;\n    return !util.nullish(val) && val.length !== undefined;\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.check = (payload) => {\n        if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {\n            return;\n        }\n        payload.issues.push({\n            origin: numericOriginMap[typeof payload.value] ?? 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.check = (payload) => {\n        if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {\n            return;\n        }\n        payload.issues.push({\n            origin: numericOriginMap[typeof payload.value] ?? 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.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            ? // `value % 0n` throws, and nothing is a multiple of zero — the number branch already fails this way via NaN\n                def.value !== BigInt(0) && 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.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.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 = _whenHasSize);\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 = _whenHasSize);\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 = _whenHasSize);\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 = _whenHasLength);\n    inst._zod.check = (payload) => {\n        const input = payload.value;\n        const units = input.length;\n        // Strings are measured in Unicode code points, not UTF-16 units. A code point is at most two units, so a string that already fits in units fits in code points; only an overflow has to be counted.\n        const length = typeof input === \"string\" && units > def.maximum ? util.codePointLength(input) : units;\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 = _whenHasLength);\n    inst._zod.check = (payload) => {\n        const input = payload.value;\n        const units = input.length;\n        // A code point is one or two UTF-16 units, so fewer units than the floor can never reach it and twice the floor always clears it. Only in between is the exact count in doubt.\n        const length = typeof input === \"string\" && units >= def.minimum && units < def.minimum * 2\n            ? util.codePointLength(input)\n            : units;\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 = _whenHasLength);\n    inst._zod.check = (payload) => {\n        const input = payload.value;\n        const units = input.length;\n        // A code point is one or two UTF-16 units, so outside `[length, length * 2]` units the target is missed either way — and missed in the same direction in both measures.\n        const length = typeof input === \"string\" && units >= def.length && units <= def.length * 2\n            ? util.codePointLength(input)\n            : units;\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    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    // `String.prototype.includes(sub, position)` matches `sub` at `position`\n    // OR LATER, so the pattern must allow at least `position` leading chars\n    // (`{N,}`), not exactly `position` chars (`{N}`).\n    const pattern = new RegExp(typeof def.position === \"number\" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);\n    def.pattern = pattern;\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.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.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 $ZodCheckProperties = /*@__PURE__*/ core.$constructor(\"$ZodCheckProperties\", (inst, def) => {\n    $ZodCheck.init(inst, def);\n    util.hide(inst, Symbol.iterator, function* () {\n        yield inst;\n    });\n    // key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema\n    let entries;\n    inst._zod.check = (payload) => {\n        // the base schema already typed the value, so only a nullish one is rejected here: the properties read on a primitive too, matching z.property() on a string's length\n        if (payload.value == null) {\n            payload.issues.push({ expected: \"object\", code: \"invalid_type\", input: payload.value, inst });\n            return undefined;\n        }\n        entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));\n        const input = payload.value;\n        let proms;\n        for (const [key, schema] of entries) {\n            const result = schema._zod.run({ value: input[key], issues: [] }, {});\n            if (result instanceof Promise) {\n                proms ?? (proms = []);\n                proms.push(result.then((result) => handleCheckPropertyResult(result, payload, key)));\n            }\n            else {\n                handleCheckPropertyResult(result, payload, key);\n            }\n        }\n        if (proms)\n            return Promise.all(proms).then(() => undefined);\n        return undefined;\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.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 = [], closed = {}) {\n        this.content = [];\n        this.indent = 0;\n        this.args = args;\n        this.closed = closed;\n    }\n    // the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it\n    indented(fn) {\n        this.indent += 1;\n        try {\n            fn(this);\n        }\n        finally {\n            this.indent -= 1;\n        }\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 content = this?.content ?? [``];\n        const factory = new F(...Object.keys(this.closed), `return function (${this.args.join(\", \")}) {\\n${content.join(\"\\n\")}\\n};`);\n        return factory(...Object.values(this.closed));\n    }\n}\n","export const version = {\n    major: 4,\n    minor: 6,\n    patch: 7,\n};\n","import * as checks from \"./checks.js\";\nimport * as core from \"./core.js\";\nimport { Doc } from \"./doc.js\";\nimport { parse, parseAsync } 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 defChecks = inst._zod.def.checks;\n    // if inst is itself a checks.$ZodCheck, run it as a check\n    const checks = inst._zod.traits.has(\"$ZodCheck\")\n        ? [inst, ...(defChecks ?? [])]\n        : defChecks?.length\n            ? [...defChecks]\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 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            if (payload.memo)\n                return payload;\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                        util.attachSchema(payload.issues, currLen, inst);\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                    util.attachSchema(payload.issues, currLen, inst);\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 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}, {\n    // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.\n    get \"~standard\"() {\n        return util.hide(this, \"~standard\", standardProps(this));\n    },\n    set \"~standard\"(value) {\n        util.own(this, \"~standard\", value);\n    },\n});\n/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */\n// a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through\nconst toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };\nasync function validateAsync(inst, value) {\n    const ctx = { async: true };\n    return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);\n}\nexport function standardProps(inst) {\n    return {\n        validate: (value) => {\n            const ctx = { async: false };\n            try {\n                const r = inst._zod.run({ value, issues: [] }, ctx);\n                if (!(r instanceof Promise))\n                    return toStandardResult(r, ctx);\n            }\n            catch (_) { }\n            // async function so a synchronously throwing check rejects instead of escaping validate\n            return validateAsync(inst, value);\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    // a format's own pattern, else unbounded; a template literal derives the check-aware form itself\n    inst._zod.pattern = def.pattern ?? regexes.anyString;\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});\n/** The `://` guard rejected the input before the URL constructor saw it. */\nexport const URL_BAD_FORMAT = 1;\n/** The URL parser rejected the input. */\nexport const URL_UNPARSEABLE = 2;\nexport function canParseURL(input) {\n    try {\n        if (typeof URL !== \"undefined\" && typeof URL.canParse === \"function\")\n            return URL.canParse(input);\n        new URL(input);\n        return true;\n    }\n    catch {\n        return false;\n    }\n}\nexport function validateURL(trimmed, def) {\n    if (!(\"normalize\" in def) && !(\"hostname\" in def) && !(\"protocol\" in def)) {\n        return canParseURL(trimmed) || URL_UNPARSEABLE;\n    }\n    return parseURLObject(trimmed, def);\n}\n/** Parses a URL while preserving the non-normalizing HTTP guard. */\nexport function parseURLObject(trimmed, def) {\n    // When normalize is off, require :// for http/https URLs. This prevents strings like \"http:example.com\" or \"https:/path\" from being silently accepted\n    if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\\/\\//i.test(trimmed)) {\n        return URL_BAD_FORMAT;\n    }\n    try {\n        if (typeof URL !== \"undefined\") {\n            const URLStatic = URL;\n            if (typeof URLStatic.parse === \"function\")\n                return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;\n        }\n        // @ts-ignore\n        return new URL(trimmed);\n    }\n    catch {\n        return URL_UNPARSEABLE;\n    }\n}\nconst asciiTabOrNewline = /[\\t\\n\\r]/g;\n/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL(\"https://exa\\nmple.com\")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */\nexport function stripTabAndNewline(value) {\n    return value.replace(asciiTabOrNewline, \"\");\n}\nexport function urlHostnameOk(url, hostname) {\n    hostname.lastIndex = 0;\n    return hostname.test(url.hostname);\n}\nexport function urlProtocolOk(url, protocol) {\n    protocol.lastIndex = 0;\n    return protocol.test(url.protocol.endsWith(\":\") ? url.protocol.slice(0, -1) : url.protocol);\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            const url = validateURL(trimmed, def);\n            if (url === URL_BAD_FORMAT) {\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            if (url === URL_UNPARSEABLE) {\n                payload.issues.push({\n                    code: \"invalid_format\",\n                    format: \"url\",\n                    input: payload.value,\n                    inst,\n                    continue: !def.abort,\n                });\n                return;\n            }\n            if (url === true) {\n                payload.value = stripTabAndNewline(trimmed);\n                return;\n            }\n            if (def.hostname && !urlHostnameOk(url, def.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            if (def.protocol && !urlProtocolOk(url, def.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            // Set the output value based on normalize flag\n            payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);\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    if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))\n        throw new Error(`Invalid nanoid length: ${def.length}`);\n    def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));\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});\n/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL(\"http://[...]\")` parses an authority, not an address, so `@` and `\\` re-delimit it and `\"::@1\\\\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `\"::1\\n\"` validated as `::1`. */\nconst ipv6Alphabet = /^[0-9a-fA-F:.]+$/;\nexport function isValidIPv6(value) {\n    if (!ipv6Alphabet.test(value))\n        return false;\n    return canParseURL(`http://[${value}]`);\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.check = (payload) => {\n        if (!isValidIPv6(payload.value)) {\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});\nexport const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor(\"$ZodCIDRv4\", (inst, def) => {\n    def.pattern ?? (def.pattern = regexes.cidrv4);\n    $ZodStringFormat.init(inst, def);\n});\nexport function isValidCIDRv6(value) {\n    const parts = value.split(\"/\");\n    if (parts.length !== 2)\n        return false;\n    const [address, prefix] = parts;\n    if (!prefix)\n        return false;\n    const prefixNum = Number(prefix);\n    if (`${prefixNum}` !== prefix)\n        return false;\n    if (prefixNum < 0 || prefixNum > 128)\n        return false;\n    return isValidIPv6(address);\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        if (!isValidCIDRv6(payload.value)) {\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}\n// lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding\nexport const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;\nexport const $ZodBase64 = /*@__PURE__*/ core.$constructor(\"$ZodBase64\", (inst, def) => {\n    def.pattern ?? (def.pattern = base64Charset);\n    $ZodStringFormat.init(inst, def);\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//////////////////////////////   ZodBase64URL   //////////////////////////////\n// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string\nexport const base64urlCharset = /^[A-Za-z0-9_-]*$/;\nexport function isValidBase64URL(data) {\n    if (!base64urlCharset.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 = base64urlCharset);\n    $ZodStringFormat.init(inst, def);\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//////////////////////////////   ZodCreditCard   //////////////////////////////\nconst CC_SANITIZE = /[- ]/g;\n/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */\nfunction isLuhnAlgo(digits) {\n    let length = digits.length;\n    let bit = 1;\n    let sum = 0;\n    while (length) {\n        const value = digits.charCodeAt(--length) - 48;\n        bit ^= 1;\n        sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;\n    }\n    return sum % 10 === 0;\n}\nexport function isValidCreditCard(input) {\n    if (!regexes.creditCard.test(input))\n        return false;\n    return isLuhnAlgo(input.replace(CC_SANITIZE, \"\"));\n}\nexport const $ZodCreditCard = /*@__PURE__*/ core.$constructor(\"$ZodCreditCard\", (inst, def) => {\n    // Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.\n    def.pattern ?? (def.pattern = regexes.creditCard);\n    $ZodStringFormat.init(inst, def);\n    inst._zod.check = (payload) => {\n        if (isValidCreditCard(payload.value))\n            return;\n        payload.issues.push({\n            code: \"invalid_format\",\n            format: \"credit_card\",\n            input: payload.value,\n            inst,\n            continue: !def.abort,\n        });\n    };\n});\n//////////////////////////////   ZodIBAN   //////////////////////////////\n// iso 7064 mod 97-10 checksum without BigInt\nfunction isIso7064Mod97(iban) {\n    let remainder = 0;\n    const len = iban.length;\n    for (let i = 4; i < len; i++) {\n        const code = iban.charCodeAt(i);\n        remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;\n    }\n    for (let i = 0; i < 4; i++) {\n        const code = iban.charCodeAt(i);\n        remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;\n    }\n    return remainder === 1;\n}\nexport function isValidIBAN(input) {\n    if (!regexes.iban.test(input))\n        return false;\n    return isIso7064Mod97(input);\n}\nexport const $ZodIBAN = /*@__PURE__*/ core.$constructor(\"$ZodIBAN\", (inst, def) => {\n    // shape only — checksum is not expressible as a pattern\n    def.pattern ?? (def.pattern = regexes.iban);\n    $ZodStringFormat.init(inst, def);\n    inst._zod.check = (payload) => {\n        if (isValidIBAN(payload.value))\n            return;\n        payload.issues.push({\n            code: \"invalid_format\",\n            format: \"iban\",\n            input: payload.value,\n            inst,\n            continue: !def.abort,\n        });\n    };\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 = 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                    ? String(input)\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});\n// an oversized container fails its leading size checks before any element is parsed\nfunction capSize(inst, size) {\n    const caps = util.sizeCaps(inst._zod.def.checks);\n    if (!caps.length)\n        return;\n    const cap = Math.min(...caps.map((c) => c[0]));\n    const parse = inst._zod.parse;\n    inst._zod.parse = (payload, ctx) => {\n        const n = size(payload.value);\n        if (n > cap && !ctx?.skipChecks && ctx?.direction !== \"backward\") {\n            for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {\n                if (n > max && ch._zod.def.when(payload)) {\n                    const start = payload.issues.length;\n                    ch._zod.check(payload);\n                    // the value is still the raw input, so no later check may read it\n                    payload.issues[start].continue = false;\n                    util.attachSchema(payload.issues, start, inst);\n                    return payload;\n                }\n            }\n        }\n        return parse(payload, ctx);\n    };\n}\nconst arraySize = (input) => (Array.isArray(input) ? input.length : -1);\nconst mapSize = (input) => (input instanceof Map ? input.size : -1);\nconst setSize = (input) => (input instanceof Set ? input.size : -1);\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    const memo = core.globalConfig.memoizer;\n    memo?.attach(inst);\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 = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);\n        const proms = [];\n        const abortEarly = ctx?.abortEarly;\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                // the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional\n                if (abortEarly && result.issues.length !== 0 && util.aborted(result))\n                    break;\n            }\n        }\n        if (proms.length) {\n            return Promise.all(proms).then(() => payload);\n        }\n        return payload; //handleArrayResultsAsync(parseResults, final);\n    };\n    capSize(inst, arraySize);\n});\nfunction handlePropertyResult(result, final, key, input, optin, optout) {\n    const isPresent = key in input;\n    const isOptionalOut = optout === \"optional\";\n    // The middle rung means \"absence permitted, nothing supplied in its place\", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.\n    if (!isPresent && isOptionalOut && optin === \"optional\") {\n        return;\n    }\n    if (result.issues.length) {\n        // For optional-in/out schemas, ignore errors on absent keys.\n        if (optin !== undefined && isOptionalOut && !isPresent) {\n            return;\n        }\n        final.issues.push(...util.prefixIssues(key, result.issues));\n    }\n    if (!isPresent && optin === undefined) {\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 || (optin === \"defaulted\" && !isOptionalOut)) {\n            final.value[key] = undefined;\n        }\n    }\n    else {\n        final.value[key] = result.value;\n    }\n}\n// one shared instance; a fresh [] per schema cost 56 bytes retained\nconst NO_SYMBOL_KEYS = [];\nfunction normalizeDef(def) {\n    const keys = Object.keys(def.shape);\n    const ownSymbols = Object.getOwnPropertySymbols(def.shape);\n    const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;\n    // aliases `keys` when there are no symbols, so a string-only shape keeps one array\n    const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;\n    for (const k of allKeys) {\n        if (!def.shape?.[k]?._zod?.traits?.has(\"$ZodType\")) {\n            throw new Error(`Invalid element at key \"${String(k)}\": expected a Zod schema`);\n        }\n    }\n    const okeys = util.optionalKeys(def.shape);\n    return {\n        ...def,\n        allKeys,\n        symbolKeys,\n        // string-only: handleCatchall matches it against `for...in`, which never yields a symbol\n        keySet: new Set(keys),\n        numKeys: keys.length,\n        optionalKeys: new Set(okeys),\n    };\n}\nfunction handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {\n    const unrecognized = [];\n    const keySet = def.keySet;\n    const _catchall = def.catchall._zod;\n    const t = _catchall.def.type;\n    const optin = _catchall.optin;\n    const optout = _catchall.optout;\n    // starts at 0, not the current length: the shape phase already ran and may have aborted\n    let seen = 0;\n    for (const key in input) {\n        if (abortEarly && payload.issues.length !== seen) {\n            if (util.aborted(payload, seen))\n                break;\n            seen = payload.issues.length;\n        }\n        // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.\n        if (keySet.has(key))\n            continue;\n        // Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.\n        if (key === \"__proto__\") {\n            if (t === \"never\")\n                unrecognized.push(key);\n            continue;\n        }\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, optin, optout)));\n        }\n        else {\n            handlePropertyResult(r, payload, key, input, optin, optout);\n        }\n    }\n    if (unrecognized.length) {\n        payload.issues.push({\n            code: \"unrecognized_keys\",\n            keys: unrecognized,\n            input,\n            inst,\n            // Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.\n            continue: true,\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 desc = Object.getOwnPropertyDescriptor(def, \"shape\");\n    // a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it\n    const sh = desc?.get ? desc.get.raw : (def.shape ?? {});\n    if (sh) {\n        // Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.\n        const get = () => {\n            const newSh = { ...sh };\n            Object.defineProperty(def, \"shape\", { value: newSh });\n            get.raw = newSh;\n            return newSh;\n        };\n        get.raw = sh;\n        Object.defineProperty(def, \"shape\", { get });\n    }\n    const _normalized = util.cached(() => normalizeDef(def));\n    util.defineLazyInternal(inst, \"propValues\", (zod) => {\n        const shape = zod.def.shape;\n        const propValues = {};\n        for (const key in shape) {\n            const field = shape[key]._zod;\n            if (field.values) {\n                if (!Object.prototype.hasOwnProperty.call(propValues, key)) {\n                    util.assignProp(propValues, key, new Set());\n                }\n                for (const v of field.values)\n                    propValues[key].add(v);\n                // An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.\n                if (field.optin !== undefined)\n                    propValues[key].add(undefined);\n            }\n        }\n        return propValues;\n    });\n    const isObject = util.isObject;\n    const catchall = def.catchall;\n    let value;\n    const memo = core.globalConfig.memoizer;\n    memo?.attach(inst);\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 = memo ? memo.alloc(inst, payload, {}, ctx) : {};\n        const proms = [];\n        const shape = value.shape;\n        const abortEarly = ctx?.abortEarly;\n        let seen = payload.issues.length;\n        for (const key of value.allKeys) {\n            if (abortEarly && payload.issues.length !== seen) {\n                if (util.aborted(payload, seen))\n                    break;\n                seen = payload.issues.length;\n            }\n            if (key === \"__proto__\")\n                continue;\n            const el = shape[key];\n            const optin = el._zod.optin;\n            const optout = el._zod.optout;\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, optin, optout)));\n            }\n            else {\n                handlePropertyResult(r, payload, key, input, optin, optout);\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, abortEarly === true);\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 memo = core.globalConfig.memoizer;\n    const generateFastpass = (shape) => {\n        const normalized = _normalized.value;\n        const syms = normalized.symbolKeys;\n        // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope\n        const doc = new Doc([\"payload\", \"ctx\"], { shape, inst, memo, syms });\n        const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;\n        // prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input\n        const prefixStr = (id, k) => `\n          let ${id}_ab = false;\n          for (let i = 0; i < ${id}.issues.length; i++) {\n            const iss = ${id}.issues[i];\n            iss.path = iss.path ? [${k}, ...iss.path] : [${k}];\n            payload.issues.push(iss);\n            if (iss.continue !== true) ${id}_ab = true;\n          }\n          if (${id}_ab && ctx && ctx.abortEarly) {\n            payload.value = newResult;\n            return payload;\n          }`;\n        doc.write(`const input = payload.value;`);\n        const ids = Object.create(null);\n        let counter = 0;\n        for (const key of normalized.allKeys) {\n            ids[key] = `key_${counter++}`;\n        }\n        // A: preserve key order {\n        doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);\n        for (const key of normalized.allKeys) {\n            if (key === \"__proto__\")\n                continue;\n            const id = ids[key];\n            const k = typeof key === \"symbol\" ? `syms[${syms.indexOf(key)}]` : util.esc(key);\n            const isPresent = `${k} in input`;\n            const schema = shape[key];\n            const optin = schema?._zod?.optin;\n            const isOptionalIn = optin !== undefined;\n            const isOptionalOut = schema?._zod?.optout === \"optional\";\n            doc.write(`const ${id} = ${parseStr(k)};`);\n            if (isOptionalIn && isOptionalOut) {\n                // For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.\n                const assign = optin === \"optional\" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;\n                doc.write(`\n        const ${id}_present = ${isPresent};\n        if (!${id}.issues.length || ${id}_present) {\n          if (${id}.issues.length) {${prefixStr(id, k)}\n          }\n\n          if (${assign}) {\n            newResult[${k}] = ${id}.value;\n          }\n        }\n\n      `);\n            }\n            else if (!isOptionalIn) {\n                doc.write(`\n        const ${id}_present = ${isPresent};\n        if (${id}.issues.length) {${prefixStr(id, k)}\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          if (ctx && ctx.abortEarly) {\n            payload.value = newResult;\n            return payload;\n          }\n        }\n\n        if (${id}_present) {\n          newResult[${k}] = ${id}.value;\n        }\n\n      `);\n            }\n            else {\n                doc.write(`\n        if (${id}.issues.length) {${prefixStr(id, k)}\n        }\n      `);\n                if (optin === \"defaulted\") {\n                    doc.write(`newResult[${k}] = ${id}.value;`);\n                }\n                else {\n                    doc.write(`\n        if (${id}.value !== undefined || ${isPresent}) {\n          newResult[${k}] = ${id}.value;\n        }\n      `);\n                }\n            }\n        }\n        doc.write(`payload.value = newResult;`);\n        doc.write(`return payload;`);\n        // closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone\n        return doc.compile();\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, ctx?.abortEarly === true);\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.defineLazyInternal(inst, \"optin\", (zod) => zod.def.options.some((o) => o._zod.optin === \"defaulted\")\n        ? \"defaulted\"\n        : zod.def.options.some((o) => o._zod.optin !== undefined)\n            ? \"optional\"\n            : undefined);\n    util.defineLazyInternal(inst, \"optout\", (zod) => zod.def.options.some((o) => o._zod.optout === \"optional\") ? \"optional\" : undefined);\n    util.defineLazyInternal(inst, \"values\", (zod) => {\n        if (zod.def.options.every((o) => o._zod.values)) {\n            return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));\n        }\n        return undefined;\n    });\n    util.defineLazyInternal(inst, \"pattern\", (zod) => {\n        if (zod.def.options.every((o) => o._zod.pattern)) {\n            const patterns = zod.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 matches = [];\n    for (let i = 0; i < results.length; i++) {\n        if (results[i].issues.length === 0)\n            matches.push(i);\n    }\n    if (matches.length === 1) {\n        final.value = results[matches[0]].value;\n        return final;\n    }\n    if (matches.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            matches,\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});\n/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */\nexport function getDiscriminatedOption(union, value) {\n    const internals = union._zod;\n    let map = internals.bag.optionsMap;\n    if (!map) {\n        map = discriminatorMap(internals.def);\n        internals.bag.optionsMap = map;\n    }\n    const option = map.get(value);\n    if (option === null)\n        throw new Error(`Ambiguous discriminator value \"${String(value)}\"`);\n    return option;\n}\nfunction discriminatorMap(def) {\n    const map = new Map();\n    for (const option of def.options) {\n        const values = option._zod.propValues?.[def.discriminator];\n        if (!values || values.size === 0)\n            throw new Error(`Invalid discriminated union option at index \"${def.options.indexOf(option)}\"`);\n        for (const value of values) {\n            if (map.has(value)) {\n                if (value !== undefined)\n                    throw new Error(`Duplicate discriminator value \"${String(value)}\"`);\n                // keep the collision marked so a later member cannot reclaim it\n                map.set(value, null);\n            }\n            else {\n                map.set(value, option);\n            }\n        }\n    }\n    return map;\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.defineLazyInternal(inst, \"propValues\", (zod) => {\n        const propValues = {};\n        let undefinedCount = 0;\n        for (const option of zod.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 \"${zod.def.options.indexOf(option)}\"`);\n            if (pv[zod.def.discriminator]?.has(undefined))\n                undefinedCount++;\n            for (const [k, v] of Object.entries(pv)) {\n                if (!Object.prototype.hasOwnProperty.call(propValues, k)) {\n                    util.assignProp(propValues, k, new Set());\n                }\n                for (const val of v) {\n                    propValues[k].add(val);\n                }\n            }\n        }\n        if (!zod.def.unionFallback && undefinedCount > 1)\n            propValues[zod.def.discriminator]?.delete(undefined);\n        return propValues;\n    });\n    // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.\n    def.options.forEach((option, i) => {\n        const propShape = util.rawShape(option._zod.def);\n        if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {\n            throw new Error(`Invalid discriminated union option at index \"${i}\"`);\n        }\n    });\n    const disc = util.cached(() => discriminatorMap(def));\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 value = input?.[def.discriminator];\n        const opt = disc.value.get(value);\n        // forward metadata cannot choose an encoder for an absent tag\n        if (opt && (value !== undefined || ctx.direction !== \"backward\")) {\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 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()).filter((value) => disc.value.get(value) !== null),\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});\nexport function 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        if (Object.prototype.hasOwnProperty.call(newObj, \"__proto__\"))\n            delete newObj.__proto__;\n        for (const key of sharedKeys) {\n            if (key === \"__proto__\")\n                continue;\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) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.\n    const unrecKeys = new Map();\n    let unrecIssue;\n    const keyIssues = new Map();\n    const collect = (iss, side) => {\n        let keys;\n        if (iss.code === \"unrecognized_keys\" && !iss.path?.length) {\n            unrecIssue ?? (unrecIssue = iss);\n            keys = iss.keys;\n        }\n        else if (iss.code === \"invalid_key\" && iss.origin === \"record\" && iss.path?.length === 1) {\n            const k = String(iss.path[0]);\n            if (!keyIssues.has(k))\n                keyIssues.set(k, iss);\n            keys = [k];\n        }\n        else {\n            return false;\n        }\n        for (const k of keys) {\n            if (!unrecKeys.has(k))\n                unrecKeys.set(k, {});\n            unrecKeys.get(k)[side] = true;\n        }\n        return true;\n    };\n    for (const iss of left.issues) {\n        if (!collect(iss, \"l\"))\n            result.issues.push(iss);\n    }\n    for (const iss of right.issues) {\n        if (!collect(iss, \"r\"))\n            result.issues.push(iss);\n    }\n    // Report only keys rejected by BOTH sides\n    const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);\n    if (bothKeys.length) {\n        const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];\n        if (aggregated.length)\n            result.issues.push({ ...unrecIssue, keys: aggregated });\n        for (const k of bothKeys) {\n            if (!aggregated.includes(k) && keyIssues.has(k))\n                result.issues.push(keyIssues.get(k));\n        }\n    }\n    const merged = mergeValues(left.value, right.value);\n    if (!merged.valid) {\n        if (util.aborted(result))\n            return result;\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    const memo = core.globalConfig.memoizer;\n    memo?.attach(inst);\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 = memo ? memo.alloc(inst, payload, [], ctx) : [];\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 array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.\n        const itemResults = new Array(items.length);\n        // only tracked when there is a rest loop to skip\n        const abortEarly = def.rest ? ctx?.abortEarly : undefined;\n        let itemAborted = false;\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                if (abortEarly && !itemAborted && r.issues.length)\n                    itemAborted = util.aborted(r);\n            }\n        }\n        // sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues\n        if (def.rest && !itemAborted) {\n            let i = items.length - 1;\n            const rest = input.slice(items.length);\n            let seen = payload.issues.length;\n            for (const el of rest) {\n                if (abortEarly && payload.issues.length !== seen) {\n                    if (util.aborted(payload, seen))\n                        break;\n                    seen = payload.issues.length;\n                }\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        // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.\n        const omittable = key === \"optin\" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === \"optional\";\n        if (!omittable)\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 rule, but only after `optoutStart`: the first index where the output 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        // The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.\n        if (!isPresent && i >= optoutStart && items[i]._zod.optin === \"optional\") {\n            final.value.length = i;\n            break;\n        }\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    const memo = core.globalConfig.memoizer;\n    memo?.attach(inst);\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        // no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing\n        const proms = [];\n        const values = def.keyType._zod.values;\n        if (values && !def.partial) {\n            payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};\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                    // A declared __proto__ is stripped but is not an unrecognized key.\n                    if (key === \"__proto__\")\n                        continue;\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                    if (outKey === \"__proto__\")\n                        continue;\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                    if (def.mode === \"loose\") {\n                        // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into\n                        if (key === \"__proto__\")\n                            continue;\n                        payload.value[key] = input[key];\n                    }\n                    else {\n                        unrecognized = unrecognized ?? [];\n                        unrecognized.push(key);\n                    }\n                }\n            }\n            if (unrecognized && unrecognized.length > 0) {\n                payload.issues.push({\n                    code: \"unrecognized_keys\",\n                    input,\n                    inst,\n                    keys: unrecognized,\n                    continue: true,\n                });\n            }\n        }\n        else {\n            payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};\n            // An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.\n            let unrecognized;\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). 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 if (values) {\n                        unrecognized = unrecognized ?? [];\n                        unrecognized.push(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                // the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under\n                const outKey = keyResult.value;\n                if (outKey === \"__proto__\")\n                    continue;\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            if (unrecognized && unrecognized.length > 0) {\n                payload.issues.push({\n                    code: \"unrecognized_keys\",\n                    input,\n                    inst,\n                    keys: unrecognized,\n                    continue: true,\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    const memo = core.globalConfig.memoizer;\n    memo?.attach(inst);\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 = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();\n        const abortEarly = ctx?.abortEarly;\n        let seen = payload.issues.length;\n        for (const [key, value] of input) {\n            if (abortEarly && payload.issues.length !== seen) {\n                if (util.aborted(payload, seen))\n                    break;\n                seen = payload.issues.length;\n            }\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    capSize(inst, mapSize);\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    const memo = core.globalConfig.memoizer;\n    memo?.attach(inst);\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 = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();\n        const abortEarly = ctx?.abortEarly;\n        let seen = payload.issues.length;\n        for (const item of input) {\n            if (abortEarly && payload.issues.length !== seen) {\n                if (util.aborted(payload, seen))\n                    break;\n                seen = payload.issues.length;\n            }\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    capSize(inst, setSize);\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    util.defineLazyInternal(inst, \"pattern\", (zod) => {\n        const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));\n        // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches \"\"\n        return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join(\"|\")})$` : \"^[^\\\\s\\\\S]$\");\n    });\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    const values = new Set(def.values);\n    inst._zod.values = values;\n    util.defineLazyInternal(inst, \"pattern\", (zod) => {\n        const vals = zod.def.values;\n        // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches \"\"\n        return new RegExp(vals.length\n            ? `^(${vals\n                .map((o) => typeof o === \"string\" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))\n                .join(\"|\")})$`\n            : \"^[^\\\\s\\\\S]$\");\n    });\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    core.globalConfig.memoizer?.guard(inst);\n    inst._zod.parse = (payload, ctx) => {\n        if (ctx.direction === \"backward\") {\n            throw new core.$ZodEncodeError(inst.constructor.name);\n        }\n        const _out = def.transform(payload.value, payload);\n        if (ctx.async) {\n            const output = _out instanceof Promise ? _out : Promise.resolve(_out);\n            return output.then((output) => {\n                payload.value = output;\n                return payload;\n            });\n        }\n        if (_out instanceof Promise) {\n            throw new core.$ZodAsyncError();\n        }\n        payload.value = _out;\n        return payload;\n    };\n});\nfunction handleOptionalResult(payload, result) {\n    // A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.\n    payload.value = result.issues.length ? undefined : result.value;\n    return payload;\n}\nexport const $ZodOptional = /*@__PURE__*/ core.$constructor(\"$ZodOptional\", (inst, def) => {\n    $ZodType.init(inst, def);\n    // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.\n    util.defineLazyInternal(inst, \"optin\", (zod) => zod.def.innerType._zod.optin === \"defaulted\" ? \"defaulted\" : \"optional\");\n    inst._zod.optout = \"optional\";\n    util.defineLazyInternal(inst, \"values\", (zod) => {\n        const values = zod.def.innerType._zod.values;\n        return values ? new Set([...values, undefined]) : undefined;\n    });\n    util.defineLazyInternal(inst, \"pattern\", (zod) => {\n        const pattern = zod.def.innerType._zod.pattern;\n        return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;\n    });\n    inst._zod.parse = (payload, ctx) => {\n        if (payload.value === undefined) {\n            // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.\n            if (def.innerType._zod.optin !== \"defaulted\")\n                return payload;\n            // Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.\n            const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);\n            if (result instanceof Promise)\n                return result.then((result) => handleOptionalResult(payload, result));\n            return handleOptionalResult(payload, result);\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.defineLazyInternal(inst, \"values\", (zod) => zod.def.innerType._zod.values);\n    util.defineLazyInternal(inst, \"pattern\", (zod) => zod.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.defineLazyInternal(inst, \"optin\", (zod) => zod.def.innerType._zod.optin);\n    util.defineLazyInternal(inst, \"optout\", (zod) => zod.def.innerType._zod.optout);\n    util.defineLazyInternal(inst, \"pattern\", (zod) => {\n        const pattern = zod.def.innerType._zod.pattern;\n        return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;\n    });\n    util.defineLazyInternal(inst, \"values\", (zod) => {\n        return zod.def.innerType._zod.values ? new Set([...zod.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 = \"defaulted\";\n    util.defineLazyInternal(inst, \"values\", (zod) => zod.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 = \"defaulted\";\n    util.defineLazyInternal(inst, \"values\", (zod) => zod.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.defineLazyInternal(inst, \"values\", (zod) => {\n        const v = zod.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});\nfunction handleCatchResult(payload, result, def, ctx) {\n    if (!result.issues.length) {\n        payload.value = result.value;\n        // The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.\n        if (result.memo)\n            payload.memo = true;\n        return payload;\n    }\n    // Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.\n    payload.value = def.catchValue({\n        ...result,\n        value: payload.value,\n        error: {\n            issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),\n        },\n        input: payload.value,\n    });\n    return payload;\n}\nexport const $ZodCatch = /*@__PURE__*/ core.$constructor(\"$ZodCatch\", (inst, def) => {\n    $ZodType.init(inst, def);\n    util.defineLazyInternal(inst, \"optin\", (zod) => zod.def.innerType._zod.optin === \"defaulted\" ? \"defaulted\" : \"optional\");\n    util.defineLazyInternal(inst, \"optout\", (zod) => zod.def.innerType._zod.optout);\n    util.defineLazyInternal(inst, \"values\", (zod) => zod.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({ value: payload.value, issues: [] }, ctx);\n        if (result instanceof Promise) {\n            return result.then((result) => handleCatchResult(payload, result, def, ctx));\n        }\n        return handleCatchResult(payload, result, def, ctx);\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.defineLazyInternal(inst, \"values\", (zod) => zod.def.in._zod.values);\n    util.defineLazyInternal(inst, \"optin\", (zod) => zod.def.in._zod.optin);\n    util.defineLazyInternal(inst, \"optout\", (zod) => zod.def.out._zod.optout);\n    util.defineLazyInternal(inst, \"propValues\", (zod) => zod.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    // Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.\n    if (left.issues.some((iss) => iss.code !== \"unrecognized_keys\")) {\n        // prevent further checks\n        left.aborted = true;\n        return left;\n    }\n    return next._zod.run({ value: left.value, issues: left.issues }, ctx);\n}\nexport const $ZodCodec = /*@__PURE__*/ core.$constructor(\"$ZodCodec\", (inst, def) => {\n    $ZodType.init(inst, def);\n    util.defineLazyInternal(inst, \"values\", (zod) => zod.def.in._zod.values);\n    util.defineLazyInternal(inst, \"optin\", (zod) => zod.def.in._zod.optin);\n    util.defineLazyInternal(inst, \"optout\", (zod) => zod.def.out._zod.optout);\n    util.defineLazyInternal(inst, \"propValues\", (zod) => zod.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.defineLazyInternal(inst, \"propValues\", (zod) => zod.def.innerType._zod.propValues);\n    util.defineLazyInternal(inst, \"values\", (zod) => zod.def.innerType._zod.values);\n    util.defineLazyInternal(inst, \"optin\", (zod) => zod.def.innerType?._zod?.optin);\n    util.defineLazyInternal(inst, \"optout\", (zod) => zod.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    // A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.\n    if (!payload.memo)\n        payload.value = Object.freeze(payload.value);\n    return payload;\n}\n// a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it\nfunction leafPattern(schema) {\n    const def = schema._zod.def;\n    let pattern = def.pattern;\n    let isInt = !!def.format?.includes(\"int\");\n    let minimum;\n    let maximum;\n    for (const ch of def.checks ?? []) {\n        const d = ch._zod.def;\n        if (d.pattern)\n            pattern = d.pattern;\n        isInt || (isInt = !!d.format?.includes(\"int\"));\n        const lo = d.minimum ?? d.length;\n        const hi = d.maximum ?? d.length;\n        if (lo !== undefined && (minimum === undefined || lo > minimum))\n            minimum = lo;\n        if (hi !== undefined && (maximum === undefined || hi < maximum))\n            maximum = hi;\n    }\n    if (pattern)\n        return pattern.source;\n    // an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier\n    if (minimum !== undefined && maximum !== undefined && minimum > maximum)\n        return \"(?!)\";\n    if (minimum !== undefined || maximum !== undefined)\n        return regexes.string({ minimum, maximum }).source;\n    const own = schema._zod.pattern;\n    return (isInt && own === regexes.number ? regexes.integer : own)?.source;\n}\n// a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern\nfunction partPattern(schema) {\n    const def = schema._zod.def;\n    const own = schema._zod.pattern?.source;\n    // lazy resolves its inner on the internals, not the def\n    const inner = def.innerType ?? schema._zod.innerType;\n    if (inner) {\n        const before = inner._zod.pattern?.source;\n        const after = partPattern(inner);\n        if (own && before && after && after !== before) {\n            return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));\n        }\n        return own;\n    }\n    if (def.options) {\n        const sources = def.options.map(partPattern);\n        if (sources.every(Boolean))\n            return `^(${sources.map((s) => util.cleanRegex(s)).join(\"|\")})$`;\n    }\n    return leafPattern(schema);\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            const source = partPattern(part);\n            if (!source) {\n                throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);\n            }\n            regexParts.push(util.cleanRegex(source));\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    // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.\n    Object.defineProperty(inst, \"_def\", { value: 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        // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.\n        return Object.defineProperty(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        }, \"_zod\", { value: inst._zod, enumerable: false });\n    };\n    inst.implementAsync = (func) => {\n        if (typeof func !== \"function\") {\n            throw new Error(\"implementAsync() must be called with a function\");\n        }\n        return Object.defineProperty(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        }, \"_zod\", { value: inst._zod, enumerable: false });\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 lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, 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.defineLazyInternal(inst, \"pattern\", (zod) => zod.innerType?._zod?.pattern);\n    util.defineLazyInternal(inst, \"propValues\", (zod) => zod.innerType?._zod?.propValues);\n    util.defineLazyInternal(inst, \"optin\", (zod) => zod.innerType?._zod?.optin ?? undefined);\n    util.defineLazyInternal(inst, \"optout\", (zod) => 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","import * as util from \"./util.js\";\nexport class $ZodCyclicError extends Error {\n    constructor() {\n        super(`Cannot parse a reference cycle that closes through a transform`);\n        this.name = \"ZodCyclicError\";\n    }\n}\n/** Keyed off the context object every schema in one parse call already shares. */\nconst STATE = \"~memo\";\nconst NO_ISSUES = [];\n// a value a cycle can close through\nfunction isRef(value) {\n    return value !== null && typeof value === \"object\";\n}\n// Receivers prefix paths in place, so the cache and every hand-out need their own copies.\nfunction cloneIssues(issues) {\n    return issues.map((iss) => (iss.path ? { ...iss, path: iss.path.slice() } : { ...iss }));\n}\nconst recursive = /*@__PURE__*/ new WeakMap();\n/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */\nconst NONE = 0;\nconst ASSUMED = 1;\nconst PROVEN = 2;\n/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */\nfunction isRecursive(inst, stack, resolve) {\n    const cached = recursive.get(inst);\n    if (cached !== undefined)\n        return cached ? PROVEN : NONE;\n    // Relative to the walk in progress, so not cached.\n    if (stack.has(inst))\n        return PROVEN;\n    stack.add(inst);\n    let result = NONE;\n    const check = (child) => {\n        if (result !== PROVEN && child?._zod) {\n            const answer = isRecursive(child, stack, resolve);\n            if (answer > result)\n                result = answer;\n        }\n    };\n    // `Reflect.ownKeys` rather than `Object.keys`, so a cycle through a declared symbol key is still seen\n    const shape = (sh, spread) => {\n        let answer = NONE;\n        for (const key of Reflect.ownKeys(sh)) {\n            const desc = Object.getOwnPropertyDescriptor(sh, key);\n            // an object resolves its shape by spread, so a key it does not enumerate is never parsed; `z.properties` reads every own key and so keeps them all\n            if (spread && !desc.enumerable)\n                continue;\n            // resolving runs user code, and a factory mints a fresh subtree per read, so an edge the walk can't follow counts as a cycle\n            const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;\n            if (child > answer)\n                answer = child;\n        }\n        return answer;\n    };\n    const merge = (answer) => {\n        if (answer > result)\n            result = answer;\n    };\n    const def = inst._zod.def;\n    const kind = def.type;\n    switch (kind) {\n        case \"object\": {\n            const raw = util.rawShape(def);\n            // a def with no raw shape answers `shape` from an accessor of its own, and running that can mint a whole fresh subtree\n            merge(raw ? shape(raw, true) : ASSUMED);\n            check(def.catchall);\n            break;\n        }\n        case \"array\":\n            check(def.element);\n            break;\n        case \"tuple\":\n            for (const el of def.items)\n                check(el);\n            check(def.rest);\n            break;\n        case \"record\":\n        case \"map\":\n            check(def.keyType);\n            check(def.valueType);\n            break;\n        case \"set\":\n            check(def.valueType);\n            break;\n        case \"union\":\n            for (const el of def.options)\n                check(el);\n            break;\n        case \"intersection\":\n            check(def.left);\n            check(def.right);\n            break;\n        case \"optional\":\n        case \"nullable\":\n        case \"default\":\n        case \"prefault\":\n        case \"catch\":\n        case \"readonly\":\n        case \"nonoptional\":\n        case \"promise\":\n        case \"success\":\n            check(def.innerType);\n            break;\n        case \"pipe\":\n            check(def.in);\n            check(def.out);\n            break;\n        case \"function\":\n            check(def.input);\n            check(def.output);\n            break;\n        // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly\n        case \"lazy\": {\n            const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : undefined);\n            // walked with resolution off: one hop sees past the deferral, and a lazy that yields only another unresolved lazy is generative, so it stops there\n            merge(inner ? isRecursive(inner, stack, false) : ASSUMED);\n            break;\n        }\n        // a leaf by choice: `parts` are regex fragments, not data positions\n        case \"template_literal\":\n        // leaves\n        case \"string\":\n        case \"number\":\n        case \"int\":\n        case \"boolean\":\n        case \"bigint\":\n        case \"symbol\":\n        case \"undefined\":\n        case \"null\":\n        case \"void\":\n        case \"never\":\n        case \"any\":\n        case \"unknown\":\n        case \"date\":\n        case \"nan\":\n        case \"enum\":\n        case \"literal\":\n        case \"file\":\n        case \"transform\":\n        case \"custom\":\n            break;\n        default: {\n            // a new built-in kind becomes a compile error here\n            kind;\n            // a user-defined kind can still hold children, and only its author knows where, so fall back to scanning the def — skipping accessors, since reading one can run user code\n            for (const key in def) {\n                const desc = Object.getOwnPropertyDescriptor(def, key);\n                if (!desc || desc.get)\n                    continue;\n                const value = desc.value;\n                if (!value || typeof value !== \"object\")\n                    continue;\n                if (value._zod)\n                    check(value);\n                else if (Array.isArray(value))\n                    for (const el of value)\n                        check(el);\n            }\n        }\n    }\n    stack.delete(inst);\n    return settle(inst, result);\n}\n/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */\nfunction settle(inst, answer) {\n    if (answer !== ASSUMED)\n        recursive.set(inst, answer === PROVEN);\n    return answer;\n}\n/**\n * Whether one parse can re-enter this schema, i.e. its subtree contains a cycle.\n * Exported for `z.compile`, which refuses to compile such a schema: cycle\n * breaking is driven from here off state keyed on the parse context, and a\n * generated fast path has no context to key on.\n */\nexport function isRecursiveSchema(inst) {\n    // z.compile never parses, so nothing would ever resolve a lazy for it; it runs once and already treats a throw here as recursive\n    return isRecursive(inst, new Set(), true) !== NONE;\n}\nfunction bucketFor(state, inst) {\n    let bucket = state.buckets.get(inst);\n    if (!bucket) {\n        bucket = new WeakMap();\n        state.buckets.set(inst, bucket);\n    }\n    return bucket;\n}\n// Set immediately before delegating to core and cleared immediately after, so `alloc` registers only for a visit this module is driving.\nlet handoff;\n// Allocated but unfinished entries. `alloc` and the matching pop both happen in the synchronous part of a parse, so they nest even when children are async, and one stack serves every schema.\nconst open = [];\nconst memo = {\n    alloc(_inst, payload, empty) {\n        const bucket = handoff;\n        if (!bucket)\n            return empty;\n        handoff = undefined;\n        const entry = { value: empty, issues: null };\n        bucket.set(payload.value, entry);\n        open.push(entry);\n        return empty;\n    },\n    guard(inst) {\n        var _a;\n        (_a = inst._zod).deferred ?? (_a.deferred = []);\n        inst._zod.deferred.push(() => {\n            const base = inst._zod.parse;\n            const wrapped = (payload, ctx) => {\n                // The value is a placeholder a back-edge is still waiting on, so the cycle closes through this transform. Its output can't exist in time to bind.\n                if (ctx.direction !== \"backward\" && isBackEdge(ctx, payload.value))\n                    throw new $ZodCyclicError();\n                return base(payload, ctx);\n            };\n            inst._zod.parse = wrapped;\n            if (inst._zod.run === base)\n                inst._zod.run = wrapped;\n        });\n    },\n    attach(inst) {\n        var _a;\n        let isRecursiveInst;\n        let rechecked = false;\n        // a recursive schema is re-entered many times per parse and its bucket never changes\n        let lastCtx;\n        let lastBucket;\n        // Wraps `parse` in a deferred so it sees the container's final parse. Core's own deferred copies `parse` into `run` when there are no checks, and it ran first, so `run` is patched to match; with checks, `run` reads `parse` dynamically.\n        (_a = inst._zod).deferred ?? (_a.deferred = []);\n        inst._zod.deferred.push(() => {\n            const base = inst._zod.parse;\n            const wrapped = (payload, ctx) => {\n                if (isRecursiveInst === undefined) {\n                    const walked = isRecursive(inst, new Set(), false);\n                    if (walked === NONE) {\n                        // Nothing here can ever fire, so take it back out.\n                        inst._zod.parse = base;\n                        if (inst._zod.run === wrapped)\n                            inst._zod.run = base;\n                        return base(payload, ctx);\n                    }\n                    // this parse resolves the deferred edges on its own path, so ask once more before latching\n                    if (walked === PROVEN || rechecked)\n                        isRecursiveInst = true;\n                    else\n                        rechecked = true;\n                }\n                const input = payload.value;\n                if (!isRef(input))\n                    return base(payload, ctx);\n                let state = ctx[STATE];\n                if (!state) {\n                    state = { buckets: new WeakMap(), backEdges: undefined };\n                    ctx[STATE] = state;\n                }\n                let bucket;\n                if (lastCtx === ctx) {\n                    bucket = lastBucket;\n                }\n                else {\n                    bucket = bucketFor(state, inst);\n                    lastCtx = ctx;\n                    lastBucket = bucket;\n                }\n                const hit = bucket.get(input);\n                if (hit) {\n                    payload.value = hit.value;\n                    if (hit.issues) {\n                        if (hit.issues.length)\n                            payload.issues.push(...cloneIssues(hit.issues));\n                    }\n                    else {\n                        // Still being parsed: its own checks cover it, so skip them here.\n                        payload.memo = true;\n                        state.backEdges ?? (state.backEdges = new WeakSet());\n                        state.backEdges.add(hit.value);\n                    }\n                    return payload;\n                }\n                handoff = bucket;\n                const depth = open.length;\n                const result = base(payload, ctx);\n                handoff = undefined;\n                // A container that rejected its input outright allocated nothing.\n                const entry = open.length > depth ? open.pop() : undefined;\n                // Both paths written out so the sync one allocates no closure. It runs once per node, and capturing here cost more than everything else combined.\n                if (result instanceof Promise) {\n                    return result.then((r) => {\n                        if (entry)\n                            entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;\n                        return r;\n                    });\n                }\n                if (entry)\n                    entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;\n                return result;\n            };\n            inst._zod.parse = wrapped;\n            if (inst._zod.run === base)\n                inst._zod.run = wrapped;\n        });\n    },\n};\n/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */\nexport function memoizer() {\n    return memo;\n}\n/** Whether this value is a node a back-edge resolved to before it finished. */\nexport function isBackEdge(ctx, value) {\n    const backEdges = ctx[STATE]?.backEdges;\n    return backEdges !== undefined && isRef(value) && backEdges.has(value);\n}\n","import * as util from \"../core/util.js\";\nconst error = () => {\n    const Sizable = {\n        string: { unit: \"characters\", verb: \"to have\" },\n        file: { unit: \"bytes\", verb: \"to have\" },\n        array: { unit: \"items\", verb: \"to have\" },\n        set: { unit: \"items\", verb: \"to have\" },\n        map: { unit: \"entries\", verb: \"to have\" },\n    };\n    function getSizing(origin) {\n        return Sizable[origin] ?? null;\n    }\n    const FormatDictionary = {\n        regex: \"input\",\n        email: \"email address\",\n        url: \"URL\",\n        emoji: \"emoji\",\n        uuid: \"UUID\",\n        uuidv4: \"UUIDv4\",\n        uuidv6: \"UUIDv6\",\n        nanoid: \"nanoid\",\n        guid: \"GUID\",\n        cuid: \"cuid\",\n        cuid2: \"cuid2\",\n        ulid: \"ULID\",\n        xid: \"XID\",\n        ksuid: \"KSUID\",\n        datetime: \"ISO datetime\",\n        date: \"ISO date\",\n        time: \"ISO time\",\n        duration: \"ISO duration\",\n        ipv4: \"IPv4 address\",\n        ipv6: \"IPv6 address\",\n        mac: \"MAC address\",\n        cidrv4: \"IPv4 range\",\n        cidrv6: \"IPv6 range\",\n        base64: \"base64-encoded string\",\n        base64url: \"base64url-encoded string\",\n        json_string: \"JSON string\",\n        e164: \"E.164 number\",\n        currency_code: \"currency code\",\n        credit_card: \"credit card number\",\n        iban: \"IBAN\",\n        jwt: \"JWT\",\n        template_literal: \"input\",\n    };\n    // type names: missing keys = do not translate (use raw value via ?? fallback)\n    const TypeDictionary = {\n        // Compatibility: \"nan\" -> \"NaN\" for display\n        nan: \"NaN\",\n        // All other type names omitted - they fall back to raw values via ?? operator\n    };\n    function getTypeName(type, input) {\n        if (type === \"number\" && typeof input === \"number\" && !Number.isFinite(input)) {\n            return String(input);\n        }\n        return TypeDictionary[type] ?? type;\n    }\n    return (issue) => {\n        switch (issue.code) {\n            case \"invalid_type\": {\n                const expected = getTypeName(issue.expected);\n                const receivedType = util.parsedType(issue.input);\n                const received = getTypeName(receivedType, issue.input);\n                return `Invalid input: expected ${expected}, received ${received}`;\n            }\n            case \"invalid_value\":\n                if (issue.values.length === 1)\n                    return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`;\n                return `Invalid option: expected one of ${util.joinValues(issue.values, \"|\")}`;\n            case \"too_big\": {\n                const adj = issue.exact ? \"exactly \" : issue.inclusive ? \"<=\" : \"<\";\n                const sizing = getSizing(issue.origin);\n                if (sizing)\n                    return `Too big: expected ${issue.origin ?? \"value\"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? \"elements\"}`;\n                return `Too big: expected ${issue.origin ?? \"value\"} to be ${adj}${issue.maximum.toString()}`;\n            }\n            case \"too_small\": {\n                const adj = issue.exact ? \"exactly \" : issue.inclusive ? \">=\" : \">\";\n                const sizing = getSizing(issue.origin);\n                if (sizing) {\n                    return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;\n                }\n                return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;\n            }\n            case \"invalid_format\": {\n                const _issue = issue;\n                if (_issue.format === \"starts_with\") {\n                    return `Invalid string: must start with \"${_issue.prefix}\"`;\n                }\n                if (_issue.format === \"ends_with\")\n                    return `Invalid string: must end with \"${_issue.suffix}\"`;\n                if (_issue.format === \"includes\")\n                    return `Invalid string: must include \"${_issue.includes}\"`;\n                if (_issue.format === \"regex\")\n                    return `Invalid string: must match pattern ${_issue.pattern}`;\n                return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;\n            }\n            case \"not_multiple_of\":\n                return `Invalid number: must be a multiple of ${issue.divisor}`;\n            case \"unrecognized_keys\":\n                return `Unrecognized key${issue.keys.length > 1 ? \"s\" : \"\"}: ${util.joinValues(issue.keys, \", \")}`;\n            case \"invalid_key\":\n                return `Invalid key in ${issue.origin}`;\n            case \"invalid_union\":\n                if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {\n                    const opts = issue.options.map((o) => `'${o}'`).join(\" | \");\n                    return `Invalid discriminator value. Expected ${opts}`;\n                }\n                if (issue.inclusive === false) {\n                    return \"Invalid input: more than one option matched\";\n                }\n                return \"Invalid input\";\n            case \"invalid_element\":\n                return `Invalid value in ${issue.origin}`;\n            default:\n                return `Invalid input`;\n        }\n    };\n};\nexport default function () {\n    return {\n        localeError: error(),\n    };\n}\n","var _a;\nexport const $output = /*@__PURE__*/ Symbol(\"ZodOutput\");\nexport const $input = /*@__PURE__*/ 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\";\nfunction snapshotChecks(def) {\n    if (def.checks)\n        def.checks = [...def.checks];\n    return def;\n}\n// @__NO_SIDE_EFFECTS__\nexport function _string(Class, params) {\n    return new Class(snapshotChecks({ type: \"string\", ...util.normalizeParams(params) }));\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedString(Class, params) {\n    return new Class(snapshotChecks({ type: \"string\", coerce: true, ...util.normalizeParams(params) }));\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 _creditCard(Class, params) {\n    return new Class({\n        type: \"string\",\n        format: \"credit_card\",\n        check: \"string_format\",\n        abort: false,\n        ...util.normalizeParams(params),\n    });\n}\n// @__NO_SIDE_EFFECTS__\nexport function _iban(Class, params) {\n    return new Class({\n        type: \"string\",\n        format: \"iban\",\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(snapshotChecks({ type: \"number\", checks: [], ...util.normalizeParams(params) }));\n}\n// @__NO_SIDE_EFFECTS__\nexport function _coercedNumber(Class, params) {\n    return new Class(snapshotChecks({ type: \"number\", coerce: true, checks: [], ...util.normalizeParams(params) }));\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 _properties(shape, params) {\n    return new checks.$ZodCheckProperties({\n        check: \"properties\",\n        shape,\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: 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 : util.constantCatch(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                if (!(\"input\" in _issue))\n                    _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    codec._zod.bag.truthy = truthyArray;\n    codec._zod.bag.falsy = falsyArray;\n    codec._zod.bag.case = params.case ?? \"insensitive\";\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        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\";\nimport { assignProp } from \"./util.js\";\nfunction assignProps(target, ...sources) {\n    for (const source of sources) {\n        for (const key of Reflect.ownKeys(source)) {\n            if (Object.prototype.propertyIsEnumerable.call(source, key)) {\n                assignProp(target, key, source[key]);\n            }\n        }\n    }\n    return target;\n}\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        sharedDefsExtractedFor: undefined,\n        sharedEmitDoneFor: undefined,\n        cycles: params?.cycles ?? \"ref\",\n        reused: params?.reused ?? \"inline\",\n        intersections: [],\n        deferred: [],\n        external: params?.external ?? undefined,\n    };\n}\n/**\n * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws\n * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a\n * custom JSON Schema was written into `json`, in which case the caller must not write its own.\n */\nexport function handleUnrepresentable(schema, ctx, json, params, message) {\n    const result = typeof ctx.unrepresentable === \"function\"\n        ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message })\n        : ctx.unrepresentable;\n    if (result === \"any\")\n        return false;\n    if (result === undefined || result === \"throw\")\n        throw new Error(message);\n    Object.assign(json, result);\n    return true;\n}\n// never rename this back to `process`: bundler polyfills inject a top-level `const process` that a lexical declaration of the same name collides with (#6397)\nexport function processSchema(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    ctx.sharedDefsExtractedFor = undefined;\n    ctx.sharedEmitDoneFor = undefined;\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            processSchema(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        assignProps(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}\n/** @deprecated Renamed to `processSchema`. An export alias declares no binding, so it is safe to keep. */\nexport { processSchema as process };\n// Escape a reference token for use in a JSON Pointer fragment (RFC 6901): `~` becomes `~0` and `/` becomes `~1`. The `~` replacement must run first.\nfunction encodeJSONPointerSegment(segment) {\n    return segment.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\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    // With `external` set, every registered schema resolves through the external branch of `makeURI`, so the root branch below produces the same ref the external branch would — this pass is identical whichever schema it is called with, and only needs to run once.\n    if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external)\n        return;\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 defId will be empty if the ref points to an external schema (or #)\n    const makeURI = (entry) => {\n        // comparing the seen objects because sometimes multiple schemas map to the same seen object. 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}/${encodeJSONPointerSegment(id)}` };\n        }\n        const uriPrefix = `#`;\n        const defUriPrefix = `${uriPrefix}/${defsSegment}/`;\n        // an id-less root has nowhere to be extracted to, so it stays inline and self-references as `#`\n        if (entry[1] === root && !entry[1].schema.id) {\n            return { ref: uriPrefix };\n        }\n        // self-contained schema\n        const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;\n        return { defId, ref: defUriPrefix + encodeJSONPointerSegment(defId) };\n    };\n    // stored cached version in `def` property 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 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            }\n        }\n    }\n    if (ctx.external)\n        ctx.sharedDefsExtractedFor = ctx.external;\n}\n/** Rewrites `anyOf: [{type: \"a\"}, {type: \"b\"}]` to `type: [\"a\", \"b\"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so \"exactly one\" and \"at least one\" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */\nfunction compactTypeUnion(schema) {\n    const options = schema.anyOf;\n    if (!Array.isArray(options) || options.length === 0 || schema.type !== undefined)\n        return;\n    const types = [];\n    for (const option of options) {\n        if (!option || typeof option !== \"object\")\n            return;\n        // A branch that is itself a compactible union folds into this one — nested `anyOf` and a flat `type` array say the same thing. Compacting it first also makes the result independent of the order this pass walks the seen map in.\n        compactTypeUnion(option);\n        const keys = Object.keys(option);\n        if (keys.length !== 1 || keys[0] !== \"type\")\n            return;\n        const type = option.type;\n        for (const member of Array.isArray(type) ? type : [type]) {\n            if (typeof member !== \"string\")\n                return;\n            if (!types.includes(member))\n                types.push(member);\n        }\n    }\n    delete schema.anyOf;\n    // A `type` array must be non-empty and unique (metaschema); a single member is spelled as a bare string.\n    schema.type = types.length === 1 ? types[0] : types;\n}\n/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,\n * an annotation like `description` — makes a member unfoldable, so a constraint this does not\n * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */\nconst FOLDABLE_KEYS = new Set([\"type\", \"properties\", \"required\", \"additionalProperties\"]);\nconst UNION_KEYS = [\"oneOf\", \"anyOf\"];\n/** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */\nfunction undeclaredConstraint(member) {\n    const extra = member.additionalProperties;\n    if (extra === undefined || extra === false || typeof extra !== \"object\" || extra === null)\n        return null;\n    return Object.keys(extra).length ? extra : null;\n}\n/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */\nfunction foldObjects(members) {\n    const objects = [];\n    for (const member of members) {\n        // A boolean subschema is legal JSON Schema and carries no keywords to fold.\n        if (typeof member !== \"object\" || member.type !== \"object\")\n            return null;\n        for (const key in member) {\n            if (!FOLDABLE_KEYS.has(key))\n                return null;\n        }\n        objects.push(member);\n    }\n    const properties = {};\n    const required = new Set();\n    for (const object of objects) {\n        for (const key in object.properties) {\n            // `in` would report a `__proto__` key as already present via the prototype chain and skip it.\n            if (Object.prototype.hasOwnProperty.call(properties, key))\n                continue;\n            // Every member constrains this key: the ones that declare it say how, and a `catchall` member constrains it too even though it does not name it. The key has to satisfy all of them, which is the same intersection one level down.\n            const parts = [];\n            for (const other of objects) {\n                const part = other.properties?.[key] ?? undeclaredConstraint(other);\n                if (part === null || part === undefined)\n                    continue;\n                if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part)))\n                    parts.push(part);\n            }\n            const merged = parts.length === 1\n                ? parts[0]\n                : (foldObjects(parts) ?? { allOf: parts });\n            assignProp(properties, key, merged);\n        }\n        for (const key of object.required ?? [])\n            required.add(key);\n    }\n    const folded = { type: \"object\", properties };\n    if (required.size)\n        folded.required = [...required];\n    // A key no member declares is rejected only when every member rejects it, so the fold is closed only when every member is. Otherwise it carries whatever the `catchall` members demand of such a key.\n    if (objects.every((object) => object.additionalProperties === false)) {\n        folded.additionalProperties = false;\n    }\n    else {\n        const constraints = [];\n        for (const object of objects) {\n            const constraint = undeclaredConstraint(object);\n            if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint)))\n                constraints.push(constraint);\n        }\n        if (constraints.length === 1)\n            folded.additionalProperties = constraints[0];\n        else if (constraints.length > 1)\n            folded.additionalProperties = { allOf: constraints };\n    }\n    return folded;\n}\n/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two\n * closed object members reject each other's keys and the schema validates nothing. Zod's parser\n * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when\n * *every* side rejects it — so the emitted schema has to pool them too, and folding the members\n * into one object is the encoding that says so on every target.\n *\n * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`\n * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it\n * keeps its reference and its own closedness rather than being inlined as a stale copy. */\nfunction foldIntersection(json) {\n    const allOf = json.allOf;\n    if (!Array.isArray(allOf) || allOf.length < 2)\n        return;\n    // An `override` runs before this pass and may have written object keywords onto the intersection itself. Those are deliberate, so decline rather than overwrite them.\n    for (const key of FOLDABLE_KEYS)\n        if (key in json)\n            return;\n    // An intersection distributes over a union: `A & (X | Y)` is `(A & X) | (A & Y)`. Only the first union is distributed over; a second one stays among the members every branch folds against, where it fails the object check and declines the whole intersection rather than multiplying out.\n    const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));\n    let folded = null;\n    if (!unions.length) {\n        folded = foldObjects(allOf);\n    }\n    else {\n        const union = unions[0];\n        const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));\n        if (Object.keys(union).length !== 1)\n            return;\n        const rest = allOf.filter((m) => m !== union);\n        const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));\n        if (branches.some((b) => !b))\n            return;\n        folded = { [keyword]: branches };\n    }\n    if (!folded)\n        return;\n    delete json.allOf;\n    assignProps(json, folded);\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                assignProps(schema, refSchema);\n            }\n            // restore child's own properties (child wins)\n            assignProps(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. This handles cases like: readonly().meta({id}).describe() 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    // Flattening walks the whole map and clears each `ref` as it goes, so a second call over the same map is a no-op scan. Skip it outright once it has run for a registry conversion.\n    if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {\n        for (const entry of [...ctx.seen.entries()].reverse()) {\n            flattenRef(entry[0]);\n        }\n        if (ctx.target !== \"openapi-3.0\") {\n            for (const entry of ctx.seen.entries()) {\n                compactTypeUnion(entry[1].def ?? entry[1].schema);\n            }\n        }\n        for (const rewrite of ctx.deferred)\n            rewrite();\n        // After flattening, every member that was extracted is a `$ref`, so the fold sees the final shape. A schema that inherits an intersection — through `z.lazy`, or any `ref` chain — holds the same `allOf` array, so fold by array identity to catch every copy.\n        if (ctx.intersections.length) {\n            const carriers = new Map();\n            for (const seen of ctx.seen.values()) {\n                for (const json of [seen.schema, seen.def]) {\n                    const allOf = json?.allOf;\n                    if (!Array.isArray(allOf))\n                        continue;\n                    const existing = carriers.get(allOf);\n                    if (existing)\n                        existing.push(json);\n                    else\n                        carriers.set(allOf, [json]);\n                }\n            }\n            for (const allOf of ctx.intersections) {\n                for (const json of carriers.get(allOf) ?? [])\n                    foldIntersection(json);\n            }\n        }\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    // when the root was extracted into $defs, `root.schema` is the `$ref` wrapper and `root.def` is the body that now lives under $defs\n    assignProps(result, root.defId ? root.schema : (root.def ?? root.schema));\n    // The `id` in `.meta()` is a Zod-specific registration tag used to extract schemas into $defs — it is not user-facing JSON Schema metadata. Strip it from the output body where it would otherwise leak. The id is preserved 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. With `external`, `defs` is the shared object every schema writes into, so the same entries are reassigned on every call. Without it, `defs` is fresh per call and must be rebuilt.\n    const defs = ctx.external?.defs ?? {};\n    if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {\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                assignProp(defs, seen.defId, seen.def);\n            }\n        }\n    }\n    if (ctx.external)\n        ctx.sharedEmitDoneFor = ctx.external;\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 each call to finalize() is functionally independent 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        def.type === \"catch\") {\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    processSchema(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    processSchema(schema, ctx);\n    extractDefs(ctx, schema);\n    return finalize(ctx, schema);\n};\n","import * as regexes from \"./regexes.js\";\nimport { base64Charset, base64urlCharset } from \"./schemas.js\";\nimport { extractDefs, finalize, handleUnrepresentable, initializeContext, processSchema, } from \"./to-json-schema.js\";\nimport { BIGINT_FORMAT_RANGES, NUMBER_FORMAT_RANGES, assignProp, getEnumValues } from \"./util.js\";\nconst narrowMin = (agg, key, value) => {\n    if (agg[key] === undefined || value > agg[key])\n        agg[key] = value;\n};\nconst narrowMax = (agg, key, value) => {\n    if (agg[key] === undefined || value < agg[key])\n        agg[key] = value;\n};\nconst narrowBoth = (agg, value) => {\n    narrowMin(agg, \"minimum\", value);\n    narrowMax(agg, \"maximum\", value);\n};\nconst addDivisor = (agg, value) => {\n    agg.multipleOf ?? (agg.multipleOf = []);\n    if (!agg.multipleOf.includes(value))\n        agg.multipleOf.push(value);\n};\nconst addPattern = (agg, pattern) => {\n    agg.patterns ?? (agg.patterns = new Set());\n    agg.patterns.add(pattern);\n};\nconst intersectMime = (agg, mime) => {\n    agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];\n};\n// last-wins, matching the bag's historical write order; the flag keeps an integer format from being lost to a later float one\nconst setFormat = (agg, format) => {\n    agg.format = format;\n    if (format.includes(\"int\"))\n        agg.isInt = true;\n};\nconst minContributor = (agg, def) => narrowMin(agg, \"minimum\", def.minimum);\nconst maxContributor = (agg, def) => narrowMax(agg, \"maximum\", def.maximum);\nconst formatContributor = (ranges) => (agg, def) => {\n    setFormat(agg, def.format);\n    const [minimum, maximum] = ranges[def.format];\n    narrowMin(agg, \"minimum\", minimum);\n    narrowMax(agg, \"maximum\", maximum);\n};\nconst contributors = {\n    greater_than: (agg, def) => narrowMin(agg, def.inclusive ? \"minimum\" : \"exclusiveMinimum\", def.value),\n    less_than: (agg, def) => narrowMax(agg, def.inclusive ? \"maximum\" : \"exclusiveMaximum\", def.value),\n    multiple_of: (agg, def) => addDivisor(agg, def.value),\n    number_format: formatContributor(NUMBER_FORMAT_RANGES),\n    bigint_format: formatContributor(BIGINT_FORMAT_RANGES),\n    min_length: minContributor,\n    max_length: maxContributor,\n    length_equals: (agg, def) => narrowBoth(agg, def.length),\n    min_size: minContributor,\n    max_size: maxContributor,\n    size_equals: (agg, def) => narrowBoth(agg, def.size),\n    string_format: (agg, def) => {\n        setFormat(agg, def.format);\n        if (def.pattern)\n            addPattern(agg, def.pattern);\n        if (def.format === \"base64\" || def.format === \"base64url\")\n            agg.contentEncoding = def.format;\n        if (def.local || def.precision === -1)\n            agg.laxFormat = true;\n    },\n    mime_type: (agg, def) => intersectMime(agg, def.mime),\n};\nexport function aggregateChecks(schema) {\n    const agg = {};\n    const def = schema._zod.def;\n    // a format schema is its own first check, same rule as $ZodType init\n    const list = schema._zod.traits.has(\"$ZodCheck\")\n        ? [schema, ...(def.checks ?? [])]\n        : (def.checks ?? []);\n    for (const ch of list)\n        contributors[ch._zod.def.check]?.(agg, ch._zod.def);\n    // reconcile with the bag so third-party onattach contributions still land; first-party residue is never tighter than the fold, so merging it back is idempotent for one and additive for the other\n    const bag = schema._zod.bag;\n    if (bag.minimum !== undefined)\n        narrowMin(agg, \"minimum\", bag.minimum);\n    if (bag.exclusiveMinimum !== undefined)\n        narrowMin(agg, \"exclusiveMinimum\", bag.exclusiveMinimum);\n    if (bag.maximum !== undefined)\n        narrowMax(agg, \"maximum\", bag.maximum);\n    if (bag.exclusiveMaximum !== undefined)\n        narrowMax(agg, \"exclusiveMaximum\", bag.exclusiveMaximum);\n    if (bag.multipleOf !== undefined)\n        addDivisor(agg, bag.multipleOf);\n    if (bag.format !== undefined) {\n        agg.format ?? (agg.format = bag.format);\n        if (bag.format.includes(\"int\"))\n            agg.isInt = true;\n    }\n    if (bag.mime)\n        intersectMime(agg, bag.mime);\n    for (const pattern of bag.patterns ?? [])\n        addPattern(agg, pattern);\n    return agg;\n}\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 ====================\n// the runtime patterns are lax so parse paths never overflow the regex stack; the emitted schema swaps in the exact block forms, which zod itself never executes\nconst exactPatterns = new Map([\n    [base64Charset, regexes.base64],\n    [base64urlCharset, regexes.base64url],\n]);\nconst exactPattern = (p) => exactPatterns.get(p) ?? p;\nexport const stringProcessor = (schema, ctx, _json, _params) => {\n    const json = _json;\n    json.type = \"string\";\n    const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);\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        // `z.iso.time()` is never full-time, and `laxFormat` carries the datetime shapes that also accept what their keyword forbids\n        if (format === \"time\" || laxFormat) {\n            delete json.format;\n        }\n    }\n    if (contentEncoding)\n        json.contentEncoding = contentEncoding;\n    if (patterns && patterns.size > 0) {\n        const patternList = [...patterns].map(exactPattern);\n        if (patternList.length === 1)\n            json.pattern = patternList[0].source;\n        else if (patternList.length > 1) {\n            json.allOf = [\n                ...patternList.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, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);\n    json.type = isInt ? \"integer\" : \"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 (multipleOf) {\n        // JSON Schema requires a divisor strictly greater than zero, and a non-finite one does not survive JSON at all. A negative divisor accepts exactly what its absolute value accepts, so it still maps; zero, NaN and Infinity have no keyword form.\n        const divisors = new Set();\n        for (const divisor of multipleOf) {\n            if (Number.isFinite(divisor) && divisor !== 0)\n                divisors.add(Math.abs(divisor));\n            else\n                handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);\n        }\n        // chained divisors are a conjunction the keyword cannot carry alone, so extras ride an allOf, same as stacked patterns\n        const [first, ...rest] = divisors;\n        if (first !== undefined)\n            json.multipleOf = first;\n        if (rest.length)\n            json.allOf = [...(json.allOf ?? []), ...rest.map((m) => ({ multipleOf: m }))];\n    }\n};\nexport const booleanProcessor = (_schema, _ctx, json, _params) => {\n    json.type = \"boolean\";\n};\nexport const bigintProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"BigInt cannot be represented in JSON Schema\");\n};\nexport const symbolProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Symbols cannot be represented in JSON Schema\");\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    handleUnrepresentable(schema, ctx, json, params, \"Undefined cannot be represented in JSON Schema\");\n};\nexport const voidProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Void cannot be represented in JSON Schema\");\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    handleUnrepresentable(schema, ctx, json, params, \"Date cannot be represented in JSON Schema\");\n};\nexport const enumProcessor = (schema, _ctx, json, _params) => {\n    const def = schema._zod.def;\n    const values = getEnumValues(def.entries);\n    // an empty enum accepts nothing, same as z.never()\n    if (values.length === 0) {\n        json.not = {};\n        return;\n    }\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    // a literal with no values accepts nothing, same as z.never()\n    if (def.values.length === 0) {\n        json.not = {};\n        return;\n    }\n    const vals = [];\n    for (const val of def.values) {\n        if (val === undefined) {\n            // a custom schema replaces the whole literal, so there is nothing left to accumulate\n            if (handleUnrepresentable(schema, ctx, json, params, \"Literal `undefined` cannot be represented in JSON Schema\"))\n                return;\n            // otherwise do not add to vals\n        }\n        else if (typeof val === \"bigint\") {\n            if (handleUnrepresentable(schema, ctx, json, params, \"BigInt literals cannot be represented in JSON Schema\"))\n                return;\n            vals.push(Number(val));\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    handleUnrepresentable(schema, ctx, json, params, \"NaN cannot be represented in JSON Schema\");\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    _json.type = \"string\";\n    _json.format = \"binary\";\n    _json.contentEncoding = \"binary\";\n    const { minimum, maximum, mime } = aggregateChecks(schema);\n    if (minimum !== undefined)\n        _json.minLength = minimum;\n    if (maximum !== undefined)\n        _json.maxLength = maximum;\n    if (!mime)\n        return;\n    // an empty intersection means the mime checks share no value, so nothing passes at runtime; `anyOf` must be non-empty, so the false schema is `not: {}`\n    if (mime.length === 0)\n        _json.not = {};\n    else if (mime.length === 1)\n        _json.contentMediaType = mime[0];\n    // only contentMediaType differs, so the shared props stay at the root\n    else\n        _json.anyOf = mime.map((m) => ({ contentMediaType: m }));\n};\nexport const successProcessor = (_schema, _ctx, json, _params) => {\n    json.type = \"boolean\";\n};\nexport const customProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Custom types cannot be represented in JSON Schema\");\n};\nexport const functionProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Function types cannot be represented in JSON Schema\");\n};\nexport const transformProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Transforms cannot be represented in JSON Schema\");\n};\nexport const mapProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Map cannot be represented in JSON Schema\");\n};\nexport const setProcessor = (schema, ctx, json, params) => {\n    handleUnrepresentable(schema, ctx, json, params, \"Set cannot be represented in JSON Schema\");\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 } = aggregateChecks(schema);\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 = processSchema(def.element, ctx, {\n        ...params,\n        path: [...params.path, \"items\"],\n    });\n};\n// Transform and catch set `optin = \"optional\"` at runtime so the parser lets them observe an\n// absent key, but their declared input type stays required. An input JSON Schema describes the\n// declared type, so resolve past them to the schema that actually carries the optionality.\n// Used by both `objectProcessor` (for `required`) and `tupleProcessor` (for `minItems`); see\n// wiki/optionality.md, \"The JSON Schema emitter reads the *static* value\".\nfunction inputOptin(schema) {\n    const def = schema._zod.def;\n    if (def.type === \"pipe\" && def.in._zod.traits.has(\"$ZodTransform\")) {\n        return inputOptin(def.out);\n    }\n    if (def.type === \"catch\") {\n        return inputOptin(def.innerType);\n    }\n    return schema._zod.optin;\n}\nexport const objectProcessor = (schema, ctx, _json, params) => {\n    const json = _json;\n    const def = schema._zod.def;\n    const shape = def.shape;\n    // dropping it while still emitting `additionalProperties: false` would emit a schema that rejects data this one requires\n    const symbolKeys = Object.getOwnPropertySymbols(shape);\n    if (symbolKeys.length &&\n        handleUnrepresentable(schema, ctx, json, params, \"Symbol keys cannot be represented in JSON Schema\")) {\n        return;\n    }\n    json.type = \"object\";\n    json.properties = {};\n    for (const key in shape) {\n        // assignProp so a __proto__ key becomes an own property instead of hitting the inherited setter on the plain {} we build into\n        assignProp(json.properties, key, processSchema(shape[key], ctx, {\n            ...params,\n            path: [...params.path, \"properties\", key],\n        }));\n    }\n    // required keys\n    const requiredKeys = [];\n    for (const key of Object.keys(shape)) {\n        const field = def.shape[key];\n        if (ctx.io === \"input\" ? inputOptin(field) === undefined : field._zod.optout === undefined) {\n            requiredKeys.push(key);\n        }\n    }\n    if (requiredKeys.length > 0) {\n        json.required = 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 = processSchema(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). This includes both z.xor() and discriminated unions\n    const isExclusive = def.inclusive === false;\n    const options = def.options.map((x, i) => processSchema(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 = processSchema(def.left, ctx, {\n        ...params,\n        path: [...params.path, \"allOf\", 0],\n    });\n    const b = processSchema(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    // Recorded innermost first, so a nested intersection has already folded by the time this one is considered. The array is the handle rather than the schema, because a wrapper that inherits this schema shares the same array; `finalize` folds every object holding it. See `foldIntersection`.\n    ctx.intersections.push(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) => processSchema(x, ctx, {\n        ...params,\n        path: [...params.path, prefixPath, i],\n    }));\n    const rest = def.rest\n        ? processSchema(def.rest, ctx, {\n            ...params,\n            path: [...params.path, restPath, ...(ctx.target === \"openapi-3.0\" ? [def.items.length] : [])],\n        })\n        : null;\n    let minItems = def.items.length;\n    while (minItems > 0) {\n        const item = def.items[minItems - 1];\n        const optional = ctx.io === \"input\" ? inputOptin(item) !== undefined : item._zod.optout === \"optional\";\n        if (!optional)\n            break;\n        minItems--;\n    }\n    const maxItems = def.items.length;\n    const isClosed = !def.rest;\n    if (ctx.target === \"draft-2020-12\") {\n        json.prefixItems = prefixItems;\n        if (isClosed) {\n            json.items = false;\n        }\n        else if (rest) {\n            json.items = rest;\n        }\n        if (minItems > 0)\n            json.minItems = minItems;\n        if (isClosed)\n            json.maxItems = maxItems;\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        if (minItems > 0)\n            json.minItems = minItems;\n        if (isClosed)\n            json.maxItems = maxItems;\n    }\n    else {\n        json.items = prefixItems;\n        if (isClosed) {\n            json.additionalItems = false;\n        }\n        else if (rest) {\n            json.additionalItems = rest;\n        }\n        if (minItems > 0)\n            json.minItems = minItems;\n        if (isClosed)\n            json.maxItems = maxItems;\n    }\n    // explicit user-defined length checks take precedence\n    const { minimum, maximum } = aggregateChecks(schema);\n    if (typeof minimum === \"number\")\n        json.minItems = minimum;\n    if (typeof maximum === \"number\")\n        json.maxItems = maximum;\n};\n/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the\n * numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key\n * behind a wrapper only carries its own `type` before then, and a union key only has its branches.\n *\n * A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather\n * than carried over: keeping them beside `type: \"string\"` reproduces the match-nothing schema this\n * exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`\n * accepts `\"3\"` — which is the deliberate trade, since throwing on it would reject an ordinary schema\n * outright. */\nfunction stringifyKeyNames(bySchema, json, visited) {\n    // an extracted key that rewrites cannot go on sharing its definition — the string form a key position needs is not the number form every other reference wants — so it inlines. One that does not rewrite keeps the `$ref`.\n    if (json.$ref) {\n        // a recursive key holds its own reference inside its definition, so a node already on the path is left alone rather than resolved again\n        if (visited.has(json))\n            return json;\n        visited.add(json);\n        const def = bySchema.get(json)?.def;\n        if (!def)\n            return json;\n        const inlined = stringifyKeyNames(bySchema, def, visited);\n        return inlined === def ? json : inlined;\n    }\n    for (const keyword of [\"anyOf\", \"oneOf\"]) {\n        const branches = json[keyword];\n        if (!Array.isArray(branches))\n            continue;\n        const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));\n        // rebuilding regardless would detach a key that had nothing to re-express, dropping its `$ref` and leaking the internal `id`\n        if (mapped.some((branch, i) => branch !== branches[i]))\n            json = { ...json, [keyword]: mapped };\n    }\n    // a member that already admits a string leaves the key unconstrained, so the node's own type re-expresses only when every member is numeric\n    const types = Array.isArray(json.type) ? json.type : [json.type];\n    const numericType = !types.includes(\"string\") && types.some((t) => t === \"number\" || t === \"integer\");\n    // a heterogeneous key carries no type at all, so its numeric members are caught here instead\n    const values = json.enum ?? (json.const !== undefined ? [json.const] : undefined);\n    if (!numericType && !values?.some((v) => typeof v === \"number\"))\n        return json;\n    const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;\n    if (rest.enum)\n        rest.enum = rest.enum.map((v) => (typeof v === \"number\" ? String(v) : v));\n    else if (typeof rest.const === \"number\")\n        rest.const = String(rest.const);\n    // a heterogeneous key keeps its absent type: the stringified members already say what a key may be\n    if (!numericType)\n        return rest;\n    rest.type = \"string\";\n    if (!values)\n        rest.pattern = (types.includes(\"number\") ? regexes.number : regexes.integer).source;\n    return rest;\n}\n/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */\nconst pendingRecords = new WeakMap();\nfunction rewriteKeyNames(ctx) {\n    // an extracted key is resolved by the object `extractToDef` left in its place, so the map is built once rather than searched per reference. `_zod.toJSONSchema` can hand the same object to two schemas, so the first entry carrying a body wins, as a search would have found it.\n    const bySchema = new Map();\n    for (const entry of ctx.seen.values()) {\n        if (entry.def && !bySchema.has(entry.schema))\n            bySchema.set(entry.schema, entry);\n    }\n    const rewrites = new Map();\n    for (const record of pendingRecords.get(ctx) ?? []) {\n        const seen = ctx.seen.get(record);\n        const names = (seen?.def ?? seen?.schema)?.propertyNames;\n        if (!names || names === true || rewrites.has(names))\n            continue;\n        const rewritten = stringifyKeyNames(bySchema, names, new Set());\n        if (rewritten !== names)\n            rewrites.set(names, rewritten);\n    }\n    if (!rewrites.size)\n        return;\n    // the flatten has already copied each record's own properties onto every wrapper by reference, and an extracted body is another such copy, so every carrier holding a rewritten key is updated together\n    for (const entry of ctx.seen.values()) {\n        for (const carrier of [entry.schema, entry.def]) {\n            const rewritten = carrier && rewrites.get(carrier.propertyNames);\n            if (rewritten)\n                carrier.propertyNames = rewritten;\n        }\n    }\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. This correctly represents \"only validate keys matching the pattern\" semantics and composes well with allOf (intersections)\n    const keyType = def.keyType;\n    const patterns = aggregateChecks(keyType).patterns;\n    if (def.mode === \"loose\" && patterns && patterns.size > 0) {\n        // Use patternProperties for looseRecord with regex patterns\n        const valueSchema = processSchema(def.valueType, ctx, {\n            ...params,\n            path: [...params.path, \"patternProperties\", \"*\"],\n        });\n        json.patternProperties = {};\n        for (const pattern of patterns) {\n            assignProp(json.patternProperties, exactPattern(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 = processSchema(def.keyType, ctx, {\n                ...params,\n                path: [...params.path, \"propertyNames\"],\n            });\n            let pending = pendingRecords.get(ctx);\n            if (!pending) {\n                pending = [];\n                pendingRecords.set(ctx, pending);\n                ctx.deferred.push(() => rewriteKeyNames(ctx));\n            }\n            pending.push(schema);\n        }\n        json.additionalProperties = processSchema(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    // Every key shares one value schema, so an optional-in value makes the whole key set omittable on input. Output keeps them: the exhaustive branch assigns every key, even one whose value came back undefined.\n    const omittableOnInput = ctx.io === \"input\" && inputOptin(def.valueType) !== undefined;\n    if (keyValues && !def.partial && !omittableOnInput) {\n        const validKeyValues = [...keyValues].filter((v) => typeof v === \"string\" || typeof v === \"number\");\n        if (validKeyValues.length > 0) {\n            json.required = validKeyValues.map(String);\n        }\n    }\n};\nexport const nullableProcessor = (schema, ctx, json, params) => {\n    const def = schema._zod.def;\n    const inner = processSchema(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    processSchema(def.innerType, ctx, params);\n    const seen = ctx.seen.get(schema);\n    seen.ref = def.innerType;\n};\n/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.\n * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other\n * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */\nconst UNREPRESENTABLE_DEFAULT = Symbol();\nfunction serializeDefaultValue(value, schema, ctx, json, params) {\n    let unrepresentable = false;\n    const serialized = JSON.stringify(value, (_, val) => {\n        if (typeof val !== \"bigint\")\n            return val;\n        unrepresentable = true;\n        return null;\n    });\n    if (!unrepresentable)\n        return JSON.parse(serialized);\n    handleUnrepresentable(schema, ctx, json, params, \"BigInt defaults cannot be represented in JSON Schema\");\n    return UNREPRESENTABLE_DEFAULT;\n}\nexport const defaultProcessor = (schema, ctx, json, params) => {\n    const def = schema._zod.def;\n    processSchema(def.innerType, ctx, params);\n    const seen = ctx.seen.get(schema);\n    seen.ref = def.innerType;\n    const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);\n    if (value !== UNREPRESENTABLE_DEFAULT)\n        json.default = value;\n};\nexport const prefaultProcessor = (schema, ctx, json, params) => {\n    const def = schema._zod.def;\n    processSchema(def.innerType, ctx, params);\n    const seen = ctx.seen.get(schema);\n    seen.ref = def.innerType;\n    if (ctx.io !== \"input\")\n        return;\n    const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);\n    if (value !== UNREPRESENTABLE_DEFAULT)\n        json._prefault = value;\n};\nexport const catchProcessor = (schema, ctx, json, params) => {\n    const def = schema._zod.def;\n    processSchema(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        handleUnrepresentable(schema, ctx, json, params, \"Dynamic catch values are not supported in JSON Schema\");\n        return;\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    processSchema(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    processSchema(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    processSchema(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    processSchema(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    processSchema(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            processSchema(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            assignProp(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    processSchema(input, ctx);\n    extractDefs(ctx, input);\n    return finalize(ctx, input);\n}\n","import * as core from \"../core/index.js\";\nimport { $ZodError } from \"../core/index.js\";\nimport * as util from \"../core/util.js\";\n/* Prototypes that already carry the lazy helper methods. Seeded with the\n * intrinsics so that `init` on a foreign object — it accepts any object —\n * can never install an accessor onto a prototype we do not own. */\nconst _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);\n/* Helper methods live as non-enumerable lazy getters on the shared\n * prototype instead of own properties on every instance. On first\n * access the getter allocates the per-instance closure and caches it\n * as a non-enumerable own property, so detached usage still works and\n * the allocation only happens for methods actually touched. */\nfunction _lazyMethod(proto, key, make) {\n    Object.defineProperty(proto, key, {\n        configurable: true,\n        enumerable: false,\n        get() {\n            const value = make(this);\n            Object.defineProperty(this, key, { value, configurable: true, writable: true });\n            return value;\n        },\n        set(value) {\n            Object.defineProperty(this, key, { value, configurable: true, writable: true });\n        },\n    });\n}\nconst initializer = (inst, issues) => {\n    $ZodError.init(inst, issues);\n    inst.name = \"ZodError\";\n    const proto = Object.getPrototypeOf(inst);\n    if (_installedErrorProtos.has(proto))\n        return;\n    _installedErrorProtos.add(proto);\n    _lazyMethod(proto, \"format\", (self) => (mapper) => core.formatError(self, mapper));\n    _lazyMethod(proto, \"flatten\", (self) => (mapper) => core.flattenError(self, mapper));\n    _lazyMethod(proto, \"addIssue\", (self) => (issue) => {\n        self.issues.push(issue);\n        self.message = JSON.stringify(self.issues, util.jsonStringifyReplacer, 2);\n    });\n    _lazyMethod(proto, \"addIssues\", (self) => (issues) => {\n        self.issues.push(...issues);\n        self.message = JSON.stringify(self.issues, util.jsonStringifyReplacer, 2);\n    });\n    Object.defineProperty(proto, \"isEmpty\", {\n        configurable: true,\n        enumerable: false,\n        get() {\n            return this.issues.length === 0;\n        },\n    });\n};\nexport const ZodError = /*@__PURE__*/ core.$constructor(\"ZodError\", initializer);\nexport const ZodRealError = /*@__PURE__*/ core.$constructor(\"ZodError\", initializer, undefined, {\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);\nexport { validate, validateAsync } from \"../core/index.js\";\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 * as regexes from \"../core/regexes.js\";\nimport { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from \"../core/to-json-schema.js\";\nimport en from \"../locales/en.js\";\nimport * as checks from \"./checks.js\";\nimport * as parse from \"./parse.js\";\n// Register English as the default locale on first ZodType construction. Hooked into the `ZodType` `$constructor` (rather than a top-level `config(en())` in `external.ts`) so bundlers honoring `sideEffects: false` can't tree-shake it out — see #5953, #5725. An explicit `z.config(z.locales.xx())` call wins regardless of order, since this only sets the default when none is present.\nfunction _ensureDefaultLocale() {\n    if (!core.globalConfig.localeError)\n        core.config(en());\n}\n// the default memoizer is read by the core container init, which runs before `ZodType.init`, so each container calls this first\nfunction _ensureDefaultMemoizer() {\n    if (!core.globalConfig.memoizer)\n        core.config({ memoizer: core.memoizer() });\n}\nexport const ZodType = /*@__PURE__*/ core.$constructor(\"ZodType\", (inst, def) => {\n    _ensureDefaultLocale();\n    core.$ZodType.init(inst, def);\n    inst.def = def;\n    inst.type = def.type;\n    return inst;\n}, {\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) returns a clone with `data` registered. The mapped type picks up the second overload, so we accept variadic any-args and 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, ...args) {\n        return args.length === 0 ? fn(this) : fn(this, ...args);\n    },\n    // Overrides core's `~standard` to add `jsonSchema`. Must stay a prototype entry: redefining it per instance demotes instances to dictionary mode.\n    get \"~standard\"() {\n        return util.hide(this, \"~standard\", {\n            ...core.standardProps(this),\n            jsonSchema: {\n                input: createStandardJSONSchemaMethod(this, \"input\"),\n                output: createStandardJSONSchemaMethod(this, \"output\"),\n            },\n        });\n    },\n    set \"~standard\"(value) {\n        util.own(this, \"~standard\", value);\n    },\n    parse: function _parse(data, params) {\n        return parse.parse(this, data, params, { callee: _parse });\n    },\n    parseAsync: async function _parseAsync(data, params) {\n        return await parse.parseAsync(this, data, params, { callee: _parseAsync });\n    },\n    safeParse(data, params) {\n        return parse.safeParse(this, data, params);\n    },\n    async safeParseAsync(data, params) {\n        return parse.safeParseAsync(this, data, params);\n    },\n    // `spa` is an alias: same function object as `safeParseAsync`, as before.\n    get spa() {\n        return this?.safeParseAsync;\n    },\n    set spa(value) {\n        util.own(this, \"spa\", value);\n    },\n    validate(data, params) {\n        return parse.validate(this, data, params);\n    },\n    validateAsync(data, params) {\n        return parse.validateAsync(this, data, params);\n    },\n    encode: function _encode(data, params) {\n        return parse.encode(this, data, params, { callee: _encode });\n    },\n    decode: function _decode(data, params) {\n        return parse.decode(this, data, params, { callee: _decode });\n    },\n    encodeAsync: async function _encodeAsync(data, params) {\n        return await parse.encodeAsync(this, data, params, { callee: _encodeAsync });\n    },\n    decodeAsync: async function _decodeAsync(data, params) {\n        return await parse.decodeAsync(this, data, params, { callee: _decodeAsync });\n    },\n    safeEncode(data, params) {\n        return parse.safeEncode(this, data, params);\n    },\n    safeDecode(data, params) {\n        return parse.safeDecode(this, data, params);\n    },\n    async safeEncodeAsync(data, params) {\n        return parse.safeEncodeAsync(this, data, params);\n    },\n    async safeDecodeAsync(data, params) {\n        return parse.safeDecodeAsync(this, data, params);\n    },\n    toJSONSchema(params) {\n        return createToJSONSchemaMethod(this, {})(params);\n    },\n    // Reads through to the registry on every access, so it must not cache.\n    get description() {\n        return core.globalRegistry.get(this)?.description;\n    },\n    // No setter: `schema._def = x` throws, as it did when `_def` was a non-writable own property.\n    get _def() {\n        return this._zod.def;\n    },\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}, \n/*@__PURE__*/ util.derived({\n    format: (inst) => processors.aggregateChecks(inst).format ?? null,\n    minLength: (inst) => processors.aggregateChecks(inst).minimum ?? null,\n    maxLength: (inst) => processors.aggregateChecks(inst).maximum ?? null,\n}, {\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}));\nexport const ZodString = /*@__PURE__*/ core.$constructor(\"ZodString\", (inst, def) => {\n    core.$ZodString.init(inst, def);\n    _ZodString.init(inst, def);\n}, {\n    email(params) {\n        return this.check(core._email(ZodEmail, params));\n    },\n    url(params) {\n        return this.check(core._url(ZodURL, params));\n    },\n    jwt(params) {\n        return this.check(core._jwt(ZodJWT, params));\n    },\n    emoji(params) {\n        return this.check(core._emoji(ZodEmoji, params));\n    },\n    guid(params) {\n        return this.check(core._guid(ZodGUID, params));\n    },\n    uuid(params) {\n        return this.check(core._uuid(ZodUUID, params));\n    },\n    uuidv4(params) {\n        return this.check(core._uuidv4(ZodUUID, params));\n    },\n    uuidv6(params) {\n        return this.check(core._uuidv6(ZodUUID, params));\n    },\n    uuidv7(params) {\n        return this.check(core._uuidv7(ZodUUID, params));\n    },\n    nanoid(params) {\n        return this.check(core._nanoid(ZodNanoID, params));\n    },\n    cuid(params) {\n        return this.check(core._cuid(ZodCUID, params));\n    },\n    cuid2(params) {\n        return this.check(core._cuid2(ZodCUID2, params));\n    },\n    ulid(params) {\n        return this.check(core._ulid(ZodULID, params));\n    },\n    base64(params) {\n        return this.check(core._base64(ZodBase64, params));\n    },\n    base64url(params) {\n        return this.check(core._base64url(ZodBase64URL, params));\n    },\n    xid(params) {\n        return this.check(core._xid(ZodXID, params));\n    },\n    ksuid(params) {\n        return this.check(core._ksuid(ZodKSUID, params));\n    },\n    ipv4(params) {\n        return this.check(core._ipv4(ZodIPv4, params));\n    },\n    ipv6(params) {\n        return this.check(core._ipv6(ZodIPv6, params));\n    },\n    cidrv4(params) {\n        return this.check(core._cidrv4(ZodCIDRv4, params));\n    },\n    cidrv6(params) {\n        return this.check(core._cidrv6(ZodCIDRv6, params));\n    },\n    e164(params) {\n        return this.check(core._e164(ZodE164, params));\n    },\n    datetime(params) {\n        return this.check(core._isoDateTime(ZodISODateTime, params));\n    },\n    date(params) {\n        return this.check(core._isoDate(ZodISODate, params));\n    },\n    time(params) {\n        return this.check(core._isoTime(ZodISOTime, params));\n    },\n    duration(params) {\n        return this.check(core._isoDuration(ZodISODuration, params));\n    },\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 ZodISODateTime = /*@__PURE__*/ core.$constructor(\"ZodISODateTime\", (inst, def) => {\n    core.$ZodISODateTime.init(inst, def);\n    ZodStringFormat.init(inst, def);\n});\nexport const ZodISODate = /*@__PURE__*/ core.$constructor(\"ZodISODate\", (inst, def) => {\n    core.$ZodISODate.init(inst, def);\n    ZodStringFormat.init(inst, def);\n});\nexport const ZodISOTime = /*@__PURE__*/ core.$constructor(\"ZodISOTime\", (inst, def) => {\n    core.$ZodISOTime.init(inst, def);\n    ZodStringFormat.init(inst, def);\n});\nexport const ZodISODuration = /*@__PURE__*/ core.$constructor(\"ZodISODuration\", (inst, def) => {\n    core.$ZodISODuration.init(inst, def);\n    ZodStringFormat.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: regexes.httpProtocol,\n        hostname: 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 ZodCreditCard = /*@__PURE__*/ core.$constructor(\"ZodCreditCard\", (inst, def) => {\n    core.$ZodCreditCard.init(inst, def);\n    ZodStringFormat.init(inst, def);\n});\nexport function creditCard(params) {\n    return core._creditCard(ZodCreditCard, params);\n}\nexport const ZodIBAN = /*@__PURE__*/ core.$constructor(\"ZodIBAN\", (inst, def) => {\n    core.$ZodIBAN.init(inst, def);\n    ZodStringFormat.init(inst, def);\n});\nexport function iban(params) {\n    return core._iban(ZodIBAN, 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\", regexes.hostname, _params);\n}\nexport function hex(_params) {\n    return core._stringFormat(ZodCustomStringFormat, \"hex\", regexes.hex, _params);\n}\nexport function currencyCode(_params) {\n    return core._stringFormat(ZodCustomStringFormat, \"currency_code\", regexes.currencyCode, _params);\n}\nexport function hash(alg, params) {\n    const enc = params?.enc ?? \"hex\";\n    const format = `${alg}_${enc}`;\n    const regex = core.regexes[format];\n    if (!regex)\n        throw new Error(`Unrecognized hash format: ${format}`);\n    return core._stringFormat(ZodCustomStringFormat, format, regex, params);\n}\nexport const ZodNumber = /*@__PURE__*/ core.$constructor(\"ZodNumber\", (inst, def) => {\n    core.$ZodNumber.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);\n    inst.isFinite = true;\n}, \n/*@__PURE__*/ util.derived({\n    minValue: (inst) => {\n        const { minimum, exclusiveMinimum } = processors.aggregateChecks(inst);\n        return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);\n    },\n    maxValue: (inst) => {\n        const { maximum, exclusiveMaximum } = processors.aggregateChecks(inst);\n        return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);\n    },\n    isInt: (inst) => {\n        const { isInt, multipleOf } = processors.aggregateChecks(inst);\n        return !!isInt || !!multipleOf?.some(Number.isSafeInteger);\n    },\n    format: (inst) => processors.aggregateChecks(inst).format ?? null,\n}, {\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}));\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}, \n/*@__PURE__*/ util.derived({\n    minValue: (inst) => processors.aggregateChecks(inst).minimum ?? null,\n    maxValue: (inst) => processors.aggregateChecks(inst).maximum ?? null,\n    format: (inst) => processors.aggregateChecks(inst).format ?? null,\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    gt(value, params) {\n        return this.check(checks.gt(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    positive(params) {\n        return this.check(checks.gt(BigInt(0), params));\n    },\n    negative(params) {\n        return this.check(checks.lt(BigInt(0), params));\n    },\n    nonpositive(params) {\n        return this.check(checks.lte(BigInt(0), params));\n    },\n    nonnegative(params) {\n        return this.check(checks.gte(BigInt(0), params));\n    },\n    multipleOf(value, params) {\n        return this.check(checks.multipleOf(value, params));\n    },\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});\nexport function int64(params) {\n    return core._int64(ZodBigIntFormat, params);\n}\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}, \n/*@__PURE__*/ util.derived({\n    minDate: (inst) => {\n        const { minimum } = processors.aggregateChecks(inst);\n        return minimum ? new Date(minimum) : null;\n    },\n    maxDate: (inst) => {\n        const { maximum } = processors.aggregateChecks(inst);\n        return maximum ? new Date(maximum) : null;\n    },\n}, {}));\nexport function date(params) {\n    return core._date(ZodDate, params);\n}\nexport const ZodArray = /*@__PURE__*/ core.$constructor(\"ZodArray\", (inst, def) => {\n    _ensureDefaultMemoizer();\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}, {\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});\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    _ensureDefaultMemoizer();\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.installLazyProp(inst, \"shape\", (self) => self._zod.def.shape, false);\n}, {\n    keyof() {\n        return _enum(Object.keys(this._zod.def.shape));\n    },\n    catchall(catchall) {\n        // `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree\n        return this.clone(util.mergeDefs(this._zod.def, { catchall: catchall }));\n    },\n    passthrough() {\n        return this.clone(util.mergeDefs(this._zod.def, { catchall: unknown() }));\n    },\n    loose() {\n        return this.clone(util.mergeDefs(this._zod.def, { catchall: unknown() }));\n    },\n    strict() {\n        return this.clone(util.mergeDefs(this._zod.def, { catchall: never() }));\n    },\n    strip() {\n        return this.clone(util.mergeDefs(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    exactPartial(...args) {\n        return util.partial(ZodExactOptional, this, args[0], \"exactPartial\");\n    },\n    required(...args) {\n        return util.required(ZodNonOptional, this, args[0]);\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: 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    _ensureDefaultMemoizer();\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}, {\n    rest(rest) {\n        return this.clone({\n            ...this._zod.def,\n            rest: rest,\n        });\n    },\n    partial() {\n        const def = this._zod.def;\n        // a refinement was authored against the full arity; partialing would run it on a shorter array\n        if (def.checks?.length)\n            throw new Error(\".partial() cannot be used on tuple schemas containing refinements\");\n        return this.clone({\n            ...def,\n            items: def.items.map((item) => new ZodOptional({ type: \"optional\", innerType: item })),\n        });\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    _ensureDefaultMemoizer();\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    return new ZodRecord({\n        type: \"record\",\n        keyType,\n        valueType: valueType,\n        ...util.normalizeParams(params),\n        partial: true,\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    _ensureDefaultMemoizer();\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    _ensureDefaultMemoizer();\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    // reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out\n    inst.options = [...inst._zod.values];\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    _ensureDefaultMemoizer();\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                if (!(\"input\" in _issue))\n                    _issue.input = payload.value;\n                _issue.inst ?? (_issue.inst = inst);\n                // _issue.continue ??= true;\n                payload.issues.push(util.issue(_issue));\n            }\n        };\n        const output = def.transform(payload.value, payload);\n        if (output instanceof Promise) {\n            return output.then((output) => {\n                payload.value = output;\n                return payload;\n            });\n        }\n        payload.value = output;\n        return payload;\n    };\n});\nexport function transform(fn) {\n    return new ZodTransform({\n        type: \"transform\",\n        transform: fn,\n    });\n}\nexport const ZodOptional = /*@__PURE__*/ core.$constructor(\"ZodOptional\", (inst, def) => {\n    core.$ZodOptional.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function optional(innerType) {\n    return new ZodOptional({\n        type: \"optional\",\n        innerType: innerType,\n    });\n}\nexport const ZodExactOptional = /*@__PURE__*/ core.$constructor(\"ZodExactOptional\", (inst, def) => {\n    core.$ZodExactOptional.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function exactOptional(innerType) {\n    return new ZodExactOptional({\n        type: \"optional\",\n        innerType: innerType,\n    });\n}\nexport const ZodNullable = /*@__PURE__*/ core.$constructor(\"ZodNullable\", (inst, def) => {\n    core.$ZodNullable.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.nullableProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function nullable(innerType) {\n    return new ZodNullable({\n        type: \"nullable\",\n        innerType: innerType,\n    });\n}\n// nullish\nexport function nullish(innerType) {\n    return optional(nullable(innerType));\n}\nexport const ZodDefault = /*@__PURE__*/ core.$constructor(\"ZodDefault\", (inst, def) => {\n    core.$ZodDefault.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.defaultProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n    inst.removeDefault = inst.unwrap;\n});\nexport function _default(innerType, defaultValue) {\n    return new ZodDefault({\n        type: \"default\",\n        innerType: innerType,\n        get defaultValue() {\n            return typeof defaultValue === \"function\" ? defaultValue() : util.shallowClone(defaultValue);\n        },\n    });\n}\nexport const ZodPrefault = /*@__PURE__*/ core.$constructor(\"ZodPrefault\", (inst, def) => {\n    core.$ZodPrefault.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.prefaultProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function prefault(innerType, defaultValue) {\n    return new ZodPrefault({\n        type: \"prefault\",\n        innerType: innerType,\n        get defaultValue() {\n            return typeof defaultValue === \"function\" ? defaultValue() : util.shallowClone(defaultValue);\n        },\n    });\n}\nexport const ZodNonOptional = /*@__PURE__*/ core.$constructor(\"ZodNonOptional\", (inst, def) => {\n    core.$ZodNonOptional.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.nonoptionalProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function nonoptional(innerType, params) {\n    return new ZodNonOptional({\n        type: \"nonoptional\",\n        innerType: innerType,\n        ...util.normalizeParams(params),\n    });\n}\nexport const ZodSuccess = /*@__PURE__*/ core.$constructor(\"ZodSuccess\", (inst, def) => {\n    core.$ZodSuccess.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.successProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n});\nexport function success(innerType) {\n    return new ZodSuccess({\n        type: \"success\",\n        innerType: innerType,\n    });\n}\nexport const ZodCatch = /*@__PURE__*/ core.$constructor(\"ZodCatch\", (inst, def) => {\n    core.$ZodCatch.init(inst, def);\n    ZodType.init(inst, def);\n    inst._zod.processJSONSchema = (ctx, json, params) => processors.catchProcessor(inst, ctx, json, params);\n    inst.unwrap = () => inst._zod.def.innerType;\n    inst.removeCatch = inst.unwrap;\n});\nfunction _catch(innerType, catchValue) {\n    return new ZodCatch({\n        type: \"catch\",\n        innerType: innerType,\n        catchValue: (typeof catchValue === \"function\" ? catchValue : core.util.constantCatch(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;\nexport const ZodInstanceOf = /*@__PURE__*/ core.$constructor(\"ZodInstanceOf\", (inst, def) => {\n    ZodCustom.init(inst, def);\n}, {\n    properties(shape, params) {\n        // asserts in place, so the narrowed output type is truthful without a wrapper\n        return this.check(core._properties(shape, params));\n    },\n});\nfunction _instanceof(cls, params = {}) {\n    const inst = new ZodInstanceOf({\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","export var util;\n(function (util) {\n    util.assertEqual = (_) => { };\n    function assertIs(_arg) { }\n    util.assertIs = assertIs;\n    function assertNever(_x) {\n        throw new Error();\n    }\n    util.assertNever = assertNever;\n    util.arrayToEnum = (items) => {\n        const obj = {};\n        for (const item of items) {\n            obj[item] = item;\n        }\n        return obj;\n    };\n    util.getValidEnumValues = (obj) => {\n        const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== \"number\");\n        const filtered = {};\n        for (const k of validKeys) {\n            filtered[k] = obj[k];\n        }\n        return util.objectValues(filtered);\n    };\n    util.objectValues = (obj) => {\n        return util.objectKeys(obj).map(function (e) {\n            return obj[e];\n        });\n    };\n    util.objectKeys = typeof Object.keys === \"function\" // eslint-disable-line ban/ban\n        ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban\n        : (object) => {\n            const keys = [];\n            for (const key in object) {\n                if (Object.prototype.hasOwnProperty.call(object, key)) {\n                    keys.push(key);\n                }\n            }\n            return keys;\n        };\n    util.find = (arr, checker) => {\n        for (const item of arr) {\n            if (checker(item))\n                return item;\n        }\n        return undefined;\n    };\n    util.isInteger = typeof Number.isInteger === \"function\"\n        ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban\n        : (val) => typeof val === \"number\" && Number.isFinite(val) && Math.floor(val) === val;\n    function joinValues(array, separator = \" | \") {\n        return array.map((val) => (typeof val === \"string\" ? `'${val}'` : val)).join(separator);\n    }\n    util.joinValues = joinValues;\n    util.jsonStringifyReplacer = (_, value) => {\n        if (typeof value === \"bigint\") {\n            return value.toString();\n        }\n        return value;\n    };\n})(util || (util = {}));\nexport var objectUtil;\n(function (objectUtil) {\n    objectUtil.mergeShapes = (first, second) => {\n        return {\n            ...first,\n            ...second, // second overwrites first\n        };\n    };\n})(objectUtil || (objectUtil = {}));\nexport const ZodParsedType = util.arrayToEnum([\n    \"string\",\n    \"nan\",\n    \"number\",\n    \"integer\",\n    \"float\",\n    \"boolean\",\n    \"date\",\n    \"bigint\",\n    \"symbol\",\n    \"function\",\n    \"undefined\",\n    \"null\",\n    \"array\",\n    \"object\",\n    \"unknown\",\n    \"promise\",\n    \"void\",\n    \"never\",\n    \"map\",\n    \"set\",\n]);\nexport const getParsedType = (data) => {\n    const t = typeof data;\n    switch (t) {\n        case \"undefined\":\n            return ZodParsedType.undefined;\n        case \"string\":\n            return ZodParsedType.string;\n        case \"number\":\n            return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n        case \"boolean\":\n            return ZodParsedType.boolean;\n        case \"function\":\n            return ZodParsedType.function;\n        case \"bigint\":\n            return ZodParsedType.bigint;\n        case \"symbol\":\n            return ZodParsedType.symbol;\n        case \"object\":\n            if (Array.isArray(data)) {\n                return ZodParsedType.array;\n            }\n            if (data === null) {\n                return ZodParsedType.null;\n            }\n            if (data.then && typeof data.then === \"function\" && data.catch && typeof data.catch === \"function\") {\n                return ZodParsedType.promise;\n            }\n            if (typeof Map !== \"undefined\" && data instanceof Map) {\n                return ZodParsedType.map;\n            }\n            if (typeof Set !== \"undefined\" && data instanceof Set) {\n                return ZodParsedType.set;\n            }\n            if (typeof Date !== \"undefined\" && data instanceof Date) {\n                return ZodParsedType.date;\n            }\n            return ZodParsedType.object;\n        default:\n            return ZodParsedType.unknown;\n    }\n};\n","import { util } from \"./helpers/util.js\";\nexport const ZodIssueCode = util.arrayToEnum([\n    \"invalid_type\",\n    \"invalid_literal\",\n    \"custom\",\n    \"invalid_union\",\n    \"invalid_union_discriminator\",\n    \"invalid_enum_value\",\n    \"unrecognized_keys\",\n    \"invalid_arguments\",\n    \"invalid_return_type\",\n    \"invalid_date\",\n    \"invalid_string\",\n    \"too_small\",\n    \"too_big\",\n    \"invalid_intersection_types\",\n    \"not_multiple_of\",\n    \"not_finite\",\n]);\nexport const quotelessJson = (obj) => {\n    const json = JSON.stringify(obj, null, 2);\n    return json.replace(/\"([^\"]+)\":/g, \"$1:\");\n};\nexport class ZodError extends Error {\n    get errors() {\n        return this.issues;\n    }\n    constructor(issues) {\n        super();\n        this.issues = [];\n        this.addIssue = (sub) => {\n            this.issues = [...this.issues, sub];\n        };\n        this.addIssues = (subs = []) => {\n            this.issues = [...this.issues, ...subs];\n        };\n        const actualProto = new.target.prototype;\n        if (Object.setPrototypeOf) {\n            // eslint-disable-next-line ban/ban\n            Object.setPrototypeOf(this, actualProto);\n        }\n        else {\n            this.__proto__ = actualProto;\n        }\n        this.name = \"ZodError\";\n        this.issues = issues;\n    }\n    format(_mapper) {\n        const mapper = _mapper ||\n            function (issue) {\n                return issue.message;\n            };\n        const fieldErrors = { _errors: [] };\n        const processError = (error) => {\n            for (const issue of error.issues) {\n                if (issue.code === \"invalid_union\") {\n                    issue.unionErrors.map(processError);\n                }\n                else if (issue.code === \"invalid_return_type\") {\n                    processError(issue.returnTypeError);\n                }\n                else if (issue.code === \"invalid_arguments\") {\n                    processError(issue.argumentsError);\n                }\n                else if (issue.path.length === 0) {\n                    fieldErrors._errors.push(mapper(issue));\n                }\n                else {\n                    let curr = fieldErrors;\n                    let i = 0;\n                    while (i < issue.path.length) {\n                        const el = issue.path[i];\n                        const terminal = i === issue.path.length - 1;\n                        // `_errors` is reserved by this legacy format, so merge a matching path segment into the current node instead of treating its array as a child.\n                        if (el === \"_errors\") {\n                            if (terminal)\n                                curr._errors.push(mapper(issue));\n                            i++;\n                            continue;\n                        }\n                        // Create `el` as an own data property. A segment naming an inherited member (\"toString\", \"constructor\") would otherwise read through to the prototype, and assigning \"__proto__\" would hit the setter and walk into Object.prototype.\n                        if (!Object.prototype.hasOwnProperty.call(curr, el)) {\n                            if (el === \"__proto__\") {\n                                Object.defineProperty(curr, el, {\n                                    value: { _errors: [] },\n                                    writable: true,\n                                    enumerable: true,\n                                    configurable: true,\n                                });\n                            }\n                            else {\n                                curr[el] = { _errors: [] };\n                            }\n                        }\n                        curr = curr[el];\n                        if (terminal) {\n                            curr._errors.push(mapper(issue));\n                        }\n                        i++;\n                    }\n                }\n            }\n        };\n        processError(this);\n        return fieldErrors;\n    }\n    static assert(value) {\n        if (!(value instanceof ZodError)) {\n            throw new Error(`Not a ZodError: ${value}`);\n        }\n    }\n    toString() {\n        return this.message;\n    }\n    get message() {\n        return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n    }\n    get isEmpty() {\n        return this.issues.length === 0;\n    }\n    flatten(mapper = (issue) => issue.message) {\n        const fieldErrors = Object.create(null);\n        const formErrors = [];\n        for (const sub of this.issues) {\n            if (sub.path.length > 0) {\n                const firstEl = sub.path[0];\n                fieldErrors[firstEl] = fieldErrors[firstEl] || [];\n                fieldErrors[firstEl].push(mapper(sub));\n            }\n            else {\n                formErrors.push(mapper(sub));\n            }\n        }\n        return { formErrors, fieldErrors };\n    }\n    get formErrors() {\n        return this.flatten();\n    }\n}\nZodError.create = (issues) => {\n    const error = new ZodError(issues);\n    return error;\n};\n","import { ZodIssueCode } from \"../ZodError.js\";\nimport { util, ZodParsedType } from \"../helpers/util.js\";\nconst errorMap = (issue, _ctx) => {\n    let message;\n    switch (issue.code) {\n        case ZodIssueCode.invalid_type:\n            if (issue.received === ZodParsedType.undefined) {\n                message = \"Required\";\n            }\n            else {\n                message = `Expected ${issue.expected}, received ${issue.received}`;\n            }\n            break;\n        case ZodIssueCode.invalid_literal:\n            message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;\n            break;\n        case ZodIssueCode.unrecognized_keys:\n            message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, \", \")}`;\n            break;\n        case ZodIssueCode.invalid_union:\n            message = `Invalid input`;\n            break;\n        case ZodIssueCode.invalid_union_discriminator:\n            message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;\n            break;\n        case ZodIssueCode.invalid_enum_value:\n            message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;\n            break;\n        case ZodIssueCode.invalid_arguments:\n            message = `Invalid function arguments`;\n            break;\n        case ZodIssueCode.invalid_return_type:\n            message = `Invalid function return type`;\n            break;\n        case ZodIssueCode.invalid_date:\n            message = `Invalid date`;\n            break;\n        case ZodIssueCode.invalid_string:\n            if (typeof issue.validation === \"object\") {\n                if (\"includes\" in issue.validation) {\n                    message = `Invalid input: must include \"${issue.validation.includes}\"`;\n                    if (typeof issue.validation.position === \"number\") {\n                        message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;\n                    }\n                }\n                else if (\"startsWith\" in issue.validation) {\n                    message = `Invalid input: must start with \"${issue.validation.startsWith}\"`;\n                }\n                else if (\"endsWith\" in issue.validation) {\n                    message = `Invalid input: must end with \"${issue.validation.endsWith}\"`;\n                }\n                else {\n                    util.assertNever(issue.validation);\n                }\n            }\n            else if (issue.validation !== \"regex\") {\n                message = `Invalid ${issue.validation}`;\n            }\n            else {\n                message = \"Invalid\";\n            }\n            break;\n        case ZodIssueCode.too_small:\n            if (issue.type === \"array\")\n                message = `Array must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;\n            else if (issue.type === \"string\")\n                message = `String must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;\n            else if (issue.type === \"number\")\n                message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n            else if (issue.type === \"bigint\")\n                message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n            else if (issue.type === \"date\")\n                message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;\n            else\n                message = \"Invalid input\";\n            break;\n        case ZodIssueCode.too_big:\n            if (issue.type === \"array\")\n                message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;\n            else if (issue.type === \"string\")\n                message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;\n            else if (issue.type === \"number\")\n                message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n            else if (issue.type === \"bigint\")\n                message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n            else if (issue.type === \"date\")\n                message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;\n            else\n                message = \"Invalid input\";\n            break;\n        case ZodIssueCode.custom:\n            message = `Invalid input`;\n            break;\n        case ZodIssueCode.invalid_intersection_types:\n            message = `Intersection results could not be merged`;\n            break;\n        case ZodIssueCode.not_multiple_of:\n            message = `Number must be a multiple of ${issue.multipleOf}`;\n            break;\n        case ZodIssueCode.not_finite:\n            message = \"Number must be finite\";\n            break;\n        default:\n            message = _ctx.defaultError;\n            util.assertNever(issue);\n    }\n    return { message };\n};\nexport default errorMap;\n","import defaultErrorMap from \"./locales/en.js\";\nlet overrideErrorMap = defaultErrorMap;\nexport { defaultErrorMap };\nexport function setErrorMap(map) {\n    overrideErrorMap = map;\n}\nexport function getErrorMap() {\n    return overrideErrorMap;\n}\n","import { getErrorMap } from \"../errors.js\";\nimport defaultErrorMap from \"../locales/en.js\";\nexport const makeIssue = (params) => {\n    const { data, path, errorMaps, issueData } = params;\n    const fullPath = [...path, ...(issueData.path || [])];\n    const fullIssue = {\n        ...issueData,\n        path: fullPath,\n    };\n    if (issueData.message !== undefined) {\n        return {\n            ...issueData,\n            path: fullPath,\n            message: issueData.message,\n        };\n    }\n    let errorMessage = \"\";\n    const maps = errorMaps\n        .filter((m) => !!m)\n        .slice()\n        .reverse();\n    for (const map of maps) {\n        errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n    }\n    return {\n        ...issueData,\n        path: fullPath,\n        message: errorMessage,\n    };\n};\nexport const EMPTY_PATH = [];\nexport function addIssueToContext(ctx, issueData) {\n    const overrideMap = getErrorMap();\n    const issue = makeIssue({\n        issueData: issueData,\n        data: ctx.data,\n        path: ctx.path,\n        errorMaps: [\n            ctx.common.contextualErrorMap, // contextual error map is first priority\n            ctx.schemaErrorMap, // then schema-bound map if available\n            overrideMap, // then global override map\n            overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map\n        ].filter((x) => !!x),\n    });\n    ctx.common.issues.push(issue);\n}\nexport class ParseStatus {\n    constructor() {\n        this.value = \"valid\";\n    }\n    dirty() {\n        if (this.value === \"valid\")\n            this.value = \"dirty\";\n    }\n    abort() {\n        if (this.value !== \"aborted\")\n            this.value = \"aborted\";\n    }\n    static mergeArray(status, results) {\n        const arrayValue = [];\n        for (const s of results) {\n            if (s.status === \"aborted\")\n                return INVALID;\n            if (s.status === \"dirty\")\n                status.dirty();\n            arrayValue.push(s.value);\n        }\n        return { status: status.value, value: arrayValue };\n    }\n    static async mergeObjectAsync(status, pairs) {\n        const syncPairs = [];\n        for (const pair of pairs) {\n            const key = await pair.key;\n            const value = await pair.value;\n            syncPairs.push({\n                key,\n                value,\n            });\n        }\n        return ParseStatus.mergeObjectSync(status, syncPairs);\n    }\n    static mergeObjectSync(status, pairs) {\n        const finalObject = {};\n        for (const pair of pairs) {\n            const { key, value } = pair;\n            if (key.status === \"aborted\")\n                return INVALID;\n            if (value.status === \"aborted\")\n                return INVALID;\n            if (key.status === \"dirty\")\n                status.dirty();\n            if (value.status === \"dirty\")\n                status.dirty();\n            if (key.value !== \"__proto__\" && (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n                finalObject[key.value] = value.value;\n            }\n        }\n        return { status: status.value, value: finalObject };\n    }\n}\nexport const INVALID = Object.freeze({\n    status: \"aborted\",\n});\nexport const DIRTY = (value) => ({ status: \"dirty\", value });\nexport const OK = (value) => ({ status: \"valid\", value });\nexport const isAborted = (x) => x.status === \"aborted\";\nexport const isDirty = (x) => x.status === \"dirty\";\nexport const isValid = (x) => x.status === \"valid\";\nexport const isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n","export var errorUtil;\n(function (errorUtil) {\n    errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n    // biome-ignore lint/suspicious/noShadowRestrictedNames: renaming churns 31 v3 call sites\n    errorUtil.toString = (message) => typeof message === \"string\" ? message : message?.message;\n})(errorUtil || (errorUtil = {}));\n","import { ZodError, ZodIssueCode, } from \"./ZodError.js\";\nimport { defaultErrorMap, getErrorMap } from \"./errors.js\";\nimport { errorUtil } from \"./helpers/errorUtil.js\";\nimport { DIRTY, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue, } from \"./helpers/parseUtil.js\";\nimport { util, ZodParsedType, getParsedType } from \"./helpers/util.js\";\nclass ParseInputLazyPath {\n    constructor(parent, value, path, key) {\n        this._cachedPath = [];\n        this.parent = parent;\n        this.data = value;\n        this._path = path;\n        this._key = key;\n    }\n    get path() {\n        if (!this._cachedPath.length) {\n            if (Array.isArray(this._key)) {\n                this._cachedPath.push(...this._path, ...this._key);\n            }\n            else {\n                this._cachedPath.push(...this._path, this._key);\n            }\n        }\n        return this._cachedPath;\n    }\n}\nconst handleResult = (ctx, result) => {\n    if (isValid(result)) {\n        return { success: true, data: result.value };\n    }\n    else {\n        if (!ctx.common.issues.length) {\n            throw new Error(\"Validation failed but no issues detected.\");\n        }\n        return {\n            success: false,\n            get error() {\n                if (this._error)\n                    return this._error;\n                const error = new ZodError(ctx.common.issues);\n                this._error = error;\n                return this._error;\n            },\n        };\n    }\n};\nfunction processCreateParams(params) {\n    if (!params)\n        return {};\n    const { errorMap, invalid_type_error, required_error, description } = params;\n    if (errorMap && (invalid_type_error || required_error)) {\n        throw new Error(`Can't use \"invalid_type_error\" or \"required_error\" in conjunction with custom error map.`);\n    }\n    if (errorMap)\n        return { errorMap: errorMap, description };\n    const customMap = (iss, ctx) => {\n        const { message } = params;\n        if (iss.code === \"invalid_enum_value\") {\n            return { message: message ?? ctx.defaultError };\n        }\n        if (typeof ctx.data === \"undefined\") {\n            return { message: message ?? required_error ?? ctx.defaultError };\n        }\n        if (iss.code !== \"invalid_type\")\n            return { message: ctx.defaultError };\n        return { message: message ?? invalid_type_error ?? ctx.defaultError };\n    };\n    return { errorMap: customMap, description };\n}\nexport class ZodType {\n    get description() {\n        return this._def.description;\n    }\n    _getType(input) {\n        return getParsedType(input.data);\n    }\n    _getOrReturnCtx(input, ctx) {\n        return (ctx || {\n            common: input.parent.common,\n            data: input.data,\n            parsedType: getParsedType(input.data),\n            schemaErrorMap: this._def.errorMap,\n            path: input.path,\n            parent: input.parent,\n        });\n    }\n    _processInputParams(input) {\n        return {\n            status: new ParseStatus(),\n            ctx: {\n                common: input.parent.common,\n                data: input.data,\n                parsedType: getParsedType(input.data),\n                schemaErrorMap: this._def.errorMap,\n                path: input.path,\n                parent: input.parent,\n            },\n        };\n    }\n    _parseSync(input) {\n        const result = this._parse(input);\n        if (isAsync(result)) {\n            throw new Error(\"Synchronous parse encountered promise.\");\n        }\n        return result;\n    }\n    _parseAsync(input) {\n        const result = this._parse(input);\n        return Promise.resolve(result);\n    }\n    parse(data, params) {\n        const result = this.safeParse(data, params);\n        if (result.success)\n            return result.data;\n        throw result.error;\n    }\n    safeParse(data, params) {\n        const ctx = {\n            common: {\n                issues: [],\n                async: params?.async ?? false,\n                contextualErrorMap: params?.errorMap,\n            },\n            path: params?.path || [],\n            schemaErrorMap: this._def.errorMap,\n            parent: null,\n            data,\n            parsedType: getParsedType(data),\n        };\n        const result = this._parseSync({ data, path: ctx.path, parent: ctx });\n        return handleResult(ctx, result);\n    }\n    \"~validate\"(data) {\n        const ctx = {\n            common: {\n                issues: [],\n                async: !!this[\"~standard\"].async,\n            },\n            path: [],\n            schemaErrorMap: this._def.errorMap,\n            parent: null,\n            data,\n            parsedType: getParsedType(data),\n        };\n        if (!this[\"~standard\"].async) {\n            try {\n                const result = this._parseSync({ data, path: [], parent: ctx });\n                return isValid(result)\n                    ? {\n                        value: result.value,\n                    }\n                    : {\n                        issues: ctx.common.issues,\n                    };\n            }\n            catch (err) {\n                if (err?.message?.toLowerCase()?.includes(\"encountered\")) {\n                    this[\"~standard\"].async = true;\n                }\n                ctx.common = {\n                    issues: [],\n                    async: true,\n                };\n            }\n        }\n        return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result)\n            ? {\n                value: result.value,\n            }\n            : {\n                issues: ctx.common.issues,\n            });\n    }\n    async parseAsync(data, params) {\n        const result = await this.safeParseAsync(data, params);\n        if (result.success)\n            return result.data;\n        throw result.error;\n    }\n    async safeParseAsync(data, params) {\n        const ctx = {\n            common: {\n                issues: [],\n                contextualErrorMap: params?.errorMap,\n                async: true,\n            },\n            path: params?.path || [],\n            schemaErrorMap: this._def.errorMap,\n            parent: null,\n            data,\n            parsedType: getParsedType(data),\n        };\n        const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });\n        const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));\n        return handleResult(ctx, result);\n    }\n    refine(check, message) {\n        const getIssueProperties = (val) => {\n            if (typeof message === \"string\" || typeof message === \"undefined\") {\n                return { message };\n            }\n            else if (typeof message === \"function\") {\n                return message(val);\n            }\n            else {\n                return message;\n            }\n        };\n        return this._refinement((val, ctx) => {\n            const result = check(val);\n            const setError = () => ctx.addIssue({\n                code: ZodIssueCode.custom,\n                ...getIssueProperties(val),\n            });\n            if (typeof Promise !== \"undefined\" && result instanceof Promise) {\n                return result.then((data) => {\n                    if (!data) {\n                        setError();\n                        return false;\n                    }\n                    else {\n                        return true;\n                    }\n                });\n            }\n            if (!result) {\n                setError();\n                return false;\n            }\n            else {\n                return true;\n            }\n        });\n    }\n    refinement(check, refinementData) {\n        return this._refinement((val, ctx) => {\n            if (!check(val)) {\n                ctx.addIssue(typeof refinementData === \"function\" ? refinementData(val, ctx) : refinementData);\n                return false;\n            }\n            else {\n                return true;\n            }\n        });\n    }\n    _refinement(refinement) {\n        return new ZodEffects({\n            schema: this,\n            typeName: ZodFirstPartyTypeKind.ZodEffects,\n            effect: { type: \"refinement\", refinement },\n        });\n    }\n    superRefine(refinement) {\n        return this._refinement(refinement);\n    }\n    constructor(def) {\n        /** Alias of safeParseAsync */\n        this.spa = this.safeParseAsync;\n        this._def = def;\n        this.parse = this.parse.bind(this);\n        this.safeParse = this.safeParse.bind(this);\n        this.parseAsync = this.parseAsync.bind(this);\n        this.safeParseAsync = this.safeParseAsync.bind(this);\n        this.spa = this.spa.bind(this);\n        this.refine = this.refine.bind(this);\n        this.refinement = this.refinement.bind(this);\n        this.superRefine = this.superRefine.bind(this);\n        this.optional = this.optional.bind(this);\n        this.nullable = this.nullable.bind(this);\n        this.nullish = this.nullish.bind(this);\n        this.array = this.array.bind(this);\n        this.promise = this.promise.bind(this);\n        this.or = this.or.bind(this);\n        this.and = this.and.bind(this);\n        this.transform = this.transform.bind(this);\n        this.brand = this.brand.bind(this);\n        this.default = this.default.bind(this);\n        this.catch = this.catch.bind(this);\n        this.describe = this.describe.bind(this);\n        this.pipe = this.pipe.bind(this);\n        this.readonly = this.readonly.bind(this);\n        this.isNullable = this.isNullable.bind(this);\n        this.isOptional = this.isOptional.bind(this);\n        this[\"~standard\"] = {\n            version: 1,\n            vendor: \"zod\",\n            validate: (data) => this[\"~validate\"](data),\n        };\n    }\n    optional() {\n        return ZodOptional.create(this, this._def);\n    }\n    nullable() {\n        return ZodNullable.create(this, this._def);\n    }\n    nullish() {\n        return this.nullable().optional();\n    }\n    array() {\n        return ZodArray.create(this);\n    }\n    promise() {\n        return ZodPromise.create(this, this._def);\n    }\n    or(option) {\n        return ZodUnion.create([this, option], this._def);\n    }\n    and(incoming) {\n        return ZodIntersection.create(this, incoming, this._def);\n    }\n    transform(transform) {\n        return new ZodEffects({\n            ...processCreateParams(this._def),\n            schema: this,\n            typeName: ZodFirstPartyTypeKind.ZodEffects,\n            effect: { type: \"transform\", transform },\n        });\n    }\n    default(def) {\n        const defaultValueFunc = typeof def === \"function\" ? def : () => def;\n        return new ZodDefault({\n            ...processCreateParams(this._def),\n            innerType: this,\n            defaultValue: defaultValueFunc,\n            typeName: ZodFirstPartyTypeKind.ZodDefault,\n        });\n    }\n    brand() {\n        return new ZodBranded({\n            typeName: ZodFirstPartyTypeKind.ZodBranded,\n            type: this,\n            ...processCreateParams(this._def),\n        });\n    }\n    catch(def) {\n        const catchValueFunc = typeof def === \"function\" ? def : () => def;\n        return new ZodCatch({\n            ...processCreateParams(this._def),\n            innerType: this,\n            catchValue: catchValueFunc,\n            typeName: ZodFirstPartyTypeKind.ZodCatch,\n        });\n    }\n    describe(description) {\n        const This = this.constructor;\n        return new This({\n            ...this._def,\n            description,\n        });\n    }\n    pipe(target) {\n        return ZodPipeline.create(this, target);\n    }\n    readonly() {\n        return ZodReadonly.create(this);\n    }\n    isOptional() {\n        return this.safeParse(undefined).success;\n    }\n    isNullable() {\n        return this.safeParse(null).success;\n    }\n}\nconst cuidRegex = /^c[^\\s-]{8,}$/i;\nconst cuid2Regex = /^[0-9a-z]+$/;\nconst ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;\n// const uuidRegex =\n//   /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;\nconst uuidRegex = /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/i;\nconst nanoidRegex = /^[a-z0-9_-]{21}$/i;\nconst jwtRegex = /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/;\nconst durationRegex = /^[-+]?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// from https://stackoverflow.com/a/46181/1550155\n// old version: too slow, didn't support unicode\n// const emailRegex = /^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))$/i;\n//old email regex\n// const emailRegex = /^(([^<>()[\\].,;:\\s@\"]+(\\.[^<>()[\\].,;:\\s@\"]+)*)|(\".+\"))@((?!-)([^<>()[\\].,;:\\s@\"]+\\.)+[^<>()[\\].,;:\\s@\"]{1,})[^-<>()[\\].,;:\\s@\"]$/i;\n// eslint-disable-next-line\n// const emailRegex =\n//   /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\])|(\\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\\.[A-Za-z]{2,})+))$/;\n// const emailRegex =\n//   /^[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// const emailRegex =\n//   /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/i;\nconst emailRegex = /^(?!\\.)(?!.*\\.\\.)([A-Z0-9_'+\\-\\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\\-]*\\.)+[A-Z]{2,}$/i;\n// const emailRegex =\n//   /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\\.[a-z0-9\\-]+)*$/i;\n// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression\nconst _emojiRegex = `^[\\\\p{Extended_Pictographic}\\\\p{Emoji_Component}]+$`;\nlet emojiRegex;\n// faster, simpler, safer\nconst ipv4Regex = /^(?:(?: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])$/;\nconst ipv4CidrRegex = /^(?:(?: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])\\/(3[0-2]|[12]?[0-9])$/;\n// const ipv6Regex =\n// /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;\nconst ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,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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0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\\/(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\nconst base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;\n// https://base64.guru/standards/base64url\nconst base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n// simple\n// const dateRegexSource = `\\\\d{4}-\\\\d{2}-\\\\d{2}`;\n// no leap year validation\n// const dateRegexSource = `\\\\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\\\\d|2\\\\d))`;\n// with leap year validation\nconst dateRegexSource = `((\\\\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 dateRegex = new RegExp(`^${dateRegexSource}$`);\nfunction timeRegexSource(args) {\n    let secondsRegexSource = `[0-5]\\\\d`;\n    if (args.precision) {\n        secondsRegexSource = `${secondsRegexSource}\\\\.\\\\d{${args.precision}}`;\n    }\n    else if (args.precision == null) {\n        secondsRegexSource = `${secondsRegexSource}(\\\\.\\\\d+)?`;\n    }\n    const secondsQuantifier = args.precision ? \"+\" : \"?\"; // require seconds if precision is nonzero\n    return `([01]\\\\d|2[0-3]):[0-5]\\\\d(:${secondsRegexSource})${secondsQuantifier}`;\n}\nfunction timeRegex(args) {\n    return new RegExp(`^${timeRegexSource(args)}$`);\n}\n// Adapted from https://stackoverflow.com/a/3143231\nexport function datetimeRegex(args) {\n    let regex = `${dateRegexSource}T${timeRegexSource(args)}`;\n    const opts = [];\n    opts.push(args.local ? `Z?` : `Z`);\n    if (args.offset)\n        opts.push(`([+-]\\\\d{2}:?\\\\d{2})`);\n    regex = `${regex}(${opts.join(\"|\")})`;\n    return new RegExp(`^${regex}$`);\n}\nfunction isValidIP(ip, version) {\n    if ((version === \"v4\" || !version) && ipv4Regex.test(ip)) {\n        return true;\n    }\n    if ((version === \"v6\" || !version) && ipv6Regex.test(ip)) {\n        return true;\n    }\n    return false;\n}\nfunction isValidJWT(jwt, alg) {\n    if (!jwtRegex.test(jwt))\n        return false;\n    try {\n        const [header] = jwt.split(\".\");\n        if (!header)\n            return false;\n        // Convert base64url to base64\n        const base64 = header\n            .replace(/-/g, \"+\")\n            .replace(/_/g, \"/\")\n            .padEnd(header.length + ((4 - (header.length % 4)) % 4), \"=\");\n        // @ts-ignore\n        const decoded = JSON.parse(atob(base64));\n        if (typeof decoded !== \"object\" || decoded === null)\n            return false;\n        if (\"typ\" in decoded && decoded?.typ !== \"JWT\")\n            return false;\n        if (!decoded.alg)\n            return false;\n        if (alg && decoded.alg !== alg)\n            return false;\n        return true;\n    }\n    catch {\n        return false;\n    }\n}\nfunction isValidCidr(ip, version) {\n    if ((version === \"v4\" || !version) && ipv4CidrRegex.test(ip)) {\n        return true;\n    }\n    if ((version === \"v6\" || !version) && ipv6CidrRegex.test(ip)) {\n        return true;\n    }\n    return false;\n}\nexport class ZodString extends ZodType {\n    _parse(input) {\n        if (this._def.coerce) {\n            input.data = String(input.data);\n        }\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.string) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.string,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const status = new ParseStatus();\n        let ctx = undefined;\n        for (const check of this._def.checks) {\n            if (check.kind === \"min\") {\n                if (input.data.length < check.value) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_small,\n                        minimum: check.value,\n                        type: \"string\",\n                        inclusive: true,\n                        exact: false,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"max\") {\n                if (input.data.length > check.value) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_big,\n                        maximum: check.value,\n                        type: \"string\",\n                        inclusive: true,\n                        exact: false,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"length\") {\n                const tooBig = input.data.length > check.value;\n                const tooSmall = input.data.length < check.value;\n                if (tooBig || tooSmall) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    if (tooBig) {\n                        addIssueToContext(ctx, {\n                            code: ZodIssueCode.too_big,\n                            maximum: check.value,\n                            type: \"string\",\n                            inclusive: true,\n                            exact: true,\n                            message: check.message,\n                        });\n                    }\n                    else if (tooSmall) {\n                        addIssueToContext(ctx, {\n                            code: ZodIssueCode.too_small,\n                            minimum: check.value,\n                            type: \"string\",\n                            inclusive: true,\n                            exact: true,\n                            message: check.message,\n                        });\n                    }\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"email\") {\n                if (!emailRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"email\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"emoji\") {\n                if (!emojiRegex) {\n                    emojiRegex = new RegExp(_emojiRegex, \"u\");\n                }\n                if (!emojiRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"emoji\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"uuid\") {\n                if (!uuidRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"uuid\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"nanoid\") {\n                if (!nanoidRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"nanoid\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"cuid\") {\n                if (!cuidRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"cuid\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"cuid2\") {\n                if (!cuid2Regex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"cuid2\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"ulid\") {\n                if (!ulidRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"ulid\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"url\") {\n                try {\n                    // @ts-ignore\n                    new URL(input.data);\n                }\n                catch {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"url\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"regex\") {\n                check.regex.lastIndex = 0;\n                const testResult = check.regex.test(input.data);\n                if (!testResult) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"regex\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"trim\") {\n                input.data = input.data.trim();\n            }\n            else if (check.kind === \"includes\") {\n                if (!input.data.includes(check.value, check.position)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_string,\n                        validation: { includes: check.value, position: check.position },\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"toLowerCase\") {\n                input.data = input.data.toLowerCase();\n            }\n            else if (check.kind === \"toUpperCase\") {\n                input.data = input.data.toUpperCase();\n            }\n            else if (check.kind === \"startsWith\") {\n                if (!input.data.startsWith(check.value)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_string,\n                        validation: { startsWith: check.value },\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"endsWith\") {\n                if (!input.data.endsWith(check.value)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_string,\n                        validation: { endsWith: check.value },\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"datetime\") {\n                const regex = datetimeRegex(check);\n                if (!regex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_string,\n                        validation: \"datetime\",\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"date\") {\n                const regex = dateRegex;\n                if (!regex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_string,\n                        validation: \"date\",\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"time\") {\n                const regex = timeRegex(check);\n                if (!regex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_string,\n                        validation: \"time\",\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"duration\") {\n                if (!durationRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"duration\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"ip\") {\n                if (!isValidIP(input.data, check.version)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"ip\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"jwt\") {\n                if (!isValidJWT(input.data, check.alg)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"jwt\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"cidr\") {\n                if (!isValidCidr(input.data, check.version)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"cidr\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"base64\") {\n                if (!base64Regex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"base64\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"base64url\") {\n                if (!base64urlRegex.test(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        validation: \"base64url\",\n                        code: ZodIssueCode.invalid_string,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else {\n                util.assertNever(check);\n            }\n        }\n        return { status: status.value, value: input.data };\n    }\n    _regex(regex, validation, message) {\n        return this.refinement((data) => regex.test(data), {\n            validation,\n            code: ZodIssueCode.invalid_string,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    _addCheck(check) {\n        return new ZodString({\n            ...this._def,\n            checks: [...this._def.checks, check],\n        });\n    }\n    email(message) {\n        return this._addCheck({ kind: \"email\", ...errorUtil.errToObj(message) });\n    }\n    url(message) {\n        return this._addCheck({ kind: \"url\", ...errorUtil.errToObj(message) });\n    }\n    emoji(message) {\n        return this._addCheck({ kind: \"emoji\", ...errorUtil.errToObj(message) });\n    }\n    uuid(message) {\n        return this._addCheck({ kind: \"uuid\", ...errorUtil.errToObj(message) });\n    }\n    nanoid(message) {\n        return this._addCheck({ kind: \"nanoid\", ...errorUtil.errToObj(message) });\n    }\n    cuid(message) {\n        return this._addCheck({ kind: \"cuid\", ...errorUtil.errToObj(message) });\n    }\n    cuid2(message) {\n        return this._addCheck({ kind: \"cuid2\", ...errorUtil.errToObj(message) });\n    }\n    ulid(message) {\n        return this._addCheck({ kind: \"ulid\", ...errorUtil.errToObj(message) });\n    }\n    base64(message) {\n        return this._addCheck({ kind: \"base64\", ...errorUtil.errToObj(message) });\n    }\n    base64url(message) {\n        // base64url encoding is a modification of base64 that can safely be used in URLs and filenames\n        return this._addCheck({\n            kind: \"base64url\",\n            ...errorUtil.errToObj(message),\n        });\n    }\n    jwt(options) {\n        return this._addCheck({ kind: \"jwt\", ...errorUtil.errToObj(options) });\n    }\n    ip(options) {\n        return this._addCheck({ kind: \"ip\", ...errorUtil.errToObj(options) });\n    }\n    cidr(options) {\n        return this._addCheck({ kind: \"cidr\", ...errorUtil.errToObj(options) });\n    }\n    datetime(options) {\n        if (typeof options === \"string\") {\n            return this._addCheck({\n                kind: \"datetime\",\n                precision: null,\n                offset: false,\n                local: false,\n                message: options,\n            });\n        }\n        return this._addCheck({\n            kind: \"datetime\",\n            precision: typeof options?.precision === \"undefined\" ? null : options?.precision,\n            offset: options?.offset ?? false,\n            local: options?.local ?? false,\n            ...errorUtil.errToObj(options?.message),\n        });\n    }\n    date(message) {\n        return this._addCheck({ kind: \"date\", message });\n    }\n    time(options) {\n        if (typeof options === \"string\") {\n            return this._addCheck({\n                kind: \"time\",\n                precision: null,\n                message: options,\n            });\n        }\n        return this._addCheck({\n            kind: \"time\",\n            precision: typeof options?.precision === \"undefined\" ? null : options?.precision,\n            ...errorUtil.errToObj(options?.message),\n        });\n    }\n    duration(message) {\n        return this._addCheck({ kind: \"duration\", ...errorUtil.errToObj(message) });\n    }\n    regex(regex, message) {\n        return this._addCheck({\n            kind: \"regex\",\n            regex: regex,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    includes(value, options) {\n        return this._addCheck({\n            kind: \"includes\",\n            value: value,\n            position: options?.position,\n            ...errorUtil.errToObj(options?.message),\n        });\n    }\n    startsWith(value, message) {\n        return this._addCheck({\n            kind: \"startsWith\",\n            value: value,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    endsWith(value, message) {\n        return this._addCheck({\n            kind: \"endsWith\",\n            value: value,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    min(minLength, message) {\n        return this._addCheck({\n            kind: \"min\",\n            value: minLength,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    max(maxLength, message) {\n        return this._addCheck({\n            kind: \"max\",\n            value: maxLength,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    length(len, message) {\n        return this._addCheck({\n            kind: \"length\",\n            value: len,\n            ...errorUtil.errToObj(message),\n        });\n    }\n    /**\n     * Equivalent to `.min(1)`\n     */\n    nonempty(message) {\n        return this.min(1, errorUtil.errToObj(message));\n    }\n    trim() {\n        return new ZodString({\n            ...this._def,\n            checks: [...this._def.checks, { kind: \"trim\" }],\n        });\n    }\n    toLowerCase() {\n        return new ZodString({\n            ...this._def,\n            checks: [...this._def.checks, { kind: \"toLowerCase\" }],\n        });\n    }\n    toUpperCase() {\n        return new ZodString({\n            ...this._def,\n            checks: [...this._def.checks, { kind: \"toUpperCase\" }],\n        });\n    }\n    get isDatetime() {\n        return !!this._def.checks.find((ch) => ch.kind === \"datetime\");\n    }\n    get isDate() {\n        return !!this._def.checks.find((ch) => ch.kind === \"date\");\n    }\n    get isTime() {\n        return !!this._def.checks.find((ch) => ch.kind === \"time\");\n    }\n    get isDuration() {\n        return !!this._def.checks.find((ch) => ch.kind === \"duration\");\n    }\n    get isEmail() {\n        return !!this._def.checks.find((ch) => ch.kind === \"email\");\n    }\n    get isURL() {\n        return !!this._def.checks.find((ch) => ch.kind === \"url\");\n    }\n    get isEmoji() {\n        return !!this._def.checks.find((ch) => ch.kind === \"emoji\");\n    }\n    get isUUID() {\n        return !!this._def.checks.find((ch) => ch.kind === \"uuid\");\n    }\n    get isNANOID() {\n        return !!this._def.checks.find((ch) => ch.kind === \"nanoid\");\n    }\n    get isCUID() {\n        return !!this._def.checks.find((ch) => ch.kind === \"cuid\");\n    }\n    get isCUID2() {\n        return !!this._def.checks.find((ch) => ch.kind === \"cuid2\");\n    }\n    get isULID() {\n        return !!this._def.checks.find((ch) => ch.kind === \"ulid\");\n    }\n    get isIP() {\n        return !!this._def.checks.find((ch) => ch.kind === \"ip\");\n    }\n    get isCIDR() {\n        return !!this._def.checks.find((ch) => ch.kind === \"cidr\");\n    }\n    get isBase64() {\n        return !!this._def.checks.find((ch) => ch.kind === \"base64\");\n    }\n    get isBase64url() {\n        // base64url encoding is a modification of base64 that can safely be used in URLs and filenames\n        return !!this._def.checks.find((ch) => ch.kind === \"base64url\");\n    }\n    get minLength() {\n        let min = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"min\") {\n                if (min === null || ch.value > min)\n                    min = ch.value;\n            }\n        }\n        return min;\n    }\n    get maxLength() {\n        let max = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"max\") {\n                if (max === null || ch.value < max)\n                    max = ch.value;\n            }\n        }\n        return max;\n    }\n}\nZodString.create = (params) => {\n    return new ZodString({\n        checks: [],\n        typeName: ZodFirstPartyTypeKind.ZodString,\n        coerce: params?.coerce ?? false,\n        ...processCreateParams(params),\n    });\n};\n// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034\nfunction floatSafeRemainder(val, step) {\n    const valDecCount = (val.toString().split(\".\")[1] || \"\").length;\n    const stepDecCount = (step.toString().split(\".\")[1] || \"\").length;\n    const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n    const valInt = Number.parseInt(val.toFixed(decCount).replace(\".\", \"\"));\n    const stepInt = Number.parseInt(step.toFixed(decCount).replace(\".\", \"\"));\n    return (valInt % stepInt) / 10 ** decCount;\n}\nexport class ZodNumber extends ZodType {\n    constructor() {\n        super(...arguments);\n        this.min = this.gte;\n        this.max = this.lte;\n        this.step = this.multipleOf;\n    }\n    _parse(input) {\n        if (this._def.coerce) {\n            input.data = Number(input.data);\n        }\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.number) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.number,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        let ctx = undefined;\n        const status = new ParseStatus();\n        for (const check of this._def.checks) {\n            if (check.kind === \"int\") {\n                if (!util.isInteger(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.invalid_type,\n                        expected: \"integer\",\n                        received: \"float\",\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"min\") {\n                const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n                if (tooSmall) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_small,\n                        minimum: check.value,\n                        type: \"number\",\n                        inclusive: check.inclusive,\n                        exact: false,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"max\") {\n                const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n                if (tooBig) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_big,\n                        maximum: check.value,\n                        type: \"number\",\n                        inclusive: check.inclusive,\n                        exact: false,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"multipleOf\") {\n                if (floatSafeRemainder(input.data, check.value) !== 0) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.not_multiple_of,\n                        multipleOf: check.value,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"finite\") {\n                if (!Number.isFinite(input.data)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.not_finite,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else {\n                util.assertNever(check);\n            }\n        }\n        return { status: status.value, value: input.data };\n    }\n    gte(value, message) {\n        return this.setLimit(\"min\", value, true, errorUtil.toString(message));\n    }\n    gt(value, message) {\n        return this.setLimit(\"min\", value, false, errorUtil.toString(message));\n    }\n    lte(value, message) {\n        return this.setLimit(\"max\", value, true, errorUtil.toString(message));\n    }\n    lt(value, message) {\n        return this.setLimit(\"max\", value, false, errorUtil.toString(message));\n    }\n    setLimit(kind, value, inclusive, message) {\n        return new ZodNumber({\n            ...this._def,\n            checks: [\n                ...this._def.checks,\n                {\n                    kind,\n                    value,\n                    inclusive,\n                    message: errorUtil.toString(message),\n                },\n            ],\n        });\n    }\n    _addCheck(check) {\n        return new ZodNumber({\n            ...this._def,\n            checks: [...this._def.checks, check],\n        });\n    }\n    int(message) {\n        return this._addCheck({\n            kind: \"int\",\n            message: errorUtil.toString(message),\n        });\n    }\n    positive(message) {\n        return this._addCheck({\n            kind: \"min\",\n            value: 0,\n            inclusive: false,\n            message: errorUtil.toString(message),\n        });\n    }\n    negative(message) {\n        return this._addCheck({\n            kind: \"max\",\n            value: 0,\n            inclusive: false,\n            message: errorUtil.toString(message),\n        });\n    }\n    nonpositive(message) {\n        return this._addCheck({\n            kind: \"max\",\n            value: 0,\n            inclusive: true,\n            message: errorUtil.toString(message),\n        });\n    }\n    nonnegative(message) {\n        return this._addCheck({\n            kind: \"min\",\n            value: 0,\n            inclusive: true,\n            message: errorUtil.toString(message),\n        });\n    }\n    multipleOf(value, message) {\n        return this._addCheck({\n            kind: \"multipleOf\",\n            value: value,\n            message: errorUtil.toString(message),\n        });\n    }\n    finite(message) {\n        return this._addCheck({\n            kind: \"finite\",\n            message: errorUtil.toString(message),\n        });\n    }\n    safe(message) {\n        return this._addCheck({\n            kind: \"min\",\n            inclusive: true,\n            value: Number.MIN_SAFE_INTEGER,\n            message: errorUtil.toString(message),\n        })._addCheck({\n            kind: \"max\",\n            inclusive: true,\n            value: Number.MAX_SAFE_INTEGER,\n            message: errorUtil.toString(message),\n        });\n    }\n    get minValue() {\n        let min = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"min\") {\n                if (min === null || ch.value > min)\n                    min = ch.value;\n            }\n        }\n        return min;\n    }\n    get maxValue() {\n        let max = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"max\") {\n                if (max === null || ch.value < max)\n                    max = ch.value;\n            }\n        }\n        return max;\n    }\n    get isInt() {\n        return !!this._def.checks.find((ch) => ch.kind === \"int\" || (ch.kind === \"multipleOf\" && util.isInteger(ch.value)));\n    }\n    get isFinite() {\n        let max = null;\n        let min = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"finite\" || ch.kind === \"int\" || ch.kind === \"multipleOf\") {\n                return true;\n            }\n            else if (ch.kind === \"min\") {\n                if (min === null || ch.value > min)\n                    min = ch.value;\n            }\n            else if (ch.kind === \"max\") {\n                if (max === null || ch.value < max)\n                    max = ch.value;\n            }\n        }\n        return Number.isFinite(min) && Number.isFinite(max);\n    }\n}\nZodNumber.create = (params) => {\n    return new ZodNumber({\n        checks: [],\n        typeName: ZodFirstPartyTypeKind.ZodNumber,\n        coerce: params?.coerce || false,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodBigInt extends ZodType {\n    constructor() {\n        super(...arguments);\n        this.min = this.gte;\n        this.max = this.lte;\n    }\n    _parse(input) {\n        if (this._def.coerce) {\n            try {\n                input.data = BigInt(input.data);\n            }\n            catch {\n                return this._getInvalidInput(input);\n            }\n        }\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.bigint) {\n            return this._getInvalidInput(input);\n        }\n        let ctx = undefined;\n        const status = new ParseStatus();\n        for (const check of this._def.checks) {\n            if (check.kind === \"min\") {\n                const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n                if (tooSmall) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_small,\n                        type: \"bigint\",\n                        minimum: check.value,\n                        inclusive: check.inclusive,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"max\") {\n                const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n                if (tooBig) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_big,\n                        type: \"bigint\",\n                        maximum: check.value,\n                        inclusive: check.inclusive,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"multipleOf\") {\n                if (input.data % check.value !== BigInt(0)) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.not_multiple_of,\n                        multipleOf: check.value,\n                        message: check.message,\n                    });\n                    status.dirty();\n                }\n            }\n            else {\n                util.assertNever(check);\n            }\n        }\n        return { status: status.value, value: input.data };\n    }\n    _getInvalidInput(input) {\n        const ctx = this._getOrReturnCtx(input);\n        addIssueToContext(ctx, {\n            code: ZodIssueCode.invalid_type,\n            expected: ZodParsedType.bigint,\n            received: ctx.parsedType,\n        });\n        return INVALID;\n    }\n    gte(value, message) {\n        return this.setLimit(\"min\", value, true, errorUtil.toString(message));\n    }\n    gt(value, message) {\n        return this.setLimit(\"min\", value, false, errorUtil.toString(message));\n    }\n    lte(value, message) {\n        return this.setLimit(\"max\", value, true, errorUtil.toString(message));\n    }\n    lt(value, message) {\n        return this.setLimit(\"max\", value, false, errorUtil.toString(message));\n    }\n    setLimit(kind, value, inclusive, message) {\n        return new ZodBigInt({\n            ...this._def,\n            checks: [\n                ...this._def.checks,\n                {\n                    kind,\n                    value,\n                    inclusive,\n                    message: errorUtil.toString(message),\n                },\n            ],\n        });\n    }\n    _addCheck(check) {\n        return new ZodBigInt({\n            ...this._def,\n            checks: [...this._def.checks, check],\n        });\n    }\n    positive(message) {\n        return this._addCheck({\n            kind: \"min\",\n            value: BigInt(0),\n            inclusive: false,\n            message: errorUtil.toString(message),\n        });\n    }\n    negative(message) {\n        return this._addCheck({\n            kind: \"max\",\n            value: BigInt(0),\n            inclusive: false,\n            message: errorUtil.toString(message),\n        });\n    }\n    nonpositive(message) {\n        return this._addCheck({\n            kind: \"max\",\n            value: BigInt(0),\n            inclusive: true,\n            message: errorUtil.toString(message),\n        });\n    }\n    nonnegative(message) {\n        return this._addCheck({\n            kind: \"min\",\n            value: BigInt(0),\n            inclusive: true,\n            message: errorUtil.toString(message),\n        });\n    }\n    multipleOf(value, message) {\n        return this._addCheck({\n            kind: \"multipleOf\",\n            value,\n            message: errorUtil.toString(message),\n        });\n    }\n    get minValue() {\n        let min = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"min\") {\n                if (min === null || ch.value > min)\n                    min = ch.value;\n            }\n        }\n        return min;\n    }\n    get maxValue() {\n        let max = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"max\") {\n                if (max === null || ch.value < max)\n                    max = ch.value;\n            }\n        }\n        return max;\n    }\n}\nZodBigInt.create = (params) => {\n    return new ZodBigInt({\n        checks: [],\n        typeName: ZodFirstPartyTypeKind.ZodBigInt,\n        coerce: params?.coerce ?? false,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodBoolean extends ZodType {\n    _parse(input) {\n        if (this._def.coerce) {\n            input.data = Boolean(input.data);\n        }\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.boolean) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.boolean,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n}\nZodBoolean.create = (params) => {\n    return new ZodBoolean({\n        typeName: ZodFirstPartyTypeKind.ZodBoolean,\n        coerce: params?.coerce || false,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodDate extends ZodType {\n    _parse(input) {\n        if (this._def.coerce) {\n            input.data = new Date(input.data);\n        }\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.date) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.date,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        if (Number.isNaN(input.data.getTime())) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_date,\n            });\n            return INVALID;\n        }\n        const status = new ParseStatus();\n        let ctx = undefined;\n        for (const check of this._def.checks) {\n            if (check.kind === \"min\") {\n                if (input.data.getTime() < check.value) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_small,\n                        message: check.message,\n                        inclusive: true,\n                        exact: false,\n                        minimum: check.value,\n                        type: \"date\",\n                    });\n                    status.dirty();\n                }\n            }\n            else if (check.kind === \"max\") {\n                if (input.data.getTime() > check.value) {\n                    ctx = this._getOrReturnCtx(input, ctx);\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.too_big,\n                        message: check.message,\n                        inclusive: true,\n                        exact: false,\n                        maximum: check.value,\n                        type: \"date\",\n                    });\n                    status.dirty();\n                }\n            }\n            else {\n                util.assertNever(check);\n            }\n        }\n        return {\n            status: status.value,\n            value: new Date(input.data.getTime()),\n        };\n    }\n    _addCheck(check) {\n        return new ZodDate({\n            ...this._def,\n            checks: [...this._def.checks, check],\n        });\n    }\n    min(minDate, message) {\n        return this._addCheck({\n            kind: \"min\",\n            value: minDate.getTime(),\n            message: errorUtil.toString(message),\n        });\n    }\n    max(maxDate, message) {\n        return this._addCheck({\n            kind: \"max\",\n            value: maxDate.getTime(),\n            message: errorUtil.toString(message),\n        });\n    }\n    get minDate() {\n        let min = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"min\") {\n                if (min === null || ch.value > min)\n                    min = ch.value;\n            }\n        }\n        return min != null ? new Date(min) : null;\n    }\n    get maxDate() {\n        let max = null;\n        for (const ch of this._def.checks) {\n            if (ch.kind === \"max\") {\n                if (max === null || ch.value < max)\n                    max = ch.value;\n            }\n        }\n        return max != null ? new Date(max) : null;\n    }\n}\nZodDate.create = (params) => {\n    return new ZodDate({\n        checks: [],\n        coerce: params?.coerce || false,\n        typeName: ZodFirstPartyTypeKind.ZodDate,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodSymbol extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.symbol) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.symbol,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n}\nZodSymbol.create = (params) => {\n    return new ZodSymbol({\n        typeName: ZodFirstPartyTypeKind.ZodSymbol,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodUndefined extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.undefined) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.undefined,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n}\nZodUndefined.create = (params) => {\n    return new ZodUndefined({\n        typeName: ZodFirstPartyTypeKind.ZodUndefined,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodNull extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.null) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.null,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n}\nZodNull.create = (params) => {\n    return new ZodNull({\n        typeName: ZodFirstPartyTypeKind.ZodNull,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodAny extends ZodType {\n    constructor() {\n        super(...arguments);\n        // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.\n        this._any = true;\n    }\n    _parse(input) {\n        return OK(input.data);\n    }\n}\nZodAny.create = (params) => {\n    return new ZodAny({\n        typeName: ZodFirstPartyTypeKind.ZodAny,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodUnknown extends ZodType {\n    constructor() {\n        super(...arguments);\n        // required\n        this._unknown = true;\n    }\n    _parse(input) {\n        return OK(input.data);\n    }\n}\nZodUnknown.create = (params) => {\n    return new ZodUnknown({\n        typeName: ZodFirstPartyTypeKind.ZodUnknown,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodNever extends ZodType {\n    _parse(input) {\n        const ctx = this._getOrReturnCtx(input);\n        addIssueToContext(ctx, {\n            code: ZodIssueCode.invalid_type,\n            expected: ZodParsedType.never,\n            received: ctx.parsedType,\n        });\n        return INVALID;\n    }\n}\nZodNever.create = (params) => {\n    return new ZodNever({\n        typeName: ZodFirstPartyTypeKind.ZodNever,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodVoid extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.undefined) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.void,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n}\nZodVoid.create = (params) => {\n    return new ZodVoid({\n        typeName: ZodFirstPartyTypeKind.ZodVoid,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodArray extends ZodType {\n    _parse(input) {\n        const { ctx, status } = this._processInputParams(input);\n        const def = this._def;\n        if (ctx.parsedType !== ZodParsedType.array) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.array,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        if (def.exactLength !== null) {\n            const tooBig = ctx.data.length > def.exactLength.value;\n            const tooSmall = ctx.data.length < def.exactLength.value;\n            if (tooBig || tooSmall) {\n                addIssueToContext(ctx, {\n                    code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,\n                    minimum: (tooSmall ? def.exactLength.value : undefined),\n                    maximum: (tooBig ? def.exactLength.value : undefined),\n                    type: \"array\",\n                    inclusive: true,\n                    exact: true,\n                    message: def.exactLength.message,\n                });\n                status.dirty();\n            }\n        }\n        if (def.minLength !== null) {\n            if (ctx.data.length < def.minLength.value) {\n                addIssueToContext(ctx, {\n                    code: ZodIssueCode.too_small,\n                    minimum: def.minLength.value,\n                    type: \"array\",\n                    inclusive: true,\n                    exact: false,\n                    message: def.minLength.message,\n                });\n                status.dirty();\n            }\n        }\n        if (def.maxLength !== null) {\n            if (ctx.data.length > def.maxLength.value) {\n                addIssueToContext(ctx, {\n                    code: ZodIssueCode.too_big,\n                    maximum: def.maxLength.value,\n                    type: \"array\",\n                    inclusive: true,\n                    exact: false,\n                    message: def.maxLength.message,\n                });\n                status.dirty();\n            }\n        }\n        if (ctx.common.async) {\n            return Promise.all([...ctx.data].map((item, i) => {\n                return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));\n            })).then((result) => {\n                return ParseStatus.mergeArray(status, result);\n            });\n        }\n        const result = [...ctx.data].map((item, i) => {\n            return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));\n        });\n        return ParseStatus.mergeArray(status, result);\n    }\n    get element() {\n        return this._def.type;\n    }\n    min(minLength, message) {\n        return new ZodArray({\n            ...this._def,\n            minLength: { value: minLength, message: errorUtil.toString(message) },\n        });\n    }\n    max(maxLength, message) {\n        return new ZodArray({\n            ...this._def,\n            maxLength: { value: maxLength, message: errorUtil.toString(message) },\n        });\n    }\n    length(len, message) {\n        return new ZodArray({\n            ...this._def,\n            exactLength: { value: len, message: errorUtil.toString(message) },\n        });\n    }\n    nonempty(message) {\n        return this.min(1, message);\n    }\n}\nZodArray.create = (schema, params) => {\n    return new ZodArray({\n        type: schema,\n        minLength: null,\n        maxLength: null,\n        exactLength: null,\n        typeName: ZodFirstPartyTypeKind.ZodArray,\n        ...processCreateParams(params),\n    });\n};\nfunction deepPartialify(schema) {\n    if (schema instanceof ZodObject) {\n        const newShape = {};\n        for (const key in schema.shape) {\n            const fieldSchema = schema.shape[key];\n            newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));\n        }\n        return new ZodObject({\n            ...schema._def,\n            shape: () => newShape,\n        });\n    }\n    else if (schema instanceof ZodArray) {\n        return new ZodArray({\n            ...schema._def,\n            type: deepPartialify(schema.element),\n        });\n    }\n    else if (schema instanceof ZodOptional) {\n        return ZodOptional.create(deepPartialify(schema.unwrap()));\n    }\n    else if (schema instanceof ZodNullable) {\n        return ZodNullable.create(deepPartialify(schema.unwrap()));\n    }\n    else if (schema instanceof ZodTuple) {\n        return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));\n    }\n    else {\n        return schema;\n    }\n}\nexport class ZodObject extends ZodType {\n    constructor() {\n        super(...arguments);\n        this._cached = null;\n        /**\n         * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.\n         * If you want to pass through unknown properties, use `.passthrough()` instead.\n         */\n        this.nonstrict = this.passthrough;\n        // extend<\n        //   Augmentation extends ZodRawShape,\n        //   NewOutput extends util.flatten<{\n        //     [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n        //       ? Augmentation[k][\"_output\"]\n        //       : k extends keyof Output\n        //       ? Output[k]\n        //       : never;\n        //   }>,\n        //   NewInput extends util.flatten<{\n        //     [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n        //       ? Augmentation[k][\"_input\"]\n        //       : k extends keyof Input\n        //       ? Input[k]\n        //       : never;\n        //   }>\n        // >(\n        //   augmentation: Augmentation\n        // ): ZodObject<\n        //   extendShape<T, Augmentation>,\n        //   UnknownKeys,\n        //   Catchall,\n        //   NewOutput,\n        //   NewInput\n        // > {\n        //   return new ZodObject({\n        //     ...this._def,\n        //     shape: () => ({\n        //       ...this._def.shape(),\n        //       ...augmentation,\n        //     }),\n        //   }) as any;\n        // }\n        /**\n         * @deprecated Use `.extend` instead\n         *  */\n        this.augment = this.extend;\n    }\n    _getCached() {\n        if (this._cached !== null)\n            return this._cached;\n        const shape = this._def.shape();\n        const keys = util.objectKeys(shape);\n        this._cached = { shape, keys };\n        return this._cached;\n    }\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.object) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.object,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const { status, ctx } = this._processInputParams(input);\n        const { shape, keys: shapeKeys } = this._getCached();\n        const extraKeys = [];\n        if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === \"strip\")) {\n            for (const key in ctx.data) {\n                if (!shapeKeys.includes(key)) {\n                    extraKeys.push(key);\n                }\n            }\n        }\n        const pairs = [];\n        for (const key of shapeKeys) {\n            const keyValidator = shape[key];\n            const value = ctx.data[key];\n            pairs.push({\n                key: { status: \"valid\", value: key },\n                value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),\n                alwaysSet: key in ctx.data,\n            });\n        }\n        if (this._def.catchall instanceof ZodNever) {\n            const unknownKeys = this._def.unknownKeys;\n            if (unknownKeys === \"passthrough\") {\n                for (const key of extraKeys) {\n                    pairs.push({\n                        key: { status: \"valid\", value: key },\n                        value: { status: \"valid\", value: ctx.data[key] },\n                    });\n                }\n            }\n            else if (unknownKeys === \"strict\") {\n                if (extraKeys.length > 0) {\n                    addIssueToContext(ctx, {\n                        code: ZodIssueCode.unrecognized_keys,\n                        keys: extraKeys,\n                    });\n                    status.dirty();\n                }\n            }\n            else if (unknownKeys === \"strip\") {\n            }\n            else {\n                throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);\n            }\n        }\n        else {\n            // run catchall validation\n            const catchall = this._def.catchall;\n            for (const key of extraKeys) {\n                const value = ctx.data[key];\n                pairs.push({\n                    key: { status: \"valid\", value: key },\n                    value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key) //, ctx.child(key), value, getParsedType(value)\n                    ),\n                    alwaysSet: key in ctx.data,\n                });\n            }\n        }\n        if (ctx.common.async) {\n            return Promise.resolve()\n                .then(async () => {\n                const syncPairs = [];\n                for (const pair of pairs) {\n                    const key = await pair.key;\n                    const value = await pair.value;\n                    syncPairs.push({\n                        key,\n                        value,\n                        alwaysSet: pair.alwaysSet,\n                    });\n                }\n                return syncPairs;\n            })\n                .then((syncPairs) => {\n                return ParseStatus.mergeObjectSync(status, syncPairs);\n            });\n        }\n        else {\n            return ParseStatus.mergeObjectSync(status, pairs);\n        }\n    }\n    get shape() {\n        return this._def.shape();\n    }\n    strict(message) {\n        errorUtil.errToObj;\n        return new ZodObject({\n            ...this._def,\n            unknownKeys: \"strict\",\n            ...(message !== undefined\n                ? {\n                    errorMap: (issue, ctx) => {\n                        const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;\n                        if (issue.code === \"unrecognized_keys\")\n                            return {\n                                message: errorUtil.errToObj(message).message ?? defaultError,\n                            };\n                        return {\n                            message: defaultError,\n                        };\n                    },\n                }\n                : {}),\n        });\n    }\n    strip() {\n        return new ZodObject({\n            ...this._def,\n            unknownKeys: \"strip\",\n        });\n    }\n    passthrough() {\n        return new ZodObject({\n            ...this._def,\n            unknownKeys: \"passthrough\",\n        });\n    }\n    // const AugmentFactory =\n    //   <Def extends ZodObjectDef>(def: Def) =>\n    //   <Augmentation extends ZodRawShape>(\n    //     augmentation: Augmentation\n    //   ): ZodObject<\n    //     extendShape<ReturnType<Def[\"shape\"]>, Augmentation>,\n    //     Def[\"unknownKeys\"],\n    //     Def[\"catchall\"]\n    //   > => {\n    //     return new ZodObject({\n    //       ...def,\n    //       shape: () => ({\n    //         ...def.shape(),\n    //         ...augmentation,\n    //       }),\n    //     }) as any;\n    //   };\n    extend(augmentation) {\n        return new ZodObject({\n            ...this._def,\n            shape: () => ({\n                ...this._def.shape(),\n                ...augmentation,\n            }),\n        });\n    }\n    /**\n     * Prior to zod@1.0.12 there was a bug in the\n     * inferred type of merged objects. Please\n     * upgrade if you are experiencing issues.\n     */\n    merge(merging) {\n        const merged = new ZodObject({\n            unknownKeys: merging._def.unknownKeys,\n            catchall: merging._def.catchall,\n            shape: () => ({\n                ...this._def.shape(),\n                ...merging._def.shape(),\n            }),\n            typeName: ZodFirstPartyTypeKind.ZodObject,\n        });\n        return merged;\n    }\n    // merge<\n    //   Incoming extends AnyZodObject,\n    //   Augmentation extends Incoming[\"shape\"],\n    //   NewOutput extends {\n    //     [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n    //       ? Augmentation[k][\"_output\"]\n    //       : k extends keyof Output\n    //       ? Output[k]\n    //       : never;\n    //   },\n    //   NewInput extends {\n    //     [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n    //       ? Augmentation[k][\"_input\"]\n    //       : k extends keyof Input\n    //       ? Input[k]\n    //       : never;\n    //   }\n    // >(\n    //   merging: Incoming\n    // ): ZodObject<\n    //   extendShape<T, ReturnType<Incoming[\"_def\"][\"shape\"]>>,\n    //   Incoming[\"_def\"][\"unknownKeys\"],\n    //   Incoming[\"_def\"][\"catchall\"],\n    //   NewOutput,\n    //   NewInput\n    // > {\n    //   const merged: any = new ZodObject({\n    //     unknownKeys: merging._def.unknownKeys,\n    //     catchall: merging._def.catchall,\n    //     shape: () =>\n    //       objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n    //     typeName: ZodFirstPartyTypeKind.ZodObject,\n    //   }) as any;\n    //   return merged;\n    // }\n    setKey(key, schema) {\n        return this.augment({ [key]: schema });\n    }\n    // merge<Incoming extends AnyZodObject>(\n    //   merging: Incoming\n    // ): //ZodObject<T & Incoming[\"_shape\"], UnknownKeys, Catchall> = (merging) => {\n    // ZodObject<\n    //   extendShape<T, ReturnType<Incoming[\"_def\"][\"shape\"]>>,\n    //   Incoming[\"_def\"][\"unknownKeys\"],\n    //   Incoming[\"_def\"][\"catchall\"]\n    // > {\n    //   // const mergedShape = objectUtil.mergeShapes(\n    //   //   this._def.shape(),\n    //   //   merging._def.shape()\n    //   // );\n    //   const merged: any = new ZodObject({\n    //     unknownKeys: merging._def.unknownKeys,\n    //     catchall: merging._def.catchall,\n    //     shape: () =>\n    //       objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n    //     typeName: ZodFirstPartyTypeKind.ZodObject,\n    //   }) as any;\n    //   return merged;\n    // }\n    catchall(index) {\n        return new ZodObject({\n            ...this._def,\n            catchall: index,\n        });\n    }\n    pick(mask) {\n        const shape = {};\n        for (const key of util.objectKeys(mask)) {\n            if (mask[key] && this.shape[key]) {\n                shape[key] = this.shape[key];\n            }\n        }\n        return new ZodObject({\n            ...this._def,\n            shape: () => shape,\n        });\n    }\n    omit(mask) {\n        const shape = {};\n        for (const key of util.objectKeys(this.shape)) {\n            if (!mask[key]) {\n                shape[key] = this.shape[key];\n            }\n        }\n        return new ZodObject({\n            ...this._def,\n            shape: () => shape,\n        });\n    }\n    /**\n     * @deprecated\n     */\n    deepPartial() {\n        return deepPartialify(this);\n    }\n    partial(mask) {\n        const newShape = {};\n        for (const key of util.objectKeys(this.shape)) {\n            const fieldSchema = this.shape[key];\n            if (mask && !mask[key]) {\n                newShape[key] = fieldSchema;\n            }\n            else {\n                newShape[key] = fieldSchema.optional();\n            }\n        }\n        return new ZodObject({\n            ...this._def,\n            shape: () => newShape,\n        });\n    }\n    required(mask) {\n        const newShape = {};\n        for (const key of util.objectKeys(this.shape)) {\n            if (mask && !mask[key]) {\n                newShape[key] = this.shape[key];\n            }\n            else {\n                const fieldSchema = this.shape[key];\n                let newField = fieldSchema;\n                while (newField instanceof ZodOptional) {\n                    newField = newField._def.innerType;\n                }\n                newShape[key] = newField;\n            }\n        }\n        return new ZodObject({\n            ...this._def,\n            shape: () => newShape,\n        });\n    }\n    keyof() {\n        return createZodEnum(util.objectKeys(this.shape));\n    }\n}\nZodObject.create = (shape, params) => {\n    return new ZodObject({\n        shape: () => shape,\n        unknownKeys: \"strip\",\n        catchall: ZodNever.create(),\n        typeName: ZodFirstPartyTypeKind.ZodObject,\n        ...processCreateParams(params),\n    });\n};\nZodObject.strictCreate = (shape, params) => {\n    return new ZodObject({\n        shape: () => shape,\n        unknownKeys: \"strict\",\n        catchall: ZodNever.create(),\n        typeName: ZodFirstPartyTypeKind.ZodObject,\n        ...processCreateParams(params),\n    });\n};\nZodObject.lazycreate = (shape, params) => {\n    return new ZodObject({\n        shape,\n        unknownKeys: \"strip\",\n        catchall: ZodNever.create(),\n        typeName: ZodFirstPartyTypeKind.ZodObject,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodUnion extends ZodType {\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        const options = this._def.options;\n        function handleResults(results) {\n            // return first issue-free validation if it exists\n            for (const result of results) {\n                if (result.result.status === \"valid\") {\n                    return result.result;\n                }\n            }\n            for (const result of results) {\n                if (result.result.status === \"dirty\") {\n                    // add issues from dirty option\n                    ctx.common.issues.push(...result.ctx.common.issues);\n                    return result.result;\n                }\n            }\n            // return invalid\n            const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_union,\n                unionErrors,\n            });\n            return INVALID;\n        }\n        if (ctx.common.async) {\n            return Promise.all(options.map(async (option) => {\n                const childCtx = {\n                    ...ctx,\n                    common: {\n                        ...ctx.common,\n                        issues: [],\n                    },\n                    parent: null,\n                };\n                return {\n                    result: await option._parseAsync({\n                        data: ctx.data,\n                        path: ctx.path,\n                        parent: childCtx,\n                    }),\n                    ctx: childCtx,\n                };\n            })).then(handleResults);\n        }\n        else {\n            let dirty = undefined;\n            const issues = [];\n            for (const option of options) {\n                const childCtx = {\n                    ...ctx,\n                    common: {\n                        ...ctx.common,\n                        issues: [],\n                    },\n                    parent: null,\n                };\n                const result = option._parseSync({\n                    data: ctx.data,\n                    path: ctx.path,\n                    parent: childCtx,\n                });\n                if (result.status === \"valid\") {\n                    return result;\n                }\n                else if (result.status === \"dirty\" && !dirty) {\n                    dirty = { result, ctx: childCtx };\n                }\n                if (childCtx.common.issues.length) {\n                    issues.push(childCtx.common.issues);\n                }\n            }\n            if (dirty) {\n                ctx.common.issues.push(...dirty.ctx.common.issues);\n                return dirty.result;\n            }\n            const unionErrors = issues.map((issues) => new ZodError(issues));\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_union,\n                unionErrors,\n            });\n            return INVALID;\n        }\n    }\n    get options() {\n        return this._def.options;\n    }\n}\nZodUnion.create = (types, params) => {\n    return new ZodUnion({\n        options: types,\n        typeName: ZodFirstPartyTypeKind.ZodUnion,\n        ...processCreateParams(params),\n    });\n};\n/////////////////////////////////////////////////////\n/////////////////////////////////////////////////////\n//////////                                 //////////\n//////////      ZodDiscriminatedUnion      //////////\n//////////                                 //////////\n/////////////////////////////////////////////////////\n/////////////////////////////////////////////////////\nconst getDiscriminator = (type) => {\n    if (type instanceof ZodLazy) {\n        return getDiscriminator(type.schema);\n    }\n    else if (type instanceof ZodEffects) {\n        return getDiscriminator(type.innerType());\n    }\n    else if (type instanceof ZodLiteral) {\n        return [type.value];\n    }\n    else if (type instanceof ZodEnum) {\n        return type.options;\n    }\n    else if (type instanceof ZodNativeEnum) {\n        // eslint-disable-next-line ban/ban\n        return util.objectValues(type.enum);\n    }\n    else if (type instanceof ZodDefault) {\n        return getDiscriminator(type._def.innerType);\n    }\n    else if (type instanceof ZodUndefined) {\n        return [undefined];\n    }\n    else if (type instanceof ZodNull) {\n        return [null];\n    }\n    else if (type instanceof ZodOptional) {\n        return [undefined, ...getDiscriminator(type.unwrap())];\n    }\n    else if (type instanceof ZodNullable) {\n        return [null, ...getDiscriminator(type.unwrap())];\n    }\n    else if (type instanceof ZodBranded) {\n        return getDiscriminator(type.unwrap());\n    }\n    else if (type instanceof ZodReadonly) {\n        return getDiscriminator(type.unwrap());\n    }\n    else if (type instanceof ZodCatch) {\n        return getDiscriminator(type._def.innerType);\n    }\n    else {\n        return [];\n    }\n};\nexport class ZodDiscriminatedUnion extends ZodType {\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.object) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.object,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const discriminator = this.discriminator;\n        const discriminatorValue = ctx.data[discriminator];\n        const option = this.optionsMap.get(discriminatorValue);\n        if (!option) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_union_discriminator,\n                options: Array.from(this.optionsMap.keys()),\n                path: [discriminator],\n            });\n            return INVALID;\n        }\n        if (ctx.common.async) {\n            return option._parseAsync({\n                data: ctx.data,\n                path: ctx.path,\n                parent: ctx,\n            });\n        }\n        else {\n            return option._parseSync({\n                data: ctx.data,\n                path: ctx.path,\n                parent: ctx,\n            });\n        }\n    }\n    get discriminator() {\n        return this._def.discriminator;\n    }\n    get options() {\n        return this._def.options;\n    }\n    get optionsMap() {\n        return this._def.optionsMap;\n    }\n    /**\n     * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.\n     * However, it only allows a union of objects, all of which need to share a discriminator property. This property must\n     * have a different value for each object in the union.\n     * @param discriminator the name of the discriminator property\n     * @param types an array of object schemas\n     * @param params\n     */\n    static create(discriminator, options, params) {\n        // Get all the valid discriminator values\n        const optionsMap = new Map();\n        // try {\n        for (const type of options) {\n            const discriminatorValues = getDiscriminator(type.shape[discriminator]);\n            if (!discriminatorValues.length) {\n                throw new Error(`A discriminator value for key \\`${discriminator}\\` could not be extracted from all schema options`);\n            }\n            for (const value of discriminatorValues) {\n                if (optionsMap.has(value)) {\n                    throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);\n                }\n                optionsMap.set(value, type);\n            }\n        }\n        return new ZodDiscriminatedUnion({\n            typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,\n            discriminator,\n            options,\n            optionsMap,\n            ...processCreateParams(params),\n        });\n    }\n}\nfunction mergeValues(a, b) {\n    const aType = getParsedType(a);\n    const bType = getParsedType(b);\n    if (a === b) {\n        return { valid: true, data: a };\n    }\n    else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {\n        const bKeys = util.objectKeys(b);\n        const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);\n        const newObj = { ...a, ...b };\n        if (Object.prototype.hasOwnProperty.call(newObj, \"__proto__\"))\n            delete newObj.__proto__;\n        for (const key of sharedKeys) {\n            if (key === \"__proto__\")\n                continue;\n            const sharedValue = mergeValues(a[key], b[key]);\n            if (!sharedValue.valid) {\n                return { valid: false };\n            }\n            newObj[key] = sharedValue.data;\n        }\n        return { valid: true, data: newObj };\n    }\n    else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {\n        if (a.length !== b.length) {\n            return { valid: false };\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 { valid: false };\n            }\n            newArray.push(sharedValue.data);\n        }\n        return { valid: true, data: newArray };\n    }\n    else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {\n        return { valid: true, data: a };\n    }\n    else {\n        return { valid: false };\n    }\n}\nexport class ZodIntersection extends ZodType {\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        const handleParsed = (parsedLeft, parsedRight) => {\n            if (isAborted(parsedLeft) || isAborted(parsedRight)) {\n                return INVALID;\n            }\n            const merged = mergeValues(parsedLeft.value, parsedRight.value);\n            if (!merged.valid) {\n                addIssueToContext(ctx, {\n                    code: ZodIssueCode.invalid_intersection_types,\n                });\n                return INVALID;\n            }\n            if (isDirty(parsedLeft) || isDirty(parsedRight)) {\n                status.dirty();\n            }\n            return { status: status.value, value: merged.data };\n        };\n        if (ctx.common.async) {\n            return Promise.all([\n                this._def.left._parseAsync({\n                    data: ctx.data,\n                    path: ctx.path,\n                    parent: ctx,\n                }),\n                this._def.right._parseAsync({\n                    data: ctx.data,\n                    path: ctx.path,\n                    parent: ctx,\n                }),\n            ]).then(([left, right]) => handleParsed(left, right));\n        }\n        else {\n            return handleParsed(this._def.left._parseSync({\n                data: ctx.data,\n                path: ctx.path,\n                parent: ctx,\n            }), this._def.right._parseSync({\n                data: ctx.data,\n                path: ctx.path,\n                parent: ctx,\n            }));\n        }\n    }\n}\nZodIntersection.create = (left, right, params) => {\n    return new ZodIntersection({\n        left: left,\n        right: right,\n        typeName: ZodFirstPartyTypeKind.ZodIntersection,\n        ...processCreateParams(params),\n    });\n};\n// type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];\nexport class ZodTuple extends ZodType {\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.array) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.array,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        if (ctx.data.length < this._def.items.length) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.too_small,\n                minimum: this._def.items.length,\n                inclusive: true,\n                exact: false,\n                type: \"array\",\n            });\n            return INVALID;\n        }\n        const rest = this._def.rest;\n        if (!rest && ctx.data.length > this._def.items.length) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.too_big,\n                maximum: this._def.items.length,\n                inclusive: true,\n                exact: false,\n                type: \"array\",\n            });\n            status.dirty();\n        }\n        const items = [...ctx.data]\n            .map((item, itemIndex) => {\n            const schema = this._def.items[itemIndex] || this._def.rest;\n            if (!schema)\n                return null;\n            return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));\n        })\n            .filter((x) => !!x); // filter nulls\n        if (ctx.common.async) {\n            return Promise.all(items).then((results) => {\n                return ParseStatus.mergeArray(status, results);\n            });\n        }\n        else {\n            return ParseStatus.mergeArray(status, items);\n        }\n    }\n    get items() {\n        return this._def.items;\n    }\n    rest(rest) {\n        return new ZodTuple({\n            ...this._def,\n            rest,\n        });\n    }\n}\nZodTuple.create = (schemas, params) => {\n    if (!Array.isArray(schemas)) {\n        throw new Error(\"You must pass an array of schemas to z.tuple([ ... ])\");\n    }\n    return new ZodTuple({\n        items: schemas,\n        typeName: ZodFirstPartyTypeKind.ZodTuple,\n        rest: null,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodRecord extends ZodType {\n    get keySchema() {\n        return this._def.keyType;\n    }\n    get valueSchema() {\n        return this._def.valueType;\n    }\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.object) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.object,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const pairs = [];\n        const keyType = this._def.keyType;\n        const valueType = this._def.valueType;\n        for (const key in ctx.data) {\n            pairs.push({\n                key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),\n                value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),\n                alwaysSet: key in ctx.data,\n            });\n        }\n        if (ctx.common.async) {\n            return ParseStatus.mergeObjectAsync(status, pairs);\n        }\n        else {\n            return ParseStatus.mergeObjectSync(status, pairs);\n        }\n    }\n    get element() {\n        return this._def.valueType;\n    }\n    static create(first, second, third) {\n        if (second instanceof ZodType) {\n            return new ZodRecord({\n                keyType: first,\n                valueType: second,\n                typeName: ZodFirstPartyTypeKind.ZodRecord,\n                ...processCreateParams(third),\n            });\n        }\n        return new ZodRecord({\n            keyType: ZodString.create(),\n            valueType: first,\n            typeName: ZodFirstPartyTypeKind.ZodRecord,\n            ...processCreateParams(second),\n        });\n    }\n}\nexport class ZodMap extends ZodType {\n    get keySchema() {\n        return this._def.keyType;\n    }\n    get valueSchema() {\n        return this._def.valueType;\n    }\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.map) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.map,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const keyType = this._def.keyType;\n        const valueType = this._def.valueType;\n        const pairs = [...ctx.data.entries()].map(([key, value], index) => {\n            return {\n                key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, \"key\"])),\n                value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, \"value\"])),\n            };\n        });\n        if (ctx.common.async) {\n            const finalMap = new Map();\n            return Promise.resolve().then(async () => {\n                for (const pair of pairs) {\n                    const key = await pair.key;\n                    const value = await pair.value;\n                    if (key.status === \"aborted\" || value.status === \"aborted\") {\n                        return INVALID;\n                    }\n                    if (key.status === \"dirty\" || value.status === \"dirty\") {\n                        status.dirty();\n                    }\n                    finalMap.set(key.value, value.value);\n                }\n                return { status: status.value, value: finalMap };\n            });\n        }\n        else {\n            const finalMap = new Map();\n            for (const pair of pairs) {\n                const key = pair.key;\n                const value = pair.value;\n                if (key.status === \"aborted\" || value.status === \"aborted\") {\n                    return INVALID;\n                }\n                if (key.status === \"dirty\" || value.status === \"dirty\") {\n                    status.dirty();\n                }\n                finalMap.set(key.value, value.value);\n            }\n            return { status: status.value, value: finalMap };\n        }\n    }\n}\nZodMap.create = (keyType, valueType, params) => {\n    return new ZodMap({\n        valueType,\n        keyType,\n        typeName: ZodFirstPartyTypeKind.ZodMap,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodSet extends ZodType {\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.set) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.set,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const def = this._def;\n        if (def.minSize !== null) {\n            if (ctx.data.size < def.minSize.value) {\n                addIssueToContext(ctx, {\n                    code: ZodIssueCode.too_small,\n                    minimum: def.minSize.value,\n                    type: \"set\",\n                    inclusive: true,\n                    exact: false,\n                    message: def.minSize.message,\n                });\n                status.dirty();\n            }\n        }\n        if (def.maxSize !== null) {\n            if (ctx.data.size > def.maxSize.value) {\n                addIssueToContext(ctx, {\n                    code: ZodIssueCode.too_big,\n                    maximum: def.maxSize.value,\n                    type: \"set\",\n                    inclusive: true,\n                    exact: false,\n                    message: def.maxSize.message,\n                });\n                status.dirty();\n            }\n        }\n        const valueType = this._def.valueType;\n        function finalizeSet(elements) {\n            const parsedSet = new Set();\n            for (const element of elements) {\n                if (element.status === \"aborted\")\n                    return INVALID;\n                if (element.status === \"dirty\")\n                    status.dirty();\n                parsedSet.add(element.value);\n            }\n            return { status: status.value, value: parsedSet };\n        }\n        const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));\n        if (ctx.common.async) {\n            return Promise.all(elements).then((elements) => finalizeSet(elements));\n        }\n        else {\n            return finalizeSet(elements);\n        }\n    }\n    min(minSize, message) {\n        return new ZodSet({\n            ...this._def,\n            minSize: { value: minSize, message: errorUtil.toString(message) },\n        });\n    }\n    max(maxSize, message) {\n        return new ZodSet({\n            ...this._def,\n            maxSize: { value: maxSize, message: errorUtil.toString(message) },\n        });\n    }\n    size(size, message) {\n        return this.min(size, message).max(size, message);\n    }\n    nonempty(message) {\n        return this.min(1, message);\n    }\n}\nZodSet.create = (valueType, params) => {\n    return new ZodSet({\n        valueType,\n        minSize: null,\n        maxSize: null,\n        typeName: ZodFirstPartyTypeKind.ZodSet,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodFunction extends ZodType {\n    constructor() {\n        super(...arguments);\n        this.validate = this.implement;\n    }\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.function) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.function,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        function makeArgsIssue(args, error) {\n            return makeIssue({\n                data: args,\n                path: ctx.path,\n                errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), defaultErrorMap].filter((x) => !!x),\n                issueData: {\n                    code: ZodIssueCode.invalid_arguments,\n                    argumentsError: error,\n                },\n            });\n        }\n        function makeReturnsIssue(returns, error) {\n            return makeIssue({\n                data: returns,\n                path: ctx.path,\n                errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), defaultErrorMap].filter((x) => !!x),\n                issueData: {\n                    code: ZodIssueCode.invalid_return_type,\n                    returnTypeError: error,\n                },\n            });\n        }\n        const params = { errorMap: ctx.common.contextualErrorMap };\n        const fn = ctx.data;\n        if (this._def.returns instanceof ZodPromise) {\n            // Would love a way to avoid disabling this rule, but we need an alias (using an arrow function was what caused 2651).\n            // eslint-disable-next-line @typescript-eslint/no-this-alias\n            const me = this;\n            return OK(async function (...args) {\n                const error = new ZodError([]);\n                const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {\n                    error.addIssue(makeArgsIssue(args, e));\n                    throw error;\n                });\n                const result = await Reflect.apply(fn, this, parsedArgs);\n                const parsedReturns = await me._def.returns._def.type\n                    .parseAsync(result, params)\n                    .catch((e) => {\n                    error.addIssue(makeReturnsIssue(result, e));\n                    throw error;\n                });\n                return parsedReturns;\n            });\n        }\n        else {\n            // Would love a way to avoid disabling this rule, but we need an alias (using an arrow function was what caused 2651).\n            // eslint-disable-next-line @typescript-eslint/no-this-alias\n            const me = this;\n            return OK(function (...args) {\n                const parsedArgs = me._def.args.safeParse(args, params);\n                if (!parsedArgs.success) {\n                    throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);\n                }\n                const result = Reflect.apply(fn, this, parsedArgs.data);\n                const parsedReturns = me._def.returns.safeParse(result, params);\n                if (!parsedReturns.success) {\n                    throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);\n                }\n                return parsedReturns.data;\n            });\n        }\n    }\n    parameters() {\n        return this._def.args;\n    }\n    returnType() {\n        return this._def.returns;\n    }\n    args(...items) {\n        return new ZodFunction({\n            ...this._def,\n            args: ZodTuple.create(items).rest(ZodUnknown.create()),\n        });\n    }\n    returns(returnType) {\n        return new ZodFunction({\n            ...this._def,\n            returns: returnType,\n        });\n    }\n    implement(func) {\n        const validatedFunc = this.parse(func);\n        return validatedFunc;\n    }\n    strictImplement(func) {\n        const validatedFunc = this.parse(func);\n        return validatedFunc;\n    }\n    static create(args, returns, params) {\n        return new ZodFunction({\n            args: (args ? args : ZodTuple.create([]).rest(ZodUnknown.create())),\n            returns: returns || ZodUnknown.create(),\n            typeName: ZodFirstPartyTypeKind.ZodFunction,\n            ...processCreateParams(params),\n        });\n    }\n}\nexport class ZodLazy extends ZodType {\n    get schema() {\n        return this._def.getter();\n    }\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        const lazySchema = this._def.getter();\n        return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });\n    }\n}\nZodLazy.create = (getter, params) => {\n    return new ZodLazy({\n        getter: getter,\n        typeName: ZodFirstPartyTypeKind.ZodLazy,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodLiteral extends ZodType {\n    _parse(input) {\n        if (input.data !== this._def.value) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                received: ctx.data,\n                code: ZodIssueCode.invalid_literal,\n                expected: this._def.value,\n            });\n            return INVALID;\n        }\n        return { status: \"valid\", value: input.data };\n    }\n    get value() {\n        return this._def.value;\n    }\n}\nZodLiteral.create = (value, params) => {\n    return new ZodLiteral({\n        value: value,\n        typeName: ZodFirstPartyTypeKind.ZodLiteral,\n        ...processCreateParams(params),\n    });\n};\nfunction createZodEnum(values, params) {\n    return new ZodEnum({\n        values,\n        typeName: ZodFirstPartyTypeKind.ZodEnum,\n        ...processCreateParams(params),\n    });\n}\nexport class ZodEnum extends ZodType {\n    _parse(input) {\n        if (typeof input.data !== \"string\") {\n            const ctx = this._getOrReturnCtx(input);\n            const expectedValues = this._def.values;\n            addIssueToContext(ctx, {\n                expected: util.joinValues(expectedValues),\n                received: ctx.parsedType,\n                code: ZodIssueCode.invalid_type,\n            });\n            return INVALID;\n        }\n        if (!this._cache) {\n            this._cache = new Set(this._def.values);\n        }\n        if (!this._cache.has(input.data)) {\n            const ctx = this._getOrReturnCtx(input);\n            const expectedValues = this._def.values;\n            addIssueToContext(ctx, {\n                received: ctx.data,\n                code: ZodIssueCode.invalid_enum_value,\n                options: expectedValues,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n    get options() {\n        return this._def.values;\n    }\n    get enum() {\n        const enumValues = {};\n        for (const val of this._def.values) {\n            enumValues[val] = val;\n        }\n        return enumValues;\n    }\n    get Values() {\n        const enumValues = {};\n        for (const val of this._def.values) {\n            enumValues[val] = val;\n        }\n        return enumValues;\n    }\n    get Enum() {\n        const enumValues = {};\n        for (const val of this._def.values) {\n            enumValues[val] = val;\n        }\n        return enumValues;\n    }\n    extract(values, newDef = this._def) {\n        return ZodEnum.create(values, {\n            ...this._def,\n            ...newDef,\n        });\n    }\n    exclude(values, newDef = this._def) {\n        return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {\n            ...this._def,\n            ...newDef,\n        });\n    }\n}\nZodEnum.create = createZodEnum;\nexport class ZodNativeEnum extends ZodType {\n    _parse(input) {\n        const nativeEnumValues = util.getValidEnumValues(this._def.values);\n        const ctx = this._getOrReturnCtx(input);\n        if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {\n            const expectedValues = util.objectValues(nativeEnumValues);\n            addIssueToContext(ctx, {\n                expected: util.joinValues(expectedValues),\n                received: ctx.parsedType,\n                code: ZodIssueCode.invalid_type,\n            });\n            return INVALID;\n        }\n        if (!this._cache) {\n            this._cache = new Set(util.getValidEnumValues(this._def.values));\n        }\n        if (!this._cache.has(input.data)) {\n            const expectedValues = util.objectValues(nativeEnumValues);\n            addIssueToContext(ctx, {\n                received: ctx.data,\n                code: ZodIssueCode.invalid_enum_value,\n                options: expectedValues,\n            });\n            return INVALID;\n        }\n        return OK(input.data);\n    }\n    get enum() {\n        return this._def.values;\n    }\n}\nZodNativeEnum.create = (values, params) => {\n    return new ZodNativeEnum({\n        values: values,\n        typeName: ZodFirstPartyTypeKind.ZodNativeEnum,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodPromise extends ZodType {\n    unwrap() {\n        return this._def.type;\n    }\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.promise,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);\n        return OK(promisified.then((data) => {\n            return this._def.type.parseAsync(data, {\n                path: ctx.path,\n                errorMap: ctx.common.contextualErrorMap,\n            });\n        }));\n    }\n}\nZodPromise.create = (schema, params) => {\n    return new ZodPromise({\n        type: schema,\n        typeName: ZodFirstPartyTypeKind.ZodPromise,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodEffects extends ZodType {\n    innerType() {\n        return this._def.schema;\n    }\n    sourceType() {\n        return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects\n            ? this._def.schema.sourceType()\n            : this._def.schema;\n    }\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        const effect = this._def.effect || null;\n        const checkCtx = {\n            addIssue: (arg) => {\n                addIssueToContext(ctx, arg);\n                if (arg.fatal) {\n                    status.abort();\n                }\n                else {\n                    status.dirty();\n                }\n            },\n            get path() {\n                return ctx.path;\n            },\n        };\n        checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);\n        if (effect.type === \"preprocess\") {\n            const processed = effect.transform(ctx.data, checkCtx);\n            if (ctx.common.async) {\n                return Promise.resolve(processed).then(async (processed) => {\n                    if (status.value === \"aborted\")\n                        return INVALID;\n                    const result = await this._def.schema._parseAsync({\n                        data: processed,\n                        path: ctx.path,\n                        parent: ctx,\n                    });\n                    if (result.status === \"aborted\")\n                        return INVALID;\n                    if (result.status === \"dirty\")\n                        return DIRTY(result.value);\n                    if (status.value === \"dirty\")\n                        return DIRTY(result.value);\n                    return result;\n                });\n            }\n            else {\n                if (status.value === \"aborted\")\n                    return INVALID;\n                const result = this._def.schema._parseSync({\n                    data: processed,\n                    path: ctx.path,\n                    parent: ctx,\n                });\n                if (result.status === \"aborted\")\n                    return INVALID;\n                if (result.status === \"dirty\")\n                    return DIRTY(result.value);\n                if (status.value === \"dirty\")\n                    return DIRTY(result.value);\n                return result;\n            }\n        }\n        if (effect.type === \"refinement\") {\n            const executeRefinement = (acc) => {\n                const result = effect.refinement(acc, checkCtx);\n                if (ctx.common.async) {\n                    return Promise.resolve(result);\n                }\n                if (result instanceof Promise) {\n                    throw new Error(\"Async refinement encountered during synchronous parse operation. Use .parseAsync instead.\");\n                }\n                return acc;\n            };\n            if (ctx.common.async === false) {\n                const inner = this._def.schema._parseSync({\n                    data: ctx.data,\n                    path: ctx.path,\n                    parent: ctx,\n                });\n                if (inner.status === \"aborted\")\n                    return INVALID;\n                if (inner.status === \"dirty\")\n                    status.dirty();\n                // return value is ignored\n                executeRefinement(inner.value);\n                return { status: status.value, value: inner.value };\n            }\n            else {\n                return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {\n                    if (inner.status === \"aborted\")\n                        return INVALID;\n                    if (inner.status === \"dirty\")\n                        status.dirty();\n                    return executeRefinement(inner.value).then(() => {\n                        return { status: status.value, value: inner.value };\n                    });\n                });\n            }\n        }\n        if (effect.type === \"transform\") {\n            if (ctx.common.async === false) {\n                const base = this._def.schema._parseSync({\n                    data: ctx.data,\n                    path: ctx.path,\n                    parent: ctx,\n                });\n                if (!isValid(base))\n                    return INVALID;\n                const result = effect.transform(base.value, checkCtx);\n                if (result instanceof Promise) {\n                    throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);\n                }\n                return { status: status.value, value: result };\n            }\n            else {\n                return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {\n                    if (!isValid(base))\n                        return INVALID;\n                    return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({\n                        status: status.value,\n                        value: result,\n                    }));\n                });\n            }\n        }\n        util.assertNever(effect);\n    }\n}\nZodEffects.create = (schema, effect, params) => {\n    return new ZodEffects({\n        schema,\n        typeName: ZodFirstPartyTypeKind.ZodEffects,\n        effect,\n        ...processCreateParams(params),\n    });\n};\nZodEffects.createWithPreprocess = (preprocess, schema, params) => {\n    return new ZodEffects({\n        schema,\n        effect: { type: \"preprocess\", transform: preprocess },\n        typeName: ZodFirstPartyTypeKind.ZodEffects,\n        ...processCreateParams(params),\n    });\n};\nexport { ZodEffects as ZodTransformer };\nexport class ZodOptional extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType === ZodParsedType.undefined) {\n            return OK(undefined);\n        }\n        return this._def.innerType._parse(input);\n    }\n    unwrap() {\n        return this._def.innerType;\n    }\n}\nZodOptional.create = (type, params) => {\n    return new ZodOptional({\n        innerType: type,\n        typeName: ZodFirstPartyTypeKind.ZodOptional,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodNullable extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType === ZodParsedType.null) {\n            return OK(null);\n        }\n        return this._def.innerType._parse(input);\n    }\n    unwrap() {\n        return this._def.innerType;\n    }\n}\nZodNullable.create = (type, params) => {\n    return new ZodNullable({\n        innerType: type,\n        typeName: ZodFirstPartyTypeKind.ZodNullable,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodDefault extends ZodType {\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        let data = ctx.data;\n        if (ctx.parsedType === ZodParsedType.undefined) {\n            data = this._def.defaultValue();\n        }\n        return this._def.innerType._parse({\n            data,\n            path: ctx.path,\n            parent: ctx,\n        });\n    }\n    removeDefault() {\n        return this._def.innerType;\n    }\n}\nZodDefault.create = (type, params) => {\n    return new ZodDefault({\n        innerType: type,\n        typeName: ZodFirstPartyTypeKind.ZodDefault,\n        defaultValue: typeof params.default === \"function\" ? params.default : () => params.default,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodCatch extends ZodType {\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        // newCtx is used to not collect issues from inner types in ctx\n        const newCtx = {\n            ...ctx,\n            common: {\n                ...ctx.common,\n                issues: [],\n            },\n        };\n        const result = this._def.innerType._parse({\n            data: newCtx.data,\n            path: newCtx.path,\n            parent: {\n                ...newCtx,\n            },\n        });\n        if (isAsync(result)) {\n            return result.then((result) => {\n                return {\n                    status: \"valid\",\n                    value: result.status === \"valid\"\n                        ? result.value\n                        : this._def.catchValue({\n                            get error() {\n                                return new ZodError(newCtx.common.issues);\n                            },\n                            input: newCtx.data,\n                        }),\n                };\n            });\n        }\n        else {\n            return {\n                status: \"valid\",\n                value: result.status === \"valid\"\n                    ? result.value\n                    : this._def.catchValue({\n                        get error() {\n                            return new ZodError(newCtx.common.issues);\n                        },\n                        input: newCtx.data,\n                    }),\n            };\n        }\n    }\n    removeCatch() {\n        return this._def.innerType;\n    }\n}\nZodCatch.create = (type, params) => {\n    return new ZodCatch({\n        innerType: type,\n        typeName: ZodFirstPartyTypeKind.ZodCatch,\n        catchValue: typeof params.catch === \"function\" ? params.catch : () => params.catch,\n        ...processCreateParams(params),\n    });\n};\nexport class ZodNaN extends ZodType {\n    _parse(input) {\n        const parsedType = this._getType(input);\n        if (parsedType !== ZodParsedType.nan) {\n            const ctx = this._getOrReturnCtx(input);\n            addIssueToContext(ctx, {\n                code: ZodIssueCode.invalid_type,\n                expected: ZodParsedType.nan,\n                received: ctx.parsedType,\n            });\n            return INVALID;\n        }\n        return { status: \"valid\", value: input.data };\n    }\n}\nZodNaN.create = (params) => {\n    return new ZodNaN({\n        typeName: ZodFirstPartyTypeKind.ZodNaN,\n        ...processCreateParams(params),\n    });\n};\nexport const BRAND = Symbol(\"zod_brand\");\nexport class ZodBranded extends ZodType {\n    _parse(input) {\n        const { ctx } = this._processInputParams(input);\n        const data = ctx.data;\n        return this._def.type._parse({\n            data,\n            path: ctx.path,\n            parent: ctx,\n        });\n    }\n    unwrap() {\n        return this._def.type;\n    }\n}\nexport class ZodPipeline extends ZodType {\n    _parse(input) {\n        const { status, ctx } = this._processInputParams(input);\n        if (ctx.common.async) {\n            const handleAsync = async () => {\n                const inResult = await this._def.in._parseAsync({\n                    data: ctx.data,\n                    path: ctx.path,\n                    parent: ctx,\n                });\n                if (inResult.status === \"aborted\")\n                    return INVALID;\n                if (inResult.status === \"dirty\") {\n                    status.dirty();\n                    return DIRTY(inResult.value);\n                }\n                else {\n                    return this._def.out._parseAsync({\n                        data: inResult.value,\n                        path: ctx.path,\n                        parent: ctx,\n                    });\n                }\n            };\n            return handleAsync();\n        }\n        else {\n            const inResult = this._def.in._parseSync({\n                data: ctx.data,\n                path: ctx.path,\n                parent: ctx,\n            });\n            if (inResult.status === \"aborted\")\n                return INVALID;\n            if (inResult.status === \"dirty\") {\n                status.dirty();\n                return {\n                    status: \"dirty\",\n                    value: inResult.value,\n                };\n            }\n            else {\n                return this._def.out._parseSync({\n                    data: inResult.value,\n                    path: ctx.path,\n                    parent: ctx,\n                });\n            }\n        }\n    }\n    static create(a, b) {\n        return new ZodPipeline({\n            in: a,\n            out: b,\n            typeName: ZodFirstPartyTypeKind.ZodPipeline,\n        });\n    }\n}\nexport class ZodReadonly extends ZodType {\n    _parse(input) {\n        const result = this._def.innerType._parse(input);\n        const freeze = (data) => {\n            if (isValid(data)) {\n                data.value = Object.freeze(data.value);\n            }\n            return data;\n        };\n        return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);\n    }\n    unwrap() {\n        return this._def.innerType;\n    }\n}\nZodReadonly.create = (type, params) => {\n    return new ZodReadonly({\n        innerType: type,\n        typeName: ZodFirstPartyTypeKind.ZodReadonly,\n        ...processCreateParams(params),\n    });\n};\n////////////////////////////////////////\n////////////////////////////////////////\n//////////                    //////////\n//////////      z.custom      //////////\n//////////                    //////////\n////////////////////////////////////////\n////////////////////////////////////////\nfunction cleanParams(params, data) {\n    const p = typeof params === \"function\" ? params(data) : typeof params === \"string\" ? { message: params } : params;\n    const p2 = typeof p === \"string\" ? { message: p } : p;\n    return p2;\n}\nexport function custom(check, _params = {}, \n/**\n * @deprecated\n *\n * Pass `fatal` into the params object instead:\n *\n * ```ts\n * z.string().custom((val) => val.length > 5, { fatal: false })\n * ```\n *\n */\nfatal) {\n    if (check)\n        return ZodAny.create().superRefine((data, ctx) => {\n            const r = check(data);\n            if (r instanceof Promise) {\n                return r.then((r) => {\n                    if (!r) {\n                        const params = cleanParams(_params, data);\n                        const _fatal = params.fatal ?? fatal ?? true;\n                        ctx.addIssue({ code: \"custom\", ...params, fatal: _fatal });\n                    }\n                });\n            }\n            if (!r) {\n                const params = cleanParams(_params, data);\n                const _fatal = params.fatal ?? fatal ?? true;\n                ctx.addIssue({ code: \"custom\", ...params, fatal: _fatal });\n            }\n            return;\n        });\n    return ZodAny.create();\n}\nexport { ZodType as Schema, ZodType as ZodSchema };\nexport const late = {\n    object: ZodObject.lazycreate,\n};\nexport var ZodFirstPartyTypeKind;\n(function (ZodFirstPartyTypeKind) {\n    ZodFirstPartyTypeKind[\"ZodString\"] = \"ZodString\";\n    ZodFirstPartyTypeKind[\"ZodNumber\"] = \"ZodNumber\";\n    ZodFirstPartyTypeKind[\"ZodNaN\"] = \"ZodNaN\";\n    ZodFirstPartyTypeKind[\"ZodBigInt\"] = \"ZodBigInt\";\n    ZodFirstPartyTypeKind[\"ZodBoolean\"] = \"ZodBoolean\";\n    ZodFirstPartyTypeKind[\"ZodDate\"] = \"ZodDate\";\n    ZodFirstPartyTypeKind[\"ZodSymbol\"] = \"ZodSymbol\";\n    ZodFirstPartyTypeKind[\"ZodUndefined\"] = \"ZodUndefined\";\n    ZodFirstPartyTypeKind[\"ZodNull\"] = \"ZodNull\";\n    ZodFirstPartyTypeKind[\"ZodAny\"] = \"ZodAny\";\n    ZodFirstPartyTypeKind[\"ZodUnknown\"] = \"ZodUnknown\";\n    ZodFirstPartyTypeKind[\"ZodNever\"] = \"ZodNever\";\n    ZodFirstPartyTypeKind[\"ZodVoid\"] = \"ZodVoid\";\n    ZodFirstPartyTypeKind[\"ZodArray\"] = \"ZodArray\";\n    ZodFirstPartyTypeKind[\"ZodObject\"] = \"ZodObject\";\n    ZodFirstPartyTypeKind[\"ZodUnion\"] = \"ZodUnion\";\n    ZodFirstPartyTypeKind[\"ZodDiscriminatedUnion\"] = \"ZodDiscriminatedUnion\";\n    ZodFirstPartyTypeKind[\"ZodIntersection\"] = \"ZodIntersection\";\n    ZodFirstPartyTypeKind[\"ZodTuple\"] = \"ZodTuple\";\n    ZodFirstPartyTypeKind[\"ZodRecord\"] = \"ZodRecord\";\n    ZodFirstPartyTypeKind[\"ZodMap\"] = \"ZodMap\";\n    ZodFirstPartyTypeKind[\"ZodSet\"] = \"ZodSet\";\n    ZodFirstPartyTypeKind[\"ZodFunction\"] = \"ZodFunction\";\n    ZodFirstPartyTypeKind[\"ZodLazy\"] = \"ZodLazy\";\n    ZodFirstPartyTypeKind[\"ZodLiteral\"] = \"ZodLiteral\";\n    ZodFirstPartyTypeKind[\"ZodEnum\"] = \"ZodEnum\";\n    ZodFirstPartyTypeKind[\"ZodEffects\"] = \"ZodEffects\";\n    ZodFirstPartyTypeKind[\"ZodNativeEnum\"] = \"ZodNativeEnum\";\n    ZodFirstPartyTypeKind[\"ZodOptional\"] = \"ZodOptional\";\n    ZodFirstPartyTypeKind[\"ZodNullable\"] = \"ZodNullable\";\n    ZodFirstPartyTypeKind[\"ZodDefault\"] = \"ZodDefault\";\n    ZodFirstPartyTypeKind[\"ZodCatch\"] = \"ZodCatch\";\n    ZodFirstPartyTypeKind[\"ZodPromise\"] = \"ZodPromise\";\n    ZodFirstPartyTypeKind[\"ZodBranded\"] = \"ZodBranded\";\n    ZodFirstPartyTypeKind[\"ZodPipeline\"] = \"ZodPipeline\";\n    ZodFirstPartyTypeKind[\"ZodReadonly\"] = \"ZodReadonly\";\n})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));\n// requires TS 4.4+\nclass Class {\n    constructor(..._) { }\n}\nconst instanceOfType = (\n// const instanceOfType = <T extends new (...args: any[]) => any>(\ncls, params = {\n    message: `Input not instance of ${cls.name}`,\n}) => custom((data) => data instanceof cls, params);\nconst stringType = ZodString.create;\nconst numberType = ZodNumber.create;\nconst nanType = ZodNaN.create;\nconst bigIntType = ZodBigInt.create;\nconst booleanType = ZodBoolean.create;\nconst dateType = ZodDate.create;\nconst symbolType = ZodSymbol.create;\nconst undefinedType = ZodUndefined.create;\nconst nullType = ZodNull.create;\nconst anyType = ZodAny.create;\nconst unknownType = ZodUnknown.create;\nconst neverType = ZodNever.create;\nconst voidType = ZodVoid.create;\nconst arrayType = ZodArray.create;\nconst objectType = ZodObject.create;\nconst strictObjectType = ZodObject.strictCreate;\nconst unionType = ZodUnion.create;\nconst discriminatedUnionType = ZodDiscriminatedUnion.create;\nconst intersectionType = ZodIntersection.create;\nconst tupleType = ZodTuple.create;\nconst recordType = ZodRecord.create;\nconst mapType = ZodMap.create;\nconst setType = ZodSet.create;\nconst functionType = ZodFunction.create;\nconst lazyType = ZodLazy.create;\nconst literalType = ZodLiteral.create;\nconst enumType = ZodEnum.create;\nconst nativeEnumType = ZodNativeEnum.create;\nconst promiseType = ZodPromise.create;\nconst effectsType = ZodEffects.create;\nconst optionalType = ZodOptional.create;\nconst nullableType = ZodNullable.create;\nconst preprocessType = ZodEffects.createWithPreprocess;\nconst pipelineType = ZodPipeline.create;\nconst ostring = () => stringType().optional();\nconst onumber = () => numberType().optional();\nconst oboolean = () => booleanType().optional();\nexport const coerce = {\n    string: ((arg) => ZodString.create({ ...arg, coerce: true })),\n    number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),\n    boolean: ((arg) => ZodBoolean.create({\n        ...arg,\n        coerce: true,\n    })),\n    bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),\n    date: ((arg) => ZodDate.create({ ...arg, coerce: true })),\n};\nexport { anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, dateType as date, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, instanceOfType as instanceof, intersectionType as intersection, lazyType as lazy, literalType as literal, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, recordType as record, setType as set, strictObjectType as strictObject, stringType as string, symbolType as symbol, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, };\nexport const NEVER = INVALID;\n","import * as z4 from \"zod/v4\";\nimport { ZodFirstPartyTypeKind } from \"zod/v3\";\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider/2.0.5/2c8283d13e9eb4f0e5a1ac47681372d3f46a500d1f90320b75e3c03a424c2390/node_modules/@ai-sdk/provider/dist/index.mjs\nvar marker$1 = \"vercel.ai.error\";\nvar symbol$1 = Symbol.for(marker$1);\nvar _a$1;\nvar _b$1;\nvar AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1) {\n\t/**\n\t* Creates an AI SDK Error.\n\t*\n\t* @param {Object} params - The parameters for creating the error.\n\t* @param {string} params.name - The name of the error.\n\t* @param {string} params.message - The error message.\n\t* @param {unknown} [params.cause] - The underlying cause of the error.\n\t*/\n\tconstructor({ name: name14, message, cause }) {\n\t\tsuper(message);\n\t\tthis[_a$1] = true;\n\t\tthis.name = name14;\n\t\tthis.cause = cause;\n\t}\n\t/**\n\t* Checks if the given error is an AI SDK Error.\n\t* @param {unknown} error - The error to check.\n\t* @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n\t*/\n\tstatic isInstance(error) {\n\t\treturn _AISDKError.hasMarker(error, marker$1);\n\t}\n\tstatic hasMarker(error, marker15) {\n\t\tconst markerSymbol = Symbol.for(marker15);\n\t\treturn error != null && typeof error === \"object\" && markerSymbol in error && typeof error[markerSymbol] === \"boolean\" && error[markerSymbol] === true;\n\t}\n};\nvar name$1 = \"AI_APICallError\";\nvar marker2 = `vercel.ai.error.${name$1}`;\nvar symbol2 = Symbol.for(marker2);\nvar _a2;\nvar _b2;\nvar APICallError = class extends (_b2 = AISDKError, _a2 = symbol2, _b2) {\n\tconstructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {\n\t\tsuper({\n\t\t\tname: name$1,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a2] = true;\n\t\tthis.url = url;\n\t\tthis.requestBodyValues = requestBodyValues;\n\t\tthis.statusCode = statusCode;\n\t\tthis.responseHeaders = responseHeaders;\n\t\tthis.responseBody = responseBody;\n\t\tthis.isRetryable = isRetryable;\n\t\tthis.data = data;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker2);\n\t}\n};\nvar name2 = \"AI_EmptyResponseBodyError\";\nvar marker3 = `vercel.ai.error.${name2}`;\nvar symbol3 = Symbol.for(marker3);\nvar _a3;\nvar _b3;\nvar EmptyResponseBodyError = class extends (_b3 = AISDKError, _a3 = symbol3, _b3) {\n\tconstructor({ message = \"Empty response body\" } = {}) {\n\t\tsuper({\n\t\t\tname: name2,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a3] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker3);\n\t}\n};\nfunction getErrorMessage$1(error) {\n\tif (error == null) return \"unknown error\";\n\tif (typeof error === \"string\") return error;\n\tif (error instanceof Error) return error.message;\n\treturn JSON.stringify(error);\n}\nvar name3 = \"AI_InvalidArgumentError\";\nvar marker4 = `vercel.ai.error.${name3}`;\nvar symbol4 = Symbol.for(marker4);\nvar _a4;\nvar _b4;\nvar InvalidArgumentError = class extends (_b4 = AISDKError, _a4 = symbol4, _b4) {\n\tconstructor({ message, cause, argument }) {\n\t\tsuper({\n\t\t\tname: name3,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a4] = true;\n\t\tthis.argument = argument;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker4);\n\t}\n};\nvar name4 = \"AI_InvalidPromptError\";\nvar marker5 = `vercel.ai.error.${name4}`;\nvar symbol5 = Symbol.for(marker5);\nvar _a5;\nvar _b5;\nvar InvalidPromptError = class extends (_b5 = AISDKError, _a5 = symbol5, _b5) {\n\tconstructor({ prompt, message, cause }) {\n\t\tsuper({\n\t\t\tname: name4,\n\t\t\tmessage: `Invalid prompt: ${message}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a5] = true;\n\t\tthis.prompt = prompt;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker5);\n\t}\n};\nvar name5 = \"AI_InvalidResponseDataError\";\nvar marker6 = `vercel.ai.error.${name5}`;\nvar symbol6 = Symbol.for(marker6);\nvar _a6;\nvar _b6;\nvar InvalidResponseDataError = class extends (_b6 = AISDKError, _a6 = symbol6, _b6) {\n\tconstructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {\n\t\tsuper({\n\t\t\tname: name5,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a6] = true;\n\t\tthis.data = data;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker6);\n\t}\n};\nvar name6 = \"AI_JSONParseError\";\nvar marker7 = `vercel.ai.error.${name6}`;\nvar symbol7 = Symbol.for(marker7);\nvar _a7;\nvar _b7;\nvar JSONParseError = class extends (_b7 = AISDKError, _a7 = symbol7, _b7) {\n\tconstructor({ text, cause }) {\n\t\tsuper({\n\t\t\tname: name6,\n\t\t\tmessage: `JSON parsing failed: Text: ${text}.\nError message: ${getErrorMessage$1(cause)}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a7] = true;\n\t\tthis.text = text;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker7);\n\t}\n};\nvar name7 = \"AI_LoadAPIKeyError\";\nvar marker8 = `vercel.ai.error.${name7}`;\nvar symbol8 = Symbol.for(marker8);\nvar _a8;\nvar _b8;\nvar LoadAPIKeyError = class extends (_b8 = AISDKError, _a8 = symbol8, _b8) {\n\tconstructor({ message }) {\n\t\tsuper({\n\t\t\tname: name7,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a8] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker8);\n\t}\n};\nvar name8 = \"AI_LoadSettingError\";\nvar marker9 = `vercel.ai.error.${name8}`;\nvar symbol9 = Symbol.for(marker9);\nvar _a9;\nvar _b9;\nvar LoadSettingError = class extends (_b9 = AISDKError, _a9 = symbol9, _b9) {\n\tconstructor({ message }) {\n\t\tsuper({\n\t\t\tname: name8,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a9] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker9);\n\t}\n};\nvar name9 = \"AI_NoContentGeneratedError\";\nvar marker10 = `vercel.ai.error.${name9}`;\nvar symbol10 = Symbol.for(marker10);\nvar _a10;\nvar _b10;\nvar NoContentGeneratedError = class extends (_b10 = AISDKError, _a10 = symbol10, _b10) {\n\tconstructor({ message = \"No content generated.\" } = {}) {\n\t\tsuper({\n\t\t\tname: name9,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a10] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker10);\n\t}\n};\nvar name10 = \"AI_NoSuchModelError\";\nvar marker11 = `vercel.ai.error.${name10}`;\nvar symbol11 = Symbol.for(marker11);\nvar _a11;\nvar _b11;\nvar NoSuchModelError = class extends (_b11 = AISDKError, _a11 = symbol11, _b11) {\n\tconstructor({ errorName = name10, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {\n\t\tsuper({\n\t\t\tname: errorName,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a11] = true;\n\t\tthis.modelId = modelId;\n\t\tthis.modelType = modelType;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker11);\n\t}\n};\nvar name11 = \"AI_TooManyEmbeddingValuesForCallError\";\nvar marker12 = `vercel.ai.error.${name11}`;\nvar symbol12 = Symbol.for(marker12);\nvar _a12;\nvar _b12;\nvar TooManyEmbeddingValuesForCallError = class extends (_b12 = AISDKError, _a12 = symbol12, _b12) {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: name11,\n\t\t\tmessage: `Too many values for a single embedding call. The ${options.provider} model \"${options.modelId}\" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`\n\t\t});\n\t\tthis[_a12] = true;\n\t\tthis.provider = options.provider;\n\t\tthis.modelId = options.modelId;\n\t\tthis.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n\t\tthis.values = options.values;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker12);\n\t}\n};\nvar name12 = \"AI_TypeValidationError\";\nvar marker13 = `vercel.ai.error.${name12}`;\nvar symbol13 = Symbol.for(marker13);\nvar _a13;\nvar _b13;\nvar TypeValidationError = class _TypeValidationError extends (_b13 = AISDKError, _a13 = symbol13, _b13) {\n\tconstructor({ value, cause }) {\n\t\tsuper({\n\t\t\tname: name12,\n\t\t\tmessage: `Type validation failed: Value: ${JSON.stringify(value)}.\nError message: ${getErrorMessage$1(cause)}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a13] = true;\n\t\tthis.value = value;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker13);\n\t}\n\t/**\n\t* Wraps an error into a TypeValidationError.\n\t* If the cause is already a TypeValidationError with the same value, it returns the cause.\n\t* Otherwise, it creates a new TypeValidationError.\n\t*\n\t* @param {Object} params - The parameters for wrapping the error.\n\t* @param {unknown} params.value - The value that failed validation.\n\t* @param {unknown} params.cause - The original error or cause of the validation failure.\n\t* @returns {TypeValidationError} A TypeValidationError instance.\n\t*/\n\tstatic wrap({ value, cause }) {\n\t\treturn _TypeValidationError.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError({\n\t\t\tvalue,\n\t\t\tcause\n\t\t});\n\t}\n};\nvar name13 = \"AI_UnsupportedFunctionalityError\";\nvar marker14 = `vercel.ai.error.${name13}`;\nvar symbol14 = Symbol.for(marker14);\nvar _a14;\nvar _b14;\nvar UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = symbol14, _b14) {\n\tconstructor({ functionality, message = `'${functionality}' functionality not supported.` }) {\n\t\tsuper({\n\t\t\tname: name13,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a14] = true;\n\t\tthis.functionality = functionality;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker14);\n\t}\n};\nfunction isJSONValue(value) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") return true;\n\tif (Array.isArray(value)) return value.every(isJSONValue);\n\tif (typeof value === \"object\") return Object.entries(value).every(([key, val]) => typeof key === \"string\" && isJSONValue(val));\n\treturn false;\n}\nfunction isJSONArray(value) {\n\treturn Array.isArray(value) && value.every(isJSONValue);\n}\nfunction isJSONObject(value) {\n\treturn value != null && typeof value === \"object\" && Object.entries(value).every(([key, val]) => typeof key === \"string\" && isJSONValue(val));\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/eventsource-parser/3.0.8/353c45c343d0acc1586e9cb9ff7be48ebf30a434bf7b8c9762d411b79278d167/node_modules/eventsource-parser/dist/index.js\nvar ParseError = class extends Error {\n\tconstructor(message, options) {\n\t\tsuper(message), this.name = \"ParseError\", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;\n\t}\n};\nconst LF = 10;\nconst CR = 13;\nconst SPACE = 32;\nfunction noop(_arg) {}\nfunction createParser(callbacks) {\n\tif (typeof callbacks == \"function\") throw new TypeError(\"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?\");\n\tconst { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];\n\tlet isFirstChunk = !0, id, data = \"\", dataLines = 0, eventType;\n\tfunction feed(chunk) {\n\t\tif (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {\n\t\t\tconst trailing2 = processLines(chunk);\n\t\t\ttrailing2 !== \"\" && pendingFragments.push(trailing2);\n\t\t\treturn;\n\t\t}\n\t\tif (chunk.indexOf(`\n`) === -1 && chunk.indexOf(\"\\r\") === -1) {\n\t\t\tpendingFragments.push(chunk);\n\t\t\treturn;\n\t\t}\n\t\tpendingFragments.push(chunk);\n\t\tconst input = pendingFragments.join(\"\");\n\t\tpendingFragments.length = 0;\n\t\tconst trailing = processLines(input);\n\t\ttrailing !== \"\" && pendingFragments.push(trailing);\n\t}\n\tfunction processLines(chunk) {\n\t\tlet searchIndex = 0;\n\t\tif (chunk.indexOf(\"\\r\") === -1) {\n\t\t\tlet lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\tfor (; lfIndex !== -1;) {\n\t\t\t\tif (searchIndex === lfIndex) {\n\t\t\t\t\tdataLines > 0 && onEvent({\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tevent: eventType,\n\t\t\t\t\t\tdata\n\t\t\t\t\t}), id = void 0, data = \"\", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst firstCharCode = chunk.charCodeAt(searchIndex);\n\t\t\t\tif (isDataPrefix(chunk, searchIndex, firstCharCode)) {\n\t\t\t\t\tconst valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);\n\t\t\t\t\tif (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {\n\t\t\t\t\t\tonEvent({\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tevent: eventType,\n\t\t\t\t\t\t\tdata: value\n\t\t\t\t\t\t}), id = void 0, data = \"\", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tdata = dataLines === 0 ? value : `${data}\n${value}`, dataLines++;\n\t\t\t\t} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6, lfIndex) || void 0 : parseLine(chunk, searchIndex, lfIndex);\n\t\t\t\tsearchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\t}\n\t\t\treturn chunk.slice(searchIndex);\n\t\t}\n\t\tfor (; searchIndex < chunk.length;) {\n\t\t\tconst crIndex = chunk.indexOf(\"\\r\", searchIndex), lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\tlet lineEnd = -1;\n\t\t\tif (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) break;\n\t\t\tparseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;\n\t\t}\n\t\treturn chunk.slice(searchIndex);\n\t}\n\tfunction parseLine(chunk, start, end) {\n\t\tif (start === end) {\n\t\t\tdispatchEvent();\n\t\t\treturn;\n\t\t}\n\t\tconst firstCharCode = chunk.charCodeAt(start);\n\t\tif (isDataPrefix(chunk, start, firstCharCode)) {\n\t\t\tconst valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);\n\t\t\tdata = dataLines === 0 ? value2 : `${data}\n${value2}`, dataLines++;\n\t\t\treturn;\n\t\t}\n\t\tif (isEventPrefix(chunk, start, firstCharCode)) {\n\t\t\teventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;\n\t\t\treturn;\n\t\t}\n\t\tif (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {\n\t\t\tconst value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);\n\t\t\tid = value2.includes(\"\\0\") ? void 0 : value2;\n\t\t\treturn;\n\t\t}\n\t\tif (firstCharCode === 58) {\n\t\t\tif (onComment) {\n\t\t\t\tconst line2 = chunk.slice(start, end);\n\t\t\t\tonComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(\":\");\n\t\tif (fieldSeparatorIndex === -1) {\n\t\t\tprocessField(line, \"\", line);\n\t\t\treturn;\n\t\t}\n\t\tconst field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1;\n\t\tprocessField(field, line.slice(fieldSeparatorIndex + offset), line);\n\t}\n\tfunction processField(field, value, line) {\n\t\tswitch (field) {\n\t\t\tcase \"event\":\n\t\t\t\teventType = value || void 0;\n\t\t\t\tbreak;\n\t\t\tcase \"data\":\n\t\t\t\tdata = dataLines === 0 ? value : `${data}\n${value}`, dataLines++;\n\t\t\t\tbreak;\n\t\t\tcase \"id\":\n\t\t\t\tid = value.includes(\"\\0\") ? void 0 : value;\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\t/^\\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \\`retry\\` value: \"${value}\"`, {\n\t\t\t\t\ttype: \"invalid-retry\",\n\t\t\t\t\tvalue,\n\t\t\t\t\tline\n\t\t\t\t}));\n\t\t\t\tbreak;\n\t\t\tdefault: onError(new ParseError(`Unknown field \"${field.length > 20 ? `${field.slice(0, 20)}\\u2026` : field}\"`, {\n\t\t\t\ttype: \"unknown-field\",\n\t\t\t\tfield,\n\t\t\t\tvalue,\n\t\t\t\tline\n\t\t\t}));\n\t\t}\n\t}\n\tfunction dispatchEvent() {\n\t\tdataLines > 0 && onEvent({\n\t\t\tid,\n\t\t\tevent: eventType,\n\t\t\tdata\n\t\t}), id = void 0, data = \"\", dataLines = 0, eventType = void 0;\n\t}\n\tfunction reset(options = {}) {\n\t\tif (options.consume && pendingFragments.length > 0) {\n\t\t\tconst incompleteLine = pendingFragments.join(\"\");\n\t\t\tparseLine(incompleteLine, 0, incompleteLine.length);\n\t\t}\n\t\tisFirstChunk = !0, id = void 0, data = \"\", dataLines = 0, eventType = void 0, pendingFragments.length = 0;\n\t}\n\treturn {\n\t\tfeed,\n\t\treset\n\t};\n}\nfunction isDataPrefix(chunk, i, firstCharCode) {\n\treturn firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;\n}\nfunction isEventPrefix(chunk, i, firstCharCode) {\n\treturn firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/eventsource-parser/3.0.8/353c45c343d0acc1586e9cb9ff7be48ebf30a434bf7b8c9762d411b79278d167/node_modules/eventsource-parser/dist/stream.js\nvar EventSourceParserStream = class extends TransformStream {\n\tconstructor({ onError, onRetry, onComment } = {}) {\n\t\tlet parser;\n\t\tsuper({\n\t\t\tstart(controller) {\n\t\t\t\tparser = createParser({\n\t\t\t\t\tonEvent: (event) => {\n\t\t\t\t\t\tcontroller.enqueue(event);\n\t\t\t\t\t},\n\t\t\t\t\tonError(error) {\n\t\t\t\t\t\tonError === \"terminate\" ? controller.error(error) : typeof onError == \"function\" && onError(error);\n\t\t\t\t\t},\n\t\t\t\t\tonRetry,\n\t\t\t\t\tonComment\n\t\t\t\t});\n\t\t\t},\n\t\t\ttransform(chunk) {\n\t\t\t\tparser.feed(chunk);\n\t\t\t}\n\t\t});\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider-utils/3.0.41/54e168e422da5c6dae737841145e850d4c63e250333cbae0fbb23672ec8ff617/node_modules/@ai-sdk/provider-utils/dist/index.mjs\nfunction combineHeaders(...headers) {\n\treturn headers.reduce((combinedHeaders, currentHeaders) => ({\n\t\t...combinedHeaders,\n\t\t...currentHeaders\n\t}), {});\n}\nfunction convertAsyncIteratorToReadableStream(iterator) {\n\tlet cancelled = false;\n\treturn new ReadableStream({\n\t\t/**\n\t\t* Called when the consumer wants to pull more data from the stream.\n\t\t*\n\t\t* @param {ReadableStreamDefaultController<T>} controller - The controller to enqueue data into the stream.\n\t\t* @returns {Promise<void>}\n\t\t*/\n\t\tasync pull(controller) {\n\t\t\tif (cancelled) return;\n\t\t\ttry {\n\t\t\t\tconst { value, done } = await iterator.next();\n\t\t\t\tif (done) controller.close();\n\t\t\t\telse controller.enqueue(value);\n\t\t\t} catch (error) {\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t* Called when the consumer cancels the stream.\n\t\t*/\n\t\tasync cancel(reason) {\n\t\t\tcancelled = true;\n\t\t\tif (iterator.return) try {\n\t\t\t\tawait iterator.return(reason);\n\t\t\t} catch (e) {}\n\t\t}\n\t});\n}\nasync function delay(delayInMs, options) {\n\tif (delayInMs == null) return Promise.resolve();\n\tconst signal = options == null ? void 0 : options.abortSignal;\n\treturn new Promise((resolve2, reject) => {\n\t\tif (signal == null ? void 0 : signal.aborted) {\n\t\t\treject(createAbortError());\n\t\t\treturn;\n\t\t}\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tcleanup();\n\t\t\tresolve2();\n\t\t}, delayInMs);\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeoutId);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t};\n\t\tconst onAbort = () => {\n\t\t\tcleanup();\n\t\t\treject(createAbortError());\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort);\n\t});\n}\nfunction createAbortError() {\n\treturn new DOMException(\"Delay was aborted\", \"AbortError\");\n}\nvar DelayedPromise = class {\n\tconstructor() {\n\t\tthis.status = { type: \"pending\" };\n\t\tthis._resolve = void 0;\n\t\tthis._reject = void 0;\n\t}\n\tget promise() {\n\t\tif (this._promise) return this._promise;\n\t\tthis._promise = new Promise((resolve2, reject) => {\n\t\t\tif (this.status.type === \"resolved\") resolve2(this.status.value);\n\t\t\telse if (this.status.type === \"rejected\") reject(this.status.error);\n\t\t\tthis._resolve = resolve2;\n\t\t\tthis._reject = reject;\n\t\t});\n\t\treturn this._promise;\n\t}\n\tresolve(value) {\n\t\tvar _a2;\n\t\tthis.status = {\n\t\t\ttype: \"resolved\",\n\t\t\tvalue\n\t\t};\n\t\tif (this._promise) (_a2 = this._resolve) == null || _a2.call(this, value);\n\t}\n\treject(error) {\n\t\tvar _a2;\n\t\tthis.status = {\n\t\t\ttype: \"rejected\",\n\t\t\terror\n\t\t};\n\t\tif (this._promise) (_a2 = this._reject) == null || _a2.call(this, error);\n\t}\n\tisResolved() {\n\t\treturn this.status.type === \"resolved\";\n\t}\n\tisRejected() {\n\t\treturn this.status.type === \"rejected\";\n\t}\n\tisPending() {\n\t\treturn this.status.type === \"pending\";\n\t}\n};\nfunction extractResponseHeaders(response) {\n\treturn Object.fromEntries([...response.headers]);\n}\nvar name = \"AI_DownloadError\";\nvar marker = `vercel.ai.error.${name}`;\nvar symbol = Symbol.for(marker);\nvar _a;\nvar _b;\nvar DownloadError = class extends (_b = AISDKError, _a = symbol, _b) {\n\tconstructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {\n\t\tsuper({\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a] = true;\n\t\tthis.url = url;\n\t\tthis.statusCode = statusCode;\n\t\tthis.statusText = statusText;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker);\n\t}\n};\nvar EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL = /* @__PURE__ */ Symbol.for(\"vercel.ai.embeddingModel.maxInputBytesPerCall\");\nasync function cancelResponseBody(response) {\n\tvar _a2;\n\ttry {\n\t\tawait ((_a2 = response.body) == null ? void 0 : _a2.cancel());\n\t} catch (e) {}\n}\nfunction isBrowserRuntime(globalThisAny = globalThis) {\n\treturn globalThisAny.window != null;\n}\nfunction isSameOrigin(url, baseUrl) {\n\ttry {\n\t\treturn new URL(url).origin === new URL(baseUrl).origin;\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\nfunction validateDownloadUrl(url) {\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch (e) {\n\t\tthrow new DownloadError({\n\t\t\turl,\n\t\t\tmessage: `Invalid URL: ${url}`\n\t\t});\n\t}\n\tif (parsed.protocol === \"data:\") return;\n\tif (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") throw new DownloadError({\n\t\turl,\n\t\tmessage: `URL scheme must be http, https, or data, got ${parsed.protocol}`\n\t});\n\tconst hostname = parsed.hostname.toLowerCase().replace(/\\.+$/, \"\");\n\tif (!hostname) throw new DownloadError({\n\t\turl,\n\t\tmessage: `URL must have a hostname`\n\t});\n\tif (hostname === \"localhost\" || hostname.endsWith(\".local\") || hostname.endsWith(\".localhost\")) throw new DownloadError({\n\t\turl,\n\t\tmessage: `URL with hostname ${hostname} is not allowed`\n\t});\n\tif (hostname.startsWith(\"[\") && hostname.endsWith(\"]\")) {\n\t\tif (isPrivateIPv6(hostname.slice(1, -1))) throw new DownloadError({\n\t\t\turl,\n\t\t\tmessage: `URL with IPv6 address ${hostname} is not allowed`\n\t\t});\n\t\treturn;\n\t}\n\tif (isIPv4(hostname)) {\n\t\tif (isPrivateIPv4(hostname)) throw new DownloadError({\n\t\t\turl,\n\t\t\tmessage: `URL with IP address ${hostname} is not allowed`\n\t\t});\n\t}\n}\nfunction validateDownloadAddress({ address, family, hostname }) {\n\tif (family === 4 ? !isIPv4(address) || isPrivateIPv4(address) : family === 6 ? isPrivateIPv6(address) : true) throw new DownloadError({\n\t\turl: hostname,\n\t\tmessage: `Hostname ${hostname} resolved to disallowed IP address ${address}`\n\t});\n}\nfunction isIPv4(hostname) {\n\tconst parts = hostname.split(\".\");\n\tif (parts.length !== 4) return false;\n\treturn parts.every((part) => {\n\t\tconst num = Number(part);\n\t\treturn Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;\n\t});\n}\nfunction isPrivateIPv4(ip) {\n\tconst [a, b, c] = ip.split(\".\").map(Number);\n\tif (a === 0) return true;\n\tif (a === 10) return true;\n\tif (a === 100 && b >= 64 && b <= 127) return true;\n\tif (a === 127) return true;\n\tif (a === 169 && b === 254) return true;\n\tif (a === 172 && b >= 16 && b <= 31) return true;\n\tif (a === 192 && b === 0 && c === 0) return true;\n\tif (a === 192 && b === 168) return true;\n\tif (a === 198 && (b === 18 || b === 19)) return true;\n\tif (a >= 240) return true;\n\treturn false;\n}\nfunction parseIPv6(ip) {\n\tlet address = ip.toLowerCase();\n\tconst zoneIndex = address.indexOf(\"%\");\n\tif (zoneIndex !== -1) address = address.slice(0, zoneIndex);\n\tconst halves = address.split(\"::\");\n\tif (halves.length > 2) return null;\n\tconst toGroups = (segment) => {\n\t\tif (segment === \"\") return [];\n\t\tconst groups = [];\n\t\tconst parts = segment.split(\":\");\n\t\tfor (let i = 0; i < parts.length; i++) {\n\t\t\tconst part = parts[i];\n\t\t\tif (part.includes(\".\")) {\n\t\t\t\tif (i !== parts.length - 1 || !isIPv4(part)) return null;\n\t\t\t\tconst [a, b, c, d] = part.split(\".\").map(Number);\n\t\t\t\tgroups.push(a << 8 | b, c << 8 | d);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!/^[0-9a-f]{1,4}$/.test(part)) return null;\n\t\t\tgroups.push(parseInt(part, 16));\n\t\t}\n\t\treturn groups;\n\t};\n\tconst head = toGroups(halves[0]);\n\tif (head === null) return null;\n\tif (halves.length === 2) {\n\t\tconst tail = toGroups(halves[1]);\n\t\tif (tail === null) return null;\n\t\tconst fill = 8 - head.length - tail.length;\n\t\tif (fill < 0) return null;\n\t\treturn [\n\t\t\t...head,\n\t\t\t...new Array(fill).fill(0),\n\t\t\t...tail\n\t\t];\n\t}\n\treturn head.length === 8 ? head : null;\n}\nfunction isPrivateIPv6(ip) {\n\tconst groups = parseIPv6(ip);\n\tif (groups === null) return true;\n\tconst topZero = (count) => groups.slice(0, count).every((group) => group === 0);\n\tif (topZero(7) && (groups[7] === 0 || groups[7] === 1)) return true;\n\tif ((groups[0] & 65024) === 64512) return true;\n\tif ((groups[0] & 65472) === 65152) return true;\n\tif ((groups[0] & 65472) === 65216) return true;\n\tif ((groups[0] & 65280) === 65280) return true;\n\tif (topZero(6) || topZero(5) && groups[5] === 65535 || topZero(4) && groups[4] === 65535 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 1) return isPrivateIPv4(`${groups[6] >> 8 & 255}.${groups[6] & 255}.${groups[7] >> 8 & 255}.${groups[7] & 255}`);\n\treturn false;\n}\nfunction createSafeLookup(lookup) {\n\treturn ((hostname, options, callback) => {\n\t\tlookup(hostname, {\n\t\t\t...options,\n\t\t\tall: true\n\t\t}, (error, addresses) => {\n\t\t\tif (error) {\n\t\t\t\tcallback(error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst [firstAddress] = addresses;\n\t\t\t\tif (firstAddress == null) throw new Error(`Hostname ${hostname} did not resolve to an address`);\n\t\t\t\tfor (const { address, family } of addresses) validateDownloadAddress({\n\t\t\t\t\taddress,\n\t\t\t\t\tfamily,\n\t\t\t\t\thostname\n\t\t\t\t});\n\t\t\t\tif (options.all === true) callback(null, addresses);\n\t\t\t\telse callback(null, firstAddress.address, firstAddress.family);\n\t\t\t} catch (error2) {\n\t\t\t\tcallback(error2 instanceof Error ? error2 : new Error(String(error2)));\n\t\t\t}\n\t\t});\n\t});\n}\nvar safeNodeFetchPromise;\nfunction isNodeRuntime() {\n\tvar _a2, _b2, _c;\n\tconst runtimeProcess = globalThis.process;\n\treturn ((_a2 = runtimeProcess == null ? void 0 : runtimeProcess.release) == null ? void 0 : _a2.name) === \"node\" && ((_b2 = runtimeProcess.versions) == null ? void 0 : _b2.bun) == null && ((_c = runtimeProcess.versions) == null ? void 0 : _c.deno) == null && runtimeProcess.title !== \"workerd\" && globalThis.EdgeRuntime == null;\n}\nasync function getDefaultDownloadFetch() {\n\tif (!isNodeRuntime()) return globalThis.fetch;\n\treturn safeNodeFetchPromise != null ? safeNodeFetchPromise : safeNodeFetchPromise = createSafeNodeFetch();\n}\nasync function createSafeNodeFetch() {\n\tconst [module, { lookup }] = await Promise.all([loadNodeModule(\"node:module\"), loadNodeModule(\"node:dns\")]);\n\tconst { Agent, fetch } = module.createRequire(getCurrentModulePath())(\"undici\");\n\tconst dispatcher = new Agent({ connect: { lookup: createSafeLookup(lookup) } });\n\treturn ((input, init) => fetch(input, {\n\t\t...init,\n\t\tdispatcher\n\t}));\n}\nasync function loadNodeModule(id) {\n\tvar _a2;\n\tconst processWithBuiltins = globalThis.process;\n\tconst builtinModule = (_a2 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a2.call(processWithBuiltins, id);\n\treturn builtinModule == null ? await importNodeModule(id) : builtinModule;\n}\nfunction importNodeModule(id) {\n\treturn import(id);\n}\nfunction getCurrentModulePath() {\n\tconst originalPrepareStackTrace = Error.prepareStackTrace;\n\ttry {\n\t\tError.prepareStackTrace = (_error, callSites) => callSites;\n\t\tconst error = /* @__PURE__ */ new Error(\"Capture current module path\");\n\t\tError.captureStackTrace(error, getCurrentModulePath);\n\t\tconst [caller] = error.stack;\n\t\tconst fileName = caller == null ? void 0 : caller.getFileName();\n\t\tif (fileName == null) throw new Error(\"Unable to determine the current module path\");\n\t\treturn fileName;\n\t} finally {\n\t\tError.prepareStackTrace = originalPrepareStackTrace;\n\t}\n}\nvar MAX_DOWNLOAD_REDIRECTS = 10;\nasync function getValidatedFetch(customFetch) {\n\treturn customFetch == null || customFetch === globalThis.fetch ? await getDefaultDownloadFetch() : customFetch;\n}\nasync function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects = MAX_DOWNLOAD_REDIRECTS, fetch: customFetch, trustedOrigin }) {\n\tvar _a2;\n\tconst baseInit = { signal: abortSignal };\n\tif (headers !== void 0) baseInit.headers = headers;\n\tlet currentUrl = url;\n\tfor (let redirectCount = 0; redirectCount <= maxRedirects; redirectCount++) {\n\t\tconst isTrustedHop = trustedOrigin !== void 0 && isSameOrigin(currentUrl, trustedOrigin);\n\t\tif (!isTrustedHop) validateDownloadUrl(currentUrl);\n\t\tconst fetch = isTrustedHop && customFetch != null ? customFetch : isTrustedHop ? globalThis.fetch : await getValidatedFetch(customFetch);\n\t\tconst response = await fetch(currentUrl, {\n\t\t\t...baseInit,\n\t\t\tredirect: \"manual\"\n\t\t});\n\t\tif (response.type === \"opaqueredirect\") {\n\t\t\tif (!isBrowserRuntime()) throw new DownloadError({\n\t\t\t\turl,\n\t\t\t\tmessage: `Redirect from ${currentUrl} could not be validated and was blocked`\n\t\t\t});\n\t\t\treturn await fetch(currentUrl, {\n\t\t\t\t...baseInit,\n\t\t\t\tredirect: \"follow\"\n\t\t\t});\n\t\t}\n\t\tconst location = (_a2 = response.headers) == null ? void 0 : _a2.get(\"location\");\n\t\tif (response.status >= 300 && response.status < 400 && location) {\n\t\t\tawait cancelResponseBody(response);\n\t\t\tcurrentUrl = new URL(location, currentUrl).toString();\n\t\t\tcontinue;\n\t\t}\n\t\treturn response;\n\t}\n\tthrow new DownloadError({\n\t\turl,\n\t\tmessage: `Too many redirects (max ${maxRedirects})`\n\t});\n}\nvar DEFAULT_MAX_DOWNLOAD_SIZE = 2147483648;\nasync function readResponseWithSizeLimit({ response, url, maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE }) {\n\tconst contentLength = response.headers.get(\"content-length\");\n\tif (contentLength != null) {\n\t\tconst length = parseInt(contentLength, 10);\n\t\tif (!isNaN(length) && length > maxBytes) {\n\t\t\tawait cancelResponseBody(response);\n\t\t\tthrow new DownloadError({\n\t\t\t\turl,\n\t\t\t\tmessage: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`\n\t\t\t});\n\t\t}\n\t}\n\tconst body = response.body;\n\tif (body == null) return /* @__PURE__ */ new Uint8Array(0);\n\tconst reader = body.getReader();\n\tconst chunks = [];\n\tlet totalBytes = 0;\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\t\t\ttotalBytes += value.length;\n\t\t\tif (totalBytes > maxBytes) throw new DownloadError({\n\t\t\t\turl,\n\t\t\t\tmessage: `Download of ${url} exceeded maximum size of ${maxBytes} bytes.`\n\t\t\t});\n\t\t\tchunks.push(value);\n\t\t}\n\t} finally {\n\t\ttry {\n\t\t\tawait reader.cancel();\n\t\t} catch (e) {} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\t}\n\tconst result = new Uint8Array(totalBytes);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tresult.set(chunk, offset);\n\t\toffset += chunk.length;\n\t}\n\treturn result;\n}\nvar createIdGenerator = ({ prefix, size = 16, alphabet = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", separator = \"-\" } = {}) => {\n\tconst generator = () => {\n\t\tconst alphabetLength = alphabet.length;\n\t\tconst chars = new Array(size);\n\t\tfor (let i = 0; i < size; i++) chars[i] = alphabet[Math.random() * alphabetLength | 0];\n\t\treturn chars.join(\"\");\n\t};\n\tif (prefix == null) return generator;\n\tif (alphabet.includes(separator)) throw new InvalidArgumentError({\n\t\targument: \"separator\",\n\t\tmessage: `The separator \"${separator}\" must not be part of the alphabet \"${alphabet}\".`\n\t});\n\treturn () => `${prefix}${separator}${generator()}`;\n};\nvar generateId = createIdGenerator();\nfunction getErrorMessage(error) {\n\tif (error == null) return \"unknown error\";\n\tif (typeof error === \"string\") return error;\n\tif (error instanceof Error) return error.message;\n\treturn JSON.stringify(error);\n}\nfunction isAbortError(error) {\n\treturn (error instanceof Error || error instanceof DOMException) && (error.name === \"AbortError\" || error.name === \"ResponseAborted\" || error.name === \"TimeoutError\");\n}\nvar FETCH_FAILED_ERROR_MESSAGES = [\"fetch failed\", \"failed to fetch\"];\nvar RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([\n\t\"ConnectionRefused\",\n\t\"ConnectionClosed\",\n\t\"FailedToOpenSocket\",\n\t\"ECONNRESET\",\n\t\"ECONNREFUSED\",\n\t\"ETIMEDOUT\",\n\t\"EPIPE\",\n\t\"UND_ERR_SOCKET\",\n\t\"UND_ERR_HEADERS_TIMEOUT\",\n\t\"UND_ERR_BODY_TIMEOUT\",\n\t\"UND_ERR_CONNECT_TIMEOUT\"\n]);\nfunction findNetworkError(error) {\n\tconst visited = /* @__PURE__ */ new Set();\n\tlet current = error;\n\twhile (current instanceof Error && !visited.has(current)) {\n\t\tvisited.add(current);\n\t\tconst errorWithCode = current;\n\t\tif (typeof errorWithCode.code === \"string\" && RETRYABLE_NETWORK_ERROR_CODES.has(errorWithCode.code)) return errorWithCode;\n\t\tcurrent = current.cause;\n\t}\n}\nfunction handleFetchError({ error, url, requestBodyValues }) {\n\tif (isAbortError(error)) return error;\n\tif (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {\n\t\tconst cause = error.cause;\n\t\tif (cause != null) return new APICallError({\n\t\t\tmessage: `Cannot connect to API: ${cause.message}`,\n\t\t\tcause,\n\t\t\turl,\n\t\t\trequestBodyValues,\n\t\t\tisRetryable: true\n\t\t});\n\t}\n\tconst networkError = findNetworkError(error);\n\tif (networkError != null) {\n\t\tif (APICallError.isInstance(error)) return new APICallError({\n\t\t\tmessage: error.message,\n\t\t\tcause: error.cause,\n\t\t\turl: error.url,\n\t\t\trequestBodyValues: error.requestBodyValues,\n\t\t\tstatusCode: error.statusCode,\n\t\t\tresponseHeaders: error.responseHeaders,\n\t\t\tresponseBody: error.responseBody,\n\t\t\tdata: error.data,\n\t\t\tisRetryable: true\n\t\t});\n\t\treturn new APICallError({\n\t\t\tmessage: `Cannot connect to API: ${error instanceof Error ? error.message : networkError.message}`,\n\t\t\tcause: error,\n\t\t\turl,\n\t\t\trequestBodyValues,\n\t\t\tisRetryable: true\n\t\t});\n\t}\n\treturn error;\n}\nfunction getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {\n\tvar _a2, _b2, _c;\n\tif (globalThisAny.window) return `runtime/browser`;\n\tif ((_a2 = globalThisAny.navigator) == null ? void 0 : _a2.userAgent) return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;\n\tif ((_c = (_b2 = globalThisAny.process) == null ? void 0 : _b2.versions) == null ? void 0 : _c.node) return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;\n\tif (globalThisAny.EdgeRuntime) return `runtime/vercel-edge`;\n\treturn \"runtime/unknown\";\n}\nfunction normalizeHeaders(headers) {\n\tif (headers == null) return {};\n\tconst normalized = {};\n\tif (headers instanceof Headers) headers.forEach((value, key) => {\n\t\tnormalized[key.toLowerCase()] = value;\n\t});\n\telse {\n\t\tif (!Array.isArray(headers)) headers = Object.entries(headers);\n\t\tfor (const [key, value] of headers) if (value != null) normalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\nfunction withUserAgentSuffix(headers, ...userAgentSuffixParts) {\n\tconst normalizedHeaders = new Headers(normalizeHeaders(headers));\n\tconst currentUserAgentHeader = normalizedHeaders.get(\"user-agent\") || \"\";\n\tnormalizedHeaders.set(\"user-agent\", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(\" \"));\n\treturn Object.fromEntries(normalizedHeaders.entries());\n}\nvar VERSION = \"3.0.41\";\nvar getOriginalFetch = () => globalThis.fetch;\nvar getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch() }) => {\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: withUserAgentSuffix(headers, `ai-sdk/provider-utils/${VERSION}`, getRuntimeEnvironmentUserAgent()),\n\t\t\tsignal: abortSignal\n\t\t});\n\t\tconst responseHeaders = extractResponseHeaders(response);\n\t\tif (!response.ok) {\n\t\t\tlet errorInformation;\n\t\t\ttry {\n\t\t\t\terrorInformation = await failedResponseHandler({\n\t\t\t\t\tresponse,\n\t\t\t\t\turl,\n\t\t\t\t\trequestBodyValues: {}\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t\tthrow new APICallError({\n\t\t\t\t\tmessage: \"Failed to process error response\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tstatusCode: response.status,\n\t\t\t\t\turl,\n\t\t\t\t\tresponseHeaders,\n\t\t\t\t\trequestBodyValues: {}\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow errorInformation.value;\n\t\t}\n\t\ttry {\n\t\t\treturn await successfulResponseHandler({\n\t\t\t\tresponse,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues: {}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t}\n\t\t\tthrow new APICallError({\n\t\t\t\tmessage: \"Failed to process successful response\",\n\t\t\t\tcause: error,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\turl,\n\t\t\t\tresponseHeaders,\n\t\t\t\trequestBodyValues: {}\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tthrow handleFetchError({\n\t\t\terror,\n\t\t\turl,\n\t\t\trequestBodyValues: {}\n\t\t});\n\t}\n};\nfunction isUrlSupported({ mediaType, url, supportedUrls }) {\n\turl = url.toLowerCase();\n\tmediaType = mediaType.toLowerCase();\n\treturn Object.entries(supportedUrls).map(([key, value]) => {\n\t\tconst mediaType2 = key.toLowerCase();\n\t\treturn mediaType2 === \"*\" || mediaType2 === \"*/*\" ? {\n\t\t\tmediaTypePrefix: \"\",\n\t\t\tregexes: value\n\t\t} : {\n\t\t\tmediaTypePrefix: mediaType2.replace(/\\*/, \"\"),\n\t\t\tregexes: value\n\t\t};\n\t}).filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix)).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));\n}\nfunction loadOptionalSetting({ settingValue, environmentVariableName }) {\n\tif (typeof settingValue === \"string\") return settingValue;\n\tif (settingValue != null || typeof process === \"undefined\") return;\n\tsettingValue = process.env[environmentVariableName];\n\tif (settingValue == null || typeof settingValue !== \"string\") return;\n\treturn settingValue;\n}\nvar suspectProtoRx = /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*:/;\nvar suspectConstructorRx = /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\nfunction _parse(text) {\n\tconst obj = JSON.parse(text);\n\tif (obj === null || typeof obj !== \"object\") return obj;\n\tif (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) return obj;\n\treturn filter(obj);\n}\nfunction filter(obj) {\n\tlet next = [obj];\n\twhile (next.length) {\n\t\tconst nodes = next;\n\t\tnext = [];\n\t\tfor (const node of nodes) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(node, \"__proto__\")) throw new SyntaxError(\"Object contains forbidden prototype property\");\n\t\t\tif (Object.prototype.hasOwnProperty.call(node, \"constructor\") && node.constructor !== null && typeof node.constructor === \"object\" && Object.prototype.hasOwnProperty.call(node.constructor, \"prototype\")) throw new SyntaxError(\"Object contains forbidden prototype property\");\n\t\t\tfor (const key in node) {\n\t\t\t\tconst value = node[key];\n\t\t\t\tif (value && typeof value === \"object\") next.push(value);\n\t\t\t}\n\t\t}\n\t}\n\treturn obj;\n}\nfunction secureJsonParse(text) {\n\tconst { stackTraceLimit } = Error;\n\ttry {\n\t\tError.stackTraceLimit = 0;\n\t} catch (e) {\n\t\treturn _parse(text);\n\t}\n\ttry {\n\t\treturn _parse(text);\n\t} finally {\n\t\tError.stackTraceLimit = stackTraceLimit;\n\t}\n}\nvar validatorSymbol = /* @__PURE__ */ Symbol.for(\"vercel.ai.validator\");\nfunction validator(validate) {\n\treturn {\n\t\t[validatorSymbol]: true,\n\t\tvalidate\n\t};\n}\nfunction isValidator(value) {\n\treturn typeof value === \"object\" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && \"validate\" in value;\n}\nfunction lazyValidator(createValidator) {\n\tlet validator2;\n\treturn () => {\n\t\tif (validator2 == null) validator2 = createValidator();\n\t\treturn validator2;\n\t};\n}\nfunction asValidator(value) {\n\treturn isValidator(value) ? value : \"~standard\" in value ? standardSchemaValidator(value) : value();\n}\nfunction standardSchemaValidator(standardSchema) {\n\treturn validator(async (value) => {\n\t\tconst result = await standardSchema[\"~standard\"].validate(value);\n\t\treturn result.issues == null ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.value\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: new TypeValidationError({\n\t\t\t\tvalue,\n\t\t\t\tcause: result.issues\n\t\t\t})\n\t\t};\n\t});\n}\nasync function validateTypes({ value, schema }) {\n\tconst result = await safeValidateTypes({\n\t\tvalue,\n\t\tschema\n\t});\n\tif (!result.success) throw TypeValidationError.wrap({\n\t\tvalue,\n\t\tcause: result.error\n\t});\n\treturn result.value;\n}\nasync function safeValidateTypes({ value, schema }) {\n\tconst validator2 = asValidator(schema);\n\ttry {\n\t\tif (validator2.validate == null) return {\n\t\t\tsuccess: true,\n\t\t\tvalue,\n\t\t\trawValue: value\n\t\t};\n\t\tconst result = await validator2.validate(value);\n\t\tif (result.success) return {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.value,\n\t\t\trawValue: value\n\t\t};\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: TypeValidationError.wrap({\n\t\t\t\tvalue,\n\t\t\t\tcause: result.error\n\t\t\t}),\n\t\t\trawValue: value\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: TypeValidationError.wrap({\n\t\t\t\tvalue,\n\t\t\t\tcause: error\n\t\t\t}),\n\t\t\trawValue: value\n\t\t};\n\t}\n}\nasync function parseJSON({ text, schema }) {\n\ttry {\n\t\tconst value = secureJsonParse(text);\n\t\tif (schema == null) return value;\n\t\treturn validateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t} catch (error) {\n\t\tif (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) throw error;\n\t\tthrow new JSONParseError({\n\t\t\ttext,\n\t\t\tcause: error\n\t\t});\n\t}\n}\nasync function safeParseJSON({ text, schema }) {\n\ttry {\n\t\tconst value = secureJsonParse(text);\n\t\tif (schema == null) return {\n\t\t\tsuccess: true,\n\t\t\tvalue,\n\t\t\trawValue: value\n\t\t};\n\t\treturn await safeValidateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: JSONParseError.isInstance(error) ? error : new JSONParseError({\n\t\t\t\ttext,\n\t\t\t\tcause: error\n\t\t\t}),\n\t\t\trawValue: void 0\n\t\t};\n\t}\n}\nfunction parseJsonEventStream({ stream, schema }) {\n\treturn stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(new TransformStream({ async transform({ data }, controller) {\n\t\tif (data === \"[DONE]\") return;\n\t\tcontroller.enqueue(await safeParseJSON({\n\t\t\ttext: data,\n\t\t\tschema\n\t\t}));\n\t} }));\n}\nvar getOriginalFetch2 = () => globalThis.fetch;\nvar postJsonToApi = async ({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch }) => postToApi({\n\turl,\n\theaders: {\n\t\t\"Content-Type\": \"application/json\",\n\t\t...headers\n\t},\n\tbody: {\n\t\tcontent: JSON.stringify(body),\n\t\tvalues: body\n\t},\n\tfailedResponseHandler,\n\tsuccessfulResponseHandler,\n\tabortSignal,\n\tfetch\n});\nvar postToApi = async ({ url, headers = {}, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch2() }) => {\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: withUserAgentSuffix(headers, `ai-sdk/provider-utils/${VERSION}`, getRuntimeEnvironmentUserAgent()),\n\t\t\tbody: body.content,\n\t\t\tsignal: abortSignal\n\t\t});\n\t\tconst responseHeaders = extractResponseHeaders(response);\n\t\tif (!response.ok) {\n\t\t\tlet errorInformation;\n\t\t\ttry {\n\t\t\t\terrorInformation = await failedResponseHandler({\n\t\t\t\t\tresponse,\n\t\t\t\t\turl,\n\t\t\t\t\trequestBodyValues: body.values\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t\tthrow new APICallError({\n\t\t\t\t\tmessage: \"Failed to process error response\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tstatusCode: response.status,\n\t\t\t\t\turl,\n\t\t\t\t\tresponseHeaders,\n\t\t\t\t\trequestBodyValues: body.values\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow errorInformation.value;\n\t\t}\n\t\ttry {\n\t\t\treturn await successfulResponseHandler({\n\t\t\t\tresponse,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues: body.values\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t}\n\t\t\tthrow new APICallError({\n\t\t\t\tmessage: \"Failed to process successful response\",\n\t\t\t\tcause: error,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\turl,\n\t\t\t\tresponseHeaders,\n\t\t\t\trequestBodyValues: body.values\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tthrow handleFetchError({\n\t\t\terror,\n\t\t\turl,\n\t\t\trequestBodyValues: body.values\n\t\t});\n\t}\n};\nfunction tool(tool2) {\n\treturn tool2;\n}\nfunction dynamicTool(tool2) {\n\treturn {\n\t\t...tool2,\n\t\ttype: \"dynamic\"\n\t};\n}\nfunction createProviderDefinedToolFactoryWithOutputSchema({ id, name: name2, inputSchema, outputSchema }) {\n\treturn ({ execute, toModelOutput, onInputStart, onInputDelta, onInputAvailable, ...args }) => tool({\n\t\ttype: \"provider-defined\",\n\t\tid,\n\t\tname: name2,\n\t\targs,\n\t\tinputSchema,\n\t\toutputSchema,\n\t\texecute,\n\t\ttoModelOutput,\n\t\tonInputStart,\n\t\tonInputDelta,\n\t\tonInputAvailable\n\t});\n}\nasync function resolve(value) {\n\tif (typeof value === \"function\") value = value();\n\treturn Promise.resolve(value);\n}\nvar textDecoder = new TextDecoder();\nfunction wrapResponseBodyStream({ stream, url, requestBodyValues, statusCode, responseHeaders }) {\n\tconst reader = stream.getReader();\n\tlet readerReleased = false;\n\tconst releaseReader = () => {\n\t\tif (!readerReleased) {\n\t\t\treader.releaseLock();\n\t\t\treaderReleased = true;\n\t\t}\n\t};\n\treturn new ReadableStream({\n\t\tasync pull(controller) {\n\t\t\ttry {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\treleaseReader();\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else controller.enqueue(value);\n\t\t\t} catch (error) {\n\t\t\t\treleaseReader();\n\t\t\t\tif (isAbortError(error)) {\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcontroller.error(handleFetchError({\n\t\t\t\t\terror: new APICallError({\n\t\t\t\t\t\tmessage: \"Failed to process successful response\",\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\tstatusCode,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tresponseHeaders,\n\t\t\t\t\t\trequestBodyValues\n\t\t\t\t\t}),\n\t\t\t\t\turl,\n\t\t\t\t\trequestBodyValues\n\t\t\t\t}));\n\t\t\t}\n\t\t},\n\t\tasync cancel(reason) {\n\t\t\ttry {\n\t\t\t\tawait reader.cancel(reason);\n\t\t\t} finally {\n\t\t\t\treleaseReader();\n\t\t\t}\n\t\t}\n\t});\n}\nasync function readResponseBodyAsText({ response, url }) {\n\treturn textDecoder.decode(await readResponseWithSizeLimit({\n\t\tresponse,\n\t\turl\n\t}));\n}\nvar createJsonErrorResponseHandler = ({ errorSchema, errorToMessage, isRetryable }) => async ({ response, url, requestBodyValues }) => {\n\tconst responseBody = await readResponseBodyAsText({\n\t\tresponse,\n\t\turl\n\t});\n\tconst responseHeaders = extractResponseHeaders(response);\n\tif (responseBody.trim() === \"\") return {\n\t\tresponseHeaders,\n\t\tvalue: new APICallError({\n\t\t\tmessage: response.statusText,\n\t\t\turl,\n\t\t\trequestBodyValues,\n\t\t\tstatusCode: response.status,\n\t\t\tresponseHeaders,\n\t\t\tresponseBody,\n\t\t\tisRetryable: isRetryable == null ? void 0 : isRetryable(response)\n\t\t})\n\t};\n\ttry {\n\t\tconst parsedError = await parseJSON({\n\t\t\ttext: responseBody,\n\t\t\tschema: errorSchema\n\t\t});\n\t\treturn {\n\t\t\tresponseHeaders,\n\t\t\tvalue: new APICallError({\n\t\t\t\tmessage: errorToMessage(parsedError),\n\t\t\t\turl,\n\t\t\t\trequestBodyValues,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tresponseHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tdata: parsedError,\n\t\t\t\tisRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)\n\t\t\t})\n\t\t};\n\t} catch (parseError) {\n\t\treturn {\n\t\t\tresponseHeaders,\n\t\t\tvalue: new APICallError({\n\t\t\t\tmessage: response.statusText,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tresponseHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tisRetryable: isRetryable == null ? void 0 : isRetryable(response)\n\t\t\t})\n\t\t};\n\t}\n};\nvar createEventSourceResponseHandler = (chunkSchema) => async ({ response, url, requestBodyValues }) => {\n\tconst responseHeaders = extractResponseHeaders(response);\n\tif (response.body == null) throw new EmptyResponseBodyError({});\n\treturn {\n\t\tresponseHeaders,\n\t\tvalue: parseJsonEventStream({\n\t\t\tstream: wrapResponseBodyStream({\n\t\t\t\tstream: response.body,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tresponseHeaders\n\t\t\t}),\n\t\t\tschema: chunkSchema\n\t\t})\n\t};\n};\nvar createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {\n\tconst responseBody = await readResponseBodyAsText({\n\t\tresponse,\n\t\turl\n\t});\n\tconst parsedResult = await safeParseJSON({\n\t\ttext: responseBody,\n\t\tschema: responseSchema\n\t});\n\tconst responseHeaders = extractResponseHeaders(response);\n\tif (!parsedResult.success) throw new APICallError({\n\t\tmessage: \"Invalid JSON response\",\n\t\tcause: parsedResult.error,\n\t\tstatusCode: response.status,\n\t\tresponseHeaders,\n\t\tresponseBody,\n\t\turl,\n\t\trequestBodyValues\n\t});\n\treturn {\n\t\tresponseHeaders,\n\t\tvalue: parsedResult.value,\n\t\trawValue: parsedResult.rawValue\n\t};\n};\nvar schemaSymbol = /* @__PURE__ */ Symbol.for(\"vercel.ai.schema\");\nfunction lazySchema(createSchema) {\n\tlet schema;\n\treturn () => {\n\t\tif (schema == null) schema = createSchema();\n\t\treturn schema;\n\t};\n}\nfunction jsonSchema(jsonSchema2, { validate } = {}) {\n\treturn {\n\t\t[schemaSymbol]: true,\n\t\t_type: void 0,\n\t\t[validatorSymbol]: true,\n\t\tget jsonSchema() {\n\t\t\tif (typeof jsonSchema2 === \"function\") jsonSchema2 = jsonSchema2();\n\t\t\treturn jsonSchema2;\n\t\t},\n\t\tvalidate\n\t};\n}\nfunction addAdditionalPropertiesToJsonSchema(jsonSchema2) {\n\tif (jsonSchema2.type === \"object\") {\n\t\tconst { additionalProperties } = jsonSchema2;\n\t\tjsonSchema2.additionalProperties = additionalProperties != null && typeof additionalProperties !== \"boolean\" ? addAdditionalPropertiesToJsonSchema(additionalProperties) : false;\n\t\tconst properties = jsonSchema2.properties;\n\t\tif (properties != null) for (const property in properties) properties[property] = addAdditionalPropertiesToJsonSchema(properties[property]);\n\t}\n\tif (jsonSchema2.type === \"array\" && jsonSchema2.items != null) {\n\t\tif (Array.isArray(jsonSchema2.items)) jsonSchema2.items = jsonSchema2.items.map((item) => addAdditionalPropertiesToJsonSchema(item));\n\t\telse jsonSchema2.items = addAdditionalPropertiesToJsonSchema(jsonSchema2.items);\n\t}\n\treturn jsonSchema2;\n}\nvar ignoreOverride = /* @__PURE__ */ Symbol(\"Let zodToJsonSchema decide on which parser to use\");\nvar defaultOptions = {\n\tname: void 0,\n\t$refStrategy: \"root\",\n\tbasePath: [\"#\"],\n\teffectStrategy: \"input\",\n\tpipeStrategy: \"all\",\n\tdateStrategy: \"format:date-time\",\n\tmapStrategy: \"entries\",\n\tremoveAdditionalStrategy: \"passthrough\",\n\tallowedAdditionalProperties: true,\n\trejectedAdditionalProperties: false,\n\tdefinitionPath: \"definitions\",\n\tstrictUnions: false,\n\tdefinitions: {},\n\terrorMessages: false,\n\tpatternStrategy: \"escape\",\n\tapplyRegexFlags: false,\n\temailStrategy: \"format:email\",\n\tbase64Strategy: \"contentEncoding:base64\",\n\tnameStrategy: \"ref\"\n};\nvar getDefaultOptions = (options) => typeof options === \"string\" ? {\n\t...defaultOptions,\n\tname: options\n} : {\n\t...defaultOptions,\n\t...options\n};\nfunction parseAnyDef() {\n\treturn {};\n}\nfunction parseArrayDef(def, refs) {\n\tvar _a2, _b2, _c;\n\tconst res = { type: \"array\" };\n\tif (((_a2 = def.type) == null ? void 0 : _a2._def) && ((_c = (_b2 = def.type) == null ? void 0 : _b2._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"items\"]\n\t});\n\tif (def.minLength) res.minItems = def.minLength.value;\n\tif (def.maxLength) res.maxItems = def.maxLength.value;\n\tif (def.exactLength) {\n\t\tres.minItems = def.exactLength.value;\n\t\tres.maxItems = def.exactLength.value;\n\t}\n\treturn res;\n}\nfunction parseBigintDef(def) {\n\tconst res = {\n\t\ttype: \"integer\",\n\t\tformat: \"int64\"\n\t};\n\tif (!def.checks) return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tif (check.inclusive) res.minimum = check.value;\n\t\t\telse res.exclusiveMinimum = check.value;\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tif (check.inclusive) res.maximum = check.value;\n\t\t\telse res.exclusiveMaximum = check.value;\n\t\t\tbreak;\n\t\tcase \"multipleOf\": res.multipleOf = check.value;\n\t}\n\treturn res;\n}\nfunction parseBooleanDef() {\n\treturn { type: \"boolean\" };\n}\nfunction parseBrandedDef(_def, refs) {\n\treturn parseDef(_def.type._def, refs);\n}\nvar parseCatchDef = (def, refs) => {\n\treturn parseDef(def.innerType._def, refs);\n};\nfunction parseDateDef(def, refs, overrideDateStrategy) {\n\tconst strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;\n\tif (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };\n\tswitch (strategy) {\n\t\tcase \"string\":\n\t\tcase \"format:date-time\": return {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\"\n\t\t};\n\t\tcase \"format:date\": return {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date\"\n\t\t};\n\t\tcase \"integer\": return integerDateParser(def);\n\t}\n}\nvar integerDateParser = (def) => {\n\tconst res = {\n\t\ttype: \"integer\",\n\t\tformat: \"unix-time\"\n\t};\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tres.minimum = check.value;\n\t\t\tbreak;\n\t\tcase \"max\": res.maximum = check.value;\n\t}\n\treturn res;\n};\nfunction parseDefaultDef(_def, refs) {\n\treturn {\n\t\t...parseDef(_def.innerType._def, refs),\n\t\tdefault: _def.defaultValue()\n\t};\n}\nfunction parseEffectsDef(_def, refs) {\n\treturn refs.effectStrategy === \"input\" ? parseDef(_def.schema._def, refs) : parseAnyDef();\n}\nfunction parseEnumDef(def) {\n\treturn {\n\t\ttype: \"string\",\n\t\tenum: Array.from(def.values)\n\t};\n}\nvar isJsonSchema7AllOfType = (type) => {\n\tif (\"type\" in type && type.type === \"string\") return false;\n\treturn \"allOf\" in type;\n};\nfunction parseIntersectionDef(def, refs) {\n\tconst allOf = [parseDef(def.left._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"0\"\n\t\t]\n\t}), parseDef(def.right._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"1\"\n\t\t]\n\t})].filter((x) => !!x);\n\tconst mergedAllOf = [];\n\tallOf.forEach((schema) => {\n\t\tif (isJsonSchema7AllOfType(schema)) mergedAllOf.push(...schema.allOf);\n\t\telse {\n\t\t\tlet nestedSchema = schema;\n\t\t\tif (\"additionalProperties\" in schema && schema.additionalProperties === false) {\n\t\t\t\tconst { additionalProperties, ...rest } = schema;\n\t\t\t\tnestedSchema = rest;\n\t\t\t}\n\t\t\tmergedAllOf.push(nestedSchema);\n\t\t}\n\t});\n\treturn mergedAllOf.length ? { allOf: mergedAllOf } : void 0;\n}\nfunction parseLiteralDef(def) {\n\tconst parsedType = typeof def.value;\n\tif (parsedType !== \"bigint\" && parsedType !== \"number\" && parsedType !== \"boolean\" && parsedType !== \"string\") return { type: Array.isArray(def.value) ? \"array\" : \"object\" };\n\treturn {\n\t\ttype: parsedType === \"bigint\" ? \"integer\" : parsedType,\n\t\tconst: def.value\n\t};\n}\nvar emojiRegex = void 0;\nvar zodPatterns = {\n\t/**\n\t* `c` was changed to `[cC]` to replicate /i flag\n\t*/\n\tcuid: /^[cC][^\\s-]{8,}$/,\n\tcuid2: /^[0-9a-z]+$/,\n\tulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,\n\t/**\n\t* `a-z` was added to replicate /i flag\n\t*/\n\temail: /^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_'+\\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,}$/,\n\t/**\n\t* Constructed a valid Unicode RegExp\n\t*\n\t* Lazily instantiate since this type of regex isn't supported\n\t* in all envs (e.g. React Native).\n\t*\n\t* See:\n\t* https://github.com/colinhacks/zod/issues/2433\n\t* Fix in Zod:\n\t* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b\n\t*/\n\temoji: () => {\n\t\tif (emojiRegex === void 0) emojiRegex = RegExp(\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\", \"u\");\n\t\treturn emojiRegex;\n\t},\n\t/**\n\t* Unused\n\t*/\n\tuuid: /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/,\n\t/**\n\t* Unused\n\t*/\n\tipv4: /^(?:(?: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])$/,\n\tipv4Cidr: /^(?:(?: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])\\/(3[0-2]|[12]?[0-9])$/,\n\t/**\n\t* Unused\n\t*/\n\tipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,\n\tipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,\n\tbase64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,\n\tbase64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,\n\tnanoid: /^[a-zA-Z0-9_-]{21}$/,\n\tjwt: /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/\n};\nfunction parseStringDef(def, refs) {\n\tconst res = { type: \"string\" };\n\tif (def.checks) for (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tres.minLength = typeof res.minLength === \"number\" ? Math.max(res.minLength, check.value) : check.value;\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tres.maxLength = typeof res.maxLength === \"number\" ? Math.min(res.maxLength, check.value) : check.value;\n\t\t\tbreak;\n\t\tcase \"email\":\n\t\t\tswitch (refs.emailStrategy) {\n\t\t\t\tcase \"format:email\":\n\t\t\t\t\taddFormat(res, \"email\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"format:idn-email\":\n\t\t\t\t\taddFormat(res, \"idn-email\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"pattern:zod\": addPattern(res, zodPatterns.email, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"url\":\n\t\t\taddFormat(res, \"uri\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"uuid\":\n\t\t\taddFormat(res, \"uuid\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"regex\":\n\t\t\taddPattern(res, check.regex, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cuid\":\n\t\t\taddPattern(res, zodPatterns.cuid, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cuid2\":\n\t\t\taddPattern(res, zodPatterns.cuid2, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"startsWith\":\n\t\t\taddPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"endsWith\":\n\t\t\taddPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"datetime\":\n\t\t\taddFormat(res, \"date-time\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"date\":\n\t\t\taddFormat(res, \"date\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"time\":\n\t\t\taddFormat(res, \"time\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"duration\":\n\t\t\taddFormat(res, \"duration\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"length\":\n\t\t\tres.minLength = typeof res.minLength === \"number\" ? Math.max(res.minLength, check.value) : check.value;\n\t\t\tres.maxLength = typeof res.maxLength === \"number\" ? Math.min(res.maxLength, check.value) : check.value;\n\t\t\tbreak;\n\t\tcase \"includes\":\n\t\t\taddPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"ip\":\n\t\t\tif (check.version !== \"v6\") addFormat(res, \"ipv4\", check.message, refs);\n\t\t\tif (check.version !== \"v4\") addFormat(res, \"ipv6\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"base64url\":\n\t\t\taddPattern(res, zodPatterns.base64url, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"jwt\":\n\t\t\taddPattern(res, zodPatterns.jwt, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cidr\":\n\t\t\tif (check.version !== \"v6\") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);\n\t\t\tif (check.version !== \"v4\") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"emoji\":\n\t\t\taddPattern(res, zodPatterns.emoji(), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"ulid\":\n\t\t\taddPattern(res, zodPatterns.ulid, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"base64\":\n\t\t\tswitch (refs.base64Strategy) {\n\t\t\t\tcase \"format:binary\":\n\t\t\t\t\taddFormat(res, \"binary\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"contentEncoding:base64\":\n\t\t\t\t\tres.contentEncoding = \"base64\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"pattern:zod\": addPattern(res, zodPatterns.base64, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"nanoid\": addPattern(res, zodPatterns.nanoid, check.message, refs);\n\t}\n\treturn res;\n}\nfunction escapeLiteralCheckValue(literal, refs) {\n\treturn refs.patternStrategy === \"escape\" ? escapeNonAlphaNumeric(literal) : literal;\n}\nvar ALPHA_NUMERIC = /* @__PURE__ */ new Set(\"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789\");\nfunction escapeNonAlphaNumeric(source) {\n\tlet result = \"\";\n\tfor (let i = 0; i < source.length; i++) {\n\t\tif (!ALPHA_NUMERIC.has(source[i])) result += \"\\\\\";\n\t\tresult += source[i];\n\t}\n\treturn result;\n}\nfunction addFormat(schema, value, message, refs) {\n\tvar _a2;\n\tif (schema.format || ((_a2 = schema.anyOf) == null ? void 0 : _a2.some((x) => x.format))) {\n\t\tif (!schema.anyOf) schema.anyOf = [];\n\t\tif (schema.format) {\n\t\t\tschema.anyOf.push({ format: schema.format });\n\t\t\tdelete schema.format;\n\t\t}\n\t\tschema.anyOf.push({\n\t\t\tformat: value,\n\t\t\t...message && refs.errorMessages && { errorMessage: { format: message } }\n\t\t});\n\t} else schema.format = value;\n}\nfunction addPattern(schema, regex, message, refs) {\n\tvar _a2;\n\tif (schema.pattern || ((_a2 = schema.allOf) == null ? void 0 : _a2.some((x) => x.pattern))) {\n\t\tif (!schema.allOf) schema.allOf = [];\n\t\tif (schema.pattern) {\n\t\t\tschema.allOf.push({ pattern: schema.pattern });\n\t\t\tdelete schema.pattern;\n\t\t}\n\t\tschema.allOf.push({\n\t\t\tpattern: stringifyRegExpWithFlags(regex, refs),\n\t\t\t...message && refs.errorMessages && { errorMessage: { pattern: message } }\n\t\t});\n\t} else schema.pattern = stringifyRegExpWithFlags(regex, refs);\n}\nfunction stringifyRegExpWithFlags(regex, refs) {\n\tvar _a2;\n\tif (!refs.applyRegexFlags || !regex.flags) return regex.source;\n\tconst flags = {\n\t\ti: regex.flags.includes(\"i\"),\n\t\tm: regex.flags.includes(\"m\"),\n\t\ts: regex.flags.includes(\"s\")\n\t};\n\tconst source = flags.i ? regex.source.toLowerCase() : regex.source;\n\tlet pattern = \"\";\n\tlet isEscaped = false;\n\tlet inCharGroup = false;\n\tlet inCharRange = false;\n\tfor (let i = 0; i < source.length; i++) {\n\t\tif (isEscaped) {\n\t\t\tpattern += source[i];\n\t\t\tisEscaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (flags.i) {\n\t\t\tif (inCharGroup) {\n\t\t\t\tif (source[i].match(/[a-z]/)) {\n\t\t\t\t\tif (inCharRange) {\n\t\t\t\t\t\tpattern += source[i];\n\t\t\t\t\t\tpattern += `${source[i - 2]}-${source[i]}`.toUpperCase();\n\t\t\t\t\t\tinCharRange = false;\n\t\t\t\t\t} else if (source[i + 1] === \"-\" && ((_a2 = source[i + 2]) == null ? void 0 : _a2.match(/[a-z]/))) {\n\t\t\t\t\t\tpattern += source[i];\n\t\t\t\t\t\tinCharRange = true;\n\t\t\t\t\t} else pattern += `${source[i]}${source[i].toUpperCase()}`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else if (source[i].match(/[a-z]/)) {\n\t\t\t\tpattern += `[${source[i]}${source[i].toUpperCase()}]`;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (flags.m) {\n\t\t\tif (source[i] === \"^\") {\n\t\t\t\tpattern += `(^|(?<=[\\r\n]))`;\n\t\t\t\tcontinue;\n\t\t\t} else if (source[i] === \"$\") {\n\t\t\t\tpattern += `($|(?=[\\r\n]))`;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (flags.s && source[i] === \".\") {\n\t\t\tpattern += inCharGroup ? `${source[i]}\\r\n` : `[${source[i]}\\r\n]`;\n\t\t\tcontinue;\n\t\t}\n\t\tpattern += source[i];\n\t\tif (source[i] === \"\\\\\") isEscaped = true;\n\t\telse if (inCharGroup && source[i] === \"]\") inCharGroup = false;\n\t\telse if (!inCharGroup && source[i] === \"[\") inCharGroup = true;\n\t}\n\ttry {\n\t\tnew RegExp(pattern);\n\t} catch (e) {\n\t\tconsole.warn(`Could not convert regex pattern at ${refs.currentPath.join(\"/\")} to a flag-independent form! Falling back to the flag-ignorant source`);\n\t\treturn regex.source;\n\t}\n\treturn pattern;\n}\nfunction parseRecordDef(def, refs) {\n\tvar _a2, _b2, _c, _d, _e, _f;\n\tconst schema = {\n\t\ttype: \"object\",\n\t\tadditionalProperties: (_a2 = parseDef(def.valueType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"additionalProperties\"]\n\t\t})) != null ? _a2 : refs.allowedAdditionalProperties\n\t};\n\tif (((_b2 = def.keyType) == null ? void 0 : _b2._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {\n\t\tconst { type, ...keyType } = parseStringDef(def.keyType._def, refs);\n\t\treturn {\n\t\t\t...schema,\n\t\t\tpropertyNames: keyType\n\t\t};\n\t} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) return {\n\t\t...schema,\n\t\tpropertyNames: { enum: def.keyType._def.values }\n\t};\n\telse if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {\n\t\tconst { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);\n\t\treturn {\n\t\t\t...schema,\n\t\t\tpropertyNames: keyType\n\t\t};\n\t}\n\treturn schema;\n}\nfunction parseMapDef(def, refs) {\n\tif (refs.mapStrategy === \"record\") return parseRecordDef(def, refs);\n\treturn {\n\t\ttype: \"array\",\n\t\tmaxItems: 125,\n\t\titems: {\n\t\t\ttype: \"array\",\n\t\t\titems: [parseDef(def.keyType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"0\"\n\t\t\t\t]\n\t\t\t}) || parseAnyDef(), parseDef(def.valueType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"1\"\n\t\t\t\t]\n\t\t\t}) || parseAnyDef()],\n\t\t\tminItems: 2,\n\t\t\tmaxItems: 2\n\t\t}\n\t};\n}\nfunction parseNativeEnumDef(def) {\n\tconst object = def.values;\n\tconst actualValues = Object.keys(def.values).filter((key) => {\n\t\treturn typeof object[object[key]] !== \"number\";\n\t}).map((key) => object[key]);\n\tconst parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));\n\treturn {\n\t\ttype: parsedTypes.length === 1 ? parsedTypes[0] === \"string\" ? \"string\" : \"number\" : [\"string\", \"number\"],\n\t\tenum: actualValues\n\t};\n}\nfunction parseNeverDef() {\n\treturn { not: parseAnyDef() };\n}\nfunction parseNullDef() {\n\treturn { type: \"null\" };\n}\nvar primitiveMappings = {\n\tZodString: \"string\",\n\tZodNumber: \"number\",\n\tZodBigInt: \"integer\",\n\tZodBoolean: \"boolean\",\n\tZodNull: \"null\"\n};\nfunction parseUnionDef(def, refs) {\n\tconst options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;\n\tif (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {\n\t\tconst types = options.reduce((types2, x) => {\n\t\t\tconst type = primitiveMappings[x._def.typeName];\n\t\t\treturn type && !types2.includes(type) ? [...types2, type] : types2;\n\t\t}, []);\n\t\treturn { type: types.length > 1 ? types : types[0] };\n\t} else if (options.every((x) => x._def.typeName === \"ZodLiteral\" && !x.description)) {\n\t\tconst types = options.reduce((acc, x) => {\n\t\t\tconst type = typeof x._def.value;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"string\":\n\t\t\t\tcase \"number\":\n\t\t\t\tcase \"boolean\": return [...acc, type];\n\t\t\t\tcase \"bigint\": return [...acc, \"integer\"];\n\t\t\t\tcase \"object\": if (x._def.value === null) return [...acc, \"null\"];\n\t\t\t\tdefault: return acc;\n\t\t\t}\n\t\t}, []);\n\t\tif (types.length === options.length) {\n\t\t\tconst uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);\n\t\t\treturn {\n\t\t\t\ttype: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],\n\t\t\t\tenum: options.reduce((acc, x) => {\n\t\t\t\t\treturn acc.includes(x._def.value) ? acc : [...acc, x._def.value];\n\t\t\t\t}, [])\n\t\t\t};\n\t\t}\n\t} else if (options.every((x) => x._def.typeName === \"ZodEnum\")) return {\n\t\ttype: \"string\",\n\t\tenum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x2) => !acc.includes(x2))], [])\n\t};\n\treturn asAnyOf(def, refs);\n}\nvar asAnyOf = (def, refs) => {\n\tconst anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t`${i}`\n\t\t]\n\t})).filter((x) => !!x && (!refs.strictUnions || typeof x === \"object\" && Object.keys(x).length > 0));\n\treturn anyOf.length ? { anyOf } : void 0;\n};\nfunction parseNullableDef(def, refs) {\n\tif ([\n\t\t\"ZodString\",\n\t\t\"ZodNumber\",\n\t\t\"ZodBigInt\",\n\t\t\"ZodBoolean\",\n\t\t\"ZodNull\"\n\t].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) return { type: [primitiveMappings[def.innerType._def.typeName], \"null\"] };\n\tconst base = parseDef(def.innerType._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t\"0\"\n\t\t]\n\t});\n\treturn base && { anyOf: [base, { type: \"null\" }] };\n}\nfunction parseNumberDef(def) {\n\tconst res = { type: \"number\" };\n\tif (!def.checks) return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"int\":\n\t\t\tres.type = \"integer\";\n\t\t\tbreak;\n\t\tcase \"min\":\n\t\t\tif (check.inclusive) res.minimum = check.value;\n\t\t\telse res.exclusiveMinimum = check.value;\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tif (check.inclusive) res.maximum = check.value;\n\t\t\telse res.exclusiveMaximum = check.value;\n\t\t\tbreak;\n\t\tcase \"multipleOf\": res.multipleOf = check.value;\n\t}\n\treturn res;\n}\nfunction parseObjectDef(def, refs) {\n\tconst result = {\n\t\ttype: \"object\",\n\t\tproperties: {}\n\t};\n\tconst required = [];\n\tconst shape = def.shape();\n\tfor (const propName in shape) {\n\t\tlet propDef = shape[propName];\n\t\tif (propDef === void 0 || propDef._def === void 0) continue;\n\t\tconst propOptional = safeIsOptional(propDef);\n\t\tconst parsedDef = parseDef(propDef._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"properties\",\n\t\t\t\tpropName\n\t\t\t],\n\t\t\tpropertyPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"properties\",\n\t\t\t\tpropName\n\t\t\t]\n\t\t});\n\t\tif (parsedDef === void 0) continue;\n\t\tresult.properties[propName] = parsedDef;\n\t\tif (!propOptional) required.push(propName);\n\t}\n\tif (required.length) result.required = required;\n\tconst additionalProperties = decideAdditionalProperties(def, refs);\n\tif (additionalProperties !== void 0) result.additionalProperties = additionalProperties;\n\treturn result;\n}\nfunction decideAdditionalProperties(def, refs) {\n\tif (def.catchall._def.typeName !== \"ZodNever\") return parseDef(def.catchall._def, {\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"additionalProperties\"]\n\t});\n\tswitch (def.unknownKeys) {\n\t\tcase \"passthrough\": return refs.allowedAdditionalProperties;\n\t\tcase \"strict\": return refs.rejectedAdditionalProperties;\n\t\tcase \"strip\": return refs.removeAdditionalStrategy === \"strict\" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;\n\t}\n}\nfunction safeIsOptional(schema) {\n\ttry {\n\t\treturn schema.isOptional();\n\t} catch (e) {\n\t\treturn true;\n\t}\n}\nvar parseOptionalDef = (def, refs) => {\n\tvar _a2;\n\tif (refs.currentPath.toString() === ((_a2 = refs.propertyPath) == null ? void 0 : _a2.toString())) return parseDef(def.innerType._def, refs);\n\tconst innerSchema = parseDef(def.innerType._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t\"1\"\n\t\t]\n\t});\n\treturn innerSchema ? { anyOf: [{ not: parseAnyDef() }, innerSchema] } : parseAnyDef();\n};\nvar parsePipelineDef = (def, refs) => {\n\tif (refs.pipeStrategy === \"input\") return parseDef(def.in._def, refs);\n\telse if (refs.pipeStrategy === \"output\") return parseDef(def.out._def, refs);\n\tconst a = parseDef(def.in._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"0\"\n\t\t]\n\t});\n\treturn { allOf: [a, parseDef(def.out._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\ta ? \"1\" : \"0\"\n\t\t]\n\t})].filter((x) => x !== void 0) };\n};\nfunction parsePromiseDef(def, refs) {\n\treturn parseDef(def.type._def, refs);\n}\nfunction parseSetDef(def, refs) {\n\tconst schema = {\n\t\ttype: \"array\",\n\t\tuniqueItems: true,\n\t\titems: parseDef(def.valueType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"items\"]\n\t\t})\n\t};\n\tif (def.minSize) schema.minItems = def.minSize.value;\n\tif (def.maxSize) schema.maxItems = def.maxSize.value;\n\treturn schema;\n}\nfunction parseTupleDef(def, refs) {\n\tif (def.rest) return {\n\t\ttype: \"array\",\n\t\tminItems: def.items.length,\n\t\titems: def.items.map((x, i) => parseDef(x._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"items\",\n\t\t\t\t`${i}`\n\t\t\t]\n\t\t})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),\n\t\tadditionalItems: parseDef(def.rest._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"additionalItems\"]\n\t\t})\n\t};\n\telse return {\n\t\ttype: \"array\",\n\t\tminItems: def.items.length,\n\t\tmaxItems: def.items.length,\n\t\titems: def.items.map((x, i) => parseDef(x._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"items\",\n\t\t\t\t`${i}`\n\t\t\t]\n\t\t})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])\n\t};\n}\nfunction parseUndefinedDef() {\n\treturn { not: parseAnyDef() };\n}\nfunction parseUnknownDef() {\n\treturn parseAnyDef();\n}\nvar parseReadonlyDef = (def, refs) => {\n\treturn parseDef(def.innerType._def, refs);\n};\nvar selectParser = (def, typeName, refs) => {\n\tswitch (typeName) {\n\t\tcase ZodFirstPartyTypeKind.ZodString: return parseStringDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNumber: return parseNumberDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodObject: return parseObjectDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBigInt: return parseBigintDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodBoolean: return parseBooleanDef();\n\t\tcase ZodFirstPartyTypeKind.ZodDate: return parseDateDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUndefined: return parseUndefinedDef();\n\t\tcase ZodFirstPartyTypeKind.ZodNull: return parseNullDef();\n\t\tcase ZodFirstPartyTypeKind.ZodArray: return parseArrayDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUnion:\n\t\tcase ZodFirstPartyTypeKind.ZodDiscriminatedUnion: return parseUnionDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodIntersection: return parseIntersectionDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodTuple: return parseTupleDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodRecord: return parseRecordDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodLiteral: return parseLiteralDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodEnum: return parseEnumDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodNativeEnum: return parseNativeEnumDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodNullable: return parseNullableDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodLazy: return () => def.getter()._def;\n\t\tcase ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNaN:\n\t\tcase ZodFirstPartyTypeKind.ZodNever: return parseNeverDef();\n\t\tcase ZodFirstPartyTypeKind.ZodEffects: return parseEffectsDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodAny: return parseAnyDef();\n\t\tcase ZodFirstPartyTypeKind.ZodUnknown: return parseUnknownDef();\n\t\tcase ZodFirstPartyTypeKind.ZodDefault: return parseDefaultDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBranded: return parseBrandedDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodReadonly: return parseReadonlyDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodCatch: return parseCatchDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodPipeline: return parsePipelineDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodFunction:\n\t\tcase ZodFirstPartyTypeKind.ZodVoid:\n\t\tcase ZodFirstPartyTypeKind.ZodSymbol: return;\n\t\tdefault: return /* @__PURE__ */ ((_) => void 0)(typeName);\n\t}\n};\nvar getRelativePath = (pathA, pathB) => {\n\tlet i = 0;\n\tfor (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;\n\treturn [(pathA.length - i).toString(), ...pathB.slice(i)].join(\"/\");\n};\nfunction parseDef(def, refs, forceResolution = false) {\n\tvar _a2;\n\tconst seenItem = refs.seen.get(def);\n\tif (refs.override) {\n\t\tconst overrideResult = (_a2 = refs.override) == null ? void 0 : _a2.call(refs, def, refs, seenItem, forceResolution);\n\t\tif (overrideResult !== ignoreOverride) return overrideResult;\n\t}\n\tif (seenItem && !forceResolution) {\n\t\tconst seenSchema = get$ref(seenItem, refs);\n\t\tif (seenSchema !== void 0) return seenSchema;\n\t}\n\tconst newItem = {\n\t\tdef,\n\t\tpath: refs.currentPath,\n\t\tjsonSchema: void 0\n\t};\n\trefs.seen.set(def, newItem);\n\tconst jsonSchemaOrGetter = selectParser(def, def.typeName, refs);\n\tconst jsonSchema2 = typeof jsonSchemaOrGetter === \"function\" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;\n\tif (jsonSchema2) addMeta(def, refs, jsonSchema2);\n\tif (refs.postProcess) {\n\t\tconst postProcessResult = refs.postProcess(jsonSchema2, def, refs);\n\t\tnewItem.jsonSchema = jsonSchema2;\n\t\treturn postProcessResult;\n\t}\n\tnewItem.jsonSchema = jsonSchema2;\n\treturn jsonSchema2;\n}\nvar get$ref = (item, refs) => {\n\tswitch (refs.$refStrategy) {\n\t\tcase \"root\": return { $ref: item.path.join(\"/\") };\n\t\tcase \"relative\": return { $ref: getRelativePath(refs.currentPath, item.path) };\n\t\tcase \"none\":\n\t\tcase \"seen\":\n\t\t\tif (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {\n\t\t\t\tconsole.warn(`Recursive reference detected at ${refs.currentPath.join(\"/\")}! Defaulting to any`);\n\t\t\t\treturn parseAnyDef();\n\t\t\t}\n\t\t\treturn refs.$refStrategy === \"seen\" ? parseAnyDef() : void 0;\n\t}\n};\nvar addMeta = (def, refs, jsonSchema2) => {\n\tif (def.description) jsonSchema2.description = def.description;\n\treturn jsonSchema2;\n};\nvar getRefs = (options) => {\n\tconst _options = getDefaultOptions(options);\n\tconst currentPath = _options.name !== void 0 ? [\n\t\t..._options.basePath,\n\t\t_options.definitionPath,\n\t\t_options.name\n\t] : _options.basePath;\n\treturn {\n\t\t..._options,\n\t\tcurrentPath,\n\t\tpropertyPath: void 0,\n\t\tseen: new Map(Object.entries(_options.definitions).map(([name2, def]) => [def._def, {\n\t\t\tdef: def._def,\n\t\t\tpath: [\n\t\t\t\t..._options.basePath,\n\t\t\t\t_options.definitionPath,\n\t\t\t\tname2\n\t\t\t],\n\t\t\tjsonSchema: void 0\n\t\t}]))\n\t};\n};\nvar zodToJsonSchema = (schema, options) => {\n\tvar _a2;\n\tconst refs = getRefs(options);\n\tlet definitions = typeof options === \"object\" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name3, schema2]) => {\n\t\tvar _a3;\n\t\treturn {\n\t\t\t...acc,\n\t\t\t[name3]: (_a3 = parseDef(schema2._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.basePath,\n\t\t\t\t\trefs.definitionPath,\n\t\t\t\t\tname3\n\t\t\t\t]\n\t\t\t}, true)) != null ? _a3 : parseAnyDef()\n\t\t};\n\t}, {}) : void 0;\n\tconst name2 = typeof options === \"string\" ? options : (options == null ? void 0 : options.nameStrategy) === \"title\" ? void 0 : options == null ? void 0 : options.name;\n\tconst main = (_a2 = parseDef(schema._def, name2 === void 0 ? refs : {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.basePath,\n\t\t\trefs.definitionPath,\n\t\t\tname2\n\t\t]\n\t}, false)) != null ? _a2 : parseAnyDef();\n\tconst title = typeof options === \"object\" && options.name !== void 0 && options.nameStrategy === \"title\" ? options.name : void 0;\n\tif (title !== void 0) main.title = title;\n\tconst combined = name2 === void 0 ? definitions ? {\n\t\t...main,\n\t\t[refs.definitionPath]: definitions\n\t} : main : {\n\t\t$ref: [\n\t\t\t...refs.$refStrategy === \"relative\" ? [] : refs.basePath,\n\t\t\trefs.definitionPath,\n\t\t\tname2\n\t\t].join(\"/\"),\n\t\t[refs.definitionPath]: {\n\t\t\t...definitions,\n\t\t\t[name2]: main\n\t\t}\n\t};\n\tcombined.$schema = \"http://json-schema.org/draft-07/schema#\";\n\treturn combined;\n};\nvar zod_to_json_schema_default = zodToJsonSchema;\nfunction zod3Schema(zodSchema2, options) {\n\tvar _a2;\n\tconst useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;\n\treturn jsonSchema(() => zod_to_json_schema_default(zodSchema2, { $refStrategy: useReferences ? \"root\" : \"none\" }), { validate: async (value) => {\n\t\tconst result = await zodSchema2.safeParseAsync(value);\n\t\treturn result.success ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.data\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: result.error\n\t\t};\n\t} });\n}\nfunction zod4Schema(zodSchema2, options) {\n\tvar _a2;\n\tconst useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;\n\treturn jsonSchema(() => addAdditionalPropertiesToJsonSchema(z4.toJSONSchema(zodSchema2, {\n\t\ttarget: \"draft-7\",\n\t\tio: \"input\",\n\t\treused: useReferences ? \"ref\" : \"inline\"\n\t})), { validate: async (value) => {\n\t\tconst result = await z4.safeParseAsync(zodSchema2, value);\n\t\treturn result.success ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.data\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: result.error\n\t\t};\n\t} });\n}\nfunction isZod4Schema(zodSchema2) {\n\treturn \"_zod\" in zodSchema2;\n}\nfunction zodSchema(zodSchema2, options) {\n\tif (isZod4Schema(zodSchema2)) return zod4Schema(zodSchema2, options);\n\telse return zod3Schema(zodSchema2, options);\n}\nfunction isSchema(value) {\n\treturn typeof value === \"object\" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && \"jsonSchema\" in value && \"validate\" in value;\n}\nfunction asSchema(schema) {\n\treturn schema == null ? jsonSchema({\n\t\tproperties: {},\n\t\tadditionalProperties: false\n\t}) : isSchema(schema) ? schema : typeof schema === \"function\" ? schema() : zodSchema(schema);\n}\nvar { btoa, atob } = globalThis;\nfunction convertBase64ToUint8Array(base64String) {\n\tconst latin1string = atob(base64String.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n\treturn Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));\n}\nfunction convertUint8ArrayToBase64(array) {\n\tconst chunks = [];\n\tconst chunkSize = 4096;\n\tfor (let i = 0; i < array.length; i += chunkSize) chunks.push(String.fromCodePoint(...array.subarray(i, i + chunkSize)));\n\treturn btoa(chunks.join(\"\"));\n}\nfunction withoutTrailingSlash(url) {\n\treturn url == null ? void 0 : url.replace(/\\/$/, \"\");\n}\nfunction isAsyncIterable(obj) {\n\treturn obj != null && typeof obj[Symbol.asyncIterator] === \"function\";\n}\nasync function* executeTool({ execute, input, options }) {\n\tconst result = execute(input, options);\n\tif (isAsyncIterable(result)) {\n\t\tlet lastOutput;\n\t\tfor await (const output of result) {\n\t\t\tlastOutput = output;\n\t\t\tyield {\n\t\t\t\ttype: \"preliminary\",\n\t\t\t\toutput\n\t\t\t};\n\t\t}\n\t\tyield {\n\t\t\ttype: \"final\",\n\t\t\toutput: lastOutput\n\t\t};\n\t} else yield {\n\t\ttype: \"final\",\n\t\toutput: await result\n\t};\n}\n//#endregion\nexport { TooManyEmbeddingValuesForCallError as $, normalizeHeaders as A, withoutTrailingSlash as B, getRuntimeEnvironmentUserAgent as C, lazySchema as D, jsonSchema as E, safeParseJSON as F, InvalidArgumentError as G, AISDKError as H, safeValidateTypes as I, JSONParseError as J, InvalidPromptError as K, tool as L, postJsonToApi as M, readResponseWithSizeLimit as N, lazyValidator as O, resolve as P, NoSuchModelError as Q, validateTypes as R, getFromApi as S, isUrlSupported as T, APICallError as U, zodSchema as V, EmptyResponseBodyError as W, LoadSettingError as X, LoadAPIKeyError as Y, NoContentGeneratedError as Z, dynamicTool as _, asSchema as a, generateId as b, convertAsyncIteratorToReadableStream as c, createEventSourceResponseHandler as d, TypeValidationError as et, createIdGenerator as f, delay as g, createProviderDefinedToolFactoryWithOutputSchema as h, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as i, isJSONObject as it, parseJsonEventStream as j, loadOptionalSetting as k, convertBase64ToUint8Array as l, createJsonResponseHandler as m, DelayedPromise as n, getErrorMessage$1 as nt, cancelResponseBody as o, createJsonErrorResponseHandler as p, InvalidResponseDataError as q, DownloadError as r, isJSONArray as rt, combineHeaders as s, DEFAULT_MAX_DOWNLOAD_SIZE as t, UnsupportedFunctionalityError as tt, convertUint8ArrayToBase64 as u, executeTool as v, isAbortError as w, getErrorMessage as x, fetchWithValidatedRedirects as y, withUserAgentSuffix as z };\n\n//# sourceMappingURL=dist-OCi48HWi.js.map","import { $ as TooManyEmbeddingValuesForCallError, A as normalizeHeaders, C as getRuntimeEnvironmentUserAgent, E as jsonSchema, F as safeParseJSON, G as InvalidArgumentError$1, H as AISDKError, I as safeValidateTypes, J as JSONParseError, K as InvalidPromptError, L as tool, N as readResponseWithSizeLimit, O as lazyValidator, P as resolve, Q as NoSuchModelError, R as validateTypes, T as isUrlSupported, U as APICallError, V as zodSchema, W as EmptyResponseBodyError, X as LoadSettingError, Y as LoadAPIKeyError, Z as NoContentGeneratedError, _ as dynamicTool, a as asSchema, b as generateId, et as TypeValidationError, f as createIdGenerator, g as delay, i as EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, it as isJSONObject, j as parseJsonEventStream, l as convertBase64ToUint8Array, n as DelayedPromise, nt as getErrorMessage, o as cancelResponseBody, q as InvalidResponseDataError, r as DownloadError$1, rt as isJSONArray, t as DEFAULT_MAX_DOWNLOAD_SIZE, tt as UnsupportedFunctionalityError, u as convertUint8ArrayToBase64, v as executeTool, w as isAbortError, x as getErrorMessage$1, y as fetchWithValidatedRedirects, z as withUserAgentSuffix } from \"./dist-OCi48HWi.js\";\nimport { i as gateway, n as GatewayError, r as createGatewayProvider, t as GatewayAuthenticationError } from \"./dist-Bcz48aZq.js\";\nimport { z } from \"zod/v4\";\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js\n/** only globals that common to node and browsers are allowed */\nvar _globalThis = typeof globalThis === \"object\" ? globalThis : global;\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/version.js\nvar VERSION$1 = \"1.9.0\";\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/internal/semver.js\nvar re = /^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;\n/**\n* Create a function to test an API version to see if it is compatible with the provided ownVersion.\n*\n* The returned function has the following semantics:\n* - Exact match is always compatible\n* - Major versions must match exactly\n*    - 1.x package cannot use global 2.x package\n*    - 2.x package cannot use global 1.x package\n* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n*    - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n*    - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n* - Patch and build tag differences are not considered at this time\n*\n* @param ownVersion version which should be checked against\n*/\nfunction _makeCompatibilityCheck(ownVersion) {\n\tvar acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);\n\tvar rejectedVersions = /* @__PURE__ */ new Set();\n\tvar myVersionMatch = ownVersion.match(re);\n\tif (!myVersionMatch) return function() {\n\t\treturn false;\n\t};\n\tvar ownVersionParsed = {\n\t\tmajor: +myVersionMatch[1],\n\t\tminor: +myVersionMatch[2],\n\t\tpatch: +myVersionMatch[3],\n\t\tprerelease: myVersionMatch[4]\n\t};\n\tif (ownVersionParsed.prerelease != null) return function isExactmatch(globalVersion) {\n\t\treturn globalVersion === ownVersion;\n\t};\n\tfunction _reject(v) {\n\t\trejectedVersions.add(v);\n\t\treturn false;\n\t}\n\tfunction _accept(v) {\n\t\tacceptedVersions.add(v);\n\t\treturn true;\n\t}\n\treturn function isCompatible(globalVersion) {\n\t\tif (acceptedVersions.has(globalVersion)) return true;\n\t\tif (rejectedVersions.has(globalVersion)) return false;\n\t\tvar globalVersionMatch = globalVersion.match(re);\n\t\tif (!globalVersionMatch) return _reject(globalVersion);\n\t\tvar globalVersionParsed = {\n\t\t\tmajor: +globalVersionMatch[1],\n\t\t\tminor: +globalVersionMatch[2],\n\t\t\tpatch: +globalVersionMatch[3],\n\t\t\tprerelease: globalVersionMatch[4]\n\t\t};\n\t\tif (globalVersionParsed.prerelease != null) return _reject(globalVersion);\n\t\tif (ownVersionParsed.major !== globalVersionParsed.major) return _reject(globalVersion);\n\t\tif (ownVersionParsed.major === 0) {\n\t\t\tif (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) return _accept(globalVersion);\n\t\t\treturn _reject(globalVersion);\n\t\t}\n\t\tif (ownVersionParsed.minor <= globalVersionParsed.minor) return _accept(globalVersion);\n\t\treturn _reject(globalVersion);\n\t};\n}\n/**\n* Test an API version to see if it is compatible with this API.\n*\n* - Exact match is always compatible\n* - Major versions must match exactly\n*    - 1.x package cannot use global 2.x package\n*    - 2.x package cannot use global 1.x package\n* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n*    - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n*    - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n* - Patch and build tag differences are not considered at this time\n*\n* @param version version of the API requesting an instance of the global API\n*/\nvar isCompatible = _makeCompatibilityCheck(VERSION$1);\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js\nvar major = VERSION$1.split(\".\")[0];\nvar GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(\"opentelemetry.js.api.\" + major);\nvar _global = _globalThis;\nfunction registerGlobal(type, instance, diag, allowOverride) {\n\tvar _a;\n\tif (allowOverride === void 0) allowOverride = false;\n\tvar api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : { version: VERSION$1 };\n\tif (!allowOverride && api[type]) {\n\t\tvar err = /* @__PURE__ */ new Error(\"@opentelemetry/api: Attempted duplicate registration of API: \" + type);\n\t\tdiag.error(err.stack || err.message);\n\t\treturn false;\n\t}\n\tif (api.version !== \"1.9.0\") {\n\t\tvar err = /* @__PURE__ */ new Error(\"@opentelemetry/api: Registration of version v\" + api.version + \" for \" + type + \" does not match previously registered API v\" + VERSION$1);\n\t\tdiag.error(err.stack || err.message);\n\t\treturn false;\n\t}\n\tapi[type] = instance;\n\tdiag.debug(\"@opentelemetry/api: Registered a global for \" + type + \" v\" + VERSION$1 + \".\");\n\treturn true;\n}\nfunction getGlobal(type) {\n\tvar _a, _b;\n\tvar globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;\n\tif (!globalVersion || !isCompatible(globalVersion)) return;\n\treturn (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];\n}\nfunction unregisterGlobal(type, diag) {\n\tdiag.debug(\"@opentelemetry/api: Unregistering a global for \" + type + \" v\" + VERSION$1 + \".\");\n\tvar api = _global[GLOBAL_OPENTELEMETRY_API_KEY];\n\tif (api) delete api[type];\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js\nvar __read$3 = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray$3 = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\n/**\n* Component Logger which is meant to be used as part of any component which\n* will add automatically additional namespace in front of the log message.\n* It will then forward all message to global diag logger\n* @example\n* const cLogger = diag.createComponentLogger({ namespace: '@opentelemetry/instrumentation-http' });\n* cLogger.debug('test');\n* // @opentelemetry/instrumentation-http test\n*/\nvar DiagComponentLogger = function() {\n\tfunction DiagComponentLogger(props) {\n\t\tthis._namespace = props.namespace || \"DiagComponentLogger\";\n\t}\n\tDiagComponentLogger.prototype.debug = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"debug\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.error = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"error\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.info = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"info\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.warn = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"warn\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.verbose = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"verbose\", this._namespace, args);\n\t};\n\treturn DiagComponentLogger;\n}();\nfunction logProxy(funcName, namespace, args) {\n\tvar logger = getGlobal(\"diag\");\n\tif (!logger) return;\n\targs.unshift(namespace);\n\treturn logger[funcName].apply(logger, __spreadArray$3([], __read$3(args), false));\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/diag/types.js\n/**\n* Defines the available internal logging levels for the diagnostic logger, the numeric values\n* of the levels are defined to match the original values from the initial LogLevel to avoid\n* compatibility/migration issues for any implementation that assume the numeric ordering.\n*/\nvar DiagLogLevel;\n(function(DiagLogLevel) {\n\t/** Diagnostic Logging level setting to disable all logging (except and forced logs) */\n\tDiagLogLevel[DiagLogLevel[\"NONE\"] = 0] = \"NONE\";\n\t/** Identifies an error scenario */\n\tDiagLogLevel[DiagLogLevel[\"ERROR\"] = 30] = \"ERROR\";\n\t/** Identifies a warning scenario */\n\tDiagLogLevel[DiagLogLevel[\"WARN\"] = 50] = \"WARN\";\n\t/** General informational log message */\n\tDiagLogLevel[DiagLogLevel[\"INFO\"] = 60] = \"INFO\";\n\t/** General debug log message */\n\tDiagLogLevel[DiagLogLevel[\"DEBUG\"] = 70] = \"DEBUG\";\n\t/**\n\t* Detailed trace level logging should only be used for development, should only be set\n\t* in a development environment.\n\t*/\n\tDiagLogLevel[DiagLogLevel[\"VERBOSE\"] = 80] = \"VERBOSE\";\n\t/** Used to set the logging level to include all logging */\n\tDiagLogLevel[DiagLogLevel[\"ALL\"] = 9999] = \"ALL\";\n})(DiagLogLevel || (DiagLogLevel = {}));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js\nfunction createLogLevelDiagLogger(maxLevel, logger) {\n\tif (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;\n\telse if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;\n\tlogger = logger || {};\n\tfunction _filterFunc(funcName, theLevel) {\n\t\tvar theFunc = logger[funcName];\n\t\tif (typeof theFunc === \"function\" && maxLevel >= theLevel) return theFunc.bind(logger);\n\t\treturn function() {};\n\t}\n\treturn {\n\t\terror: _filterFunc(\"error\", DiagLogLevel.ERROR),\n\t\twarn: _filterFunc(\"warn\", DiagLogLevel.WARN),\n\t\tinfo: _filterFunc(\"info\", DiagLogLevel.INFO),\n\t\tdebug: _filterFunc(\"debug\", DiagLogLevel.DEBUG),\n\t\tverbose: _filterFunc(\"verbose\", DiagLogLevel.VERBOSE)\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/api/diag.js\nvar __read$2 = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray$2 = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\nvar API_NAME$2 = \"diag\";\n/**\n* Singleton object which represents the entry point to the OpenTelemetry internal\n* diagnostic API\n*/\nvar DiagAPI = function() {\n\t/**\n\t* Private internal constructor\n\t* @private\n\t*/\n\tfunction DiagAPI() {\n\t\tfunction _logProxy(funcName) {\n\t\t\treturn function() {\n\t\t\t\tvar args = [];\n\t\t\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\t\t\tvar logger = getGlobal(\"diag\");\n\t\t\t\tif (!logger) return;\n\t\t\t\treturn logger[funcName].apply(logger, __spreadArray$2([], __read$2(args), false));\n\t\t\t};\n\t\t}\n\t\tvar self = this;\n\t\tvar setLogger = function(logger, optionsOrLogLevel) {\n\t\t\tvar _a, _b, _c;\n\t\t\tif (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };\n\t\t\tif (logger === self) {\n\t\t\t\tvar err = /* @__PURE__ */ new Error(\"Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation\");\n\t\t\t\tself.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (typeof optionsOrLogLevel === \"number\") optionsOrLogLevel = { logLevel: optionsOrLogLevel };\n\t\t\tvar oldLogger = getGlobal(\"diag\");\n\t\t\tvar newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);\n\t\t\tif (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {\n\t\t\t\tvar stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : \"<failed to generate stacktrace>\";\n\t\t\t\toldLogger.warn(\"Current logger will be overwritten from \" + stack);\n\t\t\t\tnewLogger.warn(\"Current logger will overwrite one already registered from \" + stack);\n\t\t\t}\n\t\t\treturn registerGlobal(\"diag\", newLogger, self, true);\n\t\t};\n\t\tself.setLogger = setLogger;\n\t\tself.disable = function() {\n\t\t\tunregisterGlobal(API_NAME$2, self);\n\t\t};\n\t\tself.createComponentLogger = function(options) {\n\t\t\treturn new DiagComponentLogger(options);\n\t\t};\n\t\tself.verbose = _logProxy(\"verbose\");\n\t\tself.debug = _logProxy(\"debug\");\n\t\tself.info = _logProxy(\"info\");\n\t\tself.warn = _logProxy(\"warn\");\n\t\tself.error = _logProxy(\"error\");\n\t}\n\t/** Get the singleton instance of the DiagAPI API */\n\tDiagAPI.instance = function() {\n\t\tif (!this._instance) this._instance = new DiagAPI();\n\t\treturn this._instance;\n\t};\n\treturn DiagAPI;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/context/context.js\n/** Get a key to uniquely identify a context value */\nfunction createContextKey(description) {\n\treturn Symbol.for(description);\n}\n/** The root context is used as the default parent context when there is no active context */\nvar ROOT_CONTEXT = new (function() {\n\t/**\n\t* Construct a new context which inherits values from an optional parent context.\n\t*\n\t* @param parentContext a context from which to inherit values\n\t*/\n\tfunction BaseContext(parentContext) {\n\t\tvar self = this;\n\t\tself._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();\n\t\tself.getValue = function(key) {\n\t\t\treturn self._currentContext.get(key);\n\t\t};\n\t\tself.setValue = function(key, value) {\n\t\t\tvar context = new BaseContext(self._currentContext);\n\t\t\tcontext._currentContext.set(key, value);\n\t\t\treturn context;\n\t\t};\n\t\tself.deleteValue = function(key) {\n\t\t\tvar context = new BaseContext(self._currentContext);\n\t\t\tcontext._currentContext.delete(key);\n\t\t\treturn context;\n\t\t};\n\t}\n\treturn BaseContext;\n}())();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js\nvar __read$1 = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray$1 = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\nvar NoopContextManager = function() {\n\tfunction NoopContextManager() {}\n\tNoopContextManager.prototype.active = function() {\n\t\treturn ROOT_CONTEXT;\n\t};\n\tNoopContextManager.prototype.with = function(_context, fn, thisArg) {\n\t\tvar args = [];\n\t\tfor (var _i = 3; _i < arguments.length; _i++) args[_i - 3] = arguments[_i];\n\t\treturn fn.call.apply(fn, __spreadArray$1([thisArg], __read$1(args), false));\n\t};\n\tNoopContextManager.prototype.bind = function(_context, target) {\n\t\treturn target;\n\t};\n\tNoopContextManager.prototype.enable = function() {\n\t\treturn this;\n\t};\n\tNoopContextManager.prototype.disable = function() {\n\t\treturn this;\n\t};\n\treturn NoopContextManager;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/api/context.js\nvar __read = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\nvar API_NAME$1 = \"context\";\nvar NOOP_CONTEXT_MANAGER = new NoopContextManager();\n/**\n* Singleton object which represents the entry point to the OpenTelemetry Context API\n*/\nvar ContextAPI = function() {\n\t/** Empty private constructor prevents end users from constructing a new instance of the API */\n\tfunction ContextAPI() {}\n\t/** Get the singleton instance of the Context API */\n\tContextAPI.getInstance = function() {\n\t\tif (!this._instance) this._instance = new ContextAPI();\n\t\treturn this._instance;\n\t};\n\t/**\n\t* Set the current context manager.\n\t*\n\t* @returns true if the context manager was successfully registered, else false\n\t*/\n\tContextAPI.prototype.setGlobalContextManager = function(contextManager) {\n\t\treturn registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());\n\t};\n\t/**\n\t* Get the currently active context\n\t*/\n\tContextAPI.prototype.active = function() {\n\t\treturn this._getContextManager().active();\n\t};\n\t/**\n\t* Execute a function with an active context\n\t*\n\t* @param context context to be active during function execution\n\t* @param fn function to execute in a context\n\t* @param thisArg optional receiver to be used for calling fn\n\t* @param args optional arguments forwarded to fn\n\t*/\n\tContextAPI.prototype.with = function(context, fn, thisArg) {\n\t\tvar _a;\n\t\tvar args = [];\n\t\tfor (var _i = 3; _i < arguments.length; _i++) args[_i - 3] = arguments[_i];\n\t\treturn (_a = this._getContextManager()).with.apply(_a, __spreadArray([\n\t\t\tcontext,\n\t\t\tfn,\n\t\t\tthisArg\n\t\t], __read(args), false));\n\t};\n\t/**\n\t* Bind a context to a target function or event emitter\n\t*\n\t* @param context context to bind to the event emitter or function. Defaults to the currently active context\n\t* @param target function or event emitter to bind\n\t*/\n\tContextAPI.prototype.bind = function(context, target) {\n\t\treturn this._getContextManager().bind(context, target);\n\t};\n\tContextAPI.prototype._getContextManager = function() {\n\t\treturn getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;\n\t};\n\t/** Disable and remove the global context manager */\n\tContextAPI.prototype.disable = function() {\n\t\tthis._getContextManager().disable();\n\t\tunregisterGlobal(API_NAME$1, DiagAPI.instance());\n\t};\n\treturn ContextAPI;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js\nvar TraceFlags;\n(function(TraceFlags) {\n\t/** Represents no flag set. */\n\tTraceFlags[TraceFlags[\"NONE\"] = 0] = \"NONE\";\n\t/** Bit to represent whether trace is sampled in trace flags. */\n\tTraceFlags[TraceFlags[\"SAMPLED\"] = 1] = \"SAMPLED\";\n})(TraceFlags || (TraceFlags = {}));\nvar INVALID_SPAN_CONTEXT = {\n\ttraceId: \"00000000000000000000000000000000\",\n\tspanId: \"0000000000000000\",\n\ttraceFlags: TraceFlags.NONE\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js\n/**\n* The NonRecordingSpan is the default {@link Span} that is used when no Span\n* implementation is available. All operations are no-op including context\n* propagation.\n*/\nvar NonRecordingSpan = function() {\n\tfunction NonRecordingSpan(_spanContext) {\n\t\tif (_spanContext === void 0) _spanContext = INVALID_SPAN_CONTEXT;\n\t\tthis._spanContext = _spanContext;\n\t}\n\tNonRecordingSpan.prototype.spanContext = function() {\n\t\treturn this._spanContext;\n\t};\n\tNonRecordingSpan.prototype.setAttribute = function(_key, _value) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.setAttributes = function(_attributes) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.addEvent = function(_name, _attributes) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.addLink = function(_link) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.addLinks = function(_links) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.setStatus = function(_status) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.updateName = function(_name) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.end = function(_endTime) {};\n\tNonRecordingSpan.prototype.isRecording = function() {\n\t\treturn false;\n\t};\n\tNonRecordingSpan.prototype.recordException = function(_exception, _time) {};\n\treturn NonRecordingSpan;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js\n/**\n* span key\n*/\nvar SPAN_KEY = createContextKey(\"OpenTelemetry Context Key SPAN\");\n/**\n* Return the span if one exists\n*\n* @param context context to get span from\n*/\nfunction getSpan(context) {\n\treturn context.getValue(SPAN_KEY) || void 0;\n}\n/**\n* Gets the span from the current context, if one exists.\n*/\nfunction getActiveSpan() {\n\treturn getSpan(ContextAPI.getInstance().active());\n}\n/**\n* Set the span on a context\n*\n* @param context context to use as parent\n* @param span span to set active\n*/\nfunction setSpan(context, span) {\n\treturn context.setValue(SPAN_KEY, span);\n}\n/**\n* Remove current span stored in the context\n*\n* @param context context to delete span from\n*/\nfunction deleteSpan(context) {\n\treturn context.deleteValue(SPAN_KEY);\n}\n/**\n* Wrap span context in a NoopSpan and set as span in a new\n* context\n*\n* @param context context to set active span on\n* @param spanContext span context to be wrapped\n*/\nfunction setSpanContext(context, spanContext) {\n\treturn setSpan(context, new NonRecordingSpan(spanContext));\n}\n/**\n* Get the span context of the span if it exists.\n*\n* @param context context to get values from\n*/\nfunction getSpanContext(context) {\n\tvar _a;\n\treturn (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js\nvar VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;\nvar VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;\nfunction isValidTraceId(traceId) {\n\treturn VALID_TRACEID_REGEX.test(traceId) && traceId !== \"00000000000000000000000000000000\";\n}\nfunction isValidSpanId(spanId) {\n\treturn VALID_SPANID_REGEX.test(spanId) && spanId !== \"0000000000000000\";\n}\n/**\n* Returns true if this {@link SpanContext} is valid.\n* @return true if this {@link SpanContext} is valid.\n*/\nfunction isSpanContextValid(spanContext) {\n\treturn isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);\n}\n/**\n* Wrap the given {@link SpanContext} in a new non-recording {@link Span}\n*\n* @param spanContext span context to be wrapped\n* @returns a new non-recording {@link Span} with the provided context\n*/\nfunction wrapSpanContext(spanContext) {\n\treturn new NonRecordingSpan(spanContext);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js\nvar contextApi = ContextAPI.getInstance();\n/**\n* No-op implementations of {@link Tracer}.\n*/\nvar NoopTracer = function() {\n\tfunction NoopTracer() {}\n\tNoopTracer.prototype.startSpan = function(name, options, context) {\n\t\tif (context === void 0) context = contextApi.active();\n\t\tif (Boolean(options === null || options === void 0 ? void 0 : options.root)) return new NonRecordingSpan();\n\t\tvar parentFromContext = context && getSpanContext(context);\n\t\tif (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) return new NonRecordingSpan(parentFromContext);\n\t\telse return new NonRecordingSpan();\n\t};\n\tNoopTracer.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {\n\t\tvar opts;\n\t\tvar ctx;\n\t\tvar fn;\n\t\tif (arguments.length < 2) return;\n\t\telse if (arguments.length === 2) fn = arg2;\n\t\telse if (arguments.length === 3) {\n\t\t\topts = arg2;\n\t\t\tfn = arg3;\n\t\t} else {\n\t\t\topts = arg2;\n\t\t\tctx = arg3;\n\t\t\tfn = arg4;\n\t\t}\n\t\tvar parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();\n\t\tvar span = this.startSpan(name, opts, parentContext);\n\t\tvar contextWithSpanSet = setSpan(parentContext, span);\n\t\treturn contextApi.with(contextWithSpanSet, fn, void 0, span);\n\t};\n\treturn NoopTracer;\n}();\nfunction isSpanContext(spanContext) {\n\treturn typeof spanContext === \"object\" && typeof spanContext[\"spanId\"] === \"string\" && typeof spanContext[\"traceId\"] === \"string\" && typeof spanContext[\"traceFlags\"] === \"number\";\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js\nvar NOOP_TRACER = new NoopTracer();\n/**\n* Proxy tracer provided by the proxy tracer provider\n*/\nvar ProxyTracer = function() {\n\tfunction ProxyTracer(_provider, name, version, options) {\n\t\tthis._provider = _provider;\n\t\tthis.name = name;\n\t\tthis.version = version;\n\t\tthis.options = options;\n\t}\n\tProxyTracer.prototype.startSpan = function(name, options, context) {\n\t\treturn this._getTracer().startSpan(name, options, context);\n\t};\n\tProxyTracer.prototype.startActiveSpan = function(_name, _options, _context, _fn) {\n\t\tvar tracer = this._getTracer();\n\t\treturn Reflect.apply(tracer.startActiveSpan, tracer, arguments);\n\t};\n\t/**\n\t* Try to get a tracer from the proxy tracer provider.\n\t* If the proxy tracer provider has no delegate, return a noop tracer.\n\t*/\n\tProxyTracer.prototype._getTracer = function() {\n\t\tif (this._delegate) return this._delegate;\n\t\tvar tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);\n\t\tif (!tracer) return NOOP_TRACER;\n\t\tthis._delegate = tracer;\n\t\treturn this._delegate;\n\t};\n\treturn ProxyTracer;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js\nvar NOOP_TRACER_PROVIDER = new (function() {\n\tfunction NoopTracerProvider() {}\n\tNoopTracerProvider.prototype.getTracer = function(_name, _version, _options) {\n\t\treturn new NoopTracer();\n\t};\n\treturn NoopTracerProvider;\n}())();\n/**\n* Tracer provider which provides {@link ProxyTracer}s.\n*\n* Before a delegate is set, tracers provided are NoOp.\n*   When a delegate is set, traces are provided from the delegate.\n*   When a delegate is set after tracers have already been provided,\n*   all tracers already provided will use the provided delegate implementation.\n*/\nvar ProxyTracerProvider = function() {\n\tfunction ProxyTracerProvider() {}\n\t/**\n\t* Get a {@link ProxyTracer}\n\t*/\n\tProxyTracerProvider.prototype.getTracer = function(name, version, options) {\n\t\tvar _a;\n\t\treturn (_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options);\n\t};\n\tProxyTracerProvider.prototype.getDelegate = function() {\n\t\tvar _a;\n\t\treturn (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;\n\t};\n\t/**\n\t* Set the delegate tracer provider\n\t*/\n\tProxyTracerProvider.prototype.setDelegate = function(delegate) {\n\t\tthis._delegate = delegate;\n\t};\n\tProxyTracerProvider.prototype.getDelegateTracer = function(name, version, options) {\n\t\tvar _a;\n\t\treturn (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);\n\t};\n\treturn ProxyTracerProvider;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/status.js\n/**\n* An enumeration of status codes.\n*/\nvar SpanStatusCode;\n(function(SpanStatusCode) {\n\t/**\n\t* The default status.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"UNSET\"] = 0] = \"UNSET\";\n\t/**\n\t* The operation has been validated by an Application developer or\n\t* Operator to have completed successfully.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"OK\"] = 1] = \"OK\";\n\t/**\n\t* The operation contains an error.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"ERROR\"] = 2] = \"ERROR\";\n})(SpanStatusCode || (SpanStatusCode = {}));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/api/trace.js\nvar API_NAME = \"trace\";\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace-api.js\n/** Entrypoint for trace API */\nvar trace = function() {\n\t/** Empty private constructor prevents end users from constructing a new instance of the API */\n\tfunction TraceAPI() {\n\t\tthis._proxyTracerProvider = new ProxyTracerProvider();\n\t\tthis.wrapSpanContext = wrapSpanContext;\n\t\tthis.isSpanContextValid = isSpanContextValid;\n\t\tthis.deleteSpan = deleteSpan;\n\t\tthis.getSpan = getSpan;\n\t\tthis.getActiveSpan = getActiveSpan;\n\t\tthis.getSpanContext = getSpanContext;\n\t\tthis.setSpan = setSpan;\n\t\tthis.setSpanContext = setSpanContext;\n\t}\n\t/** Get the singleton instance of the Trace API */\n\tTraceAPI.getInstance = function() {\n\t\tif (!this._instance) this._instance = new TraceAPI();\n\t\treturn this._instance;\n\t};\n\t/**\n\t* Set the current global tracer.\n\t*\n\t* @returns true if the tracer provider was successfully registered, else false\n\t*/\n\tTraceAPI.prototype.setGlobalTracerProvider = function(provider) {\n\t\tvar success = registerGlobal(API_NAME, this._proxyTracerProvider, DiagAPI.instance());\n\t\tif (success) this._proxyTracerProvider.setDelegate(provider);\n\t\treturn success;\n\t};\n\t/**\n\t* Returns the global tracer provider.\n\t*/\n\tTraceAPI.prototype.getTracerProvider = function() {\n\t\treturn getGlobal(API_NAME) || this._proxyTracerProvider;\n\t};\n\t/**\n\t* Returns a tracer from the global tracer provider.\n\t*/\n\tTraceAPI.prototype.getTracer = function(name, version) {\n\t\treturn this.getTracerProvider().getTracer(name, version);\n\t};\n\t/** Remove the global tracer provider */\n\tTraceAPI.prototype.disable = function() {\n\t\tunregisterGlobal(API_NAME, DiagAPI.instance());\n\t\tthis._proxyTracerProvider = new ProxyTracerProvider();\n\t};\n\treturn TraceAPI;\n}().getInstance();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/ai/5.0.277/29baf09a3fb3418d0bb2392d80c4174b2208d7cd6fec72bb6b4b3d27f449deda/node_modules/ai/dist/index.mjs\nvar __defProp = Object.defineProperty;\nvar __export = (target, all) => {\n\tfor (var name16 in all) __defProp(target, name16, {\n\t\tget: all[name16],\n\t\tenumerable: true\n\t});\n};\nvar name = \"AI_NoOutputSpecifiedError\";\nvar marker = `vercel.ai.error.${name}`;\nvar symbol = Symbol.for(marker);\nvar _a;\nvar NoOutputSpecifiedError = class extends AISDKError {\n\tconstructor({ message = \"No output specified.\" } = {}) {\n\t\tsuper({\n\t\t\tname,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker);\n\t}\n};\n_a = symbol;\nfunction formatWarning(warning) {\n\tconst prefix = \"AI SDK Warning:\";\n\tswitch (warning.type) {\n\t\tcase \"unsupported-setting\": {\n\t\t\tlet message = `${prefix} The \"${warning.setting}\" setting is not supported by this model`;\n\t\t\tif (warning.details) message += ` - ${warning.details}`;\n\t\t\treturn message;\n\t\t}\n\t\tcase \"unsupported-tool\": {\n\t\t\tlet message = `${prefix} The tool \"${\"name\" in warning.tool ? warning.tool.name : \"unknown tool\"}\" is not supported by this model`;\n\t\t\tif (warning.details) message += ` - ${warning.details}`;\n\t\t\treturn message;\n\t\t}\n\t\tcase \"other\": return `${prefix} ${warning.message}`;\n\t\tdefault: return `${prefix} ${JSON.stringify(warning, null, 2)}`;\n\t}\n}\nvar FIRST_WARNING_INFO_MESSAGE = \"AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.\";\nvar hasLoggedBefore = false;\nfunction emitWarning({ message, type }) {\n\tif (typeof process !== \"undefined\" && typeof process.emitWarning === \"function\") process.emitWarning(message, { type });\n\telse console.warn(message);\n}\nvar logWarnings = (warnings) => {\n\tif (warnings.length === 0) return;\n\tconst logger = globalThis.AI_SDK_LOG_WARNINGS;\n\tif (logger === false) return;\n\tif (typeof logger === \"function\") {\n\t\tlogger(warnings);\n\t\treturn;\n\t}\n\tif (!hasLoggedBefore) {\n\t\thasLoggedBefore = true;\n\t\temitWarning({\n\t\t\tmessage: FIRST_WARNING_INFO_MESSAGE,\n\t\t\ttype: \"Warning\"\n\t\t});\n\t}\n\tfor (const warning of warnings) emitWarning({\n\t\tmessage: formatWarning(warning),\n\t\ttype: \"Warning\"\n\t});\n};\nvar name2 = \"AI_InvalidArgumentError\";\nvar marker2 = `vercel.ai.error.${name2}`;\nvar symbol2 = Symbol.for(marker2);\nvar _a2;\nvar InvalidArgumentError = class extends AISDKError {\n\tconstructor({ parameter, value, message }) {\n\t\tsuper({\n\t\t\tname: name2,\n\t\t\tmessage: `Invalid argument for parameter ${parameter}: ${message}`\n\t\t});\n\t\tthis[_a2] = true;\n\t\tthis.parameter = parameter;\n\t\tthis.value = value;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker2);\n\t}\n};\n_a2 = symbol2;\nvar name3 = \"AI_InvalidStreamPartError\";\nvar marker3 = `vercel.ai.error.${name3}`;\nvar symbol3 = Symbol.for(marker3);\nvar _a3;\nvar InvalidStreamPartError = class extends AISDKError {\n\tconstructor({ chunk, message }) {\n\t\tsuper({\n\t\t\tname: name3,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a3] = true;\n\t\tthis.chunk = chunk;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker3);\n\t}\n};\n_a3 = symbol3;\nvar name4 = \"AI_InvalidToolInputError\";\nvar marker4 = `vercel.ai.error.${name4}`;\nvar symbol4 = Symbol.for(marker4);\nvar _a4;\nvar InvalidToolInputError = class extends AISDKError {\n\tconstructor({ toolInput, toolName, cause, message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name4,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a4] = true;\n\t\tthis.toolInput = toolInput;\n\t\tthis.toolName = toolName;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker4);\n\t}\n};\n_a4 = symbol4;\nvar name5 = \"AI_NoImageGeneratedError\";\nvar marker5 = `vercel.ai.error.${name5}`;\nvar symbol5 = Symbol.for(marker5);\nvar _a5;\nvar NoImageGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No image generated.\", cause, responses }) {\n\t\tsuper({\n\t\t\tname: name5,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a5] = true;\n\t\tthis.responses = responses;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker5);\n\t}\n};\n_a5 = symbol5;\nvar name6 = \"AI_NoObjectGeneratedError\";\nvar marker6 = `vercel.ai.error.${name6}`;\nvar symbol6 = Symbol.for(marker6);\nvar _a6;\nvar NoObjectGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No object generated.\", cause, text: text2, response, usage, finishReason }) {\n\t\tsuper({\n\t\t\tname: name6,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a6] = true;\n\t\tthis.text = text2;\n\t\tthis.response = response;\n\t\tthis.usage = usage;\n\t\tthis.finishReason = finishReason;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker6);\n\t}\n};\n_a6 = symbol6;\nvar name7 = \"AI_NoOutputGeneratedError\";\nvar marker7 = `vercel.ai.error.${name7}`;\nvar symbol7 = Symbol.for(marker7);\nvar _a7;\nvar NoOutputGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No output generated.\", cause } = {}) {\n\t\tsuper({\n\t\t\tname: name7,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a7] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker7);\n\t}\n};\n_a7 = symbol7;\nvar NoSpeechGeneratedError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: \"AI_NoSpeechGeneratedError\",\n\t\t\tmessage: \"No speech audio generated.\"\n\t\t});\n\t\tthis.responses = options.responses;\n\t}\n};\nvar name8 = \"AI_NoSuchToolError\";\nvar marker8 = `vercel.ai.error.${name8}`;\nvar symbol8 = Symbol.for(marker8);\nvar _a8;\nvar NoSuchToolError = class extends AISDKError {\n\tconstructor({ toolName, availableTools = void 0, message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? \"No tools are available.\" : `Available tools: ${availableTools.join(\", \")}.`}` }) {\n\t\tsuper({\n\t\t\tname: name8,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a8] = true;\n\t\tthis.toolName = toolName;\n\t\tthis.availableTools = availableTools;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker8);\n\t}\n};\n_a8 = symbol8;\nvar name9 = \"AI_ToolCallRepairError\";\nvar marker9 = `vercel.ai.error.${name9}`;\nvar symbol9 = Symbol.for(marker9);\nvar _a9;\nvar ToolCallRepairError = class extends AISDKError {\n\tconstructor({ cause, originalError, message = `Error repairing tool call: ${getErrorMessage(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name9,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a9] = true;\n\t\tthis.originalError = originalError;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker9);\n\t}\n};\n_a9 = symbol9;\nvar UnsupportedModelVersionError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: \"AI_UnsupportedModelVersionError\",\n\t\t\tmessage: `Unsupported model version ${options.version} for provider \"${options.provider}\" and model \"${options.modelId}\". AI SDK 5 only supports models that implement specification version \"v2\".`\n\t\t});\n\t\tthis.version = options.version;\n\t\tthis.provider = options.provider;\n\t\tthis.modelId = options.modelId;\n\t}\n};\nvar name10 = \"AI_InvalidDataContentError\";\nvar marker10 = `vercel.ai.error.${name10}`;\nvar symbol10 = Symbol.for(marker10);\nvar _a10;\nvar InvalidDataContentError = class extends AISDKError {\n\tconstructor({ content, cause, message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.` }) {\n\t\tsuper({\n\t\t\tname: name10,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a10] = true;\n\t\tthis.content = content;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker10);\n\t}\n};\n_a10 = symbol10;\nvar name11 = \"AI_InvalidMessageRoleError\";\nvar marker11 = `vercel.ai.error.${name11}`;\nvar symbol11 = Symbol.for(marker11);\nvar _a11;\nvar InvalidMessageRoleError = class extends AISDKError {\n\tconstructor({ role, message = `Invalid message role: '${role}'. Must be one of: \"system\", \"user\", \"assistant\", \"tool\".` }) {\n\t\tsuper({\n\t\t\tname: name11,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a11] = true;\n\t\tthis.role = role;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker11);\n\t}\n};\n_a11 = symbol11;\nvar name12 = \"AI_MessageConversionError\";\nvar marker12 = `vercel.ai.error.${name12}`;\nvar symbol12 = Symbol.for(marker12);\nvar _a12;\nvar MessageConversionError = class extends AISDKError {\n\tconstructor({ originalMessage, message }) {\n\t\tsuper({\n\t\t\tname: name12,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a12] = true;\n\t\tthis.originalMessage = originalMessage;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker12);\n\t}\n};\n_a12 = symbol12;\nvar name13 = \"AI_DownloadError\";\nvar marker13 = `vercel.ai.error.${name13}`;\nvar symbol13 = Symbol.for(marker13);\nvar _a13;\nvar DownloadError = class extends AISDKError {\n\tconstructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {\n\t\tsuper({\n\t\t\tname: name13,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a13] = true;\n\t\tthis.url = url;\n\t\tthis.statusCode = statusCode;\n\t\tthis.statusText = statusText;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker13);\n\t}\n};\n_a13 = symbol13;\nvar name14 = \"AI_RetryError\";\nvar marker14 = `vercel.ai.error.${name14}`;\nvar symbol14 = Symbol.for(marker14);\nvar _a14;\nvar RetryError = class extends AISDKError {\n\tconstructor({ message, reason, errors }) {\n\t\tsuper({\n\t\t\tname: name14,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a14] = true;\n\t\tthis.reason = reason;\n\t\tthis.errors = errors;\n\t\tthis.lastError = errors[errors.length - 1];\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker14);\n\t}\n};\n_a14 = symbol14;\nfunction resolveLanguageModel(model) {\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v2\") throw new UnsupportedModelVersionError({\n\t\t\tversion: model.specificationVersion,\n\t\t\tprovider: model.provider,\n\t\t\tmodelId: model.modelId\n\t\t});\n\t\treturn model;\n\t}\n\treturn getGlobalProvider().languageModel(model);\n}\nfunction resolveEmbeddingModel(model) {\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v2\") throw new UnsupportedModelVersionError({\n\t\t\tversion: model.specificationVersion,\n\t\t\tprovider: model.provider,\n\t\t\tmodelId: model.modelId\n\t\t});\n\t\treturn model;\n\t}\n\treturn getGlobalProvider().textEmbeddingModel(model);\n}\nfunction resolveImageModel(model) {\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v2\") throw new UnsupportedModelVersionError({\n\t\t\tversion: model.specificationVersion,\n\t\t\tprovider: model.provider,\n\t\t\tmodelId: model.modelId\n\t\t});\n\t\treturn model;\n\t}\n\treturn getGlobalProvider().imageModel(model);\n}\nfunction getGlobalProvider() {\n\tvar _a16;\n\treturn (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : gateway;\n}\nvar imageMediaTypeSignatures = [\n\t{\n\t\tmediaType: \"image/gif\",\n\t\tbytesPrefix: [\n\t\t\t71,\n\t\t\t73,\n\t\t\t70\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/png\",\n\t\tbytesPrefix: [\n\t\t\t137,\n\t\t\t80,\n\t\t\t78,\n\t\t\t71\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/jpeg\",\n\t\tbytesPrefix: [255, 216]\n\t},\n\t{\n\t\tmediaType: \"image/webp\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\t87,\n\t\t\t69,\n\t\t\t66,\n\t\t\t80\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/bmp\",\n\t\tbytesPrefix: [66, 77]\n\t},\n\t{\n\t\tmediaType: \"image/tiff\",\n\t\tbytesPrefix: [\n\t\t\t73,\n\t\t\t73,\n\t\t\t42,\n\t\t\t0\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/tiff\",\n\t\tbytesPrefix: [\n\t\t\t77,\n\t\t\t77,\n\t\t\t0,\n\t\t\t42\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/avif\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t32,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t97,\n\t\t\t118,\n\t\t\t105,\n\t\t\t102\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/heic\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t32,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t104,\n\t\t\t101,\n\t\t\t105,\n\t\t\t99\n\t\t]\n\t}\n];\nvar audioMediaTypeSignatures = [\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 251]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 250]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 243]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 242]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 227]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 226]\n\t},\n\t{\n\t\tmediaType: \"audio/wav\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\t87,\n\t\t\t65,\n\t\t\t86,\n\t\t\t69\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/ogg\",\n\t\tbytesPrefix: [\n\t\t\t79,\n\t\t\t103,\n\t\t\t103,\n\t\t\t83\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/flac\",\n\t\tbytesPrefix: [\n\t\t\t102,\n\t\t\t76,\n\t\t\t97,\n\t\t\t67\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/aac\",\n\t\tbytesPrefix: [\n\t\t\t64,\n\t\t\t21,\n\t\t\t0,\n\t\t\t0\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/mp4\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tnull,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/webm\",\n\t\tbytesPrefix: [\n\t\t\t26,\n\t\t\t69,\n\t\t\t223,\n\t\t\t163\n\t\t]\n\t}\n];\nvar DEFAULT_SNIFF_BYTES = 18;\nvar ID3_SCAN_BYTES = 131084;\nfunction decodePrefix(data, maxBytes) {\n\tif (typeof data !== \"string\") return data.length > maxBytes ? data.subarray(0, maxBytes) : data;\n\tconst maxChars = Math.ceil(maxBytes / 3) * 4;\n\tconst bytes = convertBase64ToUint8Array(data.substring(0, Math.min(data.length, maxChars)));\n\treturn bytes.length > maxBytes ? bytes.subarray(0, maxBytes) : bytes;\n}\nfunction hasID3(bytes) {\n\treturn bytes.length > 10 && bytes[0] === 73 && bytes[1] === 68 && bytes[2] === 51;\n}\nvar stripID3 = (bytes) => {\n\tconst id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;\n\treturn bytes.subarray(id3Size + 10);\n};\nfunction detectMediaType({ data, signatures }) {\n\tlet bytes = decodePrefix(data, DEFAULT_SNIFF_BYTES);\n\tif (hasID3(bytes)) bytes = stripID3(decodePrefix(data, ID3_SCAN_BYTES));\n\tfor (const signature of signatures) if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => byte === null || bytes[index] === byte)) return signature.mediaType;\n}\nvar VERSION = \"5.0.277\";\nvar download = async ({ url, maxBytes, abortSignal }) => {\n\tvar _a16;\n\tconst urlText = url.toString();\n\ttry {\n\t\tconst headers = withUserAgentSuffix({}, `ai-sdk/${VERSION}`, getRuntimeEnvironmentUserAgent());\n\t\tconst response = await fetchWithValidatedRedirects({\n\t\t\turl: urlText,\n\t\t\theaders,\n\t\t\tabortSignal\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tawait cancelResponseBody(response);\n\t\t\tthrow new DownloadError$1({\n\t\t\t\turl: urlText,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tstatusText: response.statusText\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tdata: await readResponseWithSizeLimit({\n\t\t\t\tresponse,\n\t\t\t\turl: urlText,\n\t\t\t\tmaxBytes: maxBytes != null ? maxBytes : DEFAULT_MAX_DOWNLOAD_SIZE\n\t\t\t}),\n\t\t\tmediaType: (_a16 = response.headers.get(\"content-type\")) != null ? _a16 : void 0\n\t\t};\n\t} catch (error) {\n\t\tif (DownloadError$1.isInstance(error)) throw error;\n\t\tthrow new DownloadError$1({\n\t\t\turl: urlText,\n\t\t\tcause: error\n\t\t});\n\t}\n};\nvar createDefaultDownloadFunction = (download2 = download) => (requestedDownloads) => Promise.all(requestedDownloads.map(async (requestedDownload) => requestedDownload.isUrlSupportedByModel ? null : download2(requestedDownload)));\nfunction splitDataUrl(dataUrl) {\n\ttry {\n\t\tconst [header, base64Content] = dataUrl.split(\",\");\n\t\treturn {\n\t\t\tmediaType: header.split(\";\")[0].split(\":\")[1],\n\t\t\tbase64Content\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tmediaType: void 0,\n\t\t\tbase64Content: void 0\n\t\t};\n\t}\n}\nvar dataContentSchema = z.union([\n\tz.string(),\n\tz.instanceof(Uint8Array),\n\tz.instanceof(ArrayBuffer),\n\tz.custom((value) => {\n\t\tvar _a16, _b;\n\t\treturn (_b = (_a16 = globalThis.Buffer) == null ? void 0 : _a16.isBuffer(value)) != null ? _b : false;\n\t}, { message: \"Must be a Buffer\" })\n]);\nfunction convertToLanguageModelV2DataContent(content) {\n\tif (content instanceof Uint8Array) return {\n\t\tdata: content,\n\t\tmediaType: void 0\n\t};\n\tif (content instanceof ArrayBuffer) return {\n\t\tdata: new Uint8Array(content),\n\t\tmediaType: void 0\n\t};\n\tif (typeof content === \"string\") try {\n\t\tcontent = new URL(content);\n\t} catch (error) {}\n\tif (content instanceof URL && content.protocol === \"data:\") {\n\t\tconst { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(content.toString());\n\t\tif (dataUrlMediaType == null || base64Content == null) throw new AISDKError({\n\t\t\tname: \"InvalidDataContentError\",\n\t\t\tmessage: `Invalid data URL format in content ${content.toString()}`\n\t\t});\n\t\treturn {\n\t\t\tdata: base64Content,\n\t\t\tmediaType: dataUrlMediaType\n\t\t};\n\t}\n\treturn {\n\t\tdata: content,\n\t\tmediaType: void 0\n\t};\n}\nfunction convertDataContentToBase64String(content) {\n\tif (typeof content === \"string\") return content;\n\tif (content instanceof ArrayBuffer) return convertUint8ArrayToBase64(new Uint8Array(content));\n\treturn convertUint8ArrayToBase64(content);\n}\nfunction convertDataContentToUint8Array(content) {\n\tif (content instanceof Uint8Array) return content;\n\tif (typeof content === \"string\") try {\n\t\treturn convertBase64ToUint8Array(content);\n\t} catch (error) {\n\t\tthrow new InvalidDataContentError({\n\t\t\tmessage: \"Invalid data content. Content string is not a base64-encoded media.\",\n\t\t\tcontent,\n\t\t\tcause: error\n\t\t});\n\t}\n\tif (content instanceof ArrayBuffer) return new Uint8Array(content);\n\tthrow new InvalidDataContentError({ content });\n}\nasync function convertToLanguageModelPrompt({ prompt, supportedUrls, download: download2 = createDefaultDownloadFunction() }) {\n\tconst downloadedAssets = await downloadAssets(prompt.messages, download2, supportedUrls);\n\treturn [...prompt.system != null ? [{\n\t\trole: \"system\",\n\t\tcontent: prompt.system\n\t}] : [], ...prompt.messages.map((message) => convertToLanguageModelMessage({\n\t\tmessage,\n\t\tdownloadedAssets\n\t}))];\n}\nfunction convertToLanguageModelMessage({ message, downloadedAssets }) {\n\tconst role = message.role;\n\tswitch (role) {\n\t\tcase \"system\": return {\n\t\t\trole: \"system\",\n\t\t\tcontent: message.content,\n\t\t\tproviderOptions: message.providerOptions\n\t\t};\n\t\tcase \"user\":\n\t\t\tif (typeof message.content === \"string\") return {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: message.content\n\t\t\t\t}],\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: message.content.map((part) => convertPartToLanguageModelPart(part, downloadedAssets)).filter((part) => part.type !== \"text\" || part.text !== \"\"),\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\tcase \"assistant\":\n\t\t\tif (typeof message.content === \"string\") return {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: message.content\n\t\t\t\t}],\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: message.content.filter((part) => part.type !== \"text\" || part.text !== \"\" || part.providerOptions != null).map((part) => {\n\t\t\t\t\tconst providerOptions = part.providerOptions;\n\t\t\t\t\tswitch (part.type) {\n\t\t\t\t\t\tcase \"file\": {\n\t\t\t\t\t\t\tconst { data, mediaType } = convertToLanguageModelV2DataContent(part.data);\n\t\t\t\t\t\t\tconst originalUrl = getOriginalUrl(part.data, data);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\t\t\tmediaType: mediaType != null ? mediaType : part.mediaType,\n\t\t\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\t\t\t...originalUrl != null ? { originalUrl } : {}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"reasoning\": return {\n\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"text\": return {\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"tool-call\": return {\n\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t\tproviderExecuted: part.providerExecuted,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"tool-result\": return {\n\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\toutput: part.output,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\tcase \"tool\": return {\n\t\t\trole: \"tool\",\n\t\t\tcontent: message.content.map((part) => ({\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\ttoolName: part.toolName,\n\t\t\t\toutput: part.output,\n\t\t\t\tproviderOptions: part.providerOptions\n\t\t\t})),\n\t\t\tproviderOptions: message.providerOptions\n\t\t};\n\t\tdefault: throw new InvalidMessageRoleError({ role });\n\t}\n}\nasync function downloadAssets(messages, download2, supportedUrls) {\n\tconst plannedDownloads = messages.filter((message) => message.role === \"user\").map((message) => message.content).filter((content) => Array.isArray(content)).flat().filter((part) => part.type === \"image\" || part.type === \"file\").map((part) => {\n\t\tvar _a16;\n\t\tconst mediaType = (_a16 = part.mediaType) != null ? _a16 : part.type === \"image\" ? \"image/*\" : void 0;\n\t\tlet data = part.type === \"image\" ? part.image : part.data;\n\t\tif (typeof data === \"string\") try {\n\t\t\tdata = new URL(data);\n\t\t} catch (ignored) {}\n\t\treturn {\n\t\t\tmediaType,\n\t\t\tdata\n\t\t};\n\t}).filter((part) => part.data instanceof URL).map((part) => ({\n\t\turl: part.data,\n\t\tisUrlSupportedByModel: part.mediaType != null && isUrlSupported({\n\t\t\turl: part.data.toString(),\n\t\t\tmediaType: part.mediaType,\n\t\t\tsupportedUrls\n\t\t})\n\t}));\n\tconst downloadedFiles = await download2(plannedDownloads);\n\treturn Object.fromEntries(downloadedFiles.map((file, index) => file == null ? null : [plannedDownloads[index].url.toString(), {\n\t\tdata: file.data,\n\t\tmediaType: file.mediaType\n\t}]).filter((file) => file != null));\n}\nfunction getOriginalUrl(originalData, convertedData) {\n\treturn typeof originalData === \"string\" && convertedData instanceof URL && convertedData.toString() !== originalData ? originalData : void 0;\n}\nfunction convertPartToLanguageModelPart(part, downloadedAssets) {\n\tvar _a16;\n\tif (part.type === \"text\") return {\n\t\ttype: \"text\",\n\t\ttext: part.text,\n\t\tproviderOptions: part.providerOptions\n\t};\n\tlet originalData;\n\tconst type = part.type;\n\tswitch (type) {\n\t\tcase \"image\":\n\t\t\toriginalData = part.image;\n\t\t\tbreak;\n\t\tcase \"file\":\n\t\t\toriginalData = part.data;\n\t\t\tbreak;\n\t\tdefault: throw new Error(`Unsupported part type: ${type}`);\n\t}\n\tconst { data: convertedData, mediaType: convertedMediaType } = convertToLanguageModelV2DataContent(originalData);\n\tlet mediaType = convertedMediaType != null ? convertedMediaType : part.mediaType;\n\tlet data = convertedData;\n\tlet originalUrl = getOriginalUrl(originalData, convertedData);\n\tif (data instanceof URL) {\n\t\tconst downloadedFile = downloadedAssets[data.toString()];\n\t\tif (downloadedFile) {\n\t\t\tdata = downloadedFile.data;\n\t\t\tmediaType ??= downloadedFile.mediaType;\n\t\t\toriginalUrl = void 0;\n\t\t}\n\t}\n\tswitch (type) {\n\t\tcase \"image\":\n\t\t\tif (data instanceof Uint8Array || typeof data === \"string\") mediaType = (_a16 = detectMediaType({\n\t\t\t\tdata,\n\t\t\t\tsignatures: imageMediaTypeSignatures\n\t\t\t})) != null ? _a16 : mediaType;\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tmediaType: mediaType != null ? mediaType : \"image/*\",\n\t\t\t\tfilename: void 0,\n\t\t\t\tdata,\n\t\t\t\tproviderOptions: part.providerOptions,\n\t\t\t\t...originalUrl != null ? { originalUrl } : {}\n\t\t\t};\n\t\tcase \"file\":\n\t\t\tif (mediaType == null) throw new Error(`Media type is missing for file part`);\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tmediaType,\n\t\t\t\tfilename: part.filename,\n\t\t\t\tdata,\n\t\t\t\tproviderOptions: part.providerOptions,\n\t\t\t\t...originalUrl != null ? { originalUrl } : {}\n\t\t\t};\n\t}\n}\nfunction prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences }) {\n\tif (maxOutputTokens != null) {\n\t\tif (!Number.isInteger(maxOutputTokens)) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxOutputTokens\",\n\t\t\tvalue: maxOutputTokens,\n\t\t\tmessage: \"maxOutputTokens must be an integer\"\n\t\t});\n\t\tif (maxOutputTokens < 1) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxOutputTokens\",\n\t\t\tvalue: maxOutputTokens,\n\t\t\tmessage: \"maxOutputTokens must be >= 1\"\n\t\t});\n\t}\n\tif (temperature != null) {\n\t\tif (typeof temperature !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"temperature\",\n\t\t\tvalue: temperature,\n\t\t\tmessage: \"temperature must be a number\"\n\t\t});\n\t}\n\tif (topP != null) {\n\t\tif (typeof topP !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"topP\",\n\t\t\tvalue: topP,\n\t\t\tmessage: \"topP must be a number\"\n\t\t});\n\t}\n\tif (topK != null) {\n\t\tif (typeof topK !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"topK\",\n\t\t\tvalue: topK,\n\t\t\tmessage: \"topK must be a number\"\n\t\t});\n\t}\n\tif (presencePenalty != null) {\n\t\tif (typeof presencePenalty !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"presencePenalty\",\n\t\t\tvalue: presencePenalty,\n\t\t\tmessage: \"presencePenalty must be a number\"\n\t\t});\n\t}\n\tif (frequencyPenalty != null) {\n\t\tif (typeof frequencyPenalty !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"frequencyPenalty\",\n\t\t\tvalue: frequencyPenalty,\n\t\t\tmessage: \"frequencyPenalty must be a number\"\n\t\t});\n\t}\n\tif (seed != null) {\n\t\tif (!Number.isInteger(seed)) throw new InvalidArgumentError({\n\t\t\tparameter: \"seed\",\n\t\t\tvalue: seed,\n\t\t\tmessage: \"seed must be an integer\"\n\t\t});\n\t}\n\treturn {\n\t\tmaxOutputTokens,\n\t\ttemperature,\n\t\ttopP,\n\t\ttopK,\n\t\tpresencePenalty,\n\t\tfrequencyPenalty,\n\t\tstopSequences,\n\t\tseed\n\t};\n}\nfunction isNonEmptyObject(object2) {\n\treturn object2 != null && Object.keys(object2).length > 0;\n}\nfunction prepareToolsAndToolChoice({ tools, toolChoice, activeTools }) {\n\tif (!isNonEmptyObject(tools)) return {\n\t\ttools: void 0,\n\t\ttoolChoice: void 0\n\t};\n\treturn {\n\t\ttools: (activeTools != null ? Object.entries(tools).filter(([name16]) => activeTools.includes(name16)) : Object.entries(tools)).map(([name16, tool2]) => {\n\t\t\tconst toolType = tool2.type;\n\t\t\tswitch (toolType) {\n\t\t\t\tcase void 0:\n\t\t\t\tcase \"dynamic\":\n\t\t\t\tcase \"function\": return {\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: name16,\n\t\t\t\t\tdescription: tool2.description,\n\t\t\t\t\tinputSchema: asSchema(tool2.inputSchema).jsonSchema,\n\t\t\t\t\tproviderOptions: tool2.providerOptions\n\t\t\t\t};\n\t\t\t\tcase \"provider-defined\": return {\n\t\t\t\t\ttype: \"provider-defined\",\n\t\t\t\t\tname: name16,\n\t\t\t\t\tid: tool2.id,\n\t\t\t\t\targs: tool2.args\n\t\t\t\t};\n\t\t\t\tdefault: throw new Error(`Unsupported tool type: ${toolType}`);\n\t\t\t}\n\t\t}),\n\t\ttoolChoice: toolChoice == null ? { type: \"auto\" } : typeof toolChoice === \"string\" ? { type: toolChoice } : {\n\t\t\ttype: \"tool\",\n\t\t\ttoolName: toolChoice.toolName\n\t\t}\n\t};\n}\nvar jsonValueSchema = z.lazy(() => z.union([\n\tz.null(),\n\tz.string(),\n\tz.number(),\n\tz.boolean(),\n\tz.record(z.string(), jsonValueSchema.optional()),\n\tz.array(jsonValueSchema)\n]));\nvar providerMetadataSchema = z.record(z.string(), z.record(z.string(), jsonValueSchema));\nvar textPartSchema = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar imagePartSchema = z.object({\n\ttype: z.literal(\"image\"),\n\timage: z.union([dataContentSchema, z.instanceof(URL)]),\n\tmediaType: z.string().optional(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar filePartSchema = z.object({\n\ttype: z.literal(\"file\"),\n\tdata: z.union([dataContentSchema, z.instanceof(URL)]),\n\tfilename: z.string().optional(),\n\tmediaType: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar reasoningPartSchema = z.object({\n\ttype: z.literal(\"reasoning\"),\n\ttext: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar toolCallPartSchema = z.object({\n\ttype: z.literal(\"tool-call\"),\n\ttoolCallId: z.string(),\n\ttoolName: z.string(),\n\tinput: z.unknown(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\tproviderExecuted: z.boolean().optional()\n});\nvar outputSchema = z.discriminatedUnion(\"type\", [\n\tz.object({\n\t\ttype: z.literal(\"text\"),\n\t\tvalue: z.string()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"json\"),\n\t\tvalue: jsonValueSchema\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"error-text\"),\n\t\tvalue: z.string()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"error-json\"),\n\t\tvalue: jsonValueSchema\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"content\"),\n\t\tvalue: z.array(z.union([z.object({\n\t\t\ttype: z.literal(\"text\"),\n\t\t\ttext: z.string()\n\t\t}), z.object({\n\t\t\ttype: z.literal(\"media\"),\n\t\t\tdata: z.string(),\n\t\t\tmediaType: z.string()\n\t\t})]))\n\t})\n]);\nvar toolResultPartSchema = z.object({\n\ttype: z.literal(\"tool-result\"),\n\ttoolCallId: z.string(),\n\ttoolName: z.string(),\n\toutput: outputSchema,\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar systemModelMessageSchema = z.object({\n\trole: z.literal(\"system\"),\n\tcontent: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar coreSystemMessageSchema = systemModelMessageSchema;\nvar userModelMessageSchema = z.object({\n\trole: z.literal(\"user\"),\n\tcontent: z.union([z.string(), z.array(z.union([\n\t\ttextPartSchema,\n\t\timagePartSchema,\n\t\tfilePartSchema\n\t]))]),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar coreUserMessageSchema = userModelMessageSchema;\nvar assistantModelMessageSchema = z.object({\n\trole: z.literal(\"assistant\"),\n\tcontent: z.union([z.string(), z.array(z.union([\n\t\ttextPartSchema,\n\t\tfilePartSchema,\n\t\treasoningPartSchema,\n\t\ttoolCallPartSchema,\n\t\ttoolResultPartSchema\n\t]))]),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar coreAssistantMessageSchema = assistantModelMessageSchema;\nvar toolModelMessageSchema = z.object({\n\trole: z.literal(\"tool\"),\n\tcontent: z.array(toolResultPartSchema),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar coreToolMessageSchema = toolModelMessageSchema;\nvar modelMessageSchema = z.union([\n\tsystemModelMessageSchema,\n\tuserModelMessageSchema,\n\tassistantModelMessageSchema,\n\ttoolModelMessageSchema\n]);\nvar coreMessageSchema = modelMessageSchema;\nasync function standardizePrompt({ allowSystemInMessages, system, prompt, messages }) {\n\tif (prompt == null && messages == null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt or messages must be defined\"\n\t});\n\tif (prompt != null && messages != null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt and messages cannot be defined at the same time\"\n\t});\n\tif (system != null && typeof system !== \"string\") throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"system must be a string\"\n\t});\n\tif (prompt != null && typeof prompt === \"string\") messages = [{\n\t\trole: \"user\",\n\t\tcontent: prompt\n\t}];\n\telse if (prompt != null && Array.isArray(prompt)) messages = prompt;\n\telse if (messages == null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt or messages must be defined\"\n\t});\n\tif (messages.length === 0) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"messages must not be empty\"\n\t});\n\tif (messages.some((message) => message.role === \"system\")) {\n\t\tif (allowSystemInMessages === false) throw new InvalidPromptError({\n\t\t\tprompt,\n\t\t\tmessage: \"System messages are not allowed in the prompt or messages fields. Use the system option instead.\"\n\t\t});\n\t\tif (allowSystemInMessages === void 0) console.warn(\"AI SDK Warning: System messages in the prompt or messages fields can be a security risk because they may enable prompt injection attacks. Use the system option instead when possible. Set allowSystemInMessages to true to suppress this warning, or false to throw an error.\");\n\t}\n\tconst validationResult = await safeValidateTypes({\n\t\tvalue: messages,\n\t\tschema: z.array(modelMessageSchema)\n\t});\n\tif (!validationResult.success) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.\",\n\t\tcause: validationResult.error\n\t});\n\treturn {\n\t\tmessages,\n\t\tsystem\n\t};\n}\nfunction wrapGatewayError(error) {\n\tif (!GatewayAuthenticationError.isInstance(error)) return error;\n\tconst isProductionEnv = (process == null ? void 0 : \"production\") === \"production\";\n\tconst moreInfoURL = \"https://v5.ai-sdk.dev/unauthenticated-ai-gateway\";\n\tif (isProductionEnv) return new AISDKError({\n\t\tname: \"GatewayError\",\n\t\tmessage: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`\n\t});\n\treturn Object.assign(/* @__PURE__ */ new Error(`\\x1B[1m\\x1B[31mUnauthenticated request to AI Gateway.\\x1B[0m\n\nTo authenticate, set the \\x1B[33mAI_GATEWAY_API_KEY\\x1B[0m environment variable with your API key.\n\nAlternatively, you can use a provider module instead of the AI Gateway.\n\nLearn more: \\x1B[34m${moreInfoURL}\\x1B[0m\n\n`), { name: \"GatewayAuthenticationError\" });\n}\nfunction assembleOperationName({ operationId, telemetry }) {\n\treturn {\n\t\t\"operation.name\": `${operationId}${(telemetry == null ? void 0 : telemetry.functionId) != null ? ` ${telemetry.functionId}` : \"\"}`,\n\t\t\"resource.name\": telemetry == null ? void 0 : telemetry.functionId,\n\t\t\"ai.operationId\": operationId,\n\t\t\"ai.telemetry.functionId\": telemetry == null ? void 0 : telemetry.functionId\n\t};\n}\nfunction getTelemetryMetadataAttributes(telemetry) {\n\tvar _a16;\n\treturn Object.entries((_a16 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a16 : {}).reduce((attributes, [key, value]) => {\n\t\tattributes[`ai.telemetry.metadata.${key}`] = value;\n\t\treturn attributes;\n\t}, {});\n}\nfunction getBaseTelemetryAttributes({ model, settings, telemetry, headers }) {\n\treturn {\n\t\t\"ai.model.provider\": model.provider,\n\t\t\"ai.model.id\": model.modelId,\n\t\t...Object.entries(settings).reduce((attributes, [key, value]) => {\n\t\t\tattributes[`ai.settings.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {}),\n\t\t...getTelemetryMetadataAttributes(telemetry),\n\t\t...Object.entries(headers != null ? headers : {}).reduce((attributes, [key, value]) => {\n\t\t\tif (value !== void 0) attributes[`ai.request.headers.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {})\n\t};\n}\nvar noopTracer = {\n\tstartSpan() {\n\t\treturn noopSpan;\n\t},\n\tstartActiveSpan(name16, arg1, arg2, arg3) {\n\t\tif (typeof arg1 === \"function\") return arg1(noopSpan);\n\t\tif (typeof arg2 === \"function\") return arg2(noopSpan);\n\t\tif (typeof arg3 === \"function\") return arg3(noopSpan);\n\t}\n};\nvar noopSpan = {\n\tspanContext() {\n\t\treturn noopSpanContext;\n\t},\n\tsetAttribute() {\n\t\treturn this;\n\t},\n\tsetAttributes() {\n\t\treturn this;\n\t},\n\taddEvent() {\n\t\treturn this;\n\t},\n\taddLink() {\n\t\treturn this;\n\t},\n\taddLinks() {\n\t\treturn this;\n\t},\n\tsetStatus() {\n\t\treturn this;\n\t},\n\tupdateName() {\n\t\treturn this;\n\t},\n\tend() {\n\t\treturn this;\n\t},\n\tisRecording() {\n\t\treturn false;\n\t},\n\trecordException() {\n\t\treturn this;\n\t}\n};\nvar noopSpanContext = {\n\ttraceId: \"\",\n\tspanId: \"\",\n\ttraceFlags: 0\n};\nfunction getTracer({ isEnabled = false, tracer } = {}) {\n\tif (!isEnabled) return noopTracer;\n\tif (tracer) return tracer;\n\treturn trace.getTracer(\"ai\");\n}\nfunction recordSpan({ name: name16, tracer, attributes, fn, endWhenDone = true, endOnError = endWhenDone }) {\n\treturn tracer.startActiveSpan(name16, { attributes }, async (span) => {\n\t\ttry {\n\t\t\tconst result = await fn(span);\n\t\t\tif (endWhenDone) span.end();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t} finally {\n\t\t\t\tif (endOnError) span.end();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t});\n}\nfunction recordErrorOnSpan(span, error) {\n\tif (error instanceof Error) {\n\t\tspan.recordException({\n\t\t\tname: error.name,\n\t\t\tmessage: error.message,\n\t\t\tstack: error.stack\n\t\t});\n\t\tspan.setStatus({\n\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\tmessage: error.message\n\t\t});\n\t} else span.setStatus({ code: SpanStatusCode.ERROR });\n}\nfunction selectTelemetryAttributes({ telemetry, attributes }) {\n\tif ((telemetry == null ? void 0 : telemetry.isEnabled) !== true) return {};\n\treturn Object.entries(attributes).reduce((attributes2, [key, value]) => {\n\t\tif (value == null) return attributes2;\n\t\tif (typeof value === \"object\" && \"input\" in value && typeof value.input === \"function\") {\n\t\t\tif ((telemetry == null ? void 0 : telemetry.recordInputs) === false) return attributes2;\n\t\t\tconst result = value.input();\n\t\t\treturn result == null ? attributes2 : {\n\t\t\t\t...attributes2,\n\t\t\t\t[key]: result\n\t\t\t};\n\t\t}\n\t\tif (typeof value === \"object\" && \"output\" in value && typeof value.output === \"function\") {\n\t\t\tif ((telemetry == null ? void 0 : telemetry.recordOutputs) === false) return attributes2;\n\t\t\tconst result = value.output();\n\t\t\treturn result == null ? attributes2 : {\n\t\t\t\t...attributes2,\n\t\t\t\t[key]: result\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...attributes2,\n\t\t\t[key]: value\n\t\t};\n\t}, {});\n}\nfunction stringifyForTelemetry(prompt) {\n\treturn JSON.stringify(prompt.map((message) => ({\n\t\t...message,\n\t\tcontent: typeof message.content === \"string\" ? message.content : message.content.map((part) => part.type === \"file\" ? {\n\t\t\t...part,\n\t\t\tdata: part.data instanceof Uint8Array ? convertDataContentToBase64String(part.data) : part.data\n\t\t} : part)\n\t})));\n}\nfunction addLanguageModelUsage(usage1, usage2) {\n\treturn {\n\t\tinputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),\n\t\toutputTokens: addTokenCounts(usage1.outputTokens, usage2.outputTokens),\n\t\ttotalTokens: addTokenCounts(usage1.totalTokens, usage2.totalTokens),\n\t\treasoningTokens: addTokenCounts(usage1.reasoningTokens, usage2.reasoningTokens),\n\t\tcachedInputTokens: addTokenCounts(usage1.cachedInputTokens, usage2.cachedInputTokens)\n\t};\n}\nfunction addTokenCounts(tokenCount1, tokenCount2) {\n\treturn tokenCount1 == null && tokenCount2 == null ? void 0 : (tokenCount1 != null ? tokenCount1 : 0) + (tokenCount2 != null ? tokenCount2 : 0);\n}\nfunction asArray(value) {\n\treturn value === void 0 ? [] : Array.isArray(value) ? value : [value];\n}\nfunction getRetryDelayInMs({ error, exponentialBackoffDelay }) {\n\tconst headers = APICallError.isInstance(error) ? error.responseHeaders : APICallError.isInstance(error.cause) ? error.cause.responseHeaders : void 0;\n\tif (!headers) return exponentialBackoffDelay;\n\tlet ms;\n\tconst retryAfterMs = headers[\"retry-after-ms\"];\n\tif (retryAfterMs) {\n\t\tconst timeoutMs = parseFloat(retryAfterMs);\n\t\tif (!Number.isNaN(timeoutMs)) ms = timeoutMs;\n\t}\n\tconst retryAfter = headers[\"retry-after\"];\n\tif (retryAfter && ms === void 0) {\n\t\tconst timeoutSeconds = parseFloat(retryAfter);\n\t\tif (!Number.isNaN(timeoutSeconds)) ms = timeoutSeconds * 1e3;\n\t\telse ms = Date.parse(retryAfter) - Date.now();\n\t}\n\tif (ms != null && !Number.isNaN(ms) && 0 <= ms && (ms < 6e4 || ms < exponentialBackoffDelay)) return ms;\n\treturn exponentialBackoffDelay;\n}\nvar retryWithExponentialBackoffRespectingRetryHeaders = ({ maxRetries = 2, initialDelayInMs = 2e3, backoffFactor = 2, abortSignal, additionalRetryableError } = {}) => async (f) => _retryWithExponentialBackoff(f, {\n\tmaxRetries,\n\tdelayInMs: initialDelayInMs,\n\tbackoffFactor,\n\tabortSignal,\n\tadditionalRetryableError\n});\nasync function _retryWithExponentialBackoff(f, { maxRetries, delayInMs, backoffFactor, abortSignal, additionalRetryableError }, errors = []) {\n\ttry {\n\t\treturn await f();\n\t} catch (error) {\n\t\tif (isAbortError(error)) throw error;\n\t\tif (maxRetries === 0) throw error;\n\t\tconst errorMessage = getErrorMessage$1(error);\n\t\tconst newErrors = [...errors, error];\n\t\tconst tryNumber = newErrors.length;\n\t\tif (tryNumber > maxRetries) throw new RetryError({\n\t\t\tmessage: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,\n\t\t\treason: \"maxRetriesExceeded\",\n\t\t\terrors: newErrors\n\t\t});\n\t\tif ((error instanceof Error && (APICallError.isInstance(error) && error.isRetryable === true || GatewayError.isInstance(error) && error.isRetryable === true) || (additionalRetryableError == null ? void 0 : additionalRetryableError(error)) === true) && tryNumber <= maxRetries) {\n\t\t\tawait delay(getRetryDelayInMs({\n\t\t\t\terror,\n\t\t\t\texponentialBackoffDelay: delayInMs\n\t\t\t}), { abortSignal });\n\t\t\treturn _retryWithExponentialBackoff(f, {\n\t\t\t\tmaxRetries,\n\t\t\t\tdelayInMs: backoffFactor * delayInMs,\n\t\t\t\tbackoffFactor,\n\t\t\t\tabortSignal,\n\t\t\t\tadditionalRetryableError\n\t\t\t}, newErrors);\n\t\t}\n\t\tif (tryNumber === 1) throw error;\n\t\tthrow new RetryError({\n\t\t\tmessage: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,\n\t\t\treason: \"errorNotRetryable\",\n\t\t\terrors: newErrors\n\t\t});\n\t}\n}\nfunction prepareRetries({ maxRetries, abortSignal, additionalRetryableError }) {\n\tif (maxRetries != null) {\n\t\tif (!Number.isInteger(maxRetries)) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxRetries\",\n\t\t\tvalue: maxRetries,\n\t\t\tmessage: \"maxRetries must be an integer\"\n\t\t});\n\t\tif (maxRetries < 0) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxRetries\",\n\t\t\tvalue: maxRetries,\n\t\t\tmessage: \"maxRetries must be >= 0\"\n\t\t});\n\t}\n\tconst maxRetriesResult = maxRetries != null ? maxRetries : 2;\n\treturn {\n\t\tmaxRetries: maxRetriesResult,\n\t\tretry: retryWithExponentialBackoffRespectingRetryHeaders({\n\t\t\tmaxRetries: maxRetriesResult,\n\t\t\tabortSignal,\n\t\t\tadditionalRetryableError\n\t\t})\n\t};\n}\nfunction extractTextContent(content) {\n\tconst parts = content.filter((content2) => content2.type === \"text\");\n\tif (parts.length === 0) return;\n\treturn parts.map((content2) => content2.text).join(\"\");\n}\nfunction filterActiveTools({ tools, activeTools }) {\n\tif (tools == null || activeTools == null) return tools;\n\treturn Object.fromEntries(Object.entries(tools).filter(([name16]) => activeTools.includes(name16)));\n}\nvar DefaultGeneratedFile = class {\n\tconstructor({ data, mediaType }) {\n\t\tconst isUint8Array = data instanceof Uint8Array;\n\t\tthis.base64Data = isUint8Array ? void 0 : data;\n\t\tthis.uint8ArrayData = isUint8Array ? data : void 0;\n\t\tthis.mediaType = mediaType;\n\t}\n\tget base64() {\n\t\tif (this.base64Data == null) this.base64Data = convertUint8ArrayToBase64(this.uint8ArrayData);\n\t\treturn this.base64Data;\n\t}\n\tget uint8Array() {\n\t\tif (this.uint8ArrayData == null) this.uint8ArrayData = convertBase64ToUint8Array(this.base64Data);\n\t\treturn this.uint8ArrayData;\n\t}\n};\nvar DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {\n\tconstructor() {\n\t\tsuper(...arguments);\n\t\tthis.type = \"file\";\n\t}\n};\nfunction isToolExecutionAllowedFinishReason(finishReason) {\n\treturn finishReason === \"stop\" || finishReason === \"tool-calls\";\n}\nasync function parseToolCall({ toolCall, tools, repairToolCall, system, messages }) {\n\ttry {\n\t\tif (tools == null) {\n\t\t\tif (toolCall.providerExecuted) return await parseProviderExecutedDynamicToolCall(toolCall);\n\t\t\tthrow new NoSuchToolError({ toolName: toolCall.toolName });\n\t\t}\n\t\ttry {\n\t\t\treturn await doParseToolCall({\n\t\t\t\ttoolCall,\n\t\t\t\ttools\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (repairToolCall == null || !(NoSuchToolError.isInstance(error) || InvalidToolInputError.isInstance(error))) throw error;\n\t\t\tlet repairedToolCall = null;\n\t\t\ttry {\n\t\t\t\trepairedToolCall = await repairToolCall({\n\t\t\t\t\ttoolCall,\n\t\t\t\t\ttools,\n\t\t\t\t\tinputSchema: ({ toolName }) => {\n\t\t\t\t\t\tconst { inputSchema } = tools[toolName];\n\t\t\t\t\t\treturn asSchema(inputSchema).jsonSchema;\n\t\t\t\t\t},\n\t\t\t\t\tsystem,\n\t\t\t\t\tmessages,\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t} catch (repairError) {\n\t\t\t\tthrow new ToolCallRepairError({\n\t\t\t\t\tcause: repairError,\n\t\t\t\t\toriginalError: error\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (repairedToolCall == null) throw error;\n\t\t\treturn await doParseToolCall({\n\t\t\t\ttoolCall: repairedToolCall,\n\t\t\t\ttools\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tconst parsedInput = await safeParseJSON({ text: toolCall.input });\n\t\tconst input = parsedInput.success ? parsedInput.value : toolCall.input;\n\t\treturn {\n\t\t\ttype: \"tool-call\",\n\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\ttoolName: toolCall.toolName,\n\t\t\tinput,\n\t\t\tdynamic: true,\n\t\t\tinvalid: true,\n\t\t\terror,\n\t\t\tproviderMetadata: toolCall.providerMetadata\n\t\t};\n\t}\n}\nasync function parseProviderExecutedDynamicToolCall(toolCall) {\n\tconst parseResult = toolCall.input.trim() === \"\" ? {\n\t\tsuccess: true,\n\t\tvalue: {}\n\t} : await safeParseJSON({ text: toolCall.input });\n\tif (parseResult.success === false) throw new InvalidToolInputError({\n\t\ttoolName: toolCall.toolName,\n\t\ttoolInput: toolCall.input,\n\t\tcause: parseResult.error\n\t});\n\treturn {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName: toolCall.toolName,\n\t\tinput: parseResult.value,\n\t\tproviderExecuted: true,\n\t\tdynamic: true,\n\t\tproviderMetadata: toolCall.providerMetadata\n\t};\n}\nasync function doParseToolCall({ toolCall, tools }) {\n\tconst toolName = toolCall.toolName;\n\tconst tool2 = tools[toolName];\n\tif (tool2 == null) {\n\t\tif (toolCall.providerExecuted) return await parseProviderExecutedDynamicToolCall(toolCall);\n\t\tthrow new NoSuchToolError({\n\t\t\ttoolName: toolCall.toolName,\n\t\t\tavailableTools: Object.keys(tools)\n\t\t});\n\t}\n\tconst schema = asSchema(tool2.inputSchema);\n\tconst parseResult = toolCall.input.trim() === \"\" ? await safeValidateTypes({\n\t\tvalue: {},\n\t\tschema\n\t}) : await safeParseJSON({\n\t\ttext: toolCall.input,\n\t\tschema\n\t});\n\tif (parseResult.success === false) throw new InvalidToolInputError({\n\t\ttoolName,\n\t\ttoolInput: toolCall.input,\n\t\tcause: parseResult.error\n\t});\n\treturn tool2.type === \"dynamic\" ? {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName: toolCall.toolName,\n\t\tinput: parseResult.value,\n\t\tproviderExecuted: toolCall.providerExecuted,\n\t\tproviderMetadata: toolCall.providerMetadata,\n\t\tdynamic: true\n\t} : {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName,\n\t\tinput: parseResult.value,\n\t\tproviderExecuted: toolCall.providerExecuted,\n\t\tproviderMetadata: toolCall.providerMetadata\n\t};\n}\nvar DefaultStepResult = class {\n\tconstructor({ content, finishReason, usage, warnings, request, response, providerMetadata }) {\n\t\tthis.content = content;\n\t\tthis.finishReason = finishReason;\n\t\tthis.usage = usage;\n\t\tthis.warnings = warnings;\n\t\tthis.request = request;\n\t\tthis.response = response;\n\t\tthis.providerMetadata = providerMetadata;\n\t}\n\tget text() {\n\t\treturn this.content.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n\t}\n\tget reasoning() {\n\t\treturn this.content.filter((part) => part.type === \"reasoning\");\n\t}\n\tget reasoningText() {\n\t\treturn this.reasoning.length === 0 ? void 0 : this.reasoning.map((part) => part.text).join(\"\");\n\t}\n\tget files() {\n\t\treturn this.content.filter((part) => part.type === \"file\").map((part) => part.file);\n\t}\n\tget sources() {\n\t\treturn this.content.filter((part) => part.type === \"source\");\n\t}\n\tget toolCalls() {\n\t\treturn this.content.filter((part) => part.type === \"tool-call\");\n\t}\n\tget staticToolCalls() {\n\t\treturn this.toolCalls.filter((toolCall) => toolCall.dynamic !== true);\n\t}\n\tget dynamicToolCalls() {\n\t\treturn this.toolCalls.filter((toolCall) => toolCall.dynamic === true);\n\t}\n\tget toolResults() {\n\t\treturn this.content.filter((part) => part.type === \"tool-result\");\n\t}\n\tget staticToolResults() {\n\t\treturn this.toolResults.filter((toolResult) => toolResult.dynamic !== true);\n\t}\n\tget dynamicToolResults() {\n\t\treturn this.toolResults.filter((toolResult) => toolResult.dynamic === true);\n\t}\n};\nfunction stepCountIs(stepCount) {\n\treturn ({ steps }) => steps.length === stepCount;\n}\nfunction hasToolCall(toolName) {\n\treturn ({ steps }) => {\n\t\tvar _a16, _b, _c;\n\t\treturn (_c = (_b = (_a16 = steps[steps.length - 1]) == null ? void 0 : _a16.toolCalls) == null ? void 0 : _b.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;\n\t};\n}\nasync function isStopConditionMet({ stopConditions, steps }) {\n\treturn (await Promise.all(stopConditions.map((condition) => condition({ steps })))).some((result) => result);\n}\nfunction createToolModelOutput({ output, tool: tool2, errorMode }) {\n\tif (errorMode === \"text\") return {\n\t\ttype: \"error-text\",\n\t\tvalue: getErrorMessage(output)\n\t};\n\telse if (errorMode === \"json\") return {\n\t\ttype: \"error-json\",\n\t\tvalue: toJSONValue(output)\n\t};\n\tif (tool2 == null ? void 0 : tool2.toModelOutput) return tool2.toModelOutput(output);\n\treturn typeof output === \"string\" ? {\n\t\ttype: \"text\",\n\t\tvalue: output\n\t} : {\n\t\ttype: \"json\",\n\t\tvalue: toJSONValue(output)\n\t};\n}\nfunction toJSONValue(value) {\n\treturn value === void 0 ? null : value;\n}\nfunction toResponseMessages({ content: inputContent, tools }) {\n\tconst responseMessages = [];\n\tconst content = inputContent.filter((part) => part.type !== \"source\").filter((part) => (part.type !== \"tool-result\" || part.providerExecuted) && (part.type !== \"tool-error\" || part.providerExecuted)).filter((part) => part.type !== \"text\" || part.text.length > 0).map((part) => {\n\t\tswitch (part.type) {\n\t\t\tcase \"text\": return {\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: part.text,\n\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t};\n\t\t\tcase \"reasoning\": return {\n\t\t\t\ttype: \"reasoning\",\n\t\t\t\ttext: part.text,\n\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t};\n\t\t\tcase \"file\": return {\n\t\t\t\ttype: \"file\",\n\t\t\t\tdata: part.file.base64,\n\t\t\t\tmediaType: part.file.mediaType,\n\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t};\n\t\t\tcase \"tool-call\": return {\n\t\t\t\ttype: \"tool-call\",\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\ttoolName: part.toolName,\n\t\t\t\tinput: part.input,\n\t\t\t\tproviderExecuted: part.providerExecuted,\n\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t};\n\t\t\tcase \"tool-result\": return {\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\ttoolName: part.toolName,\n\t\t\t\toutput: createToolModelOutput({\n\t\t\t\t\ttool: tools == null ? void 0 : tools[part.toolName],\n\t\t\t\t\toutput: part.output,\n\t\t\t\t\terrorMode: \"none\"\n\t\t\t\t}),\n\t\t\t\tproviderExecuted: true,\n\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t};\n\t\t\tcase \"tool-error\": return {\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\ttoolName: part.toolName,\n\t\t\t\toutput: createToolModelOutput({\n\t\t\t\t\ttool: tools == null ? void 0 : tools[part.toolName],\n\t\t\t\t\toutput: part.error,\n\t\t\t\t\terrorMode: \"json\"\n\t\t\t\t}),\n\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t};\n\t\t}\n\t});\n\tif (content.length > 0) responseMessages.push({\n\t\trole: \"assistant\",\n\t\tcontent\n\t});\n\tconst toolResultContent = inputContent.filter((part) => part.type === \"tool-result\" || part.type === \"tool-error\").filter((part) => !part.providerExecuted).map((toolResult) => ({\n\t\ttype: \"tool-result\",\n\t\ttoolCallId: toolResult.toolCallId,\n\t\ttoolName: toolResult.toolName,\n\t\toutput: createToolModelOutput({\n\t\t\ttool: tools == null ? void 0 : tools[toolResult.toolName],\n\t\t\toutput: toolResult.type === \"tool-result\" ? toolResult.output : toolResult.error,\n\t\t\terrorMode: toolResult.type === \"tool-error\" ? \"text\" : \"none\"\n\t\t}),\n\t\t...toolResult.providerMetadata != null ? { providerOptions: toolResult.providerMetadata } : {}\n\t}));\n\tif (toolResultContent.length > 0) responseMessages.push({\n\t\trole: \"tool\",\n\t\tcontent: toolResultContent\n\t});\n\treturn responseMessages;\n}\nvar originalGenerateId = createIdGenerator({\n\tprefix: \"aitxt\",\n\tsize: 24\n});\nasync function generateText$1({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen = stepCountIs(1), experimental_output: output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools = experimental_activeTools, experimental_prepareStep, prepareStep = experimental_prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download2, experimental_context, _internal: { generateId: generateId3 = originalGenerateId, currentDate = () => /* @__PURE__ */ new Date() } = {}, onStepFinish, ...settings }) {\n\tconst model = resolveLanguageModel(modelArg);\n\tconst stopConditions = asArray(stopWhen);\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst callSettings = prepareCallSettings(settings);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: {\n\t\t\t...callSettings,\n\t\t\tmaxRetries\n\t\t}\n\t});\n\tconst initialPrompt = await standardizePrompt({\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tallowSystemInMessages\n\t});\n\tconst tracer = getTracer(telemetry);\n\ttry {\n\t\treturn await recordSpan({\n\t\t\tname: \"ai.generateText\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.generateText\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.model.provider\": model.provider,\n\t\t\t\t\t\"ai.model.id\": model.modelId,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) }\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tfn: async (span) => {\n\t\t\t\tvar _a16, _b, _c, _d, _e, _f, _g;\n\t\t\t\tconst callSettings2 = prepareCallSettings(settings);\n\t\t\t\tlet currentModelResponse;\n\t\t\t\tlet clientToolCalls = [];\n\t\t\t\tlet clientToolOutputs = [];\n\t\t\t\tconst responseMessages = [];\n\t\t\t\tconst steps = [];\n\t\t\t\tdo {\n\t\t\t\t\tif (steps.length > 0) abortSignal?.throwIfAborted();\n\t\t\t\t\tconst stepInputMessages = [...initialPrompt.messages, ...responseMessages];\n\t\t\t\t\tconst prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\tsteps,\n\t\t\t\t\t\tstepNumber: steps.length,\n\t\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t\t}));\n\t\t\t\t\tconst stepModel = resolveLanguageModel((_a16 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a16 : model);\n\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\tsystem: (_b = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b : initialPrompt.system,\n\t\t\t\t\t\t\tmessages: (_c = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c : stepInputMessages\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsupportedUrls: await stepModel.supportedUrls,\n\t\t\t\t\t\tdownload: download2\n\t\t\t\t\t});\n\t\t\t\t\tconst stepActiveTools = (_d = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _d : activeTools;\n\t\t\t\t\tconst stepToolSet = filterActiveTools({\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t});\n\t\t\t\t\tconst { toolChoice: stepToolChoice, tools: stepTools } = prepareToolsAndToolChoice({\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\ttoolChoice: (_e = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _e : toolChoice,\n\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t});\n\t\t\t\t\tcurrentModelResponse = await retry(() => {\n\t\t\t\t\t\tvar _a17;\n\t\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\t\tname: \"ai.generateText.doGenerate\",\n\t\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\t\toperationId: \"ai.generateText.doGenerate\",\n\t\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\t\"ai.model.provider\": stepModel.provider,\n\t\t\t\t\t\t\t\t\t\"ai.model.id\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\t\t\"ai.prompt.tools\": { input: () => stepTools == null ? void 0 : stepTools.map((tool2) => JSON.stringify(tool2)) },\n\t\t\t\t\t\t\t\t\t\"ai.prompt.toolChoice\": { input: () => stepToolChoice != null ? JSON.stringify(stepToolChoice) : void 0 },\n\t\t\t\t\t\t\t\t\t\"gen_ai.system\": stepModel.provider,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.model\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": settings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": settings.maxOutputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": settings.presencePenalty,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.stop_sequences\": settings.stopSequences,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": (_a17 = settings.temperature) != null ? _a17 : void 0,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": settings.topK,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": settings.topP\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\t\t\tvar _a18, _b2, _c2, _d2, _e2, _f2, _g2, _h;\n\t\t\t\t\t\t\t\tconst result = await stepModel.doGenerate({\n\t\t\t\t\t\t\t\t\t...callSettings2,\n\t\t\t\t\t\t\t\t\ttools: stepTools,\n\t\t\t\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\t\t\t\tresponseFormat: output == null ? void 0 : output.responseFormat,\n\t\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\t\theaders: headersWithUserAgent\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\t\t\tid: (_b2 = (_a18 = result.response) == null ? void 0 : _a18.id) != null ? _b2 : generateId3(),\n\t\t\t\t\t\t\t\t\ttimestamp: (_d2 = (_c2 = result.response) == null ? void 0 : _c2.timestamp) != null ? _d2 : currentDate(),\n\t\t\t\t\t\t\t\t\tmodelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId,\n\t\t\t\t\t\t\t\t\theaders: (_g2 = result.response) == null ? void 0 : _g2.headers,\n\t\t\t\t\t\t\t\t\tbody: (_h = result.response) == null ? void 0 : _h.body\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tspan2.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result.finishReason,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.text\": { output: () => extractTextContent(result.content) },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst toolCalls = asToolCalls(result.content);\n\t\t\t\t\t\t\t\t\t\t\treturn toolCalls == null ? void 0 : JSON.stringify(toolCalls);\n\t\t\t\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result.providerMetadata),\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": result.usage.inputTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": result.usage.outputTokens,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result.finishReason],\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": result.usage.inputTokens,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": result.usage.outputTokens\n\t\t\t\t\t\t\t\t\t}\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\t\t...result,\n\t\t\t\t\t\t\t\t\tresponse: responseData\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\tconst stepToolCalls = await Promise.all(currentModelResponse.content.filter((part) => part.type === \"tool-call\").map((toolCall) => parseToolCall({\n\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\ttools: stepToolSet,\n\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t\t})));\n\t\t\t\t\tfor (const toolCall of stepToolCalls) {\n\t\t\t\t\t\tif (toolCall.invalid) continue;\n\t\t\t\t\t\tconst tool2 = stepToolSet[toolCall.toolName];\n\t\t\t\t\t\tif (tool2.onInputStart != null) await tool2.onInputStart({\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif ((tool2 == null ? void 0 : tool2.onInputAvailable) != null) await tool2.onInputAvailable({\n\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst invalidToolCalls = stepToolCalls.filter((toolCall) => toolCall.invalid && toolCall.dynamic);\n\t\t\t\t\tclientToolOutputs = [];\n\t\t\t\t\tfor (const toolCall of invalidToolCalls) clientToolOutputs.push({\n\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\terror: getErrorMessage$1(toolCall.error),\n\t\t\t\t\t\tdynamic: true\n\t\t\t\t\t});\n\t\t\t\t\tclientToolCalls = stepToolCalls.filter((toolCall) => !toolCall.providerExecuted);\n\t\t\t\t\tif (stepToolSet != null && isToolExecutionAllowedFinishReason(currentModelResponse.finishReason)) clientToolOutputs.push(...await executeTools({\n\t\t\t\t\t\ttoolCalls: clientToolCalls.filter((toolCall) => !toolCall.invalid),\n\t\t\t\t\t\ttools: stepToolSet,\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t}));\n\t\t\t\t\tconst stepContent = asContent({\n\t\t\t\t\t\tcontent: currentModelResponse.content,\n\t\t\t\t\t\ttoolCalls: stepToolCalls,\n\t\t\t\t\t\ttoolOutputs: clientToolOutputs\n\t\t\t\t\t});\n\t\t\t\t\tresponseMessages.push(...toResponseMessages({\n\t\t\t\t\t\tcontent: stepContent,\n\t\t\t\t\t\ttools: stepToolSet\n\t\t\t\t\t}));\n\t\t\t\t\tconst currentStepResult = new DefaultStepResult({\n\t\t\t\t\t\tcontent: stepContent,\n\t\t\t\t\t\tfinishReason: currentModelResponse.finishReason,\n\t\t\t\t\t\tusage: currentModelResponse.usage,\n\t\t\t\t\t\twarnings: currentModelResponse.warnings,\n\t\t\t\t\t\tproviderMetadata: currentModelResponse.providerMetadata,\n\t\t\t\t\t\trequest: (_f = currentModelResponse.request) != null ? _f : {},\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t...currentModelResponse.response,\n\t\t\t\t\t\t\tmessages: structuredClone(responseMessages)\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tlogWarnings((_g = currentModelResponse.warnings) != null ? _g : []);\n\t\t\t\t\tsteps.push(currentStepResult);\n\t\t\t\t\tawait (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));\n\t\t\t\t} while (clientToolCalls.length > 0 && clientToolOutputs.length === clientToolCalls.length && !await isStopConditionMet({\n\t\t\t\t\tstopConditions,\n\t\t\t\t\tsteps\n\t\t\t\t}));\n\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.response.finishReason\": currentModelResponse.finishReason,\n\t\t\t\t\t\t\"ai.response.text\": { output: () => extractTextContent(currentModelResponse.content) },\n\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\tconst toolCalls = asToolCalls(currentModelResponse.content);\n\t\t\t\t\t\t\treturn toolCalls == null ? void 0 : JSON.stringify(toolCalls);\n\t\t\t\t\t\t} },\n\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(currentModelResponse.providerMetadata),\n\t\t\t\t\t\t\"ai.usage.promptTokens\": currentModelResponse.usage.inputTokens,\n\t\t\t\t\t\t\"ai.usage.completionTokens\": currentModelResponse.usage.outputTokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tconst lastStep = steps[steps.length - 1];\n\t\t\t\tlet resolvedOutput;\n\t\t\t\tif (lastStep.finishReason === \"stop\") resolvedOutput = await (output == null ? void 0 : output.parseOutput({ text: lastStep.text }, {\n\t\t\t\t\tresponse: lastStep.response,\n\t\t\t\t\tusage: lastStep.usage,\n\t\t\t\t\tfinishReason: lastStep.finishReason\n\t\t\t\t}));\n\t\t\t\treturn new DefaultGenerateTextResult({\n\t\t\t\t\tsteps,\n\t\t\t\t\tresolvedOutput\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t} catch (error) {\n\t\tthrow wrapGatewayError(error);\n\t}\n}\nasync function executeTools({ toolCalls, tools, tracer, telemetry, messages, abortSignal, experimental_context }) {\n\treturn (await Promise.all(toolCalls.map(async ({ toolCallId, toolName, input }) => {\n\t\tconst tool2 = tools[toolName];\n\t\tif ((tool2 == null ? void 0 : tool2.execute) == null) return;\n\t\treturn recordSpan({\n\t\t\tname: \"ai.toolCall\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.toolCall\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...getTelemetryMetadataAttributes(telemetry),\n\t\t\t\t\t\"ai.toolCall.name\": toolName,\n\t\t\t\t\t\"ai.toolCall.id\": toolCallId,\n\t\t\t\t\t\"ai.toolCall.args\": { output: () => JSON.stringify(input) }\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tfn: async (span) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst stream = executeTool({\n\t\t\t\t\t\texecute: tool2.execute.bind(tool2),\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tlet output;\n\t\t\t\t\tfor await (const part of stream) if (part.type === \"final\") output = part.output;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: { \"ai.toolCall.result\": { output: () => JSON.stringify(output) } }\n\t\t\t\t\t\t}));\n\t\t\t\t\t} catch (ignored) {}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\toutput,\n\t\t\t\t\t\tdynamic: tool2.type === \"dynamic\"\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tdynamic: tool2.type === \"dynamic\"\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}))).filter((output) => output != null);\n}\nvar DefaultGenerateTextResult = class {\n\tconstructor(options) {\n\t\tthis.steps = options.steps;\n\t\tthis.resolvedOutput = options.resolvedOutput;\n\t}\n\tget finalStep() {\n\t\treturn this.steps[this.steps.length - 1];\n\t}\n\tget content() {\n\t\treturn this.finalStep.content;\n\t}\n\tget text() {\n\t\treturn this.finalStep.text;\n\t}\n\tget files() {\n\t\treturn this.finalStep.files;\n\t}\n\tget reasoningText() {\n\t\treturn this.finalStep.reasoningText;\n\t}\n\tget reasoning() {\n\t\treturn this.finalStep.reasoning;\n\t}\n\tget toolCalls() {\n\t\treturn this.finalStep.toolCalls;\n\t}\n\tget staticToolCalls() {\n\t\treturn this.finalStep.staticToolCalls;\n\t}\n\tget dynamicToolCalls() {\n\t\treturn this.finalStep.dynamicToolCalls;\n\t}\n\tget toolResults() {\n\t\treturn this.finalStep.toolResults;\n\t}\n\tget staticToolResults() {\n\t\treturn this.finalStep.staticToolResults;\n\t}\n\tget dynamicToolResults() {\n\t\treturn this.finalStep.dynamicToolResults;\n\t}\n\tget sources() {\n\t\treturn this.finalStep.sources;\n\t}\n\tget finishReason() {\n\t\treturn this.finalStep.finishReason;\n\t}\n\tget warnings() {\n\t\treturn this.finalStep.warnings;\n\t}\n\tget providerMetadata() {\n\t\treturn this.finalStep.providerMetadata;\n\t}\n\tget response() {\n\t\treturn this.finalStep.response;\n\t}\n\tget request() {\n\t\treturn this.finalStep.request;\n\t}\n\tget usage() {\n\t\treturn this.finalStep.usage;\n\t}\n\tget totalUsage() {\n\t\treturn this.steps.reduce((totalUsage, step) => {\n\t\t\treturn addLanguageModelUsage(totalUsage, step.usage);\n\t\t}, {\n\t\t\tinputTokens: void 0,\n\t\t\toutputTokens: void 0,\n\t\t\ttotalTokens: void 0,\n\t\t\treasoningTokens: void 0,\n\t\t\tcachedInputTokens: void 0\n\t\t});\n\t}\n\tget experimental_output() {\n\t\tif (this.resolvedOutput == null) throw new NoOutputSpecifiedError();\n\t\treturn this.resolvedOutput;\n\t}\n};\nfunction asToolCalls(content) {\n\tconst parts = content.filter((part) => part.type === \"tool-call\");\n\tif (parts.length === 0) return;\n\treturn parts.map((toolCall) => ({\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName: toolCall.toolName,\n\t\tinput: toolCall.input\n\t}));\n}\nfunction asContent({ content, toolCalls, toolOutputs }) {\n\treturn [...content.map((part) => {\n\t\tswitch (part.type) {\n\t\t\tcase \"text\":\n\t\t\tcase \"reasoning\":\n\t\t\tcase \"source\": return part;\n\t\t\tcase \"file\": return {\n\t\t\t\ttype: \"file\",\n\t\t\t\tfile: new DefaultGeneratedFile(part)\n\t\t\t};\n\t\t\tcase \"tool-call\": return toolCalls.find((toolCall) => toolCall.toolCallId === part.toolCallId);\n\t\t\tcase \"tool-result\": {\n\t\t\t\tconst toolCall = toolCalls.find((toolCall2) => toolCall2.toolCallId === part.toolCallId);\n\t\t\t\tif (toolCall == null) throw new Error(`Tool call ${part.toolCallId} not found.`);\n\t\t\t\tif (part.isError) return {\n\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\terror: part.result,\n\t\t\t\t\tproviderExecuted: true,\n\t\t\t\t\tdynamic: toolCall.dynamic\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\toutput: part.result,\n\t\t\t\t\tproviderExecuted: true,\n\t\t\t\t\tdynamic: toolCall.dynamic\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}), ...toolOutputs];\n}\nfunction prepareHeaders(headers, defaultHeaders) {\n\tconst responseHeaders = new Headers(headers != null ? headers : {});\n\tfor (const [key, value] of Object.entries(defaultHeaders)) if (!responseHeaders.has(key)) responseHeaders.set(key, value);\n\treturn responseHeaders;\n}\nfunction createTextStreamResponse({ status, statusText, headers, textStream }) {\n\treturn new Response(textStream.pipeThrough(new TextEncoderStream()), {\n\t\tstatus: status != null ? status : 200,\n\t\tstatusText,\n\t\theaders: prepareHeaders(headers, { \"content-type\": \"text/plain; charset=utf-8\" })\n\t});\n}\nfunction writeToServerResponse({ response, status, statusText, headers, stream }) {\n\tconst statusCode = status != null ? status : 200;\n\tif (statusText !== void 0) response.writeHead(statusCode, statusText, headers);\n\telse response.writeHead(statusCode, headers);\n\tconst reader = stream.getReader();\n\tlet clientDisconnected = false;\n\tlet onDisconnect;\n\tconst handleClose = () => {\n\t\tif (response.writableFinished) return;\n\t\tclientDisconnected = true;\n\t\tonDisconnect?.();\n\t\treader.cancel(/* @__PURE__ */ new Error(\"Client disconnected.\")).catch(() => {});\n\t};\n\tresponse.once(\"close\", handleClose);\n\tif (response.destroyed) handleClose();\n\tconst read = async () => {\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done || clientDisconnected || response.destroyed) break;\n\t\t\t\tif (!response.write(value)) {\n\t\t\t\t\tawait new Promise((resolve2) => {\n\t\t\t\t\t\tonDisconnect = resolve2;\n\t\t\t\t\t\tresponse.once(\"drain\", resolve2);\n\t\t\t\t\t});\n\t\t\t\t\tonDisconnect = void 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tresponse.off(\"close\", handleClose);\n\t\t\tif (clientDisconnected || response.destroyed) reader.cancel().catch(() => {});\n\t\t\telse response.end();\n\t\t}\n\t};\n\treturn read();\n}\nfunction pipeTextStreamToResponse({ response, status, statusText, headers, textStream }) {\n\treturn writeToServerResponse({\n\t\tresponse,\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: Object.fromEntries(prepareHeaders(headers, { \"content-type\": \"text/plain; charset=utf-8\" }).entries()),\n\t\tstream: textStream.pipeThrough(new TextEncoderStream())\n\t});\n}\nvar STREAM_OPEN_COMMENT = \": stream-open\\n\\n\";\nvar KEEP_ALIVE_COMMENT = \": keep-alive\\n\\n\";\nfunction createSseStreamWithKeepAlive({ stream, keepAliveMs }) {\n\tif (keepAliveMs == null) return stream;\n\tif (!Number.isFinite(keepAliveMs) || keepAliveMs <= 0 || keepAliveMs > 2147483647) throw new Error(\"keepAliveMs must be a positive finite timer duration no greater than 2147483647\");\n\tconst reader = stream.getReader();\n\tlet keepAliveTimeout;\n\tlet isCancelled = false;\n\tconst clearKeepAliveTimeout = () => {\n\t\tclearTimeout(keepAliveTimeout);\n\t\tkeepAliveTimeout = void 0;\n\t};\n\tconst scheduleKeepAlive = (controller) => {\n\t\tclearKeepAliveTimeout();\n\t\tkeepAliveTimeout = setTimeout(() => {\n\t\t\tif (isCancelled) return;\n\t\t\tif (controller.desiredSize != null && controller.desiredSize > 0) controller.enqueue(KEEP_ALIVE_COMMENT);\n\t\t\tscheduleKeepAlive(controller);\n\t\t}, keepAliveMs);\n\t};\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\tcontroller.enqueue(STREAM_OPEN_COMMENT);\n\t\t\tscheduleKeepAlive(controller);\n\t\t},\n\t\tpull(controller) {\n\t\t\treturn reader.read().then((result) => {\n\t\t\t\tclearKeepAliveTimeout();\n\t\t\t\tif (isCancelled) return;\n\t\t\t\tif (result.done) controller.close();\n\t\t\t\telse {\n\t\t\t\t\tcontroller.enqueue(result.value);\n\t\t\t\t\tscheduleKeepAlive(controller);\n\t\t\t\t}\n\t\t\t}, (error) => {\n\t\t\t\tclearKeepAliveTimeout();\n\t\t\t\tif (!isCancelled) throw error;\n\t\t\t});\n\t\t},\n\t\tasync cancel(reason) {\n\t\t\tisCancelled = true;\n\t\t\tclearKeepAliveTimeout();\n\t\t\tawait reader.cancel(reason);\n\t\t}\n\t});\n}\nvar JsonToSseTransformStream = class extends TransformStream {\n\tconstructor() {\n\t\tsuper({\n\t\t\ttransform(part, controller) {\n\t\t\t\tcontroller.enqueue(`data: ${JSON.stringify(part)}\n\n`);\n\t\t\t},\n\t\t\tflush(controller) {\n\t\t\t\tcontroller.enqueue(\"data: [DONE]\\n\\n\");\n\t\t\t}\n\t\t});\n\t}\n};\nvar UI_MESSAGE_STREAM_HEADERS = {\n\t\"content-type\": \"text/event-stream\",\n\t\"cache-control\": \"no-cache\",\n\tconnection: \"keep-alive\",\n\t\"x-vercel-ai-ui-message-stream\": \"v1\",\n\t\"x-accel-buffering\": \"no\"\n};\nfunction createUIMessageStreamResponse({ status, statusText, headers, stream, keepAliveMs, consumeSseStream }) {\n\tlet sseStream = createSseStreamWithKeepAlive({\n\t\tstream: stream.pipeThrough(new JsonToSseTransformStream()),\n\t\tkeepAliveMs\n\t});\n\tif (consumeSseStream) {\n\t\tconst [stream1, stream2] = sseStream.tee();\n\t\tsseStream = stream1;\n\t\tconsumeSseStream({ stream: stream2 });\n\t}\n\treturn new Response(sseStream.pipeThrough(new TextEncoderStream()), {\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: prepareHeaders(headers, UI_MESSAGE_STREAM_HEADERS)\n\t});\n}\nfunction getResponseUIMessageId({ originalMessages, responseMessageId }) {\n\tif (originalMessages == null) return;\n\tconst lastMessage = originalMessages[originalMessages.length - 1];\n\treturn (lastMessage == null ? void 0 : lastMessage.role) === \"assistant\" ? lastMessage.id : typeof responseMessageId === \"function\" ? responseMessageId() : responseMessageId;\n}\nvar uiMessageChunkSchema = lazyValidator(() => zodSchema(z.union([\n\tz.looseObject({\n\t\ttype: z.literal(\"text-start\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"text-delta\"),\n\t\tid: z.string(),\n\t\tdelta: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"text-end\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"error\"),\n\t\terrorText: z.string()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-start\"),\n\t\ttoolCallId: z.string(),\n\t\ttoolName: z.string(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tdynamic: z.boolean().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-delta\"),\n\t\ttoolCallId: z.string(),\n\t\tinputTextDelta: z.string()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-available\"),\n\t\ttoolCallId: z.string(),\n\t\ttoolName: z.string(),\n\t\tinput: z.unknown(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-error\"),\n\t\ttoolCallId: z.string(),\n\t\ttoolName: z.string(),\n\t\tinput: z.unknown(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional(),\n\t\terrorText: z.string()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-output-available\"),\n\t\ttoolCallId: z.string(),\n\t\toutput: z.unknown(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tdynamic: z.boolean().optional(),\n\t\tpreliminary: z.boolean().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-output-error\"),\n\t\ttoolCallId: z.string(),\n\t\terrorText: z.string(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tdynamic: z.boolean().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"reasoning-start\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"reasoning-delta\"),\n\t\tid: z.string(),\n\t\tdelta: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"reasoning-end\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"source-url\"),\n\t\tsourceId: z.string(),\n\t\turl: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"source-document\"),\n\t\tsourceId: z.string(),\n\t\tmediaType: z.string(),\n\t\ttitle: z.string(),\n\t\tfilename: z.string().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"file\"),\n\t\turl: z.string(),\n\t\tmediaType: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.custom((value) => typeof value === \"string\" && value.startsWith(\"data-\"), { message: \"Type must start with \\\"data-\\\"\" }),\n\t\tid: z.string().optional(),\n\t\tdata: z.unknown(),\n\t\ttransient: z.boolean().optional()\n\t}),\n\tz.looseObject({ type: z.literal(\"start-step\") }),\n\tz.looseObject({ type: z.literal(\"finish-step\") }),\n\tz.looseObject({\n\t\ttype: z.literal(\"start\"),\n\t\tmessageId: z.string().optional(),\n\t\tmessageMetadata: z.unknown().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"finish\"),\n\t\tfinishReason: z.enum([\n\t\t\t\"stop\",\n\t\t\t\"length\",\n\t\t\t\"content-filter\",\n\t\t\t\"tool-calls\",\n\t\t\t\"error\",\n\t\t\t\"other\",\n\t\t\t\"unknown\"\n\t\t]).optional(),\n\t\tmessageMetadata: z.unknown().optional()\n\t}),\n\tz.looseObject({ type: z.literal(\"abort\") }),\n\tz.looseObject({\n\t\ttype: z.literal(\"message-metadata\"),\n\t\tmessageMetadata: z.unknown()\n\t})\n])));\nfunction isDataUIMessageChunk(chunk) {\n\treturn chunk.type.startsWith(\"data-\");\n}\nfunction createIdMap() {\n\treturn /* @__PURE__ */ Object.create(null);\n}\nfunction mergeObjects(base, overrides) {\n\tif (base === void 0 && overrides === void 0) return;\n\tif (base === void 0) return overrides;\n\tif (overrides === void 0) return base;\n\tconst result = { ...base };\n\tfor (const key in overrides) {\n\t\tif (key === \"__proto__\" || key === \"constructor\" || key === \"prototype\") continue;\n\t\tif (Object.prototype.hasOwnProperty.call(overrides, key)) {\n\t\t\tconst overridesValue = overrides[key];\n\t\t\tif (overridesValue === void 0) continue;\n\t\t\tconst baseValue = key in base ? base[key] : void 0;\n\t\t\tconst isSourceObject = overridesValue !== null && typeof overridesValue === \"object\" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);\n\t\t\tconst isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === \"object\" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);\n\t\t\tif (isSourceObject && isTargetObject) result[key] = mergeObjects(baseValue, overridesValue);\n\t\t\telse result[key] = overridesValue;\n\t\t}\n\t}\n\treturn result;\n}\nfunction fixJson(input) {\n\tconst stack = [\"ROOT\"];\n\tlet lastValidIndex = -1;\n\tlet literalStart = null;\n\tfunction processValueStart(char, i, swapState) {\n\t\tswitch (char) {\n\t\t\tcase \"\\\"\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_STRING\");\n\t\t\t\tbreak;\n\t\t\tcase \"f\":\n\t\t\tcase \"t\":\n\t\t\tcase \"n\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tliteralStart = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_LITERAL\");\n\t\t\t\tbreak;\n\t\t\tcase \"-\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_NUMBER\");\n\t\t\t\tbreak;\n\t\t\tcase \"0\":\n\t\t\tcase \"1\":\n\t\t\tcase \"2\":\n\t\t\tcase \"3\":\n\t\t\tcase \"4\":\n\t\t\tcase \"5\":\n\t\t\tcase \"6\":\n\t\t\tcase \"7\":\n\t\t\tcase \"8\":\n\t\t\tcase \"9\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_NUMBER\");\n\t\t\t\tbreak;\n\t\t\tcase \"{\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_OBJECT_START\");\n\t\t\t\tbreak;\n\t\t\tcase \"[\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_ARRAY_START\");\n\t\t}\n\t}\n\tfunction processAfterObjectValue(char, i) {\n\t\tswitch (char) {\n\t\t\tcase \",\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(\"INSIDE_OBJECT_AFTER_COMMA\");\n\t\t\t\tbreak;\n\t\t\tcase \"}\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t}\n\t}\n\tfunction processAfterArrayValue(char, i) {\n\t\tswitch (char) {\n\t\t\tcase \",\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n\t\t\t\tbreak;\n\t\t\tcase \"]\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t}\n\t}\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst char = input[i];\n\t\tswitch (stack[stack.length - 1]) {\n\t\t\tcase \"ROOT\":\n\t\t\t\tprocessValueStart(char, i, \"FINISH\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_START\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_KEY\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"}\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_COMMA\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_KEY\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_KEY\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_AFTER_KEY\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_KEY\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \":\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_BEFORE_VALUE\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_BEFORE_VALUE\":\n\t\t\t\tprocessValueStart(char, i, \"INSIDE_OBJECT_AFTER_VALUE\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_VALUE\":\n\t\t\t\tprocessAfterObjectValue(char, i);\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"\\\\\":\n\t\t\t\t\t\tstack.push(\"INSIDE_STRING_ESCAPE\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: lastValidIndex = i;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_START\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tprocessValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_AFTER_VALUE\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \",\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: lastValidIndex = i;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_AFTER_COMMA\":\n\t\t\t\tprocessValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING_ESCAPE\":\n\t\t\t\tstack.pop();\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_NUMBER\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"0\":\n\t\t\t\t\tcase \"1\":\n\t\t\t\t\tcase \"2\":\n\t\t\t\t\tcase \"3\":\n\t\t\t\t\tcase \"4\":\n\t\t\t\t\tcase \"5\":\n\t\t\t\t\tcase \"6\":\n\t\t\t\t\tcase \"7\":\n\t\t\t\t\tcase \"8\":\n\t\t\t\t\tcase \"9\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"e\":\n\t\t\t\t\tcase \"E\":\n\t\t\t\t\tcase \"-\":\n\t\t\t\t\tcase \".\": break;\n\t\t\t\t\tcase \",\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"}\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: stack.pop();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_LITERAL\": {\n\t\t\t\tconst partialLiteral = input.substring(literalStart, i + 1);\n\t\t\t\tif (!\"false\".startsWith(partialLiteral) && !\"true\".startsWith(partialLiteral) && !\"null\".startsWith(partialLiteral)) {\n\t\t\t\t\tstack.pop();\n\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\telse if (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t} else lastValidIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tlet result = input.slice(0, lastValidIndex + 1);\n\tfor (let i = stack.length - 1; i >= 0; i--) switch (stack[i]) {\n\t\tcase \"INSIDE_STRING\":\n\t\t\tresult += \"\\\"\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_OBJECT_KEY\":\n\t\tcase \"INSIDE_OBJECT_AFTER_KEY\":\n\t\tcase \"INSIDE_OBJECT_AFTER_COMMA\":\n\t\tcase \"INSIDE_OBJECT_START\":\n\t\tcase \"INSIDE_OBJECT_BEFORE_VALUE\":\n\t\tcase \"INSIDE_OBJECT_AFTER_VALUE\":\n\t\t\tresult += \"}\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_ARRAY_START\":\n\t\tcase \"INSIDE_ARRAY_AFTER_COMMA\":\n\t\tcase \"INSIDE_ARRAY_AFTER_VALUE\":\n\t\t\tresult += \"]\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_LITERAL\": {\n\t\t\tconst partialLiteral = input.substring(literalStart, input.length);\n\t\t\tif (\"true\".startsWith(partialLiteral)) result += \"true\".slice(partialLiteral.length);\n\t\t\telse if (\"false\".startsWith(partialLiteral)) result += \"false\".slice(partialLiteral.length);\n\t\t\telse if (\"null\".startsWith(partialLiteral)) result += \"null\".slice(partialLiteral.length);\n\t\t}\n\t}\n\treturn result;\n}\nasync function parsePartialJson(jsonText) {\n\tif (jsonText === void 0) return {\n\t\tvalue: void 0,\n\t\tstate: \"undefined-input\"\n\t};\n\tlet result = await safeParseJSON({ text: jsonText });\n\tif (result.success) return {\n\t\tvalue: result.value,\n\t\tstate: \"successful-parse\"\n\t};\n\tresult = await safeParseJSON({ text: fixJson(jsonText) });\n\tif (result.success) return {\n\t\tvalue: result.value,\n\t\tstate: \"repaired-parse\"\n\t};\n\treturn {\n\t\tvalue: void 0,\n\t\tstate: \"failed-parse\"\n\t};\n}\nfunction isDataUIPart(part) {\n\treturn part.type.startsWith(\"data-\");\n}\nfunction isTextUIPart(part) {\n\treturn part.type === \"text\";\n}\nfunction isFileUIPart(part) {\n\treturn part.type === \"file\";\n}\nfunction isReasoningUIPart(part) {\n\treturn part.type === \"reasoning\";\n}\nfunction isToolUIPart(part) {\n\treturn part.type.startsWith(\"tool-\");\n}\nfunction isDynamicToolUIPart(part) {\n\treturn part.type === \"dynamic-tool\";\n}\nfunction isToolOrDynamicToolUIPart(part) {\n\treturn isToolUIPart(part) || isDynamicToolUIPart(part);\n}\nfunction getToolName(part) {\n\treturn part.type.split(\"-\").slice(1).join(\"-\");\n}\nfunction getToolOrDynamicToolName(part) {\n\treturn isDynamicToolUIPart(part) ? part.toolName : getToolName(part);\n}\nfunction createStreamingUIMessageState({ lastMessage, messageId }) {\n\tvar _a16;\n\tconst message = (lastMessage == null ? void 0 : lastMessage.role) === \"assistant\" ? lastMessage : {\n\t\tid: messageId,\n\t\tmetadata: void 0,\n\t\trole: \"assistant\",\n\t\tparts: []\n\t};\n\tconst partialToolCalls = createIdMap();\n\tconst lastStepStartIndex = message.parts.findLastIndex((part) => part.type === \"step-start\");\n\tlet staticToolIndex = 0;\n\tfor (const part of message.parts.slice(lastStepStartIndex + 1)) {\n\t\tif (!isToolOrDynamicToolUIPart(part)) continue;\n\t\tconst index = staticToolIndex;\n\t\tif (isToolUIPart(part)) staticToolIndex++;\n\t\tif (part.state !== \"input-streaming\") continue;\n\t\tpartialToolCalls[part.toolCallId] = {\n\t\t\ttext: (_a16 = part.rawInput) != null ? _a16 : \"\",\n\t\t\tindex,\n\t\t\ttoolName: isDynamicToolUIPart(part) ? part.toolName : getToolName(part),\n\t\t\tdynamic: isDynamicToolUIPart(part)\n\t\t};\n\t}\n\treturn {\n\t\tmessage,\n\t\tactiveTextParts: createIdMap(),\n\t\tactiveReasoningParts: createIdMap(),\n\t\tpartialToolCalls\n\t};\n}\nfunction processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas, runUpdateMessageJob, onError, onToolCall, onData, resetStateOnMessageIdChange = false }) {\n\treturn stream.pipeThrough(new TransformStream({ async transform(chunk, controller) {\n\t\tawait runUpdateMessageJob(async ({ state, write }) => {\n\t\t\tvar _a16, _b, _c, _d;\n\t\t\tfunction getCurrentStepParts() {\n\t\t\t\tconst parts = state.message.parts;\n\t\t\t\tlet currentStepStartIndex = parts.length - 1;\n\t\t\t\twhile (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== \"step-start\") currentStepStartIndex--;\n\t\t\t\treturn parts.slice(currentStepStartIndex + 1);\n\t\t\t}\n\t\t\tfunction getCurrentStepToolInvocations() {\n\t\t\t\treturn getCurrentStepParts().filter(isToolUIPart);\n\t\t\t}\n\t\t\tfunction getToolInvocation(toolCallId) {\n\t\t\t\tlet toolInvocation = getCurrentStepToolInvocations().find((invocation) => invocation.toolCallId === toolCallId);\n\t\t\t\tif (toolInvocation == null) {\n\t\t\t\t\tconst parts = state.message.parts;\n\t\t\t\t\tfor (let i = parts.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tconst part = parts[i];\n\t\t\t\t\t\tif (isToolUIPart(part) && part.toolCallId === toolCallId) {\n\t\t\t\t\t\t\ttoolInvocation = part;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (toolInvocation == null) throw new Error(\"tool-output-error must be preceded by a tool-input-available\");\n\t\t\t\treturn toolInvocation;\n\t\t\t}\n\t\t\tfunction getDynamicToolInvocation(toolCallId) {\n\t\t\t\tlet toolInvocation = getCurrentStepParts().filter((part) => part.type === \"dynamic-tool\").find((invocation) => invocation.toolCallId === toolCallId);\n\t\t\t\tif (toolInvocation == null) {\n\t\t\t\t\tconst parts = state.message.parts;\n\t\t\t\t\tfor (let i = parts.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tconst part = parts[i];\n\t\t\t\t\t\tif (part.type === \"dynamic-tool\" && part.toolCallId === toolCallId) {\n\t\t\t\t\t\t\ttoolInvocation = part;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (toolInvocation == null) throw new Error(\"tool-output-error must be preceded by a tool-input-available\");\n\t\t\t\treturn toolInvocation;\n\t\t\t}\n\t\t\tfunction updateToolPart(options, existingPart) {\n\t\t\t\tvar _a17;\n\t\t\t\tconst part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId);\n\t\t\t\tconst anyOptions = options;\n\t\t\t\tconst anyPart = part;\n\t\t\t\tif (part != null) {\n\t\t\t\t\tpart.state = options.state;\n\t\t\t\t\tanyPart.input = anyOptions.input;\n\t\t\t\t\tanyPart.output = anyOptions.output;\n\t\t\t\t\tanyPart.errorText = anyOptions.errorText;\n\t\t\t\t\tanyPart.rawInput = anyOptions.rawInput;\n\t\t\t\t\tanyPart.preliminary = anyOptions.preliminary;\n\t\t\t\t\tanyPart.providerExecuted = (_a17 = anyOptions.providerExecuted) != null ? _a17 : part.providerExecuted;\n\t\t\t\t\tif (anyOptions.providerMetadata != null && part.state === \"input-available\") part.callProviderMetadata = anyOptions.providerMetadata;\n\t\t\t\t} else state.message.parts.push({\n\t\t\t\t\ttype: `tool-${options.toolName}`,\n\t\t\t\t\ttoolCallId: options.toolCallId,\n\t\t\t\t\tstate: options.state,\n\t\t\t\t\tinput: anyOptions.input,\n\t\t\t\t\toutput: anyOptions.output,\n\t\t\t\t\trawInput: anyOptions.rawInput,\n\t\t\t\t\terrorText: anyOptions.errorText,\n\t\t\t\t\tproviderExecuted: anyOptions.providerExecuted,\n\t\t\t\t\tpreliminary: anyOptions.preliminary,\n\t\t\t\t\t...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}\n\t\t\t\t});\n\t\t\t}\n\t\t\tfunction updateDynamicToolPart(options, existingPart) {\n\t\t\t\tvar _a17;\n\t\t\t\tconst part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => part2.type === \"dynamic-tool\" && part2.toolCallId === options.toolCallId);\n\t\t\t\tconst anyOptions = options;\n\t\t\t\tconst anyPart = part;\n\t\t\t\tif (part != null) {\n\t\t\t\t\tpart.state = options.state;\n\t\t\t\t\tanyPart.toolName = options.toolName;\n\t\t\t\t\tanyPart.input = anyOptions.input;\n\t\t\t\t\tanyPart.output = anyOptions.output;\n\t\t\t\t\tanyPart.errorText = anyOptions.errorText;\n\t\t\t\t\tanyPart.rawInput = anyOptions.rawInput;\n\t\t\t\t\tanyPart.preliminary = anyOptions.preliminary;\n\t\t\t\t\tanyPart.providerExecuted = (_a17 = anyOptions.providerExecuted) != null ? _a17 : part.providerExecuted;\n\t\t\t\t\tif (anyOptions.providerMetadata != null && part.state === \"input-available\") part.callProviderMetadata = anyOptions.providerMetadata;\n\t\t\t\t} else state.message.parts.push({\n\t\t\t\t\ttype: \"dynamic-tool\",\n\t\t\t\t\ttoolName: options.toolName,\n\t\t\t\t\ttoolCallId: options.toolCallId,\n\t\t\t\t\tstate: options.state,\n\t\t\t\t\tinput: anyOptions.input,\n\t\t\t\t\toutput: anyOptions.output,\n\t\t\t\t\terrorText: anyOptions.errorText,\n\t\t\t\t\tpreliminary: anyOptions.preliminary,\n\t\t\t\t\tproviderExecuted: anyOptions.providerExecuted,\n\t\t\t\t\t...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}\n\t\t\t\t});\n\t\t\t}\n\t\t\tasync function updateMessageMetadata(metadata) {\n\t\t\t\tif (metadata != null) {\n\t\t\t\t\tconst mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;\n\t\t\t\t\tif (messageMetadataSchema != null) await validateTypes({\n\t\t\t\t\t\tvalue: mergedMetadata,\n\t\t\t\t\t\tschema: messageMetadataSchema\n\t\t\t\t\t});\n\t\t\t\t\tstate.message.metadata = mergedMetadata;\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"text-start\": {\n\t\t\t\t\tconst textPart = {\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\tstate: \"streaming\"\n\t\t\t\t\t};\n\t\t\t\t\tstate.activeTextParts[chunk.id] = textPart;\n\t\t\t\t\tstate.message.parts.push(textPart);\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"text-delta\": {\n\t\t\t\t\tconst textPart = state.activeTextParts[chunk.id];\n\t\t\t\t\ttextPart.text += chunk.delta;\n\t\t\t\t\ttextPart.providerMetadata = (_a16 = chunk.providerMetadata) != null ? _a16 : textPart.providerMetadata;\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"text-end\": {\n\t\t\t\t\tconst textPart = state.activeTextParts[chunk.id];\n\t\t\t\t\ttextPart.state = \"done\";\n\t\t\t\t\ttextPart.providerMetadata = (_b = chunk.providerMetadata) != null ? _b : textPart.providerMetadata;\n\t\t\t\t\tdelete state.activeTextParts[chunk.id];\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"reasoning-start\": {\n\t\t\t\t\tconst reasoningPart = {\n\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\tid: chunk.id,\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\tstate: \"streaming\"\n\t\t\t\t\t};\n\t\t\t\t\tstate.activeReasoningParts[chunk.id] = reasoningPart;\n\t\t\t\t\tstate.message.parts.push(reasoningPart);\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"reasoning-delta\": {\n\t\t\t\t\tconst reasoningPart = state.activeReasoningParts[chunk.id];\n\t\t\t\t\treasoningPart.text += chunk.delta;\n\t\t\t\t\treasoningPart.providerMetadata = (_c = chunk.providerMetadata) != null ? _c : reasoningPart.providerMetadata;\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"reasoning-end\": {\n\t\t\t\t\tconst reasoningPart = state.activeReasoningParts[chunk.id];\n\t\t\t\t\treasoningPart.providerMetadata = (_d = chunk.providerMetadata) != null ? _d : reasoningPart.providerMetadata;\n\t\t\t\t\treasoningPart.state = \"done\";\n\t\t\t\t\tdelete state.activeReasoningParts[chunk.id];\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"file\":\n\t\t\t\t\tstate.message.parts.push({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: chunk.mediaType,\n\t\t\t\t\t\turl: chunk.url\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"source-url\":\n\t\t\t\t\tstate.message.parts.push({\n\t\t\t\t\t\ttype: \"source-url\",\n\t\t\t\t\t\tsourceId: chunk.sourceId,\n\t\t\t\t\t\turl: chunk.url,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"source-document\":\n\t\t\t\t\tstate.message.parts.push({\n\t\t\t\t\t\ttype: \"source-document\",\n\t\t\t\t\t\tsourceId: chunk.sourceId,\n\t\t\t\t\t\tmediaType: chunk.mediaType,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\tfilename: chunk.filename,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-start\": {\n\t\t\t\t\tconst toolInvocations = getCurrentStepParts().filter(isToolUIPart);\n\t\t\t\t\tstate.partialToolCalls[chunk.toolCallId] = {\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tindex: toolInvocations.length,\n\t\t\t\t\t\tdynamic: chunk.dynamic\n\t\t\t\t\t};\n\t\t\t\t\tif (chunk.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinput: void 0,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinput: void 0,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-delta\": {\n\t\t\t\t\tconst partialToolCall = state.partialToolCalls[chunk.toolCallId];\n\t\t\t\t\tpartialToolCall.text += chunk.inputTextDelta;\n\t\t\t\t\tconst { value: partialArgs } = await parsePartialJson(partialToolCall.text);\n\t\t\t\t\tif (partialToolCall.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: partialToolCall.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinput: partialArgs,\n\t\t\t\t\t\trawInput: partialToolCall.text\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: partialToolCall.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinput: partialArgs,\n\t\t\t\t\t\trawInput: partialToolCall.text\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-available\":\n\t\t\t\t\tif (chunk.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-available\",\n\t\t\t\t\t\tinput: chunk.input,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-available\",\n\t\t\t\t\t\tinput: chunk.input,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tif (onToolCall && !chunk.providerExecuted) await onToolCall({ toolCall: chunk });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-error\":\n\t\t\t\t\tif (chunk.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\tinput: chunk.input,\n\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\tinput: void 0,\n\t\t\t\t\t\trawInput: chunk.input,\n\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-output-available\":\n\t\t\t\t\tif (chunk.dynamic) {\n\t\t\t\t\t\tconst toolInvocation = getDynamicToolInvocation(chunk.toolCallId);\n\t\t\t\t\t\tupdateDynamicToolPart({\n\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\ttoolName: toolInvocation.toolName,\n\t\t\t\t\t\t\tstate: \"output-available\",\n\t\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\t\toutput: chunk.output,\n\t\t\t\t\t\t\tpreliminary: chunk.preliminary\n\t\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst toolInvocation = getToolInvocation(chunk.toolCallId);\n\t\t\t\t\t\tupdateToolPart({\n\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\ttoolName: getToolName(toolInvocation),\n\t\t\t\t\t\t\tstate: \"output-available\",\n\t\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\t\toutput: chunk.output,\n\t\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\t\tpreliminary: chunk.preliminary\n\t\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\t}\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-output-error\":\n\t\t\t\t\tif (chunk.dynamic) {\n\t\t\t\t\t\tconst toolInvocation = getDynamicToolInvocation(chunk.toolCallId);\n\t\t\t\t\t\tupdateDynamicToolPart({\n\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\ttoolName: toolInvocation.toolName,\n\t\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted\n\t\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst toolInvocation = getToolInvocation(chunk.toolCallId);\n\t\t\t\t\t\tupdateToolPart({\n\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\ttoolName: getToolName(toolInvocation),\n\t\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\t\trawInput: toolInvocation.rawInput,\n\t\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted\n\t\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\t}\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"start-step\":\n\t\t\t\t\tstate.message.parts.push({ type: \"step-start\" });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish-step\":\n\t\t\t\t\tstate.activeTextParts = createIdMap();\n\t\t\t\t\tstate.activeReasoningParts = createIdMap();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"start\":\n\t\t\t\t\tif (resetStateOnMessageIdChange && chunk.messageId != null && chunk.messageId !== state.message.id) Object.assign(state, createStreamingUIMessageState({\n\t\t\t\t\t\tlastMessage: void 0,\n\t\t\t\t\t\tmessageId: chunk.messageId\n\t\t\t\t\t}), { finishReason: void 0 });\n\t\t\t\t\tif (chunk.messageId != null) state.message.id = chunk.messageId;\n\t\t\t\t\tawait updateMessageMetadata(chunk.messageMetadata);\n\t\t\t\t\tif (chunk.messageId != null || chunk.messageMetadata != null) write({ updateStatus: false });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tif (chunk.finishReason != null) state.finishReason = chunk.finishReason;\n\t\t\t\t\tawait updateMessageMetadata(chunk.messageMetadata);\n\t\t\t\t\tif (chunk.messageMetadata != null) write();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"message-metadata\":\n\t\t\t\t\tawait updateMessageMetadata(chunk.messageMetadata);\n\t\t\t\t\tif (chunk.messageMetadata != null) write();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"error\":\n\t\t\t\t\tonError?.(new Error(chunk.errorText));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: if (isDataUIMessageChunk(chunk)) {\n\t\t\t\t\tif ((dataPartSchemas == null ? void 0 : dataPartSchemas[chunk.type]) != null) await validateTypes({\n\t\t\t\t\t\tvalue: chunk.data,\n\t\t\t\t\t\tschema: dataPartSchemas[chunk.type]\n\t\t\t\t\t});\n\t\t\t\t\tconst dataChunk = chunk;\n\t\t\t\t\tif (dataChunk.transient) {\n\t\t\t\t\t\tonData?.(dataChunk);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst existingUIPart = dataChunk.id != null ? state.message.parts.find((chunkArg) => dataChunk.type === chunkArg.type && dataChunk.id === chunkArg.id) : void 0;\n\t\t\t\t\tif (existingUIPart != null) existingUIPart.data = dataChunk.data;\n\t\t\t\t\telse state.message.parts.push(dataChunk);\n\t\t\t\t\tonData?.(dataChunk);\n\t\t\t\t\twrite();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontroller.enqueue(chunk);\n\t\t});\n\t} }));\n}\nfunction handleUIMessageStreamFinish({ messageId, originalMessages = [], onFinish, onError, stream, getOutcome }) {\n\tlet lastMessage = originalMessages == null ? void 0 : originalMessages[originalMessages.length - 1];\n\tif ((lastMessage == null ? void 0 : lastMessage.role) !== \"assistant\") lastMessage = void 0;\n\telse messageId = lastMessage.id;\n\tlet isAborted = false;\n\tlet hasProcessingFailure = false;\n\tlet processingError;\n\tconst recordProcessingFailure = (error) => {\n\t\thasProcessingFailure = true;\n\t\tprocessingError = error;\n\t};\n\tconst idInjectedStream = stream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\ttry {\n\t\t\tlet outputChunk = chunk;\n\t\t\tif (chunk.type === \"start\") {\n\t\t\t\tconst startChunk = chunk;\n\t\t\t\tif (startChunk.messageId == null && messageId != null) outputChunk = {\n\t\t\t\t\t...startChunk,\n\t\t\t\t\tmessageId\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (chunk.type === \"abort\") isAborted = true;\n\t\t\tcontroller.enqueue(outputChunk);\n\t\t} catch (error) {\n\t\t\trecordProcessingFailure(error);\n\t\t\tthrow error;\n\t\t}\n\t} }));\n\tif (onFinish == null) return idInjectedStream;\n\tconst state = createStreamingUIMessageState({\n\t\tlastMessage: lastMessage ? structuredClone(lastMessage) : void 0,\n\t\tmessageId: messageId != null ? messageId : \"\"\n\t});\n\tconst runUpdateMessageJob = async (job) => {\n\t\ttry {\n\t\t\tawait job({\n\t\t\t\tstate,\n\t\t\t\twrite: () => {}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\trecordProcessingFailure(error);\n\t\t\tthrow error;\n\t\t}\n\t};\n\tlet finishCalled = false;\n\tconst callOnFinish = async () => {\n\t\tvar _a16;\n\t\tif (finishCalled || !onFinish) return;\n\t\tfinishCalled = true;\n\t\tconst isContinuation = state.message.id === (lastMessage == null ? void 0 : lastMessage.id);\n\t\tconst declaredOutcome = (_a16 = getOutcome == null ? void 0 : getOutcome()) != null ? _a16 : { status: \"unknown\" };\n\t\tconst outcome = hasProcessingFailure ? {\n\t\t\tstatus: \"failed\",\n\t\t\terror: processingError\n\t\t} : declaredOutcome.status === \"unknown\" && isAborted ? { status: \"aborted\" } : declaredOutcome;\n\t\tawait onFinish({\n\t\t\tisAborted: isAborted || outcome.status === \"aborted\",\n\t\t\tisContinuation,\n\t\t\toutcome,\n\t\t\tresponseMessage: state.message,\n\t\t\tmessages: [...isContinuation ? originalMessages.slice(0, -1) : originalMessages, state.message],\n\t\t\tfinishReason: state.finishReason\n\t\t});\n\t};\n\treturn processUIMessageStream({\n\t\tstream: idInjectedStream,\n\t\trunUpdateMessageJob,\n\t\tonError\n\t}).pipeThrough(new TransformStream({\n\t\ttransform(chunk, controller) {\n\t\t\tcontroller.enqueue(chunk);\n\t\t},\n\t\tasync cancel() {\n\t\t\tawait callOnFinish();\n\t\t},\n\t\tasync flush() {\n\t\t\tawait callOnFinish();\n\t\t}\n\t}));\n}\nfunction pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, keepAliveMs, consumeSseStream }) {\n\tlet sseStream = createSseStreamWithKeepAlive({\n\t\tstream: stream.pipeThrough(new JsonToSseTransformStream()),\n\t\tkeepAliveMs\n\t});\n\tif (consumeSseStream) {\n\t\tconst [stream1, stream2] = sseStream.tee();\n\t\tsseStream = stream1;\n\t\tconsumeSseStream({ stream: stream2 });\n\t}\n\treturn writeToServerResponse({\n\t\tresponse,\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: Object.fromEntries(prepareHeaders(headers, UI_MESSAGE_STREAM_HEADERS).entries()),\n\t\tstream: sseStream.pipeThrough(new TextEncoderStream())\n\t});\n}\nfunction createAsyncIterableStream(source) {\n\tconst stream = source.pipeThrough(new TransformStream());\n\tstream[Symbol.asyncIterator] = function() {\n\t\tconst reader = this.getReader();\n\t\tlet finished = false;\n\t\tasync function cleanup(cancelStream) {\n\t\t\tvar _a16;\n\t\t\tfinished = true;\n\t\t\ttry {\n\t\t\t\tif (cancelStream) await ((_a16 = reader.cancel) == null ? void 0 : _a16.call(reader));\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\treader.releaseLock();\n\t\t\t\t} catch (e) {}\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t/**\n\t\t\t* Reads the next chunk from the stream.\n\t\t\t* @returns A promise resolving to the next IteratorResult.\n\t\t\t*/\n\t\t\tasync next() {\n\t\t\t\tif (finished) return {\n\t\t\t\t\tdone: true,\n\t\t\t\t\tvalue: void 0\n\t\t\t\t};\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tawait cleanup(true);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdone: true,\n\t\t\t\t\t\tvalue: void 0\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tdone: false,\n\t\t\t\t\tvalue\n\t\t\t\t};\n\t\t\t},\n\t\t\t/**\n\t\t\t* Called on early exit (e.g., break from for-await).\n\t\t\t* Ensures the stream is cancelled and resources are released.\n\t\t\t* @returns A promise resolving to a completed IteratorResult.\n\t\t\t*/\n\t\t\tasync return() {\n\t\t\t\tawait cleanup(true);\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t\tvalue: void 0\n\t\t\t\t};\n\t\t\t},\n\t\t\t/**\n\t\t\t* Called on early exit with error.\n\t\t\t* Ensures the stream is cancelled and resources are released, then rethrows the error.\n\t\t\t* @param err The error to throw.\n\t\t\t* @returns A promise that rejects with the provided error.\n\t\t\t*/\n\t\t\tasync throw(err) {\n\t\t\t\tawait cleanup(true);\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t};\n\t};\n\treturn stream;\n}\nasync function consumeStream({ stream, onError, abortSignal }) {\n\tconst reader = stream.getReader();\n\tlet cancelPromise;\n\tconst cancelOnAbort = () => {\n\t\tcancelPromise ??= reader.cancel().catch(() => {});\n\t};\n\tif (abortSignal == null ? void 0 : abortSignal.aborted) cancelOnAbort();\n\telse abortSignal?.addEventListener(\"abort\", cancelOnAbort, { once: true });\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done } = await reader.read();\n\t\t\tif (done) break;\n\t\t}\n\t} catch (error) {\n\t\tonError?.(error);\n\t} finally {\n\t\tawait cancelPromise;\n\t\tabortSignal?.removeEventListener(\"abort\", cancelOnAbort);\n\t\treader.releaseLock();\n\t}\n}\nfunction createResolvablePromise() {\n\tlet resolve2;\n\tlet reject;\n\treturn {\n\t\tpromise: new Promise((res, rej) => {\n\t\t\tresolve2 = res;\n\t\t\treject = rej;\n\t\t}),\n\t\tresolve: resolve2,\n\t\treject\n\t};\n}\nfunction createStitchableStream() {\n\tlet innerStreams = [];\n\tlet controller = null;\n\tlet isClosed = false;\n\tlet waitForNewStream = createResolvablePromise();\n\tconst terminate = () => {\n\t\tisClosed = true;\n\t\twaitForNewStream.resolve();\n\t\tinnerStreams.forEach(({ reader }) => reader.cancel());\n\t\tinnerStreams = [];\n\t\tcontroller?.close();\n\t};\n\tconst processPull = async () => {\n\t\tvar _a16, _b;\n\t\tif (isClosed && innerStreams.length === 0) {\n\t\t\tcontroller?.close();\n\t\t\treturn;\n\t\t}\n\t\tif (innerStreams.length === 0) {\n\t\t\twaitForNewStream = createResolvablePromise();\n\t\t\tawait waitForNewStream.promise;\n\t\t\treturn processPull();\n\t\t}\n\t\ttry {\n\t\t\tconst { value, done } = await innerStreams[0].reader.read();\n\t\t\tif (done) {\n\t\t\t\tinnerStreams.shift();\n\t\t\t\tif (innerStreams.length > 0) await processPull();\n\t\t\t\telse if (isClosed) controller?.close();\n\t\t\t} else controller?.enqueue(value);\n\t\t} catch (error) {\n\t\t\t(_b = (_a16 = innerStreams[0]).onError) == null || _b.call(_a16, error);\n\t\t\tcontroller?.error(error);\n\t\t\tinnerStreams.shift();\n\t\t\tterminate();\n\t\t}\n\t};\n\treturn {\n\t\tstream: new ReadableStream({\n\t\t\tstart(controllerParam) {\n\t\t\t\tcontroller = controllerParam;\n\t\t\t},\n\t\t\tpull: processPull,\n\t\t\tasync cancel() {\n\t\t\t\tfor (const { reader } of innerStreams) await reader.cancel();\n\t\t\t\tinnerStreams = [];\n\t\t\t\tisClosed = true;\n\t\t\t}\n\t\t}),\n\t\taddStream: (innerStream, callbacks) => {\n\t\t\tif (isClosed) throw new Error(\"Cannot add inner stream: outer stream is closed\");\n\t\t\tinnerStreams.push({\n\t\t\t\treader: innerStream.getReader(),\n\t\t\t\t...callbacks\n\t\t\t});\n\t\t\twaitForNewStream.resolve();\n\t\t},\n\t\t/**\n\t\t* Gracefully close the outer stream. This will let the inner streams\n\t\t* finish processing and then close the outer stream.\n\t\t*/\n\t\tclose: () => {\n\t\t\tisClosed = true;\n\t\t\twaitForNewStream.resolve();\n\t\t\tif (innerStreams.length === 0) controller?.close();\n\t\t},\n\t\t/**\n\t\t* Immediately close the outer stream. This will cancel all inner streams\n\t\t* and close the outer stream.\n\t\t*/\n\t\tterminate\n\t};\n}\nasync function notify(options) {\n\tfor (const callback of asArray(options.callbacks)) try {\n\t\tawait callback(options.event);\n\t} catch (_ignored) {}\n}\nfunction now() {\n\tvar _a16, _b;\n\treturn (_b = (_a16 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a16.now()) != null ? _b : Date.now();\n}\nfunction runToolsTransformation({ tools, generatorStream, tracer, telemetry, system, messages, abortSignal, repairToolCall, experimental_context }) {\n\tlet toolResultsStreamController = null;\n\tlet toolResultsStreamClosed = false;\n\tconst toolResultsStream = new ReadableStream({\n\t\tstart(controller) {\n\t\t\ttoolResultsStreamController = controller;\n\t\t},\n\t\tcancel() {\n\t\t\ttoolResultsStreamClosed = true;\n\t\t}\n\t});\n\tfunction enqueueToolResult(chunk) {\n\t\tif (toolResultsStreamClosed) return;\n\t\ttry {\n\t\t\ttoolResultsStreamController.enqueue(chunk);\n\t\t} catch (e) {\n\t\t\ttoolResultsStreamClosed = true;\n\t\t}\n\t}\n\tfunction closeToolResultsStream() {\n\t\tif (toolResultsStreamClosed) return;\n\t\ttoolResultsStreamClosed = true;\n\t\ttry {\n\t\t\ttoolResultsStreamController.close();\n\t\t} catch (e) {}\n\t}\n\tconst outstandingToolResults = /* @__PURE__ */ new Set();\n\tconst pendingToolCalls = [];\n\tconst toolInputs = /* @__PURE__ */ new Map();\n\tlet canClose = false;\n\tlet finishChunk = void 0;\n\tfunction attemptClose() {\n\t\tif (canClose && outstandingToolResults.size === 0) {\n\t\t\tif (finishChunk != null) enqueueToolResult(finishChunk);\n\t\t\tcloseToolResultsStream();\n\t\t}\n\t}\n\tfunction executePendingToolCall(toolCall) {\n\t\tconst tool2 = tools[toolCall.toolName];\n\t\tconst toolExecutionId = generateId();\n\t\toutstandingToolResults.add(toolExecutionId);\n\t\trecordSpan({\n\t\t\tname: \"ai.toolCall\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.toolCall\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...getTelemetryMetadataAttributes(telemetry),\n\t\t\t\t\t\"ai.toolCall.name\": toolCall.toolName,\n\t\t\t\t\t\"ai.toolCall.id\": toolCall.toolCallId,\n\t\t\t\t\t\"ai.toolCall.args\": { output: () => JSON.stringify(toolCall.input) }\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tfn: async (span) => {\n\t\t\t\tlet output;\n\t\t\t\ttry {\n\t\t\t\t\tconst stream = executeTool({\n\t\t\t\t\t\texecute: tool2.execute.bind(tool2),\n\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tfor await (const part of stream) {\n\t\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t\t...toolCall,\n\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\toutput: part.output,\n\t\t\t\t\t\t\t...part.type === \"preliminary\" && { preliminary: true }\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (part.type === \"final\") output = part.output;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t...toolCall,\n\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\terror\n\t\t\t\t\t});\n\t\t\t\t\toutstandingToolResults.delete(toolExecutionId);\n\t\t\t\t\tattemptClose();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\toutstandingToolResults.delete(toolExecutionId);\n\t\t\t\tattemptClose();\n\t\t\t\ttry {\n\t\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: { \"ai.toolCall.result\": { output: () => JSON.stringify(output) } }\n\t\t\t\t\t}));\n\t\t\t\t} catch (ignored) {}\n\t\t\t}\n\t\t});\n\t}\n\tconst activeToolCallToolNames = /* @__PURE__ */ new Map();\n\tconst forwardStream = new TransformStream({\n\t\tasync transform(chunk, controller) {\n\t\t\tvar _a16, _b, _c, _d;\n\t\t\tconst chunkType = chunk.type;\n\t\t\tswitch (chunkType) {\n\t\t\t\tcase \"stream-start\":\n\t\t\t\tcase \"text-start\":\n\t\t\t\tcase \"text-delta\":\n\t\t\t\tcase \"text-end\":\n\t\t\t\tcase \"reasoning-start\":\n\t\t\t\tcase \"reasoning-delta\":\n\t\t\t\tcase \"reasoning-end\":\n\t\t\t\tcase \"source\":\n\t\t\t\tcase \"response-metadata\":\n\t\t\t\tcase \"error\":\n\t\t\t\tcase \"raw\":\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-start\":\n\t\t\t\t\tactiveToolCallToolNames.set(chunk.id, chunk.toolName);\n\t\t\t\t\tawait ((_b = (_a16 = tools == null ? void 0 : tools[chunk.toolName]) == null ? void 0 : _a16.onInputStart) == null ? void 0 : _b.call(_a16, {\n\t\t\t\t\t\ttoolCallId: chunk.id,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t}));\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-delta\": {\n\t\t\t\t\tconst toolName = activeToolCallToolNames.get(chunk.id);\n\t\t\t\t\tif (toolName != null) await ((_d = (_c = tools == null ? void 0 : tools[toolName]) == null ? void 0 : _c.onInputDelta) == null ? void 0 : _d.call(_c, {\n\t\t\t\t\t\tinputTextDelta: chunk.delta,\n\t\t\t\t\t\ttoolCallId: chunk.id,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t}));\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-end\":\n\t\t\t\t\tactiveToolCallToolNames.delete(chunk.id);\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"file\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tfile: new DefaultGeneratedFileWithType({\n\t\t\t\t\t\t\tdata: chunk.data,\n\t\t\t\t\t\t\tmediaType: chunk.mediaType\n\t\t\t\t\t\t})\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tfinishChunk = {\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: chunk.finishReason,\n\t\t\t\t\t\tusage: chunk.usage,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\tif (isToolExecutionAllowedFinishReason(chunk.finishReason)) for (const toolCall of pendingToolCalls.splice(0)) executePendingToolCall(toolCall);\n\t\t\t\t\telse pendingToolCalls.length = 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call\":\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst toolCall = await parseToolCall({\n\t\t\t\t\t\t\ttoolCall: chunk,\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontroller.enqueue(toolCall);\n\t\t\t\t\t\tif (toolCall.invalid) {\n\t\t\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\t\terror: getErrorMessage$1(toolCall.error),\n\t\t\t\t\t\t\t\tdynamic: true\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst tool2 = tools[toolCall.toolName];\n\t\t\t\t\t\ttoolInputs.set(toolCall.toolCallId, toolCall.input);\n\t\t\t\t\t\tif (tool2.onInputAvailable != null) await tool2.onInputAvailable({\n\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (tool2.execute != null && toolCall.providerExecuted !== true) pendingToolCalls.push({ ...toolCall });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-result\": {\n\t\t\t\t\tconst toolName = chunk.toolName;\n\t\t\t\t\tif (chunk.isError) enqueueToolResult({\n\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\tinput: toolInputs.get(chunk.toolCallId),\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\terror: chunk.result\n\t\t\t\t\t});\n\t\t\t\t\telse controller.enqueue({\n\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\tinput: toolInputs.get(chunk.toolCallId),\n\t\t\t\t\t\toutput: chunk.result,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: throw new Error(`Unhandled chunk type: ${chunkType}`);\n\t\t\t}\n\t\t},\n\t\tflush() {\n\t\t\tcanClose = true;\n\t\t\tattemptClose();\n\t\t}\n\t});\n\treturn new ReadableStream({ async start(controller) {\n\t\treturn Promise.all([generatorStream.pipeThrough(forwardStream).pipeTo(new WritableStream({\n\t\t\twrite(chunk) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tclose() {}\n\t\t})), toolResultsStream.pipeTo(new WritableStream({\n\t\t\twrite(chunk) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tclose() {\n\t\t\t\tcontroller.close();\n\t\t\t}\n\t\t}))]);\n\t} });\n}\nvar originalGenerateId2 = createIdGenerator({\n\tprefix: \"aitxt\",\n\tsize: 24\n});\nfunction streamText$1({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, headers, stopWhen = stepCountIs(1), experimental_output: output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools = experimental_activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download2, includeRawChunks = false, onChunk, onError = ({ error }) => {\n\tconsole.error(error);\n}, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now: now2 = now, generateId: generateId3 = originalGenerateId2, currentDate = () => /* @__PURE__ */ new Date() } = {}, ...settings }) {\n\treturn new DefaultStreamTextResult({\n\t\tmodel: resolveLanguageModel(model),\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings,\n\t\tmaxRetries,\n\t\tabortSignal,\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tallowSystemInMessages,\n\t\ttools,\n\t\ttoolChoice,\n\t\ttransforms: asArray(transform),\n\t\tactiveTools,\n\t\trepairToolCall,\n\t\tstopConditions: asArray(stopWhen),\n\t\toutput,\n\t\tproviderOptions,\n\t\tprepareStep,\n\t\tincludeRawChunks,\n\t\tonChunk,\n\t\tonError,\n\t\tonFinish,\n\t\tonAbort,\n\t\tonStepFinish,\n\t\tnow: now2,\n\t\tcurrentDate,\n\t\tgenerateId: generateId3,\n\t\texperimental_context,\n\t\tdownload: download2\n\t});\n}\nfunction createOutputTransformStream(output) {\n\tif (!output) return new TransformStream({ transform(chunk, controller) {\n\t\tcontroller.enqueue({\n\t\t\tpart: chunk,\n\t\t\tpartialOutput: void 0\n\t\t});\n\t} });\n\tlet firstTextChunkId = void 0;\n\tlet text2 = \"\";\n\tlet textChunk = \"\";\n\tlet lastPublishedJson = \"\";\n\tfunction publishTextChunk({ controller, partialOutput = void 0 }) {\n\t\tcontroller.enqueue({\n\t\t\tpart: {\n\t\t\t\ttype: \"text-delta\",\n\t\t\t\tid: firstTextChunkId,\n\t\t\t\ttext: textChunk\n\t\t\t},\n\t\t\tpartialOutput\n\t\t});\n\t\ttextChunk = \"\";\n\t}\n\treturn new TransformStream({ async transform(chunk, controller) {\n\t\tif (chunk.type === \"finish-step\" && textChunk.length > 0) publishTextChunk({ controller });\n\t\tif (chunk.type !== \"text-delta\" && chunk.type !== \"text-start\" && chunk.type !== \"text-end\") {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (firstTextChunkId == null) firstTextChunkId = chunk.id;\n\t\telse if (chunk.id !== firstTextChunkId) {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (chunk.type === \"text-start\") {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (chunk.type === \"text-end\") {\n\t\t\tif (textChunk.length > 0) publishTextChunk({ controller });\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\ttext2 += chunk.text;\n\t\ttextChunk += chunk.text;\n\t\tif (chunk.text.length === 0 && chunk.providerMetadata != null) {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst result = await output.parsePartial({ text: text2 });\n\t\tif (result != null) {\n\t\t\tconst currentJson = JSON.stringify(result.partial);\n\t\t\tif (currentJson !== lastPublishedJson) {\n\t\t\t\tpublishTextChunk({\n\t\t\t\t\tcontroller,\n\t\t\t\t\tpartialOutput: result.partial\n\t\t\t\t});\n\t\t\t\tlastPublishedJson = currentJson;\n\t\t\t}\n\t\t}\n\t} });\n}\nvar DefaultStreamTextResult = class {\n\tconstructor({ model, telemetry, headers, settings, maxRetries: maxRetriesArg, abortSignal, system, prompt, messages, allowSystemInMessages, tools, toolChoice, transforms, activeTools, repairToolCall, stopConditions, output, providerOptions, prepareStep, includeRawChunks, now: now2, currentDate, generateId: generateId3, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, download: download2 }) {\n\t\tthis._totalUsage = new DelayedPromise();\n\t\tthis._finishReason = new DelayedPromise();\n\t\tthis._steps = new DelayedPromise();\n\t\tthis.output = output;\n\t\tthis.includeRawChunks = includeRawChunks;\n\t\tthis.tools = tools;\n\t\tlet stepFinish;\n\t\tlet recordedContent = [];\n\t\tconst recordedResponseMessages = [];\n\t\tlet recordedFinishReason = void 0;\n\t\tlet recordedTotalUsage = void 0;\n\t\tlet recordedRequest = {};\n\t\tlet recordedWarnings = [];\n\t\tconst recordedSteps = [];\n\t\tlet currentStepToolSet = tools;\n\t\tlet rootSpan;\n\t\tlet activeTextContent = createIdMap();\n\t\tlet activeReasoningContent = createIdMap();\n\t\tconst eventProcessor = new TransformStream({\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tvar _a16, _b, _c, _d;\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\tconst { part } = chunk;\n\t\t\t\tif (part.type === \"text-delta\" || part.type === \"reasoning-delta\" || part.type === \"source\" || part.type === \"tool-call\" || part.type === \"tool-result\" || part.type === \"tool-input-start\" || part.type === \"tool-input-delta\" || part.type === \"raw\") await notify({\n\t\t\t\t\tevent: { chunk: part },\n\t\t\t\t\tcallbacks: onChunk\n\t\t\t\t});\n\t\t\t\tif (part.type === \"error\") await notify({\n\t\t\t\t\tevent: { error: wrapGatewayError(part.error) },\n\t\t\t\t\tcallbacks: onError\n\t\t\t\t});\n\t\t\t\tif (part.type === \"text-start\") {\n\t\t\t\t\tactiveTextContent[part.id] = {\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\trecordedContent.push(activeTextContent[part.id]);\n\t\t\t\t}\n\t\t\t\tif (part.type === \"text-delta\") {\n\t\t\t\t\tconst activeText = activeTextContent[part.id];\n\t\t\t\t\tif (activeText == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `text part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveText.text += part.text;\n\t\t\t\t\tactiveText.providerMetadata = (_a16 = part.providerMetadata) != null ? _a16 : activeText.providerMetadata;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"text-end\") {\n\t\t\t\t\tconst activeText = activeTextContent[part.id];\n\t\t\t\t\tif (activeText == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `text part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveText.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeText.providerMetadata;\n\t\t\t\t\tdelete activeTextContent[part.id];\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-start\") {\n\t\t\t\t\tactiveReasoningContent[part.id] = {\n\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\trecordedContent.push(activeReasoningContent[part.id]);\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-delta\") {\n\t\t\t\t\tconst activeReasoning = activeReasoningContent[part.id];\n\t\t\t\t\tif (activeReasoning == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `reasoning part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveReasoning.text += part.text;\n\t\t\t\t\tactiveReasoning.providerMetadata = (_c = part.providerMetadata) != null ? _c : activeReasoning.providerMetadata;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-end\") {\n\t\t\t\t\tconst activeReasoning = activeReasoningContent[part.id];\n\t\t\t\t\tif (activeReasoning == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `reasoning part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveReasoning.providerMetadata = (_d = part.providerMetadata) != null ? _d : activeReasoning.providerMetadata;\n\t\t\t\t\tdelete activeReasoningContent[part.id];\n\t\t\t\t}\n\t\t\t\tif (part.type === \"file\") recordedContent.push({\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tfile: part.file\n\t\t\t\t});\n\t\t\t\tif (part.type === \"source\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-call\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-result\" && !part.preliminary) recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-error\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"start-step\") {\n\t\t\t\t\trecordedContent = [];\n\t\t\t\t\tactiveReasoningContent = createIdMap();\n\t\t\t\t\tactiveTextContent = createIdMap();\n\t\t\t\t\trecordedRequest = part.request;\n\t\t\t\t\trecordedWarnings = part.warnings;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"finish-step\") {\n\t\t\t\t\tconst stepMessages = toResponseMessages({\n\t\t\t\t\t\tcontent: recordedContent,\n\t\t\t\t\t\ttools: currentStepToolSet\n\t\t\t\t\t});\n\t\t\t\t\tconst currentStepResult = new DefaultStepResult({\n\t\t\t\t\t\tcontent: recordedContent,\n\t\t\t\t\t\tfinishReason: part.finishReason,\n\t\t\t\t\t\tusage: part.usage,\n\t\t\t\t\t\twarnings: recordedWarnings,\n\t\t\t\t\t\trequest: recordedRequest,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t...part.response,\n\t\t\t\t\t\t\tmessages: [...recordedResponseMessages, ...stepMessages]\n\t\t\t\t\t\t},\n\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\tawait (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));\n\t\t\t\t\tlogWarnings(recordedWarnings);\n\t\t\t\t\trecordedSteps.push(currentStepResult);\n\t\t\t\t\trecordedContent = [];\n\t\t\t\t\tactiveReasoningContent = createIdMap();\n\t\t\t\t\tactiveTextContent = createIdMap();\n\t\t\t\t\trecordedResponseMessages.push(...stepMessages);\n\t\t\t\t\tstepFinish.resolve();\n\t\t\t\t}\n\t\t\t\tif (part.type === \"finish\") {\n\t\t\t\t\trecordedTotalUsage = part.totalUsage;\n\t\t\t\t\trecordedFinishReason = part.finishReason;\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\ttry {\n\t\t\t\t\tif (recordedSteps.length === 0) {\n\t\t\t\t\t\tconst error = new NoOutputGeneratedError({ message: \"No output generated. Check the stream for errors.\" });\n\t\t\t\t\t\tself._finishReason.reject(error);\n\t\t\t\t\t\tself._totalUsage.reject(error);\n\t\t\t\t\t\tself._steps.reject(error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst finishReason = recordedFinishReason != null ? recordedFinishReason : \"unknown\";\n\t\t\t\t\tconst totalUsage = recordedTotalUsage != null ? recordedTotalUsage : {\n\t\t\t\t\t\tinputTokens: void 0,\n\t\t\t\t\t\toutputTokens: void 0,\n\t\t\t\t\t\ttotalTokens: void 0\n\t\t\t\t\t};\n\t\t\t\t\tself._finishReason.resolve(finishReason);\n\t\t\t\t\tself._totalUsage.resolve(totalUsage);\n\t\t\t\t\tself._steps.resolve(recordedSteps);\n\t\t\t\t\tconst finalStep = recordedSteps[recordedSteps.length - 1];\n\t\t\t\t\tawait (onFinish == null ? void 0 : onFinish({\n\t\t\t\t\t\tfinishReason,\n\t\t\t\t\t\ttotalUsage,\n\t\t\t\t\t\tusage: finalStep.usage,\n\t\t\t\t\t\tcontent: finalStep.content,\n\t\t\t\t\t\ttext: finalStep.text,\n\t\t\t\t\t\treasoningText: finalStep.reasoningText,\n\t\t\t\t\t\treasoning: finalStep.reasoning,\n\t\t\t\t\t\tfiles: finalStep.files,\n\t\t\t\t\t\tsources: finalStep.sources,\n\t\t\t\t\t\ttoolCalls: finalStep.toolCalls,\n\t\t\t\t\t\tstaticToolCalls: finalStep.staticToolCalls,\n\t\t\t\t\t\tdynamicToolCalls: finalStep.dynamicToolCalls,\n\t\t\t\t\t\ttoolResults: finalStep.toolResults,\n\t\t\t\t\t\tstaticToolResults: finalStep.staticToolResults,\n\t\t\t\t\t\tdynamicToolResults: finalStep.dynamicToolResults,\n\t\t\t\t\t\trequest: finalStep.request,\n\t\t\t\t\t\tresponse: finalStep.response,\n\t\t\t\t\t\twarnings: finalStep.warnings,\n\t\t\t\t\t\tproviderMetadata: finalStep.providerMetadata,\n\t\t\t\t\t\tsteps: recordedSteps\n\t\t\t\t\t}));\n\t\t\t\t\trootSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\t\"ai.response.text\": { output: () => finalStep.text },\n\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\t\tvar _a16;\n\t\t\t\t\t\t\t\treturn ((_a16 = finalStep.toolCalls) == null ? void 0 : _a16.length) ? JSON.stringify(finalStep.toolCalls) : void 0;\n\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(finalStep.providerMetadata),\n\t\t\t\t\t\t\t\"ai.usage.inputTokens\": totalUsage.inputTokens,\n\t\t\t\t\t\t\t\"ai.usage.outputTokens\": totalUsage.outputTokens,\n\t\t\t\t\t\t\t\"ai.usage.totalTokens\": totalUsage.totalTokens,\n\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": totalUsage.reasoningTokens,\n\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": totalUsage.cachedInputTokens\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t} finally {\n\t\t\t\t\trootSpan.end();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tconst stitchableStream = createStitchableStream();\n\t\tthis.addStream = stitchableStream.addStream;\n\t\tthis.closeStream = stitchableStream.close;\n\t\tconst reader = stitchableStream.stream.getReader();\n\t\tlet stream = new ReadableStream({\n\t\t\tasync start(controller) {\n\t\t\t\tcontroller.enqueue({ type: \"start\" });\n\t\t\t},\n\t\t\tasync pull(controller) {\n\t\t\t\tfunction abort() {\n\t\t\t\t\tonAbort?.({ steps: recordedSteps });\n\t\t\t\t\tcontroller.enqueue({ type: \"abort\" });\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\tif (done) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (abortSignal == null ? void 0 : abortSignal.aborted) {\n\t\t\t\t\t\tabort();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (isAbortError(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) abort();\n\t\t\t\t\telse controller.error(error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancel(reason) {\n\t\t\t\treturn stitchableStream.stream.cancel(reason);\n\t\t\t}\n\t\t});\n\t\tfor (const transform of transforms) stream = stream.pipeThrough(transform({\n\t\t\ttools,\n\t\t\tstopStream() {\n\t\t\t\tstitchableStream.terminate();\n\t\t\t}\n\t\t}));\n\t\tthis.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);\n\t\tconst { maxRetries, retry } = prepareRetries({\n\t\t\tmaxRetries: maxRetriesArg,\n\t\t\tabortSignal\n\t\t});\n\t\tconst tracer = getTracer(telemetry);\n\t\tconst callSettings = prepareCallSettings(settings);\n\t\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\t\tmodel,\n\t\t\ttelemetry,\n\t\t\theaders,\n\t\t\tsettings: {\n\t\t\t\t...callSettings,\n\t\t\t\tmaxRetries\n\t\t\t}\n\t\t});\n\t\tconst self = this;\n\t\trecordSpan({\n\t\t\tname: \"ai.streamText\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.streamText\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) }\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tendWhenDone: false,\n\t\t\tfn: async (rootSpanArg) => {\n\t\t\t\trootSpan = rootSpanArg;\n\t\t\t\tasync function streamStep({ currentStep, responseMessages, usage }) {\n\t\t\t\t\tvar _a16, _b, _c, _d, _e;\n\t\t\t\t\tconst includeRawChunks2 = self.includeRawChunks;\n\t\t\t\t\tstepFinish = new DelayedPromise();\n\t\t\t\t\tconst initialPrompt = await standardizePrompt({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tallowSystemInMessages\n\t\t\t\t\t});\n\t\t\t\t\tconst stepInputMessages = [...initialPrompt.messages, ...responseMessages];\n\t\t\t\t\tconst prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\tsteps: recordedSteps,\n\t\t\t\t\t\tstepNumber: recordedSteps.length,\n\t\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t\t}));\n\t\t\t\t\tconst stepModel = resolveLanguageModel((_a16 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a16 : model);\n\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\tsystem: (_b = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b : initialPrompt.system,\n\t\t\t\t\t\t\tmessages: (_c = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c : stepInputMessages\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsupportedUrls: await stepModel.supportedUrls,\n\t\t\t\t\t\tdownload: download2\n\t\t\t\t\t});\n\t\t\t\t\tconst stepActiveTools = (_d = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _d : activeTools;\n\t\t\t\t\tconst stepToolSet = filterActiveTools({\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t});\n\t\t\t\t\tcurrentStepToolSet = stepToolSet;\n\t\t\t\t\tconst { toolChoice: stepToolChoice, tools: stepTools } = prepareToolsAndToolChoice({\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\ttoolChoice: (_e = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _e : toolChoice,\n\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t});\n\t\t\t\t\tconst { result: { stream: stream2, response, request }, doStreamSpan, startTimestampMs } = await retry(() => recordSpan({\n\t\t\t\t\t\tname: \"ai.streamText.doStream\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.streamText.doStream\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.model.provider\": stepModel.provider,\n\t\t\t\t\t\t\t\t\"ai.model.id\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\t\"ai.prompt.tools\": { input: () => stepTools == null ? void 0 : stepTools.map((tool2) => JSON.stringify(tool2)) },\n\t\t\t\t\t\t\t\t\"ai.prompt.toolChoice\": { input: () => stepToolChoice != null ? JSON.stringify(stepToolChoice) : void 0 },\n\t\t\t\t\t\t\t\t\"gen_ai.system\": stepModel.provider,\n\t\t\t\t\t\t\t\t\"gen_ai.request.model\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": callSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": callSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": callSettings.presencePenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.stop_sequences\": callSettings.stopSequences,\n\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": callSettings.temperature,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": callSettings.topK,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": callSettings.topP\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tendWhenDone: false,\n\t\t\t\t\t\tendOnError: true,\n\t\t\t\t\t\tfn: async (doStreamSpan2) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tstartTimestampMs: now2(),\n\t\t\t\t\t\t\t\tdoStreamSpan: doStreamSpan2,\n\t\t\t\t\t\t\t\tresult: await stepModel.doStream({\n\t\t\t\t\t\t\t\t\t...callSettings,\n\t\t\t\t\t\t\t\t\ttools: stepTools,\n\t\t\t\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\t\t\t\tresponseFormat: output == null ? void 0 : output.responseFormat,\n\t\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\t\tincludeRawChunks: includeRawChunks2\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\tconst streamWithToolResults = runToolsTransformation({\n\t\t\t\t\t\ttools: stepToolSet,\n\t\t\t\t\t\tgeneratorStream: stream2,\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t});\n\t\t\t\t\tconst stepRequest = request != null ? request : {};\n\t\t\t\t\tconst stepToolCalls = [];\n\t\t\t\t\tconst stepToolOutputs = [];\n\t\t\t\t\tlet warnings;\n\t\t\t\t\tlet stepFinishReason = \"unknown\";\n\t\t\t\t\tlet stepUsage = {\n\t\t\t\t\t\tinputTokens: void 0,\n\t\t\t\t\t\toutputTokens: void 0,\n\t\t\t\t\t\ttotalTokens: void 0\n\t\t\t\t\t};\n\t\t\t\t\tlet stepProviderMetadata;\n\t\t\t\t\tlet stepFirstChunk = true;\n\t\t\t\t\tlet stepResponse = {\n\t\t\t\t\t\tid: generateId3(),\n\t\t\t\t\t\ttimestamp: currentDate(),\n\t\t\t\t\t\tmodelId: model.modelId\n\t\t\t\t\t};\n\t\t\t\t\tlet activeText = \"\";\n\t\t\t\t\tself.addStream(streamWithToolResults.pipeThrough(new TransformStream({\n\t\t\t\t\t\tasync transform(chunk, controller) {\n\t\t\t\t\t\t\tvar _a17, _b2, _c2, _d2;\n\t\t\t\t\t\t\tif (chunk.type === \"stream-start\") {\n\t\t\t\t\t\t\t\twarnings = chunk.warnings;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (stepFirstChunk) {\n\t\t\t\t\t\t\t\tconst msToFirstChunk = now2() - startTimestampMs;\n\t\t\t\t\t\t\t\tstepFirstChunk = false;\n\t\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.firstChunk\", { \"ai.response.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes({ \"ai.response.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"start-step\",\n\t\t\t\t\t\t\t\t\trequest: stepRequest,\n\t\t\t\t\t\t\t\t\twarnings: warnings != null ? warnings : []\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst chunkType = chunk.type;\n\t\t\t\t\t\t\tswitch (chunkType) {\n\t\t\t\t\t\t\t\tcase \"text-start\":\n\t\t\t\t\t\t\t\tcase \"text-end\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\t\t\t\tif (chunk.delta.length > 0 || chunk.providerMetadata != null) {\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\t\tid: chunk.id,\n\t\t\t\t\t\t\t\t\t\t\ttext: chunk.delta,\n\t\t\t\t\t\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tactiveText += chunk.delta;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"reasoning-start\":\n\t\t\t\t\t\t\t\tcase \"reasoning-end\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"reasoning-delta\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\t\t\t\tid: chunk.id,\n\t\t\t\t\t\t\t\t\t\ttext: chunk.delta,\n\t\t\t\t\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-call\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepToolCalls.push(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-result\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tif (!chunk.preliminary) stepToolOutputs.push(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-error\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepToolOutputs.push(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\t\tstepResponse = {\n\t\t\t\t\t\t\t\t\t\tid: (_a17 = chunk.id) != null ? _a17 : stepResponse.id,\n\t\t\t\t\t\t\t\t\t\ttimestamp: (_b2 = chunk.timestamp) != null ? _b2 : stepResponse.timestamp,\n\t\t\t\t\t\t\t\t\t\tmodelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"finish\": {\n\t\t\t\t\t\t\t\t\tstepUsage = chunk.usage;\n\t\t\t\t\t\t\t\t\tstepFinishReason = chunk.finishReason;\n\t\t\t\t\t\t\t\t\tstepProviderMetadata = chunk.providerMetadata;\n\t\t\t\t\t\t\t\t\tconst msToFinish = now2() - startTimestampMs;\n\t\t\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.finish\");\n\t\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes({\n\t\t\t\t\t\t\t\t\t\t\"ai.response.msToFinish\": msToFinish,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.avgOutputTokensPerSecond\": 1e3 * ((_d2 = stepUsage.outputTokens) != null ? _d2 : 0) / msToFinish\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"source\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-input-start\": {\n\t\t\t\t\t\t\t\t\tconst tool2 = stepToolSet == null ? void 0 : stepToolSet[chunk.toolName];\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\t\tdynamic: (tool2 == null ? void 0 : tool2.type) === \"dynamic\"\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase \"tool-input-end\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-input-delta\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepFinishReason = \"error\";\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"raw\":\n\t\t\t\t\t\t\t\t\tif (includeRawChunks2) controller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault: throw new Error(`Unknown chunk type: ${chunkType}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tasync flush(controller) {\n\t\t\t\t\t\t\tconst stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : void 0;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": stepFinishReason,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.text\": { output: () => activeText },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => stepToolCallsJson },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.id\": stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.model\": stepResponse.modelId,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": stepResponse.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(stepProviderMetadata),\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": stepUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": stepUsage.outputTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": stepUsage.totalTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": stepUsage.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": stepUsage.cachedInputTokens,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [stepFinishReason],\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": stepResponse.modelId,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": stepUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": stepUsage.outputTokens\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t} catch (error) {} finally {\n\t\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"finish-step\",\n\t\t\t\t\t\t\t\tfinishReason: stepFinishReason,\n\t\t\t\t\t\t\t\tusage: stepUsage,\n\t\t\t\t\t\t\t\tproviderMetadata: stepProviderMetadata,\n\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t...stepResponse,\n\t\t\t\t\t\t\t\t\theaders: response == null ? void 0 : response.headers\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst combinedUsage = addLanguageModelUsage(usage, stepUsage);\n\t\t\t\t\t\t\tawait stepFinish.promise;\n\t\t\t\t\t\t\tconst clientToolCalls = stepToolCalls.filter((toolCall) => toolCall.providerExecuted !== true);\n\t\t\t\t\t\t\tconst clientToolOutputs = stepToolOutputs.filter((toolOutput) => toolOutput.providerExecuted !== true);\n\t\t\t\t\t\t\tif (clientToolCalls.length > 0 && clientToolOutputs.length === clientToolCalls.length && !await isStopConditionMet({\n\t\t\t\t\t\t\t\tstopConditions,\n\t\t\t\t\t\t\t\tsteps: recordedSteps\n\t\t\t\t\t\t\t})) {\n\t\t\t\t\t\t\t\tresponseMessages.push(...toResponseMessages({\n\t\t\t\t\t\t\t\t\tcontent: recordedSteps[recordedSteps.length - 1].content,\n\t\t\t\t\t\t\t\t\ttools: stepToolSet\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait streamStep({\n\t\t\t\t\t\t\t\t\t\tcurrentStep: currentStep + 1,\n\t\t\t\t\t\t\t\t\t\tresponseMessages,\n\t\t\t\t\t\t\t\t\t\tusage: combinedUsage\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tself.closeStream();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\t\t\t\tfinishReason: stepFinishReason,\n\t\t\t\t\t\t\t\t\ttotalUsage: combinedUsage\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tself.closeStream();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})));\n\t\t\t\t}\n\t\t\t\tawait streamStep({\n\t\t\t\t\tcurrentStep: 0,\n\t\t\t\t\tresponseMessages: [],\n\t\t\t\t\tusage: {\n\t\t\t\t\t\tinputTokens: void 0,\n\t\t\t\t\t\toutputTokens: void 0,\n\t\t\t\t\t\ttotalTokens: void 0\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}).catch((error) => {\n\t\t\tself.addStream(new ReadableStream({ start(controller) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t\tcontroller.close();\n\t\t\t} }));\n\t\t\tself.closeStream();\n\t\t});\n\t}\n\tget steps() {\n\t\tthis.consumeStream();\n\t\treturn this._steps.promise;\n\t}\n\tget finalStep() {\n\t\treturn this.steps.then((steps) => steps[steps.length - 1]);\n\t}\n\tget content() {\n\t\treturn this.finalStep.then((step) => step.content);\n\t}\n\tget warnings() {\n\t\treturn this.finalStep.then((step) => step.warnings);\n\t}\n\tget providerMetadata() {\n\t\treturn this.finalStep.then((step) => step.providerMetadata);\n\t}\n\tget text() {\n\t\treturn this.finalStep.then((step) => step.text);\n\t}\n\tget reasoningText() {\n\t\treturn this.finalStep.then((step) => step.reasoningText);\n\t}\n\tget reasoning() {\n\t\treturn this.finalStep.then((step) => step.reasoning);\n\t}\n\tget sources() {\n\t\treturn this.finalStep.then((step) => step.sources);\n\t}\n\tget files() {\n\t\treturn this.finalStep.then((step) => step.files);\n\t}\n\tget toolCalls() {\n\t\treturn this.finalStep.then((step) => step.toolCalls);\n\t}\n\tget staticToolCalls() {\n\t\treturn this.finalStep.then((step) => step.staticToolCalls);\n\t}\n\tget dynamicToolCalls() {\n\t\treturn this.finalStep.then((step) => step.dynamicToolCalls);\n\t}\n\tget toolResults() {\n\t\treturn this.finalStep.then((step) => step.toolResults);\n\t}\n\tget staticToolResults() {\n\t\treturn this.finalStep.then((step) => step.staticToolResults);\n\t}\n\tget dynamicToolResults() {\n\t\treturn this.finalStep.then((step) => step.dynamicToolResults);\n\t}\n\tget usage() {\n\t\treturn this.finalStep.then((step) => step.usage);\n\t}\n\tget request() {\n\t\treturn this.finalStep.then((step) => step.request);\n\t}\n\tget response() {\n\t\treturn this.finalStep.then((step) => step.response);\n\t}\n\tget totalUsage() {\n\t\tthis.consumeStream();\n\t\treturn this._totalUsage.promise;\n\t}\n\tget finishReason() {\n\t\tthis.consumeStream();\n\t\treturn this._finishReason.promise;\n\t}\n\t/**\n\tSplit out a new stream from the original stream.\n\tThe original stream is replaced to allow for further splitting,\n\tsince we do not know how many times the stream will be split.\n\t\n\tNote: this leads to buffering the stream content on the server.\n\tHowever, the LLM results are expected to be small enough to not cause issues.\n\t*/\n\tteeStream() {\n\t\tconst [stream1, stream2] = this.baseStream.tee();\n\t\tthis.baseStream = stream2;\n\t\treturn stream1;\n\t}\n\tget textStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ part }, controller) {\n\t\t\tif (part.type === \"text-delta\") controller.enqueue(part.text);\n\t\t} })));\n\t}\n\tget fullStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ part }, controller) {\n\t\t\tcontroller.enqueue(part);\n\t\t} })));\n\t}\n\tasync consumeStream(options) {\n\t\tvar _a16;\n\t\ttry {\n\t\t\tawait consumeStream({\n\t\t\t\tstream: this.fullStream,\n\t\t\t\tonError: options == null ? void 0 : options.onError\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t(_a16 = options == null ? void 0 : options.onError) == null || _a16.call(options, error);\n\t\t}\n\t}\n\tget experimental_partialOutputStream() {\n\t\tif (this.output == null) throw new NoOutputSpecifiedError();\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ partialOutput }, controller) {\n\t\t\tif (partialOutput != null) controller.enqueue(partialOutput);\n\t\t} })));\n\t}\n\ttoUIMessageStream({ originalMessages, generateMessageId, onFinish, messageMetadata, sendReasoning = true, sendSources = false, sendStart = true, sendFinish = true, onError = () => \"An error occurred.\" } = {}) {\n\t\tlet outcome = { status: \"unknown\" };\n\t\tlet hasFatalFailure = false;\n\t\tconst setSourceOutcome = (newOutcome) => {\n\t\t\tif (!hasFatalFailure && outcome.status !== \"completed\" && outcome.status !== \"aborted\" && newOutcome.status !== \"unknown\" && (outcome.status === \"unknown\" || newOutcome.status !== \"failed\")) outcome = newOutcome;\n\t\t};\n\t\tconst failOutcome = (error) => {\n\t\t\thasFatalFailure = true;\n\t\t\toutcome = {\n\t\t\t\tstatus: \"failed\",\n\t\t\t\terror\n\t\t\t};\n\t\t};\n\t\tconst responseMessageId = generateMessageId != null ? getResponseUIMessageId({\n\t\t\toriginalMessages,\n\t\t\tresponseMessageId: generateMessageId\n\t\t}) : void 0;\n\t\tconst toolNamesByCallId = {};\n\t\tconst isDynamic = (toolCallId) => {\n\t\t\tvar _a16, _b;\n\t\t\tconst toolName = toolNamesByCallId[toolCallId];\n\t\t\treturn ((_b = (_a16 = this.tools) == null ? void 0 : _a16[toolName]) == null ? void 0 : _b.type) === \"dynamic\" ? true : void 0;\n\t\t};\n\t\tconst sourceReader = this.fullStream.getReader();\n\t\tlet sourceReaderReleased = false;\n\t\tlet sourceStreamCancelled = false;\n\t\tconst releaseSourceReader = () => {\n\t\t\tif (!sourceReaderReleased) {\n\t\t\t\tsourceReader.releaseLock();\n\t\t\t\tsourceReaderReleased = true;\n\t\t\t}\n\t\t};\n\t\tconst baseStreamReader = new ReadableStream({\n\t\t\tasync pull(controller) {\n\t\t\t\ttry {\n\t\t\t\t\tconst { done, value } = await sourceReader.read();\n\t\t\t\t\tif (done) {\n\t\t\t\t\t\treleaseSourceReader();\n\t\t\t\t\t\tif (!sourceStreamCancelled) controller.close();\n\t\t\t\t\t} else controller.enqueue(value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treleaseSourceReader();\n\t\t\t\t\tif (!sourceStreamCancelled) {\n\t\t\t\t\t\tfailOutcome(error);\n\t\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync cancel(reason) {\n\t\t\t\tsourceStreamCancelled = true;\n\t\t\t\tif (sourceReaderReleased) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait sourceReader.cancel(reason);\n\t\t\t\t} finally {\n\t\t\t\t\treleaseSourceReader();\n\t\t\t\t}\n\t\t\t}\n\t\t}).pipeThrough(new TransformStream({ transform: async (part, controller) => {\n\t\t\tconst messageMetadataValue = messageMetadata == null ? void 0 : messageMetadata({ part });\n\t\t\tconst partType = part.type;\n\t\t\tswitch (partType) {\n\t\t\t\tcase \"text-start\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"text-start\",\n\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\tdelta: part.text,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text-end\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"text-end\",\n\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reasoning-start\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"reasoning-start\",\n\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reasoning-delta\":\n\t\t\t\t\tif (sendReasoning) controller.enqueue({\n\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\tdelta: part.text,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reasoning-end\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"reasoning-end\",\n\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"file\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: part.file.mediaType,\n\t\t\t\t\t\turl: `data:${part.file.mediaType};base64,${part.file.base64}`\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"source\":\n\t\t\t\t\tif (sendSources && part.sourceType === \"url\") controller.enqueue({\n\t\t\t\t\t\ttype: \"source-url\",\n\t\t\t\t\t\tsourceId: part.id,\n\t\t\t\t\t\turl: part.url,\n\t\t\t\t\t\ttitle: part.title,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tif (sendSources && part.sourceType === \"document\") controller.enqueue({\n\t\t\t\t\t\ttype: \"source-document\",\n\t\t\t\t\t\tsourceId: part.id,\n\t\t\t\t\t\tmediaType: part.mediaType,\n\t\t\t\t\t\ttitle: part.title,\n\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-start\": {\n\t\t\t\t\ttoolNamesByCallId[part.id] = part.toolName;\n\t\t\t\t\tconst dynamic = isDynamic(part.id);\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"tool-input-start\",\n\t\t\t\t\t\ttoolCallId: part.id,\n\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t...dynamic != null ? { dynamic } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-delta\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"tool-input-delta\",\n\t\t\t\t\t\ttoolCallId: part.id,\n\t\t\t\t\t\tinputTextDelta: part.delta\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call\": {\n\t\t\t\t\ttoolNamesByCallId[part.toolCallId] = part.toolName;\n\t\t\t\t\tconst dynamic = isDynamic(part.toolCallId);\n\t\t\t\t\tif (part.invalid) controller.enqueue({\n\t\t\t\t\t\ttype: \"tool-input-error\",\n\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t...dynamic != null ? { dynamic } : {},\n\t\t\t\t\t\terrorText: onError(part.error)\n\t\t\t\t\t});\n\t\t\t\t\telse controller.enqueue({\n\t\t\t\t\t\ttype: \"tool-input-available\",\n\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t...dynamic != null ? { dynamic } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-result\": {\n\t\t\t\t\tconst dynamic = isDynamic(part.toolCallId);\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"tool-output-available\",\n\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\toutput: part.output,\n\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t...part.preliminary != null ? { preliminary: part.preliminary } : {},\n\t\t\t\t\t\t...dynamic != null ? { dynamic } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-error\": {\n\t\t\t\t\tconst dynamic = isDynamic(part.toolCallId);\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"tool-output-error\",\n\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\terrorText: onError(part.error),\n\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t...dynamic != null ? { dynamic } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"error\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\terrorText: onError(part.error)\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"start-step\":\n\t\t\t\t\tcontroller.enqueue({ type: \"start-step\" });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish-step\":\n\t\t\t\t\tcontroller.enqueue({ type: \"finish-step\" });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"start\":\n\t\t\t\t\tif (sendStart) controller.enqueue({\n\t\t\t\t\t\ttype: \"start\",\n\t\t\t\t\t\t...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {},\n\t\t\t\t\t\t...responseMessageId != null ? { messageId: responseMessageId } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tif (sendFinish) controller.enqueue({\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: part.finishReason,\n\t\t\t\t\t\t...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"abort\":\n\t\t\t\t\tcontroller.enqueue(part);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-end\": break;\n\t\t\t\tcase \"raw\": break;\n\t\t\t\tdefault: throw new Error(`Unknown chunk type: ${partType}`);\n\t\t\t}\n\t\t\tif (messageMetadataValue != null && partType !== \"start\" && partType !== \"finish\") controller.enqueue({\n\t\t\t\ttype: \"message-metadata\",\n\t\t\t\tmessageMetadata: messageMetadataValue\n\t\t\t});\n\t\t\tif (part.type === \"finish\") setSourceOutcome({ status: \"completed\" });\n\t\t\telse if (part.type === \"abort\") setSourceOutcome({ status: \"aborted\" });\n\t\t\telse if (part.type === \"error\") setSourceOutcome({\n\t\t\t\tstatus: \"failed\",\n\t\t\t\terror: part.error\n\t\t\t});\n\t\t} })).getReader();\n\t\tlet baseStreamReaderReleased = false;\n\t\tlet baseStreamCancelled = false;\n\t\tconst releaseBaseStreamReader = () => {\n\t\t\tif (!baseStreamReaderReleased) {\n\t\t\t\tbaseStreamReader.releaseLock();\n\t\t\t\tbaseStreamReaderReleased = true;\n\t\t\t}\n\t\t};\n\t\treturn createAsyncIterableStream(handleUIMessageStreamFinish({\n\t\t\tstream: new ReadableStream({\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { done, value } = await baseStreamReader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\treleaseBaseStreamReader();\n\t\t\t\t\t\t\tif (!baseStreamCancelled) controller.close();\n\t\t\t\t\t\t} else controller.enqueue(value);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treleaseBaseStreamReader();\n\t\t\t\t\t\tif (!baseStreamCancelled) {\n\t\t\t\t\t\t\tfailOutcome(error);\n\t\t\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync cancel(reason) {\n\t\t\t\t\tbaseStreamCancelled = true;\n\t\t\t\t\tif (baseStreamReaderReleased) return;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait baseStreamReader.cancel(reason);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\treleaseBaseStreamReader();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t\tmessageId: responseMessageId != null ? responseMessageId : generateMessageId == null ? void 0 : generateMessageId(),\n\t\t\toriginalMessages,\n\t\t\tonFinish,\n\t\t\tonError,\n\t\t\tgetOutcome: () => outcome\n\t\t}));\n\t}\n\tpipeUIMessageStreamToResponse(response, { originalMessages, generateMessageId, onFinish, messageMetadata, sendReasoning, sendSources, sendFinish, sendStart, onError, ...init } = {}) {\n\t\treturn pipeUIMessageStreamToResponse({\n\t\t\tresponse,\n\t\t\tstream: this.toUIMessageStream({\n\t\t\t\toriginalMessages,\n\t\t\t\tgenerateMessageId,\n\t\t\t\tonFinish,\n\t\t\t\tmessageMetadata,\n\t\t\t\tsendReasoning,\n\t\t\t\tsendSources,\n\t\t\t\tsendFinish,\n\t\t\t\tsendStart,\n\t\t\t\tonError\n\t\t\t}),\n\t\t\t...init\n\t\t});\n\t}\n\tpipeTextStreamToResponse(response, init) {\n\t\treturn pipeTextStreamToResponse({\n\t\t\tresponse,\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n\ttoUIMessageStreamResponse({ originalMessages, generateMessageId, onFinish, messageMetadata, sendReasoning, sendSources, sendFinish, sendStart, onError, ...init } = {}) {\n\t\treturn createUIMessageStreamResponse({\n\t\t\tstream: this.toUIMessageStream({\n\t\t\t\toriginalMessages,\n\t\t\t\tgenerateMessageId,\n\t\t\t\tonFinish,\n\t\t\t\tmessageMetadata,\n\t\t\t\tsendReasoning,\n\t\t\t\tsendSources,\n\t\t\t\tsendFinish,\n\t\t\t\tsendStart,\n\t\t\t\tonError\n\t\t\t}),\n\t\t\t...init\n\t\t});\n\t}\n\ttoTextStreamResponse(init) {\n\t\treturn createTextStreamResponse({\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n};\nfunction getOwn(obj, key) {\n\treturn obj != null && Object.hasOwn(obj, key) ? obj[key] : void 0;\n}\nfunction markToolPartAsUnavailable(part) {\n\tpart.dynamic = false;\n\treturn part;\n}\nfunction isToolPartFromUnavailableTool(part) {\n\treturn part.type === \"dynamic-tool\" && part.dynamic === false;\n}\nfunction convertToModelMessages(messages, options) {\n\tconst modelMessages = [];\n\tif (options == null ? void 0 : options.ignoreIncompleteToolCalls) messages = messages.map((message) => ({\n\t\t...message,\n\t\tparts: message.parts.filter((part) => !isToolOrDynamicToolUIPart(part) || part.state !== \"input-streaming\" && part.state !== \"input-available\" && (part.state !== \"output-available\" || part.preliminary !== true))\n\t}));\n\tfunction createModelOutput({ toolPart, toolName, output, errorMode }) {\n\t\tconst tool2 = getOwn(options == null ? void 0 : options.tools, toolName);\n\t\tif (errorMode === \"none\" && tool2 == null && isToolPartFromUnavailableTool(toolPart)) return {\n\t\t\ttype: \"text\",\n\t\t\tvalue: \"Tool output omitted because the tool is no longer available.\"\n\t\t};\n\t\treturn createToolModelOutput({\n\t\t\toutput,\n\t\t\ttool: tool2,\n\t\t\terrorMode\n\t\t});\n\t}\n\tfor (const message of messages) switch (message.role) {\n\t\tcase \"system\": {\n\t\t\tconst textParts = message.parts.filter((part) => part.type === \"text\");\n\t\t\tconst providerMetadata = textParts.reduce((acc, part) => {\n\t\t\t\tif (part.providerMetadata != null) return {\n\t\t\t\t\t...acc,\n\t\t\t\t\t...part.providerMetadata\n\t\t\t\t};\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\t\t\tmodelMessages.push({\n\t\t\t\trole: \"system\",\n\t\t\t\tcontent: textParts.map((part) => part.text).join(\"\"),\n\t\t\t\t...Object.keys(providerMetadata).length > 0 ? { providerOptions: providerMetadata } : {}\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tcase \"user\":\n\t\t\tmodelMessages.push({\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: message.parts.map((part) => {\n\t\t\t\t\tvar _a16;\n\t\t\t\t\tif (isTextUIPart(part)) return {\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t};\n\t\t\t\t\tif (isFileUIPart(part)) return {\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: part.mediaType,\n\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\tdata: part.url,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t};\n\t\t\t\t\tif (isDataUIPart(part)) return (_a16 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a16.call(options, part);\n\t\t\t\t}).filter((part) => part != null)\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"assistant\":\n\t\t\tif (message.parts != null) {\n\t\t\t\tlet processBlock2 = function() {\n\t\t\t\t\tvar _a16, _b;\n\t\t\t\t\tif (block.length === 0) return;\n\t\t\t\t\tconst content = [];\n\t\t\t\t\tfor (const part of block) if (isTextUIPart(part)) content.push({\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\telse if (isFileUIPart(part)) content.push({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: part.mediaType,\n\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\tdata: part.url\n\t\t\t\t\t});\n\t\t\t\t\telse if (isReasoningUIPart(part)) content.push({\n\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse if (isDynamicToolUIPart(part)) {\n\t\t\t\t\t\tconst toolName = part.toolName;\n\t\t\t\t\t\tif (part.state !== \"input-streaming\") content.push({\n\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t\t...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (isToolUIPart(part)) {\n\t\t\t\t\t\tconst toolName = getToolName(part);\n\t\t\t\t\t\tif (part.state !== \"input-streaming\") {\n\t\t\t\t\t\t\tcontent.push({\n\t\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\tinput: part.state === \"output-error\" ? (_a16 = part.input) != null ? _a16 : part.rawInput : part.input,\n\t\t\t\t\t\t\t\tproviderExecuted: part.providerExecuted,\n\t\t\t\t\t\t\t\t...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (part.providerExecuted === true && (part.state === \"output-available\" || part.state === \"output-error\")) content.push({\n\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\toutput: createModelOutput({\n\t\t\t\t\t\t\t\t\ttoolPart: part,\n\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\toutput: part.state === \"output-error\" ? part.errorText : part.output,\n\t\t\t\t\t\t\t\t\terrorMode: part.state === \"output-error\" ? \"json\" : \"none\"\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (isDataUIPart(part)) {\n\t\t\t\t\t\tconst dataPart = (_b = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _b.call(options, part);\n\t\t\t\t\t\tif (dataPart != null) content.push(dataPart);\n\t\t\t\t\t} else throw new Error(`Unsupported part: ${part}`);\n\t\t\t\t\tmodelMessages.push({\n\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\tcontent\n\t\t\t\t\t});\n\t\t\t\t\tconst toolParts = block.filter((part) => isToolUIPart(part) && part.providerExecuted !== true || part.type === \"dynamic-tool\");\n\t\t\t\t\tif (toolParts.length > 0) modelMessages.push({\n\t\t\t\t\t\trole: \"tool\",\n\t\t\t\t\t\tcontent: toolParts.map((toolPart) => {\n\t\t\t\t\t\t\tswitch (toolPart.state) {\n\t\t\t\t\t\t\t\tcase \"output-error\":\n\t\t\t\t\t\t\t\tcase \"output-available\": {\n\t\t\t\t\t\t\t\t\tconst toolName = getToolOrDynamicToolName(toolPart);\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\t\ttoolCallId: toolPart.toolCallId,\n\t\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\t\toutput: createModelOutput({\n\t\t\t\t\t\t\t\t\t\t\ttoolPart,\n\t\t\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\t\t\toutput: toolPart.state === \"output-error\" ? toolPart.errorText : toolPart.output,\n\t\t\t\t\t\t\t\t\t\t\terrorMode: toolPart.state === \"output-error\" ? \"text\" : \"none\"\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdefault: return null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).filter((output) => output != null)\n\t\t\t\t\t});\n\t\t\t\t\tblock = [];\n\t\t\t\t};\n\t\t\t\tlet block = [];\n\t\t\t\tfor (const part of message.parts) if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) || isToolOrDynamicToolUIPart(part) || isDataUIPart(part)) block.push(part);\n\t\t\t\telse if (part.type === \"step-start\") processBlock2();\n\t\t\t\tprocessBlock2();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst _exhaustiveCheck = message.role;\n\t\t\tthrow new MessageConversionError({\n\t\t\t\toriginalMessage: message,\n\t\t\t\tmessage: `Unsupported role: ${_exhaustiveCheck}`\n\t\t\t});\n\t\t}\n\t}\n\treturn modelMessages;\n}\nvar convertToCoreMessages = convertToModelMessages;\nvar Agent = class {\n\tconstructor(settings) {\n\t\tthis.settings = settings;\n\t}\n\tget tools() {\n\t\treturn this.settings.tools;\n\t}\n\tasync generate(options) {\n\t\treturn generateText$1({\n\t\t\t...this.settings,\n\t\t\t...options\n\t\t});\n\t}\n\tstream(options) {\n\t\treturn streamText$1({\n\t\t\t...this.settings,\n\t\t\t...options\n\t\t});\n\t}\n\t/**\n\t* Creates a response object that streams UI messages to the client.\n\t*/\n\trespond(options) {\n\t\treturn this.stream({ prompt: convertToModelMessages(options.messages) }).toUIMessageStreamResponse();\n\t}\n};\nasync function embed({ model: modelArg, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry }) {\n\tconst model = resolveEmbeddingModel(modelArg);\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.embed\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.embed\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.value\": { input: () => JSON.stringify(value) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tconst { embedding, usage, response, providerMetadata } = await retry(() => recordSpan({\n\t\t\t\tname: \"ai.embed.doEmbed\",\n\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\toperationId: \"ai.embed.doEmbed\",\n\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\"ai.values\": { input: () => [JSON.stringify(value)] }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttracer,\n\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\tvar _a16;\n\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\tvalues: [value],\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t});\n\t\t\t\t\tconst embedding2 = modelResponse.embeddings[0];\n\t\t\t\t\tconst usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };\n\t\t\t\t\tdoEmbedSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => modelResponse.embeddings.map((embedding3) => JSON.stringify(embedding3)) },\n\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\tif (embedding2 == null) throw new InvalidResponseDataError({\n\t\t\t\t\t\tdata: modelResponse.embeddings,\n\t\t\t\t\t\tmessage: \"No embedding generated.\"\n\t\t\t\t\t});\n\t\t\t\t\treturn {\n\t\t\t\t\t\tembedding: embedding2,\n\t\t\t\t\t\tusage: usage2,\n\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\tresponse: modelResponse.response\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}));\n\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.embedding\": { output: () => JSON.stringify(embedding) },\n\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn new DefaultEmbedResult({\n\t\t\t\tvalue,\n\t\t\t\tembedding,\n\t\t\t\tusage,\n\t\t\t\tproviderMetadata,\n\t\t\t\tresponse\n\t\t\t});\n\t\t}\n\t});\n}\nvar DefaultEmbedResult = class {\n\tconstructor(options) {\n\t\tthis.value = options.value;\n\t\tthis.embedding = options.embedding;\n\t\tthis.usage = options.usage;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.response = options.response;\n\t}\n};\nfunction setOwn(object2, key, value) {\n\tObject.defineProperty(object2, key, {\n\t\tvalue,\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t\twritable: true\n\t});\n}\nfunction getEmbeddingModelMaxInputBytesPerCall(model) {\n\treturn model[EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL];\n}\nfunction splitArray(array, chunkSize) {\n\tif (chunkSize <= 0) throw new Error(\"chunkSize must be greater than 0\");\n\tconst result = [];\n\tfor (let i = 0; i < array.length; i += chunkSize) result.push(array.slice(i, i + chunkSize));\n\treturn result;\n}\nasync function embedMany({ model: modelArg, values, maxParallelCalls = Infinity, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry }) {\n\tconst model = resolveEmbeddingModel(modelArg);\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.embedMany\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.embedMany\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.values\": { input: () => values.map((value) => JSON.stringify(value)) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tconst [maxEmbeddingsPerCall, maxInputBytesPerCall, supportsParallelCalls] = await Promise.all([\n\t\t\t\tmodel.maxEmbeddingsPerCall,\n\t\t\t\tgetEmbeddingModelMaxInputBytesPerCall(model),\n\t\t\t\tmodel.supportsParallelCalls\n\t\t\t]);\n\t\t\tconst hasEmbeddingLimit = maxEmbeddingsPerCall != null && maxEmbeddingsPerCall !== Infinity;\n\t\t\tconst hasInputByteLimit = maxInputBytesPerCall != null && maxInputBytesPerCall !== Infinity;\n\t\t\tif (!hasEmbeddingLimit && !hasInputByteLimit) {\n\t\t\t\tconst { embeddings: embeddings2, usage, response, providerMetadata: providerMetadata2 } = await retry(() => {\n\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\tname: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.values\": { input: () => values.map((value) => JSON.stringify(value)) }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\t\t\tvar _a16;\n\t\t\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\t\t\tvalues,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst embeddings3 = modelResponse.embeddings;\n\t\t\t\t\t\t\tconst usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };\n\t\t\t\t\t\t\tdoEmbedSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings3.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tembeddings: embeddings3,\n\t\t\t\t\t\t\t\tusage: usage2,\n\t\t\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\t\t\tresponse: modelResponse.response\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings2.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\treturn new DefaultEmbedManyResult({\n\t\t\t\t\tvalues,\n\t\t\t\t\tembeddings: embeddings2,\n\t\t\t\t\tusage,\n\t\t\t\t\tproviderMetadata: providerMetadata2,\n\t\t\t\t\tresponses: [response]\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst valueChunks = splitByEmbeddingLimits({\n\t\t\t\tvalues,\n\t\t\t\tmaxEmbeddingsPerCall: hasEmbeddingLimit ? maxEmbeddingsPerCall : Infinity,\n\t\t\t\tmaxInputBytesPerCall: hasInputByteLimit ? maxInputBytesPerCall : Infinity\n\t\t\t});\n\t\t\tconst embeddings = [];\n\t\t\tconst responses = [];\n\t\t\tlet tokens = 0;\n\t\t\tlet providerMetadata;\n\t\t\tconst parallelChunks = splitArray(valueChunks, supportsParallelCalls ? maxParallelCalls : 1);\n\t\t\tfor (const parallelChunk of parallelChunks) {\n\t\t\t\tconst results = await Promise.all(parallelChunk.map((chunk) => {\n\t\t\t\t\treturn retry(() => {\n\t\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\t\tname: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\t\toperationId: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\t\"ai.values\": { input: () => chunk.map((value) => JSON.stringify(value)) }\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\t\t\t\tvar _a16;\n\t\t\t\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\t\t\t\tvalues: chunk,\n\t\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst embeddings2 = modelResponse.embeddings;\n\t\t\t\t\t\t\t\tconst usage = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };\n\t\t\t\t\t\t\t\tdoEmbedSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings2.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t\t\t\t\t\t}\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\t\tembeddings: embeddings2,\n\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\t\t\t\tresponse: modelResponse.response\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}));\n\t\t\t\tfor (const result of results) {\n\t\t\t\t\tembeddings.push(...result.embeddings);\n\t\t\t\t\tresponses.push(result.response);\n\t\t\t\t\ttokens += result.usage.tokens;\n\t\t\t\t\tif (result.providerMetadata) {\n\t\t\t\t\t\tif (!providerMetadata) providerMetadata = { ...result.providerMetadata };\n\t\t\t\t\t\telse for (const [providerName, metadata] of Object.entries(result.providerMetadata)) setOwn(providerMetadata, providerName, {\n\t\t\t\t\t\t\t...getOwn(providerMetadata, providerName),\n\t\t\t\t\t\t\t...metadata\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\"ai.usage.tokens\": tokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn new DefaultEmbedManyResult({\n\t\t\t\tvalues,\n\t\t\t\tembeddings,\n\t\t\t\tusage: { tokens },\n\t\t\t\tproviderMetadata,\n\t\t\t\tresponses\n\t\t\t});\n\t\t}\n\t});\n}\nvar textEncoder = new TextEncoder();\nfunction splitByEmbeddingLimits({ values, maxEmbeddingsPerCall, maxInputBytesPerCall }) {\n\tif (maxEmbeddingsPerCall <= 0) throw new Error(\"maxEmbeddingsPerCall must be greater than 0\");\n\tif (maxInputBytesPerCall <= 0) throw new Error(\"maxInputBytesPerCall must be greater than 0\");\n\tif (values.length === 0) return [];\n\tconst chunks = [];\n\tlet currentChunk = [];\n\tlet currentInputBytes = 0;\n\tfor (const value of values) {\n\t\tconst inputBytes = maxInputBytesPerCall === Infinity ? 0 : textEncoder.encode(value).length;\n\t\tif (currentChunk.length > 0 && (currentChunk.length >= maxEmbeddingsPerCall || currentInputBytes + inputBytes > maxInputBytesPerCall)) {\n\t\t\tchunks.push(currentChunk);\n\t\t\tcurrentChunk = [];\n\t\t\tcurrentInputBytes = 0;\n\t\t}\n\t\tcurrentChunk.push(value);\n\t\tcurrentInputBytes += inputBytes;\n\t}\n\tchunks.push(currentChunk);\n\treturn chunks;\n}\nvar DefaultEmbedManyResult = class {\n\tconstructor(options) {\n\t\tthis.values = options.values;\n\t\tthis.embeddings = options.embeddings;\n\t\tthis.usage = options.usage;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.responses = options.responses;\n\t}\n};\nvar RetryableNoImageResultError = class extends Error {\n\tconstructor() {\n\t\tsuper(\"No image generated.\");\n\t\tthis.name = \"RetryableNoImageResultError\";\n\t}\n};\nasync function generateImage({ model: modelArg, prompt, n = 1, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tvar _a16, _b;\n\tconst model = resolveImageModel(modelArg);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal,\n\t\tadditionalRetryableError: (error) => error instanceof RetryableNoImageResultError\n\t});\n\tconst maxImagesPerCallWithDefault = (_a16 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a16 : 1;\n\tconst callCount = Math.ceil(n / maxImagesPerCallWithDefault);\n\tconst callImageCounts = Array.from({ length: callCount }, (_, i) => {\n\t\tif (i < callCount - 1) return maxImagesPerCallWithDefault;\n\t\tconst remainder = n % maxImagesPerCallWithDefault;\n\t\treturn remainder === 0 ? maxImagesPerCallWithDefault : remainder;\n\t});\n\tconst results = (await Promise.all(callImageCounts.map(async (callImageCount) => {\n\t\tconst callResults = [];\n\t\ttry {\n\t\t\tawait retry(async () => {\n\t\t\t\tconst result = await model.doGenerate({\n\t\t\t\t\tprompt,\n\t\t\t\t\tn: callImageCount,\n\t\t\t\t\tabortSignal,\n\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\tsize,\n\t\t\t\t\taspectRatio,\n\t\t\t\t\tseed,\n\t\t\t\t\tproviderOptions: providerOptions != null ? providerOptions : {}\n\t\t\t\t});\n\t\t\t\tcallResults.push(result);\n\t\t\t\tif (result.images.length === 0 && result.isRetryable !== false) throw new RetryableNoImageResultError();\n\t\t\t\treturn result;\n\t\t\t});\n\t\t\treturn callResults;\n\t\t} catch (error) {\n\t\t\tif ((error instanceof RetryableNoImageResultError ? error : RetryError.isInstance(error) && error.lastError instanceof RetryableNoImageResultError ? error.lastError : void 0) != null) return callResults;\n\t\t\tthrow error;\n\t\t}\n\t}))).flat();\n\tconst images = [];\n\tconst warnings = [];\n\tconst responses = [];\n\tconst providerMetadata = {};\n\tfor (const result of results) {\n\t\timages.push(...result.images.map((image) => {\n\t\t\tvar _a17;\n\t\t\treturn new DefaultGeneratedFile({\n\t\t\t\tdata: image,\n\t\t\t\tmediaType: (_a17 = detectMediaType({\n\t\t\t\t\tdata: image,\n\t\t\t\t\tsignatures: imageMediaTypeSignatures\n\t\t\t\t})) != null ? _a17 : \"image/png\"\n\t\t\t});\n\t\t}));\n\t\twarnings.push(...result.warnings);\n\t\tif (result.providerMetadata) for (const [providerName, metadata] of Object.entries(result.providerMetadata)) if (providerName === \"gateway\") {\n\t\t\tconst currentEntry = providerMetadata[providerName];\n\t\t\tif (currentEntry != null && typeof currentEntry === \"object\") providerMetadata[providerName] = {\n\t\t\t\t...currentEntry,\n\t\t\t\t...metadata\n\t\t\t};\n\t\t\telse providerMetadata[providerName] = metadata;\n\t\t\tconst imagesValue = providerMetadata[providerName].images;\n\t\t\tif (Array.isArray(imagesValue) && imagesValue.length === 0) delete providerMetadata[providerName].images;\n\t\t} else {\n\t\t\tconst currentEntry = (_b = getOwn(providerMetadata, providerName)) != null ? _b : { images: [] };\n\t\t\tcurrentEntry.images.push(...result.providerMetadata[providerName].images);\n\t\t\tsetOwn(providerMetadata, providerName, currentEntry);\n\t\t}\n\t\tresponses.push(result.response);\n\t}\n\tlogWarnings(warnings);\n\tif (!images.length) throw new NoImageGeneratedError({ responses });\n\treturn new DefaultGenerateImageResult({\n\t\timages,\n\t\twarnings,\n\t\tresponses,\n\t\tproviderMetadata\n\t});\n}\nvar DefaultGenerateImageResult = class {\n\tconstructor(options) {\n\t\tthis.images = options.images;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t}\n\tget image() {\n\t\treturn this.images[0];\n\t}\n};\nasync function invokeModelMaxImagesPerCall(model) {\n\tif (!(model.maxImagesPerCall instanceof Function)) return model.maxImagesPerCall;\n\treturn model.maxImagesPerCall({ modelId: model.modelId });\n}\nfunction extractReasoningContent(content) {\n\tconst parts = content.filter((content2) => content2.type === \"reasoning\");\n\treturn parts.length === 0 ? void 0 : parts.map((content2) => content2.text).join(\"\\n\");\n}\nvar noSchemaOutputStrategy = {\n\ttype: \"no-schema\",\n\tjsonSchema: void 0,\n\tasync validatePartialResult({ value, textDelta }) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tvalue: {\n\t\t\t\tpartial: value,\n\t\t\t\ttextDelta\n\t\t\t}\n\t\t};\n\t},\n\tasync validateFinalResult(value, context) {\n\t\treturn value === void 0 ? {\n\t\t\tsuccess: false,\n\t\t\terror: new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\ttext: context.text,\n\t\t\t\tresponse: context.response,\n\t\t\t\tusage: context.usage,\n\t\t\t\tfinishReason: context.finishReason\n\t\t\t})\n\t\t} : {\n\t\t\tsuccess: true,\n\t\t\tvalue\n\t\t};\n\t},\n\tcreateElementStream() {\n\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in no-schema mode\" });\n\t}\n};\nvar objectOutputStrategy = (schema) => ({\n\ttype: \"object\",\n\tjsonSchema: schema.jsonSchema,\n\tasync validatePartialResult({ value, textDelta }) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tvalue: {\n\t\t\t\tpartial: value,\n\t\t\t\ttextDelta\n\t\t\t}\n\t\t};\n\t},\n\tasync validateFinalResult(value) {\n\t\treturn safeValidateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t},\n\tcreateElementStream() {\n\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in object mode\" });\n\t}\n});\nvar arrayOutputStrategy = (schema) => {\n\tconst { $schema, ...itemSchema } = schema.jsonSchema;\n\treturn {\n\t\ttype: \"array\",\n\t\tjsonSchema: {\n\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\ttype: \"object\",\n\t\t\tproperties: { elements: {\n\t\t\t\ttype: \"array\",\n\t\t\t\titems: itemSchema\n\t\t\t} },\n\t\t\trequired: [\"elements\"],\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tasync validatePartialResult({ value, latestObject, isFirstDelta, isFinalDelta }) {\n\t\t\tvar _a16;\n\t\t\tif (!isJSONObject(value) || !isJSONArray(value.elements)) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains an array of elements\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst inputArray = value.elements;\n\t\t\tconst resultArray = [];\n\t\t\tfor (let i = 0; i < inputArray.length; i++) {\n\t\t\t\tconst element = inputArray[i];\n\t\t\t\tconst result = await safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema\n\t\t\t\t});\n\t\t\t\tif (i === inputArray.length - 1 && !isFinalDelta) continue;\n\t\t\t\tif (!result.success) return result;\n\t\t\t\tresultArray.push(result.value);\n\t\t\t}\n\t\t\tconst publishedElementCount = (_a16 = latestObject == null ? void 0 : latestObject.length) != null ? _a16 : 0;\n\t\t\tlet textDelta = \"\";\n\t\t\tif (isFirstDelta) textDelta += \"[\";\n\t\t\tif (publishedElementCount > 0) textDelta += \",\";\n\t\t\ttextDelta += resultArray.slice(publishedElementCount).map((element) => JSON.stringify(element)).join(\",\");\n\t\t\tif (isFinalDelta) textDelta += \"]\";\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tpartial: resultArray,\n\t\t\t\t\ttextDelta\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tasync validateFinalResult(value) {\n\t\t\tif (!isJSONObject(value) || !isJSONArray(value.elements)) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains an array of elements\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst inputArray = value.elements;\n\t\t\tconst resultArray = [];\n\t\t\tfor (const element of inputArray) {\n\t\t\t\tconst result = await safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema\n\t\t\t\t});\n\t\t\t\tif (!result.success) return result;\n\t\t\t\tresultArray.push(result.value);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: resultArray\n\t\t\t};\n\t\t},\n\t\tcreateElementStream(originalStream) {\n\t\t\tlet publishedElements = 0;\n\t\t\treturn createAsyncIterableStream(originalStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\tcase \"object\": {\n\t\t\t\t\t\tconst array = chunk.object;\n\t\t\t\t\t\tfor (; publishedElements < array.length; publishedElements++) controller.enqueue(array[publishedElements]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcase \"finish\":\n\t\t\t\t\tcase \"error\": break;\n\t\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t\t}\n\t\t\t} })));\n\t\t}\n\t};\n};\nvar enumOutputStrategy = (enumValues) => {\n\treturn {\n\t\ttype: \"enum\",\n\t\tjsonSchema: {\n\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\ttype: \"object\",\n\t\t\tproperties: { result: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tenum: enumValues\n\t\t\t} },\n\t\t\trequired: [\"result\"],\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tasync validateFinalResult(value) {\n\t\t\tif (!isJSONObject(value) || typeof value.result !== \"string\") return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains a string in the \\\"result\\\" property.\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst result = value.result;\n\t\t\treturn enumValues.includes(result) ? {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: result\n\t\t\t} : {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be a string in the enum\"\n\t\t\t\t})\n\t\t\t};\n\t\t},\n\t\tasync validatePartialResult({ value, textDelta }) {\n\t\t\tif (!isJSONObject(value) || typeof value.result !== \"string\") return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains a string in the \\\"result\\\" property.\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst result = value.result;\n\t\t\tconst possibleEnumValues = enumValues.filter((enumValue) => enumValue.startsWith(result));\n\t\t\tif (value.result.length === 0 || possibleEnumValues.length === 0) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be a string in the enum\"\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tpartial: possibleEnumValues.length > 1 ? result : possibleEnumValues[0],\n\t\t\t\t\ttextDelta\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tcreateElementStream() {\n\t\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in enum mode\" });\n\t\t}\n\t};\n};\nfunction getOutputStrategy({ output, schema, enumValues }) {\n\tswitch (output) {\n\t\tcase \"object\": return objectOutputStrategy(asSchema(schema));\n\t\tcase \"array\": return arrayOutputStrategy(asSchema(schema));\n\t\tcase \"enum\": return enumOutputStrategy(enumValues);\n\t\tcase \"no-schema\": return noSchemaOutputStrategy;\n\t\tdefault: throw new Error(`Unsupported output: ${output}`);\n\t}\n}\nasync function parseAndValidateObjectResult(result, outputStrategy, context) {\n\tconst parseResult = await safeParseJSON({ text: result });\n\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\tmessage: \"No object generated: could not parse the response.\",\n\t\tcause: parseResult.error,\n\t\ttext: result,\n\t\tresponse: context.response,\n\t\tusage: context.usage,\n\t\tfinishReason: context.finishReason\n\t});\n\tconst validationResult = await outputStrategy.validateFinalResult(parseResult.value, {\n\t\ttext: result,\n\t\tresponse: context.response,\n\t\tusage: context.usage\n\t});\n\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\tmessage: \"No object generated: response did not match schema.\",\n\t\tcause: validationResult.error,\n\t\ttext: result,\n\t\tresponse: context.response,\n\t\tusage: context.usage,\n\t\tfinishReason: context.finishReason\n\t});\n\treturn validationResult.value;\n}\nasync function parseAndValidateObjectResultWithRepair(result, outputStrategy, repairText, context) {\n\ttry {\n\t\treturn await parseAndValidateObjectResult(result, outputStrategy, context);\n\t} catch (error) {\n\t\tif (repairText != null && NoObjectGeneratedError.isInstance(error) && (JSONParseError.isInstance(error.cause) || TypeValidationError.isInstance(error.cause))) {\n\t\t\tconst repairedText = await repairText({\n\t\t\t\ttext: result,\n\t\t\t\terror: error.cause\n\t\t\t});\n\t\t\tif (repairedText === null) throw error;\n\t\t\treturn await parseAndValidateObjectResult(repairedText, outputStrategy, context);\n\t\t}\n\t\tthrow error;\n\t}\n}\nfunction validateObjectGenerationInput({ output, schema, schemaName, schemaDescription, enumValues }) {\n\tif (output != null && output !== \"object\" && output !== \"array\" && output !== \"enum\" && output !== \"no-schema\") throw new InvalidArgumentError({\n\t\tparameter: \"output\",\n\t\tvalue: output,\n\t\tmessage: \"Invalid output type.\"\n\t});\n\tif (output === \"no-schema\") {\n\t\tif (schema != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is not supported for no-schema output.\"\n\t\t});\n\t\tif (schemaDescription != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaDescription\",\n\t\t\tvalue: schemaDescription,\n\t\t\tmessage: \"Schema description is not supported for no-schema output.\"\n\t\t});\n\t\tif (schemaName != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaName\",\n\t\t\tvalue: schemaName,\n\t\t\tmessage: \"Schema name is not supported for no-schema output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for no-schema output.\"\n\t\t});\n\t}\n\tif (output === \"object\") {\n\t\tif (schema == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is required for object output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for object output.\"\n\t\t});\n\t}\n\tif (output === \"array\") {\n\t\tif (schema == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Element schema is required for array output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for array output.\"\n\t\t});\n\t}\n\tif (output === \"enum\") {\n\t\tif (schema != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is not supported for enum output.\"\n\t\t});\n\t\tif (schemaDescription != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaDescription\",\n\t\t\tvalue: schemaDescription,\n\t\t\tmessage: \"Schema description is not supported for enum output.\"\n\t\t});\n\t\tif (schemaName != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaName\",\n\t\t\tvalue: schemaName,\n\t\t\tmessage: \"Schema name is not supported for enum output.\"\n\t\t});\n\t\tif (enumValues == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are required for enum output.\"\n\t\t});\n\t\tfor (const value of enumValues) if (typeof value !== \"string\") throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue,\n\t\t\tmessage: \"Enum values must be strings.\"\n\t\t});\n\t}\n}\nvar originalGenerateId3 = createIdGenerator({\n\tprefix: \"aiobj\",\n\tsize: 24\n});\nasync function generateObject(options) {\n\tconst { model: modelArg, output = \"object\", system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, headers, experimental_repairText: repairText, experimental_telemetry: telemetry, experimental_download: download2, providerOptions, _internal: { generateId: generateId3 = originalGenerateId3, currentDate = () => /* @__PURE__ */ new Date() } = {}, ...settings } = options;\n\tconst model = resolveLanguageModel(modelArg);\n\tconst enumValues = \"enum\" in options ? options.enum : void 0;\n\tconst { schema: inputSchema, schemaDescription, schemaName } = \"schema\" in options ? options : {};\n\tvalidateObjectGenerationInput({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tenumValues\n\t});\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst outputStrategy = getOutputStrategy({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tenumValues\n\t});\n\tconst callSettings = prepareCallSettings(settings);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: {\n\t\t\t...callSettings,\n\t\t\tmaxRetries\n\t\t}\n\t});\n\tconst tracer = getTracer(telemetry);\n\ttry {\n\t\treturn await recordSpan({\n\t\t\tname: \"ai.generateObject\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.generateObject\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) },\n\t\t\t\t\t\"ai.schema\": outputStrategy.jsonSchema != null ? { input: () => JSON.stringify(outputStrategy.jsonSchema) } : void 0,\n\t\t\t\t\t\"ai.schema.name\": schemaName,\n\t\t\t\t\t\"ai.schema.description\": schemaDescription,\n\t\t\t\t\t\"ai.settings.output\": outputStrategy.type\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tfn: async (span) => {\n\t\t\t\tvar _a16;\n\t\t\t\tlet result;\n\t\t\t\tlet finishReason;\n\t\t\t\tlet usage;\n\t\t\t\tlet warnings;\n\t\t\t\tlet response;\n\t\t\t\tlet request;\n\t\t\t\tlet resultProviderMetadata;\n\t\t\t\tlet reasoning;\n\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\tprompt: await standardizePrompt({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tallowSystemInMessages\n\t\t\t\t\t}),\n\t\t\t\t\tsupportedUrls: await model.supportedUrls,\n\t\t\t\t\tdownload: download2\n\t\t\t\t});\n\t\t\t\tconst generateResult = await retry(() => recordSpan({\n\t\t\t\t\tname: \"ai.generateObject.doGenerate\",\n\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\toperationId: \"ai.generateObject.doGenerate\",\n\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": callSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": callSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": callSettings.presencePenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.temperature\": callSettings.temperature,\n\t\t\t\t\t\t\t\"gen_ai.request.top_k\": callSettings.topK,\n\t\t\t\t\t\t\t\"gen_ai.request.top_p\": callSettings.topP\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\ttracer,\n\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\tvar _a17, _b, _c, _d, _e, _f, _g, _h;\n\t\t\t\t\t\tconst result2 = await model.doGenerate({\n\t\t\t\t\t\t\tresponseFormat: {\n\t\t\t\t\t\t\t\ttype: \"json\",\n\t\t\t\t\t\t\t\tschema: outputStrategy.jsonSchema,\n\t\t\t\t\t\t\t\tname: schemaName,\n\t\t\t\t\t\t\t\tdescription: schemaDescription\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\theaders: headersWithUserAgent\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\tid: (_b = (_a17 = result2.response) == null ? void 0 : _a17.id) != null ? _b : generateId3(),\n\t\t\t\t\t\t\ttimestamp: (_d = (_c = result2.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),\n\t\t\t\t\t\t\tmodelId: (_f = (_e = result2.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,\n\t\t\t\t\t\t\theaders: (_g = result2.response) == null ? void 0 : _g.headers,\n\t\t\t\t\t\t\tbody: (_h = result2.response) == null ? void 0 : _h.body\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst text2 = extractTextContent(result2.content);\n\t\t\t\t\t\tconst reasoning2 = extractReasoningContent(result2.content);\n\t\t\t\t\t\tif (text2 === void 0) throw new NoObjectGeneratedError({\n\t\t\t\t\t\t\tmessage: \"No object generated: the model did not return a response.\",\n\t\t\t\t\t\t\tresponse: responseData,\n\t\t\t\t\t\t\tusage: result2.usage,\n\t\t\t\t\t\t\tfinishReason: result2.finishReason\n\t\t\t\t\t\t});\n\t\t\t\t\t\tspan2.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result2.finishReason,\n\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => text2 },\n\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result2.providerMetadata),\n\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": result2.usage.inputTokens,\n\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": result2.usage.outputTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result2.finishReason],\n\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": result2.usage.inputTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": result2.usage.outputTokens\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}));\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result2,\n\t\t\t\t\t\t\tobjectText: text2,\n\t\t\t\t\t\t\treasoning: reasoning2,\n\t\t\t\t\t\t\tresponseData\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tresult = generateResult.objectText;\n\t\t\t\tfinishReason = generateResult.finishReason;\n\t\t\t\tusage = generateResult.usage;\n\t\t\t\twarnings = generateResult.warnings;\n\t\t\t\tresultProviderMetadata = generateResult.providerMetadata;\n\t\t\t\trequest = (_a16 = generateResult.request) != null ? _a16 : {};\n\t\t\t\tresponse = generateResult.responseData;\n\t\t\t\treasoning = generateResult.reasoning;\n\t\t\t\tlogWarnings(warnings);\n\t\t\t\tconst object2 = await parseAndValidateObjectResultWithRepair(result, outputStrategy, repairText, {\n\t\t\t\t\tresponse,\n\t\t\t\t\tusage,\n\t\t\t\t\tfinishReason\n\t\t\t\t});\n\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(resultProviderMetadata),\n\t\t\t\t\t\t\"ai.usage.promptTokens\": usage.inputTokens,\n\t\t\t\t\t\t\"ai.usage.completionTokens\": usage.outputTokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\treturn new DefaultGenerateObjectResult({\n\t\t\t\t\tobject: object2,\n\t\t\t\t\treasoning,\n\t\t\t\t\tfinishReason,\n\t\t\t\t\tusage,\n\t\t\t\t\twarnings,\n\t\t\t\t\trequest,\n\t\t\t\t\tresponse,\n\t\t\t\t\tproviderMetadata: resultProviderMetadata\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t} catch (error) {\n\t\tthrow wrapGatewayError(error);\n\t}\n}\nvar DefaultGenerateObjectResult = class {\n\tconstructor(options) {\n\t\tthis.object = options.object;\n\t\tthis.finishReason = options.finishReason;\n\t\tthis.usage = options.usage;\n\t\tthis.warnings = options.warnings;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.response = options.response;\n\t\tthis.request = options.request;\n\t\tthis.reasoning = options.reasoning;\n\t}\n\ttoJsonResponse(init) {\n\t\tvar _a16;\n\t\treturn new Response(JSON.stringify(this.object), {\n\t\t\tstatus: (_a16 = init == null ? void 0 : init.status) != null ? _a16 : 200,\n\t\t\theaders: prepareHeaders(init == null ? void 0 : init.headers, { \"content-type\": \"application/json; charset=utf-8\" })\n\t\t});\n\t}\n};\nfunction cosineSimilarity(vector1, vector2) {\n\tif (vector1.length !== vector2.length) throw new InvalidArgumentError({\n\t\tparameter: \"vector1,vector2\",\n\t\tvalue: {\n\t\t\tvector1Length: vector1.length,\n\t\t\tvector2Length: vector2.length\n\t\t},\n\t\tmessage: `Vectors must have the same length`\n\t});\n\tconst n = vector1.length;\n\tif (n === 0) return 0;\n\tlet magnitudeSquared1 = 0;\n\tlet magnitudeSquared2 = 0;\n\tlet dotProduct = 0;\n\tfor (let i = 0; i < n; i++) {\n\t\tconst value1 = vector1[i];\n\t\tconst value2 = vector2[i];\n\t\tmagnitudeSquared1 += value1 * value1;\n\t\tmagnitudeSquared2 += value2 * value2;\n\t\tdotProduct += value1 * value2;\n\t}\n\treturn magnitudeSquared1 === 0 || magnitudeSquared2 === 0 ? 0 : dotProduct / (Math.sqrt(magnitudeSquared1) * Math.sqrt(magnitudeSquared2));\n}\nfunction createDownload(options) {\n\treturn ({ url, abortSignal }) => download({\n\t\turl,\n\t\tmaxBytes: options == null ? void 0 : options.maxBytes,\n\t\tabortSignal\n\t});\n}\nvar { atob } = globalThis;\nfunction getTextFromDataUrl(dataUrl) {\n\tconst [header, base64Content] = dataUrl.split(\",\");\n\tif (header.split(\";\")[0].split(\":\")[1] == null || base64Content == null) throw new Error(\"Invalid data URL format\");\n\ttry {\n\t\treturn atob(base64Content);\n\t} catch (error) {\n\t\tthrow new Error(`Error decoding data URL`);\n\t}\n}\nfunction isDeepEqualData(obj1, obj2) {\n\tif (obj1 === obj2) return true;\n\tif (obj1 == null || obj2 == null) return false;\n\tif (typeof obj1 !== \"object\" && typeof obj2 !== \"object\") return obj1 === obj2;\n\tif (obj1.constructor !== obj2.constructor) return false;\n\tif (obj1 instanceof Date && obj2 instanceof Date) return obj1.getTime() === obj2.getTime();\n\tif (Array.isArray(obj1)) {\n\t\tif (obj1.length !== obj2.length) return false;\n\t\tfor (let i = 0; i < obj1.length; i++) if (!isDeepEqualData(obj1[i], obj2[i])) return false;\n\t\treturn true;\n\t}\n\tconst keys1 = Object.keys(obj1);\n\tconst keys2 = Object.keys(obj2);\n\tif (keys1.length !== keys2.length) return false;\n\tfor (const key of keys1) {\n\t\tif (!keys2.includes(key)) return false;\n\t\tif (!isDeepEqualData(obj1[key], obj2[key])) return false;\n\t}\n\treturn true;\n}\nvar SerialJobExecutor = class {\n\tconstructor() {\n\t\tthis.queue = [];\n\t\tthis.isProcessing = false;\n\t\tthis.idleWaiters = [];\n\t}\n\tasync processQueue() {\n\t\tif (this.isProcessing) return;\n\t\tthis.isProcessing = true;\n\t\ttry {\n\t\t\twhile (this.queue.length > 0) {\n\t\t\t\tawait this.queue[0]();\n\t\t\t\tthis.queue.shift();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.isProcessing = false;\n\t\t\tfor (const resolve2 of this.idleWaiters.splice(0)) resolve2();\n\t\t}\n\t}\n\tasync run(job) {\n\t\treturn new Promise((resolve2, reject) => {\n\t\t\tthis.queue.push(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait job();\n\t\t\t\t\tresolve2();\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.processQueue();\n\t\t});\n\t}\n\tasync waitForIdle() {\n\t\tif (!this.isProcessing && this.queue.length === 0) return;\n\t\tawait new Promise((resolve2) => {\n\t\t\tthis.idleWaiters.push(resolve2);\n\t\t});\n\t}\n};\nfunction simulateReadableStream({ chunks, initialDelayInMs = 0, chunkDelayInMs = 0, _internal }) {\n\tvar _a16;\n\tconst delay2 = (_a16 = _internal == null ? void 0 : _internal.delay) != null ? _a16 : delay;\n\tlet index = 0;\n\treturn new ReadableStream({ async pull(controller) {\n\t\tif (index < chunks.length) {\n\t\t\tawait delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);\n\t\t\tcontroller.enqueue(chunks[index++]);\n\t\t} else controller.close();\n\t} });\n}\nvar originalGenerateId4 = createIdGenerator({\n\tprefix: \"aiobj\",\n\tsize: 24\n});\nasync function markPromiseAsHandled(promise) {\n\ttry {\n\t\tawait promise;\n\t} catch (e) {}\n}\nfunction streamObject(options) {\n\tconst { model, output = \"object\", system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, headers, experimental_repairText: repairText, experimental_telemetry: telemetry, experimental_download: download2, providerOptions, onError = ({ error }) => {\n\t\tconsole.error(error);\n\t}, onFinish, _internal: { generateId: generateId3 = originalGenerateId4, currentDate = () => /* @__PURE__ */ new Date(), now: now2 = now } = {}, ...settings } = options;\n\tconst enumValues = \"enum\" in options && options.enum ? options.enum : void 0;\n\tconst { schema: inputSchema, schemaDescription, schemaName } = \"schema\" in options ? options : {};\n\tvalidateObjectGenerationInput({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tenumValues\n\t});\n\treturn new DefaultStreamObjectResult({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings,\n\t\tmaxRetries,\n\t\tabortSignal,\n\t\toutputStrategy: getOutputStrategy({\n\t\t\toutput,\n\t\t\tschema: inputSchema,\n\t\t\tenumValues\n\t\t}),\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tallowSystemInMessages,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tproviderOptions,\n\t\trepairText,\n\t\tonError,\n\t\tonFinish,\n\t\tdownload: download2,\n\t\tgenerateId: generateId3,\n\t\tcurrentDate,\n\t\tnow: now2\n\t});\n}\nvar DefaultStreamObjectResult = class {\n\tconstructor({ model: modelArg, headers, telemetry, settings, maxRetries: maxRetriesArg, abortSignal, outputStrategy, system, prompt, messages, allowSystemInMessages, schemaName, schemaDescription, providerOptions, repairText, onError, onFinish, download: download2, generateId: generateId3, currentDate, now: now2 }) {\n\t\tthis._object = new DelayedPromise();\n\t\tthis._usage = new DelayedPromise();\n\t\tthis._providerMetadata = new DelayedPromise();\n\t\tthis._warnings = new DelayedPromise();\n\t\tthis._request = new DelayedPromise();\n\t\tthis._response = new DelayedPromise();\n\t\tthis._finishReason = new DelayedPromise();\n\t\tconst model = resolveLanguageModel(modelArg);\n\t\tconst { maxRetries, retry } = prepareRetries({\n\t\t\tmaxRetries: maxRetriesArg,\n\t\t\tabortSignal\n\t\t});\n\t\tconst callSettings = prepareCallSettings(settings);\n\t\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\t\tmodel,\n\t\t\ttelemetry,\n\t\t\theaders,\n\t\t\tsettings: {\n\t\t\t\t...callSettings,\n\t\t\t\tmaxRetries\n\t\t\t}\n\t\t});\n\t\tconst tracer = getTracer(telemetry);\n\t\tconst self = this;\n\t\tconst stitchableStream = createStitchableStream();\n\t\tconst eventProcessor = new TransformStream({ transform(chunk, controller) {\n\t\t\tcontroller.enqueue(chunk);\n\t\t\tif (chunk.type === \"error\") notify({\n\t\t\t\tevent: { error: wrapGatewayError(chunk.error) },\n\t\t\t\tcallbacks: onError\n\t\t\t});\n\t\t} });\n\t\tthis.baseStream = stitchableStream.stream.pipeThrough(eventProcessor);\n\t\trecordSpan({\n\t\t\tname: \"ai.streamObject\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.streamObject\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) },\n\t\t\t\t\t\"ai.schema\": outputStrategy.jsonSchema != null ? { input: () => JSON.stringify(outputStrategy.jsonSchema) } : void 0,\n\t\t\t\t\t\"ai.schema.name\": schemaName,\n\t\t\t\t\t\"ai.schema.description\": schemaDescription,\n\t\t\t\t\t\"ai.settings.output\": outputStrategy.type\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tendWhenDone: false,\n\t\t\tendOnError: true,\n\t\t\tfn: async (rootSpan) => {\n\t\t\t\tconst standardizedPrompt = await standardizePrompt({\n\t\t\t\t\tsystem,\n\t\t\t\t\tprompt,\n\t\t\t\t\tmessages,\n\t\t\t\t\tallowSystemInMessages\n\t\t\t\t});\n\t\t\t\tconst callOptions = {\n\t\t\t\t\tresponseFormat: {\n\t\t\t\t\t\ttype: \"json\",\n\t\t\t\t\t\tschema: outputStrategy.jsonSchema,\n\t\t\t\t\t\tname: schemaName,\n\t\t\t\t\t\tdescription: schemaDescription\n\t\t\t\t\t},\n\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\tprompt: await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: standardizedPrompt,\n\t\t\t\t\t\tsupportedUrls: await model.supportedUrls,\n\t\t\t\t\t\tdownload: download2\n\t\t\t\t\t}),\n\t\t\t\t\tproviderOptions,\n\t\t\t\t\tabortSignal,\n\t\t\t\t\theaders,\n\t\t\t\t\tincludeRawChunks: false\n\t\t\t\t};\n\t\t\t\tconst transformer = { transform: (chunk, controller) => {\n\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\t\tcontroller.enqueue(chunk.delta);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\tcase \"stream-start\": controller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t} };\n\t\t\t\tconst { result: { stream, response, request }, doStreamSpan, startTimestampMs } = await retry(() => recordSpan({\n\t\t\t\t\tname: \"ai.streamObject.doStream\",\n\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\toperationId: \"ai.streamObject.doStream\",\n\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(callOptions.prompt) },\n\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": callSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": callSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": callSettings.presencePenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.temperature\": callSettings.temperature,\n\t\t\t\t\t\t\t\"gen_ai.request.top_k\": callSettings.topK,\n\t\t\t\t\t\t\t\"gen_ai.request.top_p\": callSettings.topP\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\ttracer,\n\t\t\t\t\tendWhenDone: false,\n\t\t\t\t\tendOnError: true,\n\t\t\t\t\tfn: async (doStreamSpan2) => ({\n\t\t\t\t\t\tstartTimestampMs: now2(),\n\t\t\t\t\t\tdoStreamSpan: doStreamSpan2,\n\t\t\t\t\t\tresult: await model.doStream(callOptions)\n\t\t\t\t\t})\n\t\t\t\t}));\n\t\t\t\tself._request.resolve(request != null ? request : {});\n\t\t\t\tlet warnings;\n\t\t\t\tlet usage = {\n\t\t\t\t\tinputTokens: void 0,\n\t\t\t\t\toutputTokens: void 0,\n\t\t\t\t\ttotalTokens: void 0\n\t\t\t\t};\n\t\t\t\tlet finishReason;\n\t\t\t\tlet providerMetadata;\n\t\t\t\tlet object2;\n\t\t\t\tlet error;\n\t\t\t\tlet terminalError;\n\t\t\t\tlet accumulatedText = \"\";\n\t\t\t\tlet textDelta = \"\";\n\t\t\t\tlet fullResponse = {\n\t\t\t\t\tid: generateId3(),\n\t\t\t\t\ttimestamp: currentDate(),\n\t\t\t\t\tmodelId: model.modelId\n\t\t\t\t};\n\t\t\t\tlet latestObjectJson = void 0;\n\t\t\t\tlet latestObject = void 0;\n\t\t\t\tlet isFirstChunk = true;\n\t\t\t\tlet isFirstDelta = true;\n\t\t\t\tconst transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({\n\t\t\t\t\tasync transform(chunk, controller) {\n\t\t\t\t\t\tvar _a16, _b, _c;\n\t\t\t\t\t\tif (typeof chunk === \"object\" && chunk.type === \"stream-start\") {\n\t\t\t\t\t\t\twarnings = chunk.warnings;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isFirstChunk) {\n\t\t\t\t\t\t\tconst msToFirstChunk = now2() - startTimestampMs;\n\t\t\t\t\t\t\tisFirstChunk = false;\n\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.firstChunk\", { \"ai.stream.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\tdoStreamSpan.setAttributes({ \"ai.stream.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof chunk === \"string\") {\n\t\t\t\t\t\t\taccumulatedText += chunk;\n\t\t\t\t\t\t\ttextDelta += chunk;\n\t\t\t\t\t\t\tconst { value: currentObjectJson, state: parseState } = await parsePartialJson(accumulatedText);\n\t\t\t\t\t\t\tif (currentObjectJson !== void 0 && !isDeepEqualData(latestObjectJson, currentObjectJson)) {\n\t\t\t\t\t\t\t\tconst validationResult = await outputStrategy.validatePartialResult({\n\t\t\t\t\t\t\t\t\tvalue: currentObjectJson,\n\t\t\t\t\t\t\t\t\ttextDelta,\n\t\t\t\t\t\t\t\t\tlatestObject,\n\t\t\t\t\t\t\t\t\tisFirstDelta,\n\t\t\t\t\t\t\t\t\tisFinalDelta: parseState === \"successful-parse\"\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (validationResult.success && !isDeepEqualData(latestObject, validationResult.value.partial)) {\n\t\t\t\t\t\t\t\t\tlatestObjectJson = currentObjectJson;\n\t\t\t\t\t\t\t\t\tlatestObject = validationResult.value.partial;\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\t\tobject: latestObject\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\ttextDelta: validationResult.value.textDelta\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\ttextDelta = \"\";\n\t\t\t\t\t\t\t\t\tisFirstDelta = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\tfullResponse = {\n\t\t\t\t\t\t\t\t\tid: (_a16 = chunk.id) != null ? _a16 : fullResponse.id,\n\t\t\t\t\t\t\t\t\ttimestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,\n\t\t\t\t\t\t\t\t\tmodelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\t\t\tif (terminalError === void 0) {\n\t\t\t\t\t\t\t\t\tconst wrappedError = wrapGatewayError(chunk.error);\n\t\t\t\t\t\t\t\t\tterminalError = { error: wrappedError };\n\t\t\t\t\t\t\t\t\terror = wrappedError;\n\t\t\t\t\t\t\t\t\tfinishReason = \"error\";\n\t\t\t\t\t\t\t\t\tself.rejectResultPromises(wrappedError);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\t\t\tif (textDelta !== \"\") controller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\ttextDelta\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tfinishReason = terminalError === void 0 ? chunk.finishReason : \"error\";\n\t\t\t\t\t\t\t\tusage = chunk.usage;\n\t\t\t\t\t\t\t\tproviderMetadata = chunk.providerMetadata;\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\tresponse: fullResponse\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tlogWarnings(warnings != null ? warnings : []);\n\t\t\t\t\t\t\t\tif (terminalError !== void 0) break;\n\t\t\t\t\t\t\t\tself._usage.resolve(usage);\n\t\t\t\t\t\t\t\tself._providerMetadata.resolve(providerMetadata);\n\t\t\t\t\t\t\t\tself._warnings.resolve(warnings);\n\t\t\t\t\t\t\t\tself._response.resolve({\n\t\t\t\t\t\t\t\t\t...fullResponse,\n\t\t\t\t\t\t\t\t\theaders: response == null ? void 0 : response.headers\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tself._finishReason.resolve(finishReason != null ? finishReason : \"unknown\");\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tobject2 = await parseAndValidateObjectResultWithRepair(accumulatedText, outputStrategy, repairText, {\n\t\t\t\t\t\t\t\t\t\tresponse: fullResponse,\n\t\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\t\tfinishReason\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tself._object.resolve(object2);\n\t\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\t\terror = e;\n\t\t\t\t\t\t\t\t\tself._object.reject(e);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault: controller.enqueue(chunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tasync flush(controller) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst finalUsage = usage != null ? usage : {\n\t\t\t\t\t\t\t\tpromptTokens: NaN,\n\t\t\t\t\t\t\t\tcompletionTokens: NaN,\n\t\t\t\t\t\t\t\ttotalTokens: NaN\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tdoStreamSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\t\t\t\"ai.response.id\": fullResponse.id,\n\t\t\t\t\t\t\t\t\t\"ai.response.model\": fullResponse.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": fullResponse.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(providerMetadata),\n\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": finalUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": finalUsage.outputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": finalUsage.totalTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": finalUsage.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": finalUsage.cachedInputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [finishReason],\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": fullResponse.id,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": fullResponse.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": finalUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": finalUsage.outputTokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\trootSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": finalUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": finalUsage.outputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": finalUsage.totalTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": finalUsage.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": finalUsage.cachedInputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(providerMetadata)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tawait (onFinish == null ? void 0 : onFinish({\n\t\t\t\t\t\t\t\tusage: finalUsage,\n\t\t\t\t\t\t\t\tobject: object2,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t...fullResponse,\n\t\t\t\t\t\t\t\t\theaders: response == null ? void 0 : response.headers\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twarnings,\n\t\t\t\t\t\t\t\tproviderMetadata\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t} catch (error2) {\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: error2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\trootSpan.end();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tstitchableStream.addStream(transformedStream, { onError(error2) {\n\t\t\t\t\tconst wrappedError = wrapGatewayError(error2);\n\t\t\t\t\tself.rejectResultPromises(wrappedError);\n\t\t\t\t\tnotify({\n\t\t\t\t\t\tevent: { error: wrappedError },\n\t\t\t\t\t\tcallbacks: onError\n\t\t\t\t\t});\n\t\t\t\t} });\n\t\t\t}\n\t\t}).catch((error) => {\n\t\t\tself.rejectResultPromises(error);\n\t\t\tstitchableStream.addStream(new ReadableStream({ start(controller) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t\tcontroller.close();\n\t\t\t} }));\n\t\t}).finally(() => {\n\t\t\tstitchableStream.close();\n\t\t});\n\t\tthis.outputStrategy = outputStrategy;\n\t}\n\trejectResultPromises(error) {\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._object,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._usage,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._providerMetadata,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._warnings,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._request,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._response,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._finishReason,\n\t\t\terror\n\t\t});\n\t}\n\trejectResultPromise({ delayedPromise, error }) {\n\t\tif (delayedPromise.isPending()) {\n\t\t\tdelayedPromise.reject(error);\n\t\t\tmarkPromiseAsHandled(delayedPromise.promise);\n\t\t}\n\t}\n\tget object() {\n\t\treturn this._object.promise;\n\t}\n\tget usage() {\n\t\treturn this._usage.promise;\n\t}\n\tget providerMetadata() {\n\t\treturn this._providerMetadata.promise;\n\t}\n\tget warnings() {\n\t\treturn this._warnings.promise;\n\t}\n\tget request() {\n\t\treturn this._request.promise;\n\t}\n\tget response() {\n\t\treturn this._response.promise;\n\t}\n\tget finishReason() {\n\t\treturn this._finishReason.promise;\n\t}\n\tget partialObjectStream() {\n\t\treturn createAsyncIterableStream(this.baseStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"object\":\n\t\t\t\t\tcontroller.enqueue(chunk.object);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text-delta\":\n\t\t\t\tcase \"finish\":\n\t\t\t\tcase \"error\": break;\n\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t}\n\t\t} })));\n\t}\n\tget elementStream() {\n\t\treturn this.outputStrategy.createElementStream(this.baseStream);\n\t}\n\tget textStream() {\n\t\treturn createAsyncIterableStream(this.baseStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcontroller.enqueue(chunk.textDelta);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"object\":\n\t\t\t\tcase \"finish\":\n\t\t\t\tcase \"error\": break;\n\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t}\n\t\t} })));\n\t}\n\tget fullStream() {\n\t\treturn createAsyncIterableStream(this.baseStream);\n\t}\n\tpipeTextStreamToResponse(response, init) {\n\t\treturn pipeTextStreamToResponse({\n\t\t\tresponse,\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n\ttoTextStreamResponse(init) {\n\t\treturn createTextStreamResponse({\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n};\nvar DefaultGeneratedAudioFile = class extends DefaultGeneratedFile {\n\tconstructor({ data, mediaType }) {\n\t\tsuper({\n\t\t\tdata,\n\t\t\tmediaType\n\t\t});\n\t\tlet format = \"mp3\";\n\t\tif (mediaType) {\n\t\t\tconst mediaTypeParts = mediaType.split(\"/\");\n\t\t\tif (mediaTypeParts.length === 2) {\n\t\t\t\tif (mediaType !== \"audio/mpeg\") format = mediaTypeParts[1];\n\t\t\t}\n\t\t}\n\t\tif (!format) throw new Error(\"Audio format must be provided or determinable from media type\");\n\t\tthis.format = format;\n\t}\n};\nasync function generateSpeech({ model, text: text2, voice, outputFormat, instructions, speed, language, providerOptions = {}, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tvar _a16;\n\tif (model.specificationVersion !== \"v2\") throw new UnsupportedModelVersionError({\n\t\tversion: model.specificationVersion,\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst result = await retry(() => model.doGenerate({\n\t\ttext: text2,\n\t\tvoice,\n\t\toutputFormat,\n\t\tinstructions,\n\t\tspeed,\n\t\tlanguage,\n\t\tabortSignal,\n\t\theaders: headersWithUserAgent,\n\t\tproviderOptions\n\t}));\n\tif (!result.audio || result.audio.length === 0) throw new NoSpeechGeneratedError({ responses: [result.response] });\n\tlogWarnings(result.warnings);\n\treturn new DefaultSpeechResult({\n\t\taudio: new DefaultGeneratedAudioFile({\n\t\t\tdata: result.audio,\n\t\t\tmediaType: (_a16 = detectMediaType({\n\t\t\t\tdata: result.audio,\n\t\t\t\tsignatures: audioMediaTypeSignatures\n\t\t\t})) != null ? _a16 : \"audio/mp3\"\n\t\t}),\n\t\twarnings: result.warnings,\n\t\tresponses: [result.response],\n\t\tproviderMetadata: result.providerMetadata\n\t});\n}\nvar DefaultSpeechResult = class {\n\tconstructor(options) {\n\t\tvar _a16;\n\t\tthis.audio = options.audio;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = (_a16 = options.providerMetadata) != null ? _a16 : {};\n\t}\n};\nvar output_exports = {};\n__export(output_exports, {\n\tobject: () => object,\n\ttext: () => text\n});\nvar text = () => ({\n\ttype: \"text\",\n\tresponseFormat: { type: \"text\" },\n\tasync parsePartial({ text: text2 }) {\n\t\treturn { partial: text2 };\n\t},\n\tasync parseOutput({ text: text2 }) {\n\t\treturn text2;\n\t}\n});\nvar object = ({ schema: inputSchema }) => {\n\tconst schema = asSchema(inputSchema);\n\treturn {\n\t\ttype: \"object\",\n\t\tresponseFormat: {\n\t\t\ttype: \"json\",\n\t\t\tschema: schema.jsonSchema\n\t\t},\n\t\tasync parsePartial({ text: text2 }) {\n\t\t\tconst result = await parsePartialJson(text2);\n\t\t\tswitch (result.state) {\n\t\t\t\tcase \"failed-parse\":\n\t\t\t\tcase \"undefined-input\": return;\n\t\t\t\tcase \"repaired-parse\":\n\t\t\t\tcase \"successful-parse\": return { partial: result.value };\n\t\t\t\tdefault: {\n\t\t\t\t\tconst _exhaustiveCheck = result.state;\n\t\t\t\t\tthrow new Error(`Unsupported parse state: ${_exhaustiveCheck}`);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync parseOutput({ text: text2 }, context) {\n\t\t\tconst parseResult = await safeParseJSON({ text: text2 });\n\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\tcause: parseResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context.response,\n\t\t\t\tusage: context.usage,\n\t\t\t\tfinishReason: context.finishReason\n\t\t\t});\n\t\t\tconst validationResult = await safeValidateTypes({\n\t\t\t\tvalue: parseResult.value,\n\t\t\t\tschema\n\t\t\t});\n\t\t\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\tcause: validationResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context.response,\n\t\t\t\tusage: context.usage,\n\t\t\t\tfinishReason: context.finishReason\n\t\t\t});\n\t\t\treturn validationResult.value;\n\t\t}\n\t};\n};\nfunction pruneMessages({ messages, reasoning = \"none\", toolCalls = [], emptyMessages = \"remove\" }) {\n\tif (reasoning === \"all\" || reasoning === \"before-last-message\") messages = messages.map((message, messageIndex) => {\n\t\tif (message.role !== \"assistant\" || typeof message.content === \"string\" || reasoning === \"before-last-message\" && messageIndex === messages.length - 1) return message;\n\t\treturn {\n\t\t\t...message,\n\t\t\tcontent: message.content.filter((part) => part.type !== \"reasoning\")\n\t\t};\n\t});\n\tif (toolCalls === \"none\") toolCalls = [];\n\telse if (toolCalls === \"all\") toolCalls = [{ type: \"all\" }];\n\telse if (toolCalls === \"before-last-message\") toolCalls = [{ type: \"before-last-message\" }];\n\telse if (typeof toolCalls === \"string\") toolCalls = [{ type: toolCalls }];\n\tfor (const toolCall of toolCalls) {\n\t\tconst keepLastMessagesCount = toolCall.type === \"all\" ? void 0 : toolCall.type === \"before-last-message\" ? 1 : Number(toolCall.type.slice(12).slice(0, -9));\n\t\tconst keptToolCallIds = /* @__PURE__ */ new Set();\n\t\tif (keepLastMessagesCount != null) {\n\t\t\tfor (const message of messages.slice(-keepLastMessagesCount)) if ((message.role === \"assistant\" || message.role === \"tool\") && typeof message.content !== \"string\") {\n\t\t\t\tfor (const part of message.content) if (part.type === \"tool-call\" || part.type === \"tool-result\") keptToolCallIds.add(part.toolCallId);\n\t\t\t}\n\t\t}\n\t\tmessages = messages.map((message, messageIndex) => {\n\t\t\tif (message.role !== \"assistant\" && message.role !== \"tool\" || typeof message.content === \"string\" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) return message;\n\t\t\tconst toolCallIdToToolName = {};\n\t\t\treturn {\n\t\t\t\t...message,\n\t\t\t\tcontent: message.content.filter((part) => {\n\t\t\t\t\tif (part.type !== \"tool-call\" && part.type !== \"tool-result\") return true;\n\t\t\t\t\tif (part.type === \"tool-call\") toolCallIdToToolName[part.toolCallId] = part.toolName;\n\t\t\t\t\tif ((part.type === \"tool-call\" || part.type === \"tool-result\") && keptToolCallIds.has(part.toolCallId)) return true;\n\t\t\t\t\treturn toolCall.tools != null && !toolCall.tools.includes(part.toolName);\n\t\t\t\t})\n\t\t\t};\n\t\t});\n\t}\n\tif (emptyMessages === \"remove\") messages = messages.filter((message) => message.content.length > 0);\n\treturn messages;\n}\nvar CHUNKING_REGEXPS = {\n\tword: /\\S+\\s+/m,\n\tline: /\\n+/m\n};\nfunction isDocumentHidden() {\n\treturn typeof document !== \"undefined\" && document.visibilityState === \"hidden\";\n}\nfunction smoothStream({ delayInMs = 10, chunking = \"word\", _internal: { delay: delay2 = delay } = {} } = {}) {\n\tlet detectChunk;\n\tif (typeof chunking === \"function\") detectChunk = (buffer) => {\n\t\tconst match = chunking(buffer);\n\t\tif (match == null) return null;\n\t\tif (!match.length) throw new Error(`Chunking function must return a non-empty string.`);\n\t\tif (!buffer.startsWith(match)) throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: \"${match}\" expected to start with \"${buffer}\"`);\n\t\treturn match;\n\t};\n\telse {\n\t\tconst chunkingRegex = typeof chunking === \"string\" ? CHUNKING_REGEXPS[chunking] : chunking;\n\t\tif (chunkingRegex == null) throw new InvalidArgumentError$1({\n\t\t\targument: \"chunking\",\n\t\t\tmessage: `Chunking must be \"word\" or \"line\" or a RegExp. Received: ${chunking}`\n\t\t});\n\t\tdetectChunk = (buffer) => {\n\t\t\tconst match = chunkingRegex.exec(buffer);\n\t\t\tif (!match) return null;\n\t\t\treturn buffer.slice(0, match.index) + (match == null ? void 0 : match[0]);\n\t\t};\n\t}\n\treturn () => {\n\t\tlet buffer = \"\";\n\t\tlet id = \"\";\n\t\tlet providerMetadata;\n\t\tfunction flushBuffer(controller) {\n\t\t\tif (buffer.length > 0 || providerMetadata != null) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\ttext: buffer,\n\t\t\t\t\tid,\n\t\t\t\t\t...providerMetadata != null ? { providerMetadata } : {}\n\t\t\t\t});\n\t\t\t\tbuffer = \"\";\n\t\t\t\tproviderMetadata = void 0;\n\t\t\t}\n\t\t}\n\t\treturn new TransformStream({ async transform(chunk, controller) {\n\t\t\tif (chunk.type !== \"text-delta\") {\n\t\t\t\tflushBuffer(controller);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (chunk.text.length === 0 && chunk.providerMetadata != null) {\n\t\t\t\tflushBuffer(controller);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (buffer.length > 0 && (chunk.id !== id || providerMetadata != null || chunk.providerMetadata != null)) flushBuffer(controller);\n\t\t\tbuffer += chunk.text;\n\t\t\tid = chunk.id;\n\t\t\tproviderMetadata = chunk.providerMetadata;\n\t\t\tlet match;\n\t\t\twhile ((match = detectChunk(buffer)) != null) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\ttext: match,\n\t\t\t\t\tid,\n\t\t\t\t\t...providerMetadata != null ? { providerMetadata } : {}\n\t\t\t\t});\n\t\t\t\tbuffer = buffer.slice(match.length);\n\t\t\t\tawait delay2(isDocumentHidden() ? null : delayInMs);\n\t\t\t}\n\t\t\tif (buffer.length === 0) providerMetadata = void 0;\n\t\t} });\n\t};\n}\nfunction defaultSettingsMiddleware({ settings }) {\n\treturn {\n\t\tmiddlewareVersion: \"v2\",\n\t\ttransformParams: async ({ params }) => {\n\t\t\treturn mergeObjects(settings, params);\n\t\t}\n\t};\n}\nfunction getPotentialStartIndex(text2, searchedText) {\n\tif (searchedText.length === 0) return null;\n\tconst directIndex = text2.indexOf(searchedText);\n\tif (directIndex !== -1) return directIndex;\n\tfor (let i = text2.length - 1; i >= 0; i--) {\n\t\tconst suffix = text2.substring(i);\n\t\tif (searchedText.startsWith(suffix)) return i;\n\t}\n\treturn null;\n}\nfunction extractReasoningMiddleware({ tagName, separator = \"\\n\", startWithReasoning = false }) {\n\tconst openingTag = `<${tagName}>`;\n\tconst closingTag = `</${tagName}>`;\n\treturn {\n\t\tmiddlewareVersion: \"v2\",\n\t\twrapGenerate: async ({ doGenerate }) => {\n\t\t\tconst { content, ...rest } = await doGenerate();\n\t\t\tconst transformedContent = [];\n\t\t\tfor (const part of content) {\n\t\t\t\tif (part.type !== \"text\") {\n\t\t\t\t\ttransformedContent.push(part);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst text2 = startWithReasoning ? openingTag + part.text : part.text;\n\t\t\t\tconst regexp = new RegExp(`${openingTag}(.*?)${closingTag}`, \"gs\");\n\t\t\t\tconst matches = Array.from(text2.matchAll(regexp));\n\t\t\t\tif (!matches.length) {\n\t\t\t\t\ttransformedContent.push(part);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst reasoningText = matches.map((match) => match[1]).join(separator);\n\t\t\t\tlet textWithoutReasoning = text2;\n\t\t\t\tfor (let i = matches.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst match = matches[i];\n\t\t\t\t\tconst beforeMatch = textWithoutReasoning.slice(0, match.index);\n\t\t\t\t\tconst afterMatch = textWithoutReasoning.slice(match.index + match[0].length);\n\t\t\t\t\ttextWithoutReasoning = beforeMatch + (beforeMatch.length > 0 && afterMatch.length > 0 ? separator : \"\") + afterMatch;\n\t\t\t\t}\n\t\t\t\ttransformedContent.push({\n\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\ttext: reasoningText\n\t\t\t\t});\n\t\t\t\ttransformedContent.push({\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: textWithoutReasoning\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: transformedContent,\n\t\t\t\t...rest\n\t\t\t};\n\t\t},\n\t\twrapStream: async ({ doStream }) => {\n\t\t\tconst { stream, ...rest } = await doStream();\n\t\t\tconst reasoningExtractions = createIdMap();\n\t\t\tlet delayedTextStart;\n\t\t\treturn {\n\t\t\t\tstream: stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {\n\t\t\t\t\tif (chunk.type === \"text-start\") {\n\t\t\t\t\t\tdelayedTextStart = chunk;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.type === \"text-end\" && delayedTextStart) {\n\t\t\t\t\t\tcontroller.enqueue(delayedTextStart);\n\t\t\t\t\t\tdelayedTextStart = void 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.type !== \"text-delta\") {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (reasoningExtractions[chunk.id] == null) reasoningExtractions[chunk.id] = {\n\t\t\t\t\t\tisFirstReasoning: true,\n\t\t\t\t\t\tisFirstText: true,\n\t\t\t\t\t\tafterSwitch: false,\n\t\t\t\t\t\tisReasoning: startWithReasoning,\n\t\t\t\t\t\tbuffer: \"\",\n\t\t\t\t\t\tidCounter: 0,\n\t\t\t\t\t\ttextId: chunk.id\n\t\t\t\t\t};\n\t\t\t\t\tconst activeExtraction = reasoningExtractions[chunk.id];\n\t\t\t\t\tactiveExtraction.buffer += chunk.delta;\n\t\t\t\t\tfunction publish(text2) {\n\t\t\t\t\t\tif (text2.length > 0) {\n\t\t\t\t\t\t\tconst prefix = activeExtraction.afterSwitch && (activeExtraction.isReasoning ? !activeExtraction.isFirstReasoning : !activeExtraction.isFirstText) ? separator : \"\";\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning && (activeExtraction.afterSwitch || activeExtraction.isFirstReasoning)) controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-start\",\n\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter}`\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning) controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\t\tdelta: prefix + text2,\n\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter}`\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (delayedTextStart) {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(delayedTextStart);\n\t\t\t\t\t\t\t\t\tdelayedTextStart = void 0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\tdelta: prefix + text2,\n\t\t\t\t\t\t\t\t\tid: activeExtraction.textId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactiveExtraction.afterSwitch = false;\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning) activeExtraction.isFirstReasoning = false;\n\t\t\t\t\t\t\telse activeExtraction.isFirstText = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst nextTag = activeExtraction.isReasoning ? closingTag : openingTag;\n\t\t\t\t\t\tconst startIndex = getPotentialStartIndex(activeExtraction.buffer, nextTag);\n\t\t\t\t\t\tif (startIndex == null) {\n\t\t\t\t\t\t\tpublish(activeExtraction.buffer);\n\t\t\t\t\t\t\tactiveExtraction.buffer = \"\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpublish(activeExtraction.buffer.slice(0, startIndex));\n\t\t\t\t\t\tif (startIndex + nextTag.length <= activeExtraction.buffer.length) {\n\t\t\t\t\t\t\tactiveExtraction.buffer = activeExtraction.buffer.slice(startIndex + nextTag.length);\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning) controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-end\",\n\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter++}`\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tactiveExtraction.isReasoning = !activeExtraction.isReasoning;\n\t\t\t\t\t\t\tactiveExtraction.afterSwitch = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactiveExtraction.buffer = activeExtraction.buffer.slice(startIndex);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} while (true);\n\t\t\t\t} })),\n\t\t\t\t...rest\n\t\t\t};\n\t\t}\n\t};\n}\nfunction simulateStreamingMiddleware() {\n\treturn {\n\t\tmiddlewareVersion: \"v2\",\n\t\twrapStream: async ({ doGenerate }) => {\n\t\t\tconst result = await doGenerate();\n\t\t\tlet id = 0;\n\t\t\treturn {\n\t\t\t\tstream: new ReadableStream({ start(controller) {\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"stream-start\",\n\t\t\t\t\t\twarnings: result.warnings\n\t\t\t\t\t});\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"response-metadata\",\n\t\t\t\t\t\t...result.response\n\t\t\t\t\t});\n\t\t\t\t\tfor (const part of result.content) switch (part.type) {\n\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\tif (part.text.length > 0) {\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-start\",\n\t\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\t\tdelta: part.text\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-end\",\n\t\t\t\t\t\t\t\t\tid: String(id)\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tid++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"reasoning\":\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-start\",\n\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\tdelta: part.text\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-end\",\n\t\t\t\t\t\t\t\tid: String(id)\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tid++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault: controller.enqueue(part);\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: result.finishReason,\n\t\t\t\t\t\tusage: result.usage,\n\t\t\t\t\t\tproviderMetadata: result.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} }),\n\t\t\t\trequest: result.request,\n\t\t\t\tresponse: result.response\n\t\t\t};\n\t\t}\n\t};\n}\nvar wrapLanguageModel = ({ model, middleware: middlewareArg, modelId, providerId }) => {\n\treturn [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {\n\t\treturn doWrap({\n\t\t\tmodel: wrappedModel,\n\t\t\tmiddleware,\n\t\t\tmodelId,\n\t\t\tproviderId\n\t\t});\n\t}, model);\n};\nvar doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream, overrideProvider, overrideModelId, overrideSupportedUrls }, modelId, providerId }) => {\n\tvar _a16, _b, _c;\n\tasync function doTransform({ params, type }) {\n\t\treturn transformParams ? await transformParams({\n\t\t\tparams,\n\t\t\ttype,\n\t\t\tmodel\n\t\t}) : params;\n\t}\n\treturn {\n\t\tspecificationVersion: \"v2\",\n\t\tprovider: (_a16 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a16 : model.provider,\n\t\tmodelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,\n\t\tsupportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,\n\t\tasync doGenerate(params) {\n\t\t\tconst transformedParams = await doTransform({\n\t\t\t\tparams,\n\t\t\t\ttype: \"generate\"\n\t\t\t});\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\tconst doStream = async () => model.doStream(transformedParams);\n\t\t\treturn wrapGenerate ? wrapGenerate({\n\t\t\t\tdoGenerate,\n\t\t\t\tdoStream,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doGenerate();\n\t\t},\n\t\tasync doStream(params) {\n\t\t\tconst transformedParams = await doTransform({\n\t\t\t\tparams,\n\t\t\t\ttype: \"stream\"\n\t\t\t});\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\tconst doStream = async () => model.doStream(transformedParams);\n\t\t\treturn wrapStream ? wrapStream({\n\t\t\t\tdoGenerate,\n\t\t\t\tdoStream,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doStream();\n\t\t}\n\t};\n};\nfunction wrapProvider({ provider, languageModelMiddleware }) {\n\treturn {\n\t\tlanguageModel(modelId) {\n\t\t\tlet model = provider.languageModel(modelId);\n\t\t\tmodel = wrapLanguageModel({\n\t\t\t\tmodel,\n\t\t\t\tmiddleware: languageModelMiddleware\n\t\t\t});\n\t\t\treturn model;\n\t\t},\n\t\ttextEmbeddingModel: provider.textEmbeddingModel,\n\t\timageModel: provider.imageModel,\n\t\ttranscriptionModel: provider.transcriptionModel,\n\t\tspeechModel: provider.speechModel\n\t};\n}\nfunction customProvider({ languageModels, textEmbeddingModels, imageModels, transcriptionModels, speechModels, fallbackProvider }) {\n\treturn {\n\t\tlanguageModel(modelId) {\n\t\t\tif (languageModels != null && modelId in languageModels) return languageModels[modelId];\n\t\t\tif (fallbackProvider) return fallbackProvider.languageModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"languageModel\"\n\t\t\t});\n\t\t},\n\t\ttextEmbeddingModel(modelId) {\n\t\t\tif (textEmbeddingModels != null && modelId in textEmbeddingModels) return textEmbeddingModels[modelId];\n\t\t\tif (fallbackProvider) return fallbackProvider.textEmbeddingModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"textEmbeddingModel\"\n\t\t\t});\n\t\t},\n\t\timageModel(modelId) {\n\t\t\tif (imageModels != null && modelId in imageModels) return imageModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.imageModel) return fallbackProvider.imageModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"imageModel\"\n\t\t\t});\n\t\t},\n\t\ttranscriptionModel(modelId) {\n\t\t\tif (transcriptionModels != null && modelId in transcriptionModels) return transcriptionModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.transcriptionModel) return fallbackProvider.transcriptionModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"transcriptionModel\"\n\t\t\t});\n\t\t},\n\t\tspeechModel(modelId) {\n\t\t\tif (speechModels != null && modelId in speechModels) return speechModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.speechModel) return fallbackProvider.speechModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"speechModel\"\n\t\t\t});\n\t\t}\n\t};\n}\nvar experimental_customProvider = customProvider;\nvar name15 = \"AI_NoSuchProviderError\";\nvar marker15 = `vercel.ai.error.${name15}`;\nvar symbol15 = Symbol.for(marker15);\nvar _a15;\nvar NoSuchProviderError = class extends NoSuchModelError {\n\tconstructor({ modelId, modelType, providerId, availableProviders, message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})` }) {\n\t\tsuper({\n\t\t\terrorName: name15,\n\t\t\tmodelId,\n\t\t\tmodelType,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a15] = true;\n\t\tthis.providerId = providerId;\n\t\tthis.availableProviders = availableProviders;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker15);\n\t}\n};\n_a15 = symbol15;\nfunction createProviderRegistry(providers, { separator = \":\", languageModelMiddleware } = {}) {\n\tconst registry = new DefaultProviderRegistry({\n\t\tseparator,\n\t\tlanguageModelMiddleware\n\t});\n\tfor (const [id, provider] of Object.entries(providers)) registry.registerProvider({\n\t\tid,\n\t\tprovider\n\t});\n\treturn registry;\n}\nvar experimental_createProviderRegistry = createProviderRegistry;\nvar DefaultProviderRegistry = class {\n\tconstructor({ separator, languageModelMiddleware }) {\n\t\tthis.providers = /* @__PURE__ */ Object.create(null);\n\t\tthis.separator = separator;\n\t\tthis.languageModelMiddleware = languageModelMiddleware;\n\t}\n\tregisterProvider({ id, provider }) {\n\t\tthis.providers[id] = provider;\n\t}\n\tgetProvider(id, modelType) {\n\t\tconst provider = this.providers[id];\n\t\tif (provider == null) throw new NoSuchProviderError({\n\t\t\tmodelId: id,\n\t\t\tmodelType,\n\t\t\tproviderId: id,\n\t\t\tavailableProviders: Object.keys(this.providers)\n\t\t});\n\t\treturn provider;\n\t}\n\tsplitId(id, modelType) {\n\t\tconst index = id.indexOf(this.separator);\n\t\tif (index === -1) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType,\n\t\t\tmessage: `Invalid ${modelType} id for registry: ${id} (must be in the format \"providerId${this.separator}modelId\")`\n\t\t});\n\t\treturn [id.slice(0, index), id.slice(index + this.separator.length)];\n\t}\n\tlanguageModel(id) {\n\t\tvar _a16, _b;\n\t\tconst [providerId, modelId] = this.splitId(id, \"languageModel\");\n\t\tlet model = (_b = (_a16 = this.getProvider(providerId, \"languageModel\")).languageModel) == null ? void 0 : _b.call(_a16, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"languageModel\"\n\t\t});\n\t\tif (this.languageModelMiddleware != null) model = wrapLanguageModel({\n\t\t\tmodel,\n\t\t\tmiddleware: this.languageModelMiddleware\n\t\t});\n\t\treturn model;\n\t}\n\ttextEmbeddingModel(id) {\n\t\tvar _a16;\n\t\tconst [providerId, modelId] = this.splitId(id, \"textEmbeddingModel\");\n\t\tconst provider = this.getProvider(providerId, \"textEmbeddingModel\");\n\t\tconst model = (_a16 = provider.textEmbeddingModel) == null ? void 0 : _a16.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"textEmbeddingModel\"\n\t\t});\n\t\treturn model;\n\t}\n\timageModel(id) {\n\t\tvar _a16;\n\t\tconst [providerId, modelId] = this.splitId(id, \"imageModel\");\n\t\tconst provider = this.getProvider(providerId, \"imageModel\");\n\t\tconst model = (_a16 = provider.imageModel) == null ? void 0 : _a16.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"imageModel\"\n\t\t});\n\t\treturn model;\n\t}\n\ttranscriptionModel(id) {\n\t\tvar _a16;\n\t\tconst [providerId, modelId] = this.splitId(id, \"transcriptionModel\");\n\t\tconst provider = this.getProvider(providerId, \"transcriptionModel\");\n\t\tconst model = (_a16 = provider.transcriptionModel) == null ? void 0 : _a16.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"transcriptionModel\"\n\t\t});\n\t\treturn model;\n\t}\n\tspeechModel(id) {\n\t\tvar _a16;\n\t\tconst [providerId, modelId] = this.splitId(id, \"speechModel\");\n\t\tconst provider = this.getProvider(providerId, \"speechModel\");\n\t\tconst model = (_a16 = provider.speechModel) == null ? void 0 : _a16.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"speechModel\"\n\t\t});\n\t\treturn model;\n\t}\n};\nvar NoTranscriptGeneratedError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: \"AI_NoTranscriptGeneratedError\",\n\t\t\tmessage: \"No transcript generated.\"\n\t\t});\n\t\tthis.responses = options.responses;\n\t}\n};\nvar defaultDownload = createDownload();\nasync function transcribe({ model, audio, providerOptions = {}, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn = defaultDownload }) {\n\tif (model.specificationVersion !== \"v2\") throw new UnsupportedModelVersionError({\n\t\tversion: model.specificationVersion,\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst audioData = audio instanceof URL ? (await downloadFn({\n\t\turl: audio,\n\t\tabortSignal\n\t})).data : convertDataContentToUint8Array(audio);\n\tconst result = await retry(() => {\n\t\tvar _a16;\n\t\treturn model.doGenerate({\n\t\t\taudio: audioData,\n\t\t\tabortSignal,\n\t\t\theaders: headersWithUserAgent,\n\t\t\tproviderOptions,\n\t\t\tmediaType: (_a16 = detectMediaType({\n\t\t\t\tdata: audioData,\n\t\t\t\tsignatures: audioMediaTypeSignatures\n\t\t\t})) != null ? _a16 : \"audio/wav\"\n\t\t});\n\t});\n\tlogWarnings(result.warnings);\n\tif (!result.text) throw new NoTranscriptGeneratedError({ responses: [result.response] });\n\treturn new DefaultTranscriptionResult({\n\t\ttext: result.text,\n\t\tsegments: result.segments,\n\t\tlanguage: result.language,\n\t\tdurationInSeconds: result.durationInSeconds,\n\t\twarnings: result.warnings,\n\t\tresponses: [result.response],\n\t\tproviderMetadata: result.providerMetadata\n\t});\n}\nvar DefaultTranscriptionResult = class {\n\tconstructor(options) {\n\t\tvar _a16;\n\t\tthis.text = options.text;\n\t\tthis.segments = options.segments;\n\t\tthis.language = options.language;\n\t\tthis.durationInSeconds = options.durationInSeconds;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = (_a16 = options.providerMetadata) != null ? _a16 : {};\n\t}\n};\nasync function processTextStream({ stream, onTextPart }) {\n\tconst reader = stream.pipeThrough(new TextDecoderStream()).getReader();\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\tawait onTextPart(value);\n\t}\n}\nvar getOriginalFetch = () => fetch;\nasync function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol = \"data\", setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch: fetch2 = getOriginalFetch() }) {\n\tvar _a16;\n\ttry {\n\t\tsetLoading(true);\n\t\tsetError(void 0);\n\t\tconst abortController = new AbortController();\n\t\tsetAbortController(abortController);\n\t\tsetCompletion(\"\");\n\t\tconst response = await fetch2(api, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprompt,\n\t\t\t\t...body\n\t\t\t}),\n\t\t\tcredentials,\n\t\t\theaders: withUserAgentSuffix({\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t...headers\n\t\t\t}, `ai-sdk/${VERSION}`, getRuntimeEnvironmentUserAgent()),\n\t\t\tsignal: abortController.signal\n\t\t}).catch((err) => {\n\t\t\tthrow err;\n\t\t});\n\t\tif (!response.ok) throw new Error((_a16 = await response.text()) != null ? _a16 : \"Failed to fetch the chat response.\");\n\t\tif (!response.body) throw new Error(\"The response body is empty.\");\n\t\tlet result = \"\";\n\t\tswitch (streamProtocol) {\n\t\t\tcase \"text\":\n\t\t\t\tawait processTextStream({\n\t\t\t\t\tstream: response.body,\n\t\t\t\t\tonTextPart: (chunk) => {\n\t\t\t\t\t\tresult += chunk;\n\t\t\t\t\t\tsetCompletion(result);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"data\":\n\t\t\t\tawait consumeStream({\n\t\t\t\t\tstream: parseJsonEventStream({\n\t\t\t\t\t\tstream: response.body,\n\t\t\t\t\t\tschema: uiMessageChunkSchema\n\t\t\t\t\t}).pipeThrough(new TransformStream({ async transform(part) {\n\t\t\t\t\t\tif (!part.success) throw part.error;\n\t\t\t\t\t\tconst streamPart = part.value;\n\t\t\t\t\t\tif (streamPart.type === \"text-delta\") {\n\t\t\t\t\t\t\tresult += streamPart.delta;\n\t\t\t\t\t\t\tsetCompletion(result);\n\t\t\t\t\t\t} else if (streamPart.type === \"error\") throw new Error(streamPart.errorText);\n\t\t\t\t\t} })),\n\t\t\t\t\tonError: (error) => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tdefault: throw new Error(`Unknown stream protocol: ${streamProtocol}`);\n\t\t}\n\t\tif (onFinish) onFinish(prompt, result);\n\t\tsetAbortController(null);\n\t\treturn result;\n\t} catch (err) {\n\t\tif (err.name === \"AbortError\") {\n\t\t\tsetAbortController(null);\n\t\t\treturn null;\n\t\t}\n\t\tif (err instanceof Error) {\n\t\t\tif (onError) onError(err);\n\t\t}\n\t\tsetError(err);\n\t} finally {\n\t\tsetLoading(false);\n\t}\n}\nasync function convertFileListToFileUIParts(files) {\n\tif (files == null) return [];\n\tif (!globalThis.FileList || !(files instanceof globalThis.FileList)) throw new Error(\"FileList is not supported in the current environment\");\n\treturn Promise.all(Array.from(files).map(async (file) => {\n\t\tconst { name: name16, type } = file;\n\t\treturn {\n\t\t\ttype: \"file\",\n\t\t\tmediaType: type,\n\t\t\tfilename: name16,\n\t\t\turl: await new Promise((resolve2, reject) => {\n\t\t\t\tconst reader = new FileReader();\n\t\t\t\treader.onload = (readerEvent) => {\n\t\t\t\t\tvar _a16;\n\t\t\t\t\tresolve2((_a16 = readerEvent.target) == null ? void 0 : _a16.result);\n\t\t\t\t};\n\t\t\t\treader.onerror = (error) => reject(error);\n\t\t\t\treader.readAsDataURL(file);\n\t\t\t})\n\t\t};\n\t}));\n}\nfunction appendPathToUrl(url, path) {\n\tconst queryOrFragmentStart = url.search(/[?#]/);\n\tconst urlPath = queryOrFragmentStart === -1 ? url : url.slice(0, queryOrFragmentStart);\n\tconst suffix = queryOrFragmentStart === -1 ? \"\" : url.slice(queryOrFragmentStart);\n\treturn `${urlPath.endsWith(\"/\") && path.startsWith(\"/\") ? urlPath.slice(0, -1) : urlPath}${path}${suffix}`;\n}\nvar HttpChatTransport = class {\n\tconstructor({ api = \"/api/chat\", credentials, headers, body, fetch: fetch2, prepareSendMessagesRequest, prepareReconnectToStreamRequest }) {\n\t\tthis.api = api;\n\t\tthis.credentials = credentials;\n\t\tthis.headers = headers;\n\t\tthis.body = body;\n\t\tthis.fetch = fetch2;\n\t\tthis.prepareSendMessagesRequest = prepareSendMessagesRequest;\n\t\tthis.prepareReconnectToStreamRequest = prepareReconnectToStreamRequest;\n\t}\n\tasync sendMessages({ abortSignal, ...options }) {\n\t\tvar _a16, _b, _c, _d, _e;\n\t\tconst resolvedBody = await resolve(this.body);\n\t\tconst resolvedHeaders = await resolve(this.headers);\n\t\tconst resolvedCredentials = await resolve(this.credentials);\n\t\tconst baseHeaders = {\n\t\t\t...normalizeHeaders(resolvedHeaders),\n\t\t\t...normalizeHeaders(options.headers)\n\t\t};\n\t\tconst preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {\n\t\t\tapi: this.api,\n\t\t\tid: options.chatId,\n\t\t\tmessages: options.messages,\n\t\t\tbody: {\n\t\t\t\t...resolvedBody,\n\t\t\t\t...options.body\n\t\t\t},\n\t\t\theaders: baseHeaders,\n\t\t\tcredentials: resolvedCredentials,\n\t\t\trequestMetadata: options.metadata,\n\t\t\ttrigger: options.trigger,\n\t\t\tmessageId: options.messageId\n\t\t}));\n\t\tconst api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : this.api;\n\t\tconst headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? normalizeHeaders(preparedRequest.headers) : baseHeaders;\n\t\tconst body = (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : {\n\t\t\t...resolvedBody,\n\t\t\t...options.body,\n\t\t\tid: options.chatId,\n\t\t\tmessages: options.messages,\n\t\t\ttrigger: options.trigger,\n\t\t\tmessageId: options.messageId\n\t\t};\n\t\tconst credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : resolvedCredentials;\n\t\tconst response = await ((_d = this.fetch) != null ? _d : globalThis.fetch)(api, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t...headers\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t\tcredentials,\n\t\t\tsignal: abortSignal\n\t\t});\n\t\tif (!response.ok) throw new Error((_e = await response.text()) != null ? _e : \"Failed to fetch the chat response.\");\n\t\tif (!response.body) throw new Error(\"The response body is empty.\");\n\t\treturn this.processResponseStream(response.body);\n\t}\n\tasync reconnectToStream(options) {\n\t\tvar _a16, _b, _c, _d;\n\t\tconst resolvedBody = await resolve(this.body);\n\t\tconst resolvedHeaders = await resolve(this.headers);\n\t\tconst resolvedCredentials = await resolve(this.credentials);\n\t\tconst baseHeaders = {\n\t\t\t...normalizeHeaders(resolvedHeaders),\n\t\t\t...normalizeHeaders(options.headers)\n\t\t};\n\t\tconst preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {\n\t\t\tapi: this.api,\n\t\t\tid: options.chatId,\n\t\t\tbody: {\n\t\t\t\t...resolvedBody,\n\t\t\t\t...options.body\n\t\t\t},\n\t\t\theaders: baseHeaders,\n\t\t\tcredentials: resolvedCredentials,\n\t\t\trequestMetadata: options.metadata\n\t\t}));\n\t\tlet api = preparedRequest == null ? void 0 : preparedRequest.api;\n\t\tif (api == null) {\n\t\t\tif (options.chatId === \".\" || options.chatId === \"..\") throw new InvalidArgumentError({\n\t\t\t\tparameter: \"chatId\",\n\t\t\t\tvalue: options.chatId,\n\t\t\t\tmessage: \"Chat IDs must not be \\\".\\\" or \\\"..\\\" when using the default reconnect URL.\"\n\t\t\t});\n\t\t\tapi = appendPathToUrl(this.api, `/${encodeURIComponent(options.chatId)}/stream`);\n\t\t}\n\t\tconst headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? normalizeHeaders(preparedRequest.headers) : baseHeaders;\n\t\tconst credentials = (_b = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _b : resolvedCredentials;\n\t\tconst response = await ((_c = this.fetch) != null ? _c : globalThis.fetch)(api, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders,\n\t\t\tcredentials,\n\t\t\tsignal: options.abortSignal\n\t\t});\n\t\tif (response.status === 204) return null;\n\t\tif (!response.ok) throw new Error((_d = await response.text()) != null ? _d : \"Failed to fetch the chat response.\");\n\t\tif (!response.body) throw new Error(\"The response body is empty.\");\n\t\treturn this.processResponseStream(response.body);\n\t}\n};\nvar DefaultChatTransport = class extends HttpChatTransport {\n\tconstructor(options = {}) {\n\t\tsuper(options);\n\t}\n\tprocessResponseStream(stream) {\n\t\treturn parseJsonEventStream({\n\t\t\tstream,\n\t\t\tschema: uiMessageChunkSchema\n\t\t}).pipeThrough(new TransformStream({ async transform(chunk, controller) {\n\t\t\tif (!chunk.success) throw chunk.error;\n\t\t\tcontroller.enqueue(chunk.value);\n\t\t} }));\n\t}\n};\nvar AbstractChat = class {\n\tconstructor({ generateId: generateId3 = generateId, id = generateId3(), transport = new DefaultChatTransport(), messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, sendAutomaticallyWhen }) {\n\t\tthis.activeResponse = void 0;\n\t\tthis.activeResumeRequest = void 0;\n\t\tthis.resumableStreamState = void 0;\n\t\tthis.jobExecutor = new SerialJobExecutor();\n\t\tthis.activeStopCount = 0;\n\t\tthis.stopGeneration = 0;\n\t\t/**\n\t\t* Appends or replaces a user message to the chat list. This triggers the API call to fetch\n\t\t* the assistant's response.\n\t\t*\n\t\t* If a messageId is provided, the message will be replaced.\n\t\t*/\n\t\tthis.sendMessage = async (message, options) => {\n\t\t\tvar _a16, _b, _c, _d;\n\t\t\tif (message == null) {\n\t\t\t\tawait this.makeRequest({\n\t\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\t\tmessageId: (_a16 = this.lastMessage) == null ? void 0 : _a16.id,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet uiMessage;\n\t\t\tif (\"text\" in message || \"files\" in message) uiMessage = { parts: [...Array.isArray(message.files) ? message.files : await convertFileListToFileUIParts(message.files), ...\"text\" in message && message.text != null ? [{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: message.text\n\t\t\t}] : []] };\n\t\t\telse uiMessage = message;\n\t\t\tif (message.messageId != null) {\n\t\t\t\tconst messageIndex = this.state.messages.findIndex((m) => m.id === message.messageId);\n\t\t\t\tif (messageIndex === -1) throw new Error(`message with id ${message.messageId} not found`);\n\t\t\t\tif (this.state.messages[messageIndex].role !== \"user\") throw new Error(`message with id ${message.messageId} is not a user message`);\n\t\t\t\tthis.state.messages = this.state.messages.slice(0, messageIndex + 1);\n\t\t\t\tthis.state.replaceMessage(messageIndex, {\n\t\t\t\t\t...uiMessage,\n\t\t\t\t\tid: message.messageId,\n\t\t\t\t\trole: (_b = uiMessage.role) != null ? _b : \"user\",\n\t\t\t\t\tmetadata: message.metadata\n\t\t\t\t});\n\t\t\t} else this.state.pushMessage({\n\t\t\t\t...uiMessage,\n\t\t\t\tid: (_c = uiMessage.id) != null ? _c : this.generateId(),\n\t\t\t\trole: (_d = uiMessage.role) != null ? _d : \"user\",\n\t\t\t\tmetadata: message.metadata\n\t\t\t});\n\t\t\tawait this.makeRequest({\n\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\tmessageId: message.messageId,\n\t\t\t\t...options\n\t\t\t});\n\t\t};\n\t\t/**\n\t\t* Regenerate the assistant message with the provided message id.\n\t\t* If no message id is provided, the last assistant message will be regenerated.\n\t\t*/\n\t\tthis.regenerate = async ({ messageId, ...options } = {}) => {\n\t\t\tconst messageIndex = messageId == null ? this.state.messages.length - 1 : this.state.messages.findIndex((message) => message.id === messageId);\n\t\t\tif (messageIndex === -1) throw new Error(`message ${messageId} not found`);\n\t\t\tthis.state.messages = this.state.messages.slice(0, this.messages[messageIndex].role === \"assistant\" ? messageIndex : messageIndex + 1);\n\t\t\tawait this.makeRequest({\n\t\t\t\ttrigger: \"regenerate-message\",\n\t\t\t\tmessageId,\n\t\t\t\t...options\n\t\t\t});\n\t\t};\n\t\t/**\n\t\t* Attempt to resume an ongoing streaming response.\n\t\t*/\n\t\tthis.resumeStream = async (options = {}) => {\n\t\t\tawait this.makeRequest({\n\t\t\t\ttrigger: \"resume-stream\",\n\t\t\t\t...options\n\t\t\t});\n\t\t};\n\t\t/**\n\t\t* Resume the stream if the latest response ended with a resumable network\n\t\t* disconnect. If a response is still active, wait for it to settle first so\n\t\t* disconnects reported shortly after the caller's trigger are handled.\n\t\t*\n\t\t* @internal\n\t\t*/\n\t\tthis[\"~resumeStreamIfDisconnected\"] = async ({ shouldResume = () => true } = {}) => {\n\t\t\tconst activeResponse = this.activeResponse;\n\t\t\tif (this.resumableStreamState == null && activeResponse != null) {\n\t\t\t\tawait activeResponse.completionPromise;\n\t\t\t\tif (this.resumableStreamState !== activeResponse.state) return;\n\t\t\t}\n\t\t\tif (this.resumableStreamState != null && shouldResume()) await this.resumeStream();\n\t\t};\n\t\t/**\n\t\t* Clear the error state and set the status to ready if the chat is in an error state.\n\t\t*/\n\t\tthis.clearError = () => {\n\t\t\tif (this.status === \"error\") {\n\t\t\t\tthis.state.error = void 0;\n\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t}\n\t\t};\n\t\tthis.addToolOutput = async ({ state = \"output-available\", tool: tool2, toolCallId, output, errorText }) => this.jobExecutor.run(async () => {\n\t\t\tconst messages = this.state.messages;\n\t\t\tconst messageIndex = messages.findIndex((message) => message.parts.some((part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId));\n\t\t\tif (messageIndex !== -1) {\n\t\t\t\tconst message = messages[messageIndex];\n\t\t\t\tthis.state.replaceMessage(messageIndex, {\n\t\t\t\t\t...message,\n\t\t\t\t\tparts: message.parts.map((part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {\n\t\t\t\t\t\t...part,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\toutput,\n\t\t\t\t\t\terrorText\n\t\t\t\t\t} : part)\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (this.activeResponse) this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map((part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {\n\t\t\t\t...part,\n\t\t\t\tstate,\n\t\t\t\toutput,\n\t\t\t\terrorText\n\t\t\t} : part);\n\t\t\tif (messageIndex !== -1 && this.status !== \"streaming\" && this.status !== \"submitted\" && this.sendAutomaticallyWhen) {\n\t\t\t\tconst shouldSend = await this.shouldSendAutomatically();\n\t\t\t\tif (shouldSend) this.runAutomaticRequest(() => this.makeRequest({\n\t\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\t\tmessageId: messages[messageIndex].id\n\t\t\t\t}), shouldSend);\n\t\t\t}\n\t\t});\n\t\t/** @deprecated Use addToolOutput */\n\t\tthis.addToolResult = this.addToolOutput;\n\t\t/**\n\t\t* Abort the current request, keep the generated tokens if any, and wait for\n\t\t* the request pipeline to finish.\n\t\t*/\n\t\tthis.stop = async () => {\n\t\t\tthis.activeStopCount++;\n\t\t\tthis.stopGeneration++;\n\t\t\ttry {\n\t\t\t\tconst activeResumeRequest = this.activeResumeRequest;\n\t\t\t\tconst activeResponse = this.activeResponse;\n\t\t\t\tactiveResumeRequest?.abortController.abort();\n\t\t\t\tactiveResponse?.abortController.abort();\n\t\t\t\tawait Promise.all([activeResumeRequest == null ? void 0 : activeResumeRequest.completionPromise, activeResponse == null ? void 0 : activeResponse.completionPromise]);\n\t\t\t\tawait this.jobExecutor.waitForIdle();\n\t\t\t} finally {\n\t\t\t\tthis.activeStopCount--;\n\t\t\t}\n\t\t};\n\t\tthis.id = id;\n\t\tthis.transport = transport;\n\t\tthis.generateId = generateId3;\n\t\tthis.messageMetadataSchema = messageMetadataSchema;\n\t\tthis.dataPartSchemas = dataPartSchemas;\n\t\tthis.state = state;\n\t\tthis.onError = onError;\n\t\tthis.onToolCall = onToolCall;\n\t\tthis.onFinish = onFinish;\n\t\tthis.onData = onData;\n\t\tthis.sendAutomaticallyWhen = sendAutomaticallyWhen;\n\t}\n\t/**\n\t* Hook status:\n\t*\n\t* - `submitted`: The message has been sent to the API and we're awaiting the start of the response stream.\n\t* - `streaming`: The response is actively streaming in from the API, receiving chunks of data.\n\t* - `ready`: The full response has been received and processed; a new user message can be submitted.\n\t* - `error`: An error occurred during the API request, preventing successful completion.\n\t*/\n\tget status() {\n\t\treturn this.state.status;\n\t}\n\tsetStatus({ status, error }) {\n\t\tif (this.status === status) return;\n\t\tthis.state.status = status;\n\t\tthis.state.error = error;\n\t}\n\tget error() {\n\t\treturn this.state.error;\n\t}\n\tget messages() {\n\t\treturn this.state.messages;\n\t}\n\tget lastMessage() {\n\t\treturn this.state.messages[this.state.messages.length - 1];\n\t}\n\tset messages(messages) {\n\t\tthis.state.messages = messages;\n\t}\n\tasync shouldSendAutomatically() {\n\t\tif (!this.sendAutomaticallyWhen) return false;\n\t\tconst result = this.sendAutomaticallyWhen({ messages: this.state.messages });\n\t\tif (result && typeof result === \"object\" && \"then\" in result) return await result;\n\t\treturn result;\n\t}\n\tasync runAutomaticRequest(request, shouldSend) {\n\t\tconst stopGeneration = this.stopGeneration;\n\t\tconst startedWhileStopping = this.activeStopCount > 0;\n\t\tif (!(shouldSend != null ? shouldSend : await this.shouldSendAutomatically())) return;\n\t\tif (startedWhileStopping || stopGeneration !== this.stopGeneration || this.activeStopCount > 0) return;\n\t\tawait request();\n\t}\n\tasync makeRequest(options) {\n\t\tconst completion = createResolvablePromise();\n\t\ttry {\n\t\t\tawait this.makeRequestImpl({\n\t\t\t\t...options,\n\t\t\t\tcompletionPromise: completion.promise\n\t\t\t});\n\t\t} finally {\n\t\t\tcompletion.resolve();\n\t\t}\n\t}\n\tasync makeRequestImpl({ trigger, metadata, headers, body, messageId, completionPromise }) {\n\t\tvar _a16, _b;\n\t\tif (trigger !== \"resume-stream\") this.resumableStreamState = void 0;\n\t\tconst abortController = new AbortController();\n\t\tconst activeResumeRequest = trigger === \"resume-stream\" ? {\n\t\t\tabortController,\n\t\t\tcompletionPromise\n\t\t} : void 0;\n\t\tif (activeResumeRequest) {\n\t\t\t(_a16 = this.activeResumeRequest) == null || _a16.abortController.abort();\n\t\t\tthis.activeResumeRequest = activeResumeRequest;\n\t\t}\n\t\tconst isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;\n\t\tconst clearActiveResumeRequest = () => {\n\t\t\tif (this.activeResumeRequest === activeResumeRequest) this.activeResumeRequest = void 0;\n\t\t};\n\t\tthis.setStatus({\n\t\t\tstatus: \"submitted\",\n\t\t\terror: void 0\n\t\t});\n\t\tconst lastMessage = this.lastMessage;\n\t\tconst responseMessageIndex = trigger === \"submit-message\" && messageId != null ? this.state.messages.findIndex((message) => message.id === messageId) : this.state.messages.length - 1;\n\t\tconst responseMessage = responseMessageIndex === -1 ? lastMessage : this.state.messages[responseMessageIndex];\n\t\tconst originalResponseMessageId = responseMessage == null ? void 0 : responseMessage.id;\n\t\tconst resumableResponseMessage = trigger === \"resume-stream\" && (lastMessage == null ? void 0 : lastMessage.role) === \"assistant\" && lastMessage.parts.some((part) => isToolOrDynamicToolUIPart(part) && part.state === \"input-streaming\") ? this.state.snapshot(lastMessage) : void 0;\n\t\tconst usesEarlierAssistantMessage = responseMessageIndex !== -1 && responseMessageIndex < this.state.messages.length - 1 && (responseMessage == null ? void 0 : responseMessage.role) === \"assistant\";\n\t\tlet isAbort = false;\n\t\tlet isDisconnect = false;\n\t\tlet isError = false;\n\t\tlet activeResponse;\n\t\ttry {\n\t\t\tconst response = {\n\t\t\t\tstate: trigger === \"resume-stream\" && this.resumableStreamState != null ? this.resumableStreamState : createStreamingUIMessageState({\n\t\t\t\t\tlastMessage: trigger === \"resume-stream\" ? resumableResponseMessage : this.state.snapshot(responseMessage),\n\t\t\t\t\tmessageId: this.generateId()\n\t\t\t\t}),\n\t\t\t\tabortController,\n\t\t\t\tcompletionPromise\n\t\t\t};\n\t\t\tactiveResponse = response;\n\t\t\tresponse.abortController.signal.addEventListener(\"abort\", () => {\n\t\t\t\tisAbort = true;\n\t\t\t});\n\t\t\tthis.activeResponse = response;\n\t\t\tlet stream;\n\t\t\tif (trigger === \"resume-stream\") {\n\t\t\t\tconst reconnect = await this.transport.reconnectToStream({\n\t\t\t\t\tchatId: this.id,\n\t\t\t\t\tabortSignal: abortController.signal,\n\t\t\t\t\tmetadata,\n\t\t\t\t\theaders,\n\t\t\t\t\tbody\n\t\t\t\t});\n\t\t\t\tif (abortController.signal.aborted || !isCurrentRequest()) {\n\t\t\t\t\tawait (reconnect == null ? void 0 : reconnect.cancel().catch(() => {}));\n\t\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\t\tthis.resumableStreamState = void 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (reconnect == null) {\n\t\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\t\tthis.resumableStreamState = void 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tstream = reconnect;\n\t\t\t} else stream = await this.transport.sendMessages({\n\t\t\t\tchatId: this.id,\n\t\t\t\tmessages: this.state.messages,\n\t\t\t\tabortSignal: response.abortController.signal,\n\t\t\t\tmetadata,\n\t\t\t\theaders,\n\t\t\t\tbody,\n\t\t\t\ttrigger,\n\t\t\t\tmessageId\n\t\t\t});\n\t\t\tconst runUpdateMessageJob = (job) => this.jobExecutor.run(() => {\n\t\t\t\tif (response.abortController.signal.aborted) return Promise.resolve();\n\t\t\t\treturn job({\n\t\t\t\t\tstate: response.state,\n\t\t\t\t\twrite: ({ updateStatus = true } = {}) => {\n\t\t\t\t\t\tif (response.abortController.signal.aborted) return;\n\t\t\t\t\t\tif (updateStatus) this.setStatus({ status: \"streaming\" });\n\t\t\t\t\t\tconst existingMessageIndex = this.state.messages.findLastIndex((message) => message.id === response.state.message.id);\n\t\t\t\t\t\tif (existingMessageIndex !== -1) this.state.replaceMessage(existingMessageIndex, response.state.message);\n\t\t\t\t\t\telse if (usesEarlierAssistantMessage) {\n\t\t\t\t\t\t\tconst originalMessageIndex = this.state.messages.findLastIndex((message) => message.id === originalResponseMessageId);\n\t\t\t\t\t\t\tif (originalMessageIndex !== -1) this.state.replaceMessage(originalMessageIndex, response.state.message);\n\t\t\t\t\t\t\telse this.state.pushMessage(response.state.message);\n\t\t\t\t\t\t} else this.state.pushMessage(response.state.message);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t\tawait consumeStream({\n\t\t\t\tstream: processUIMessageStream({\n\t\t\t\t\tstream,\n\t\t\t\t\tonToolCall: this.onToolCall,\n\t\t\t\t\tonData: this.onData,\n\t\t\t\t\tmessageMetadataSchema: this.messageMetadataSchema,\n\t\t\t\t\tdataPartSchemas: this.dataPartSchemas,\n\t\t\t\t\trunUpdateMessageJob,\n\t\t\t\t\tonError: (error) => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tabortSignal: response.abortController.signal,\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (isAbort) {\n\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\tif (this.resumableStreamState === response.state) this.resumableStreamState = void 0;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (isCurrentRequest()) {\n\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\tif (this.resumableStreamState === response.state) this.resumableStreamState = void 0;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (isAbort || err.name === \"AbortError\") {\n\t\t\t\tisAbort = true;\n\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\tif (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) this.resumableStreamState = void 0;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!isCurrentRequest()) return null;\n\t\t\tisError = true;\n\t\t\tif (err instanceof TypeError && (err.message.toLowerCase().includes(\"fetch\") || err.message.toLowerCase().includes(\"network\"))) isDisconnect = true;\n\t\t\tif (isDisconnect) this.resumableStreamState = activeResponse == null ? void 0 : activeResponse.state;\n\t\t\telse if (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) this.resumableStreamState = void 0;\n\t\t\tif (this.onError && err instanceof Error) this.onError(err);\n\t\t\tthis.setStatus({\n\t\t\t\tstatus: \"error\",\n\t\t\t\terror: err\n\t\t\t});\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif (activeResponse) (_b = this.onFinish) == null || _b.call(this, {\n\t\t\t\t\tmessage: activeResponse.state.message,\n\t\t\t\t\tmessages: this.state.messages,\n\t\t\t\t\tisAbort,\n\t\t\t\t\tisDisconnect,\n\t\t\t\t\tisError,\n\t\t\t\t\tfinishReason: activeResponse.state.finishReason\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tif (this.activeResponse === activeResponse) this.activeResponse = void 0;\n\t\t\t\tclearActiveResumeRequest();\n\t\t\t}\n\t\t}\n\t\tif (!isAbort && !isError) await this.runAutomaticRequest(() => {\n\t\t\tvar _a17;\n\t\t\treturn this.makeRequest({\n\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\tmessageId: (_a17 = this.lastMessage) == null ? void 0 : _a17.id,\n\t\t\t\tmetadata,\n\t\t\t\theaders,\n\t\t\t\tbody\n\t\t\t});\n\t\t});\n\t}\n};\nfunction lastAssistantMessageIsCompleteWithToolCalls({ messages }) {\n\tconst message = messages[messages.length - 1];\n\tif (!message) return false;\n\tif (message.role !== \"assistant\") return false;\n\tconst lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {\n\t\treturn part.type === \"step-start\" ? index : lastIndex;\n\t}, -1);\n\tconst lastStepParts = message.parts.slice(lastStepStartIndex + 1);\n\tconst lastStepToolInvocations = lastStepParts.filter(isToolOrDynamicToolUIPart).filter((part) => !part.providerExecuted);\n\tconst lastToolInvocationIndex = lastStepParts.reduce((lastIndex, part, index) => isToolOrDynamicToolUIPart(part) && !part.providerExecuted ? index : lastIndex, -1);\n\treturn lastStepToolInvocations.length > 0 && !lastStepParts.slice(lastToolInvocationIndex + 1).some((part) => part.type === \"text\" && part.state !== \"done\") && lastStepToolInvocations.every((part) => part.state === \"output-available\" || part.state === \"output-error\");\n}\nfunction transformTextToUiMessageStream({ stream }) {\n\treturn stream.pipeThrough(new TransformStream({\n\t\tstart(controller) {\n\t\t\tcontroller.enqueue({ type: \"start\" });\n\t\t\tcontroller.enqueue({ type: \"start-step\" });\n\t\t\tcontroller.enqueue({\n\t\t\t\ttype: \"text-start\",\n\t\t\t\tid: \"text-1\"\n\t\t\t});\n\t\t},\n\t\tasync transform(part, controller) {\n\t\t\tcontroller.enqueue({\n\t\t\t\ttype: \"text-delta\",\n\t\t\t\tid: \"text-1\",\n\t\t\t\tdelta: part\n\t\t\t});\n\t\t},\n\t\tasync flush(controller) {\n\t\t\tcontroller.enqueue({\n\t\t\t\ttype: \"text-end\",\n\t\t\t\tid: \"text-1\"\n\t\t\t});\n\t\t\tcontroller.enqueue({ type: \"finish-step\" });\n\t\t\tcontroller.enqueue({ type: \"finish\" });\n\t\t}\n\t}));\n}\nvar TextStreamChatTransport = class extends HttpChatTransport {\n\tconstructor(options = {}) {\n\t\tsuper(options);\n\t}\n\tprocessResponseStream(stream) {\n\t\treturn transformTextToUiMessageStream({ stream: stream.pipeThrough(new TextDecoderStream()) });\n\t}\n};\nfunction isEmptyObject(value) {\n\treturn value != null && typeof value === \"object\" && !Array.isArray(value) && Object.keys(value).length === 0;\n}\nfunction asDynamicToolPart(toolPart) {\n\tconst common = {\n\t\ttype: \"dynamic-tool\",\n\t\ttoolName: toolPart.type.slice(5),\n\t\ttoolCallId: toolPart.toolCallId,\n\t\t...toolPart.providerExecuted === void 0 ? {} : { providerExecuted: toolPart.providerExecuted },\n\t\t...toolPart.callProviderMetadata === void 0 ? {} : { callProviderMetadata: toolPart.callProviderMetadata }\n\t};\n\tif (toolPart.state === \"output-available\") return markToolPartAsUnavailable({\n\t\t...common,\n\t\tstate: \"output-available\",\n\t\tinput: toolPart.input,\n\t\toutput: toolPart.output,\n\t\t...toolPart.preliminary === void 0 ? {} : { preliminary: toolPart.preliminary }\n\t});\n\treturn markToolPartAsUnavailable({\n\t\t...common,\n\t\tstate: \"output-error\",\n\t\tinput: toolPart.input,\n\t\terrorText: toolPart.errorText\n\t});\n}\nvar uiMessagesSchema = lazyValidator(() => zodSchema(z.array(z.object({\n\tid: z.string(),\n\trole: z.enum([\n\t\t\"system\",\n\t\t\"user\",\n\t\t\"assistant\"\n\t]),\n\tmetadata: z.unknown().optional(),\n\tparts: z.array(z.union([\n\t\tz.object({\n\t\t\ttype: z.literal(\"text\"),\n\t\t\ttext: z.string(),\n\t\t\tstate: z.enum([\"streaming\", \"done\"]).optional(),\n\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"reasoning\"),\n\t\t\tid: z.string().optional(),\n\t\t\ttext: z.string(),\n\t\t\tstate: z.enum([\"streaming\", \"done\"]).optional(),\n\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"source-url\"),\n\t\t\tsourceId: z.string(),\n\t\t\turl: z.string(),\n\t\t\ttitle: z.string().optional(),\n\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"source-document\"),\n\t\t\tsourceId: z.string(),\n\t\t\tmediaType: z.string(),\n\t\t\ttitle: z.string(),\n\t\t\tfilename: z.string().optional(),\n\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"file\"),\n\t\t\tmediaType: z.string(),\n\t\t\tfilename: z.string().optional(),\n\t\t\turl: z.string(),\n\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({ type: z.literal(\"step-start\") }),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"data-\"),\n\t\t\tid: z.string().optional(),\n\t\t\tdata: z.unknown()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\tdynamic: z.literal(false).optional(),\n\t\t\ttoolName: z.string(),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"input-streaming\"),\n\t\t\tinput: z.unknown().optional(),\n\t\t\trawInput: z.string().optional(),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\tdynamic: z.literal(false).optional(),\n\t\t\ttoolName: z.string(),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"input-available\"),\n\t\t\tinput: z.unknown(),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\tdynamic: z.literal(false).optional(),\n\t\t\ttoolName: z.string(),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"output-available\"),\n\t\t\tinput: z.unknown(),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\toutput: z.unknown(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tpreliminary: z.boolean().optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\tdynamic: z.literal(false).optional(),\n\t\t\ttoolName: z.string(),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"output-error\"),\n\t\t\tinput: z.unknown().optional(),\n\t\t\trawInput: z.unknown().optional(),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.string(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"input-streaming\"),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\tinput: z.unknown().optional(),\n\t\t\trawInput: z.string().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tapproval: z.never().optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"input-available\"),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\tinput: z.unknown(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tapproval: z.never().optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"approval-requested\"),\n\t\t\tinput: z.unknown(),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tapproval: z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tapproved: z.never().optional(),\n\t\t\t\treason: z.never().optional()\n\t\t\t})\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"approval-responded\"),\n\t\t\tinput: z.unknown(),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tapproval: z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tapproved: z.boolean(),\n\t\t\t\treason: z.string().optional()\n\t\t\t})\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"output-available\"),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\tinput: z.unknown(),\n\t\t\toutput: z.unknown(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tpreliminary: z.boolean().optional(),\n\t\t\tapproval: z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tapproved: z.literal(true),\n\t\t\t\treason: z.string().optional()\n\t\t\t}).optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"output-error\"),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\tinput: z.unknown().optional(),\n\t\t\trawInput: z.unknown().optional(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.string(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tapproval: z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tapproved: z.literal(true),\n\t\t\t\treason: z.string().optional()\n\t\t\t}).optional()\n\t\t}),\n\t\tz.object({\n\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\ttoolCallId: z.string(),\n\t\t\tstate: z.literal(\"output-denied\"),\n\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\tinput: z.unknown(),\n\t\t\toutput: z.never().optional(),\n\t\t\terrorText: z.never().optional(),\n\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\tapproval: z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tapproved: z.literal(false),\n\t\t\t\treason: z.string().optional()\n\t\t\t})\n\t\t})\n\t]))\n}).superRefine((message, context) => {\n\tif (message.role !== \"assistant\" && message.parts.length === 0) context.addIssue({\n\t\torigin: \"array\",\n\t\tcode: \"too_small\",\n\t\tminimum: 1,\n\t\tinclusive: true,\n\t\tinput: message.parts,\n\t\tpath: [\"parts\"],\n\t\tmessage: \"Message must contain at least one part\"\n\t});\n})).nonempty(\"Messages array must not be empty\")));\nasync function safeValidateUIMessages({ messages, metadataSchema, dataSchemas, tools }) {\n\ttry {\n\t\tif (messages == null) return {\n\t\t\tsuccess: false,\n\t\t\terror: new InvalidArgumentError({\n\t\t\t\tparameter: \"messages\",\n\t\t\t\tvalue: messages,\n\t\t\t\tmessage: \"messages parameter must be provided\"\n\t\t\t})\n\t\t};\n\t\tconst validatedMessages = await validateTypes({\n\t\t\tvalue: messages,\n\t\t\tschema: uiMessagesSchema\n\t\t});\n\t\tfor (const message of validatedMessages) for (const part of message.parts) {\n\t\t\tif (part.type !== \"dynamic-tool\" && !part.type.startsWith(\"tool-\")) continue;\n\t\t\tconst toolPart = part;\n\t\t\tif (toolPart.state === \"output-error\" && !(\"input\" in toolPart)) toolPart.input = void 0;\n\t\t}\n\t\tif (metadataSchema) for (const message of validatedMessages) message.metadata = await validateTypes({\n\t\t\tvalue: message.metadata,\n\t\t\tschema: metadataSchema\n\t\t});\n\t\tif (dataSchemas) for (const message of validatedMessages) {\n\t\t\tconst dataParts = message.parts.filter((part) => part.type.startsWith(\"data-\"));\n\t\t\tfor (const dataPart of dataParts) {\n\t\t\t\tconst dataName = dataPart.type.slice(5);\n\t\t\t\tconst dataSchema = dataSchemas[dataName];\n\t\t\t\tif (!dataSchema) return {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\t\tvalue: dataPart.data,\n\t\t\t\t\t\tcause: `No data schema found for data part ${dataName}`\n\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t\tdataPart.data = await validateTypes({\n\t\t\t\t\tvalue: dataPart.data,\n\t\t\t\t\tschema: dataSchema\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (tools) for (const message of validatedMessages) for (const [partIdx, part] of message.parts.entries()) {\n\t\t\tif (!part.type.startsWith(\"tool-\")) continue;\n\t\t\tconst toolPart = part;\n\t\t\tconst toolName = toolPart.type.slice(5);\n\t\t\tconst tool2 = getOwn(tools, toolName);\n\t\t\tif (!tool2 && (toolPart.state === \"output-available\" || toolPart.state === \"output-error\")) {\n\t\t\t\tmessage.parts[partIdx] = asDynamicToolPart(toolPart);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!tool2) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue: toolPart.input,\n\t\t\t\t\tcause: `No tool schema found for tool part ${toolName}`\n\t\t\t\t})\n\t\t\t};\n\t\t\tlet dynamicToolPart;\n\t\t\tif (toolPart.state === \"output-error\") {\n\t\t\t\tif (toolPart.input !== void 0) {\n\t\t\t\t\tif (!(await safeValidateTypes({\n\t\t\t\t\t\tvalue: toolPart.input,\n\t\t\t\t\t\tschema: tool2.inputSchema\n\t\t\t\t\t})).success) dynamicToolPart = asDynamicToolPart(toolPart);\n\t\t\t\t}\n\t\t\t} else if (toolPart.state === \"output-available\") {\n\t\t\t\tconst result = await safeValidateTypes({\n\t\t\t\t\tvalue: toolPart.input,\n\t\t\t\t\tschema: tool2.inputSchema\n\t\t\t\t});\n\t\t\t\tif (!result.success) {\n\t\t\t\t\tif (isEmptyObject(toolPart.input)) dynamicToolPart = asDynamicToolPart(toolPart);\n\t\t\t\t\telse throw result.error;\n\t\t\t\t}\n\t\t\t} else if (toolPart.state === \"input-available\") await validateTypes({\n\t\t\t\tvalue: toolPart.input,\n\t\t\t\tschema: tool2.inputSchema\n\t\t\t});\n\t\t\tif (toolPart.state === \"output-available\" && tool2.outputSchema) await validateTypes({\n\t\t\t\tvalue: toolPart.output,\n\t\t\t\tschema: tool2.outputSchema\n\t\t\t});\n\t\t\tif (dynamicToolPart) message.parts[partIdx] = dynamicToolPart;\n\t\t}\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: validatedMessages\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror\n\t\t};\n\t}\n}\nasync function validateUIMessages(options) {\n\tconst response = await safeValidateUIMessages(options);\n\tif (!response.success) throw response.error;\n\treturn response.data;\n}\nfunction createUIMessageStream({ execute, onError = () => \"An error occurred.\", originalMessages, onFinish, generateId: generateId3 = generateId }) {\n\tlet controller;\n\tconst ongoingStreamPromises = [];\n\tlet outcome = { status: \"unknown\" };\n\tconst stream = new ReadableStream({ start(controllerArg) {\n\t\tcontroller = controllerArg;\n\t} });\n\tfunction safeEnqueue(data) {\n\t\ttry {\n\t\t\tcontroller.enqueue(data);\n\t\t} catch (error) {}\n\t}\n\tfunction setOutcome(newOutcome) {\n\t\tif (outcome.status === \"unknown\" && newOutcome.status !== \"unknown\") outcome = newOutcome;\n\t}\n\tfunction failOutcome(error) {\n\t\toutcome = {\n\t\t\tstatus: \"failed\",\n\t\t\terror\n\t\t};\n\t}\n\tfunction safeError(error) {\n\t\ttry {\n\t\t\tcontroller.error(error);\n\t\t} catch (e) {}\n\t}\n\tfunction handleError(error) {\n\t\tfailOutcome(error);\n\t\tlet errorText;\n\t\ttry {\n\t\t\terrorText = onError(error);\n\t\t} catch (onErrorError) {\n\t\t\tfailOutcome(onErrorError);\n\t\t\tsafeError(onErrorError);\n\t\t\treturn;\n\t\t}\n\t\tsafeEnqueue({\n\t\t\ttype: \"error\",\n\t\t\terrorText\n\t\t});\n\t}\n\ttry {\n\t\tconst result = execute({ writer: {\n\t\t\twrite(part) {\n\t\t\t\tsafeEnqueue(part);\n\t\t\t},\n\t\t\tmerge(streamArg) {\n\t\t\t\tongoingStreamPromises.push((async () => {\n\t\t\t\t\tconst reader = streamArg.getReader();\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\tif (done) break;\n\t\t\t\t\t\tsafeEnqueue(value);\n\t\t\t\t\t}\n\t\t\t\t})().catch((error) => {\n\t\t\t\t\thandleError(error);\n\t\t\t\t}));\n\t\t\t},\n\t\t\tsetOutcome,\n\t\t\tonError\n\t\t} });\n\t\tif (result) ongoingStreamPromises.push(result.catch((error) => {\n\t\t\thandleError(error);\n\t\t}));\n\t} catch (error) {\n\t\thandleError(error);\n\t}\n\t(async () => {\n\t\twhile (ongoingStreamPromises.length > 0) await ongoingStreamPromises.shift();\n\t})().finally(() => {\n\t\ttry {\n\t\t\tcontroller.close();\n\t\t} catch (error) {}\n\t});\n\treturn handleUIMessageStreamFinish({\n\t\tstream,\n\t\tmessageId: generateId3(),\n\t\toriginalMessages,\n\t\tonFinish,\n\t\tonError,\n\t\tgetOutcome: () => outcome\n\t});\n}\nfunction createUIMessageSnapshot(message) {\n\tconst textByPartIndex = /* @__PURE__ */ new Map();\n\tconst messageWithoutText = {\n\t\t...message,\n\t\tparts: message.parts.map((part, index) => {\n\t\t\tif (part.type === \"text\" || part.type === \"reasoning\") {\n\t\t\t\ttextByPartIndex.set(index, part.text);\n\t\t\t\treturn {\n\t\t\t\t\t...part,\n\t\t\t\t\ttext: \"\"\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn part;\n\t\t})\n\t};\n\tconst snapshot = structuredClone(messageWithoutText);\n\tfor (const [index, text2] of textByPartIndex) {\n\t\tconst part = snapshot.parts[index];\n\t\tif (part.type === \"text\" || part.type === \"reasoning\") part.text = text2;\n\t}\n\treturn snapshot;\n}\nfunction readUIMessageStream({ message, stream, onError, terminateOnError = false }) {\n\tvar _a16;\n\tlet controller;\n\tlet hasErrored = false;\n\tlet isCancelled = false;\n\tconst abortController = new AbortController();\n\tconst outputStream = new ReadableStream({\n\t\tstart(controllerParam) {\n\t\t\tcontroller = controllerParam;\n\t\t},\n\t\tcancel() {\n\t\t\tisCancelled = true;\n\t\t\tabortController.abort();\n\t\t}\n\t});\n\tconst state = createStreamingUIMessageState({\n\t\tmessageId: (_a16 = message == null ? void 0 : message.id) != null ? _a16 : \"\",\n\t\tlastMessage: message\n\t});\n\tconst handleError = (error) => {\n\t\tonError?.(error);\n\t\tif (!hasErrored && terminateOnError) {\n\t\t\thasErrored = true;\n\t\t\tcontroller?.error(error);\n\t\t}\n\t};\n\tconsumeStream({\n\t\tstream: processUIMessageStream({\n\t\t\tstream,\n\t\t\tresetStateOnMessageIdChange: true,\n\t\t\trunUpdateMessageJob(job) {\n\t\t\t\treturn job({\n\t\t\t\t\tstate,\n\t\t\t\t\twrite: () => {\n\t\t\t\t\t\tif (!isCancelled) controller?.enqueue(createUIMessageSnapshot(state.message));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tonError: handleError\n\t\t}),\n\t\tonError: handleError,\n\t\tabortSignal: abortController.signal\n\t}).finally(() => {\n\t\tif (!hasErrored && !isCancelled) controller?.close();\n\t});\n\treturn createAsyncIterableStream(outputStream);\n}\n//#endregion\n//#region src/index.ts\nconst generateText = (options) => generateText$1({\n\t...options,\n\tallowSystemInMessages: false\n});\nconst streamText = (options) => streamText$1({\n\t...options,\n\tallowSystemInMessages: false\n});\n//#endregion\nexport { AISDKError, APICallError, AbstractChat, DefaultChatTransport, DownloadError, EmptyResponseBodyError, Agent as Experimental_Agent, HttpChatTransport, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidPromptError, InvalidResponseDataError, InvalidStreamPartError, InvalidToolInputError, JSONParseError, JsonToSseTransformStream, LoadAPIKeyError, LoadSettingError, MessageConversionError, NoContentGeneratedError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, output_exports as Output, RetryError, SerialJobExecutor, TextStreamChatTransport, TooManyEmbeddingValuesForCallError, ToolCallRepairError, TypeValidationError, UI_MESSAGE_STREAM_HEADERS, UnsupportedFunctionalityError, UnsupportedModelVersionError, asSchema, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDownload, createGatewayProvider as createGateway, createIdGenerator, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, dynamicTool, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, gateway, generateId, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, jsonSchema, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parseJsonEventStream, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider, zodSchema };\n\n//# sourceMappingURL=index.js.map","//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider/1.1.3/7d8eaddb7973e5820d04ac18a887c85cc63f173732e3c66432ceefbff819b4ac/node_modules/@ai-sdk/provider/dist/index.mjs\nvar marker = \"vercel.ai.error\";\nvar symbol = Symbol.for(marker);\nvar _a;\nvar _AISDKError = class _AISDKError extends Error {\n\t/**\n\t* Creates an AI SDK Error.\n\t*\n\t* @param {Object} params - The parameters for creating the error.\n\t* @param {string} params.name - The name of the error.\n\t* @param {string} params.message - The error message.\n\t* @param {unknown} [params.cause] - The underlying cause of the error.\n\t*/\n\tconstructor({ name: name14, message, cause }) {\n\t\tsuper(message);\n\t\tthis[_a] = true;\n\t\tthis.name = name14;\n\t\tthis.cause = cause;\n\t}\n\t/**\n\t* Checks if the given error is an AI SDK Error.\n\t* @param {unknown} error - The error to check.\n\t* @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n\t*/\n\tstatic isInstance(error) {\n\t\treturn _AISDKError.hasMarker(error, marker);\n\t}\n\tstatic hasMarker(error, marker15) {\n\t\tconst markerSymbol = Symbol.for(marker15);\n\t\treturn error != null && typeof error === \"object\" && markerSymbol in error && typeof error[markerSymbol] === \"boolean\" && error[markerSymbol] === true;\n\t}\n};\n_a = symbol;\nvar AISDKError = _AISDKError;\nvar name = \"AI_APICallError\";\nvar marker2 = `vercel.ai.error.${name}`;\nvar symbol2 = Symbol.for(marker2);\nvar _a2;\nvar APICallError = class extends AISDKError {\n\tconstructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {\n\t\tsuper({\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a2] = true;\n\t\tthis.url = url;\n\t\tthis.requestBodyValues = requestBodyValues;\n\t\tthis.statusCode = statusCode;\n\t\tthis.responseHeaders = responseHeaders;\n\t\tthis.responseBody = responseBody;\n\t\tthis.isRetryable = isRetryable;\n\t\tthis.data = data;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker2);\n\t}\n};\n_a2 = symbol2;\nvar name2 = \"AI_EmptyResponseBodyError\";\nvar marker3 = `vercel.ai.error.${name2}`;\nvar symbol3 = Symbol.for(marker3);\nvar _a3;\nvar EmptyResponseBodyError = class extends AISDKError {\n\tconstructor({ message = \"Empty response body\" } = {}) {\n\t\tsuper({\n\t\t\tname: name2,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a3] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker3);\n\t}\n};\n_a3 = symbol3;\nfunction getErrorMessage(error) {\n\tif (error == null) return \"unknown error\";\n\tif (typeof error === \"string\") return error;\n\tif (error instanceof Error) return error.message;\n\treturn JSON.stringify(error);\n}\nvar name3 = \"AI_InvalidArgumentError\";\nvar marker4 = `vercel.ai.error.${name3}`;\nvar symbol4 = Symbol.for(marker4);\nvar _a4;\nvar InvalidArgumentError = class extends AISDKError {\n\tconstructor({ message, cause, argument }) {\n\t\tsuper({\n\t\t\tname: name3,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a4] = true;\n\t\tthis.argument = argument;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker4);\n\t}\n};\n_a4 = symbol4;\nvar name4 = \"AI_InvalidPromptError\";\nvar marker5 = `vercel.ai.error.${name4}`;\nvar symbol5 = Symbol.for(marker5);\nvar _a5;\nvar InvalidPromptError = class extends AISDKError {\n\tconstructor({ prompt, message, cause }) {\n\t\tsuper({\n\t\t\tname: name4,\n\t\t\tmessage: `Invalid prompt: ${message}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a5] = true;\n\t\tthis.prompt = prompt;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker5);\n\t}\n};\n_a5 = symbol5;\nvar name5 = \"AI_InvalidResponseDataError\";\nvar marker6 = `vercel.ai.error.${name5}`;\nvar symbol6 = Symbol.for(marker6);\nvar _a6;\nvar InvalidResponseDataError = class extends AISDKError {\n\tconstructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {\n\t\tsuper({\n\t\t\tname: name5,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a6] = true;\n\t\tthis.data = data;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker6);\n\t}\n};\n_a6 = symbol6;\nvar name6 = \"AI_JSONParseError\";\nvar marker7 = `vercel.ai.error.${name6}`;\nvar symbol7 = Symbol.for(marker7);\nvar _a7;\nvar JSONParseError = class extends AISDKError {\n\tconstructor({ text, cause }) {\n\t\tsuper({\n\t\t\tname: name6,\n\t\t\tmessage: `JSON parsing failed: Text: ${text}.\nError message: ${getErrorMessage(cause)}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a7] = true;\n\t\tthis.text = text;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker7);\n\t}\n};\n_a7 = symbol7;\nvar name7 = \"AI_LoadAPIKeyError\";\nvar marker8 = `vercel.ai.error.${name7}`;\nvar symbol8 = Symbol.for(marker8);\nvar _a8;\nvar LoadAPIKeyError = class extends AISDKError {\n\tconstructor({ message }) {\n\t\tsuper({\n\t\t\tname: name7,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a8] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker8);\n\t}\n};\n_a8 = symbol8;\nvar name9 = \"AI_NoContentGeneratedError\";\nvar marker10 = `vercel.ai.error.${name9}`;\nvar symbol10 = Symbol.for(marker10);\nvar _a10;\nvar NoContentGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No content generated.\" } = {}) {\n\t\tsuper({\n\t\t\tname: name9,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a10] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker10);\n\t}\n};\n_a10 = symbol10;\nvar name10 = \"AI_NoSuchModelError\";\nvar marker11 = `vercel.ai.error.${name10}`;\nvar symbol11 = Symbol.for(marker11);\nvar _a11;\nvar NoSuchModelError = class extends AISDKError {\n\tconstructor({ errorName = name10, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {\n\t\tsuper({\n\t\t\tname: errorName,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a11] = true;\n\t\tthis.modelId = modelId;\n\t\tthis.modelType = modelType;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker11);\n\t}\n};\n_a11 = symbol11;\nvar name12 = \"AI_TypeValidationError\";\nvar marker13 = `vercel.ai.error.${name12}`;\nvar symbol13 = Symbol.for(marker13);\nvar _a13;\nvar _TypeValidationError = class _TypeValidationError extends AISDKError {\n\tconstructor({ value, cause }) {\n\t\tsuper({\n\t\t\tname: name12,\n\t\t\tmessage: `Type validation failed: Value: ${JSON.stringify(value)}.\nError message: ${getErrorMessage(cause)}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a13] = true;\n\t\tthis.value = value;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker13);\n\t}\n\t/**\n\t* Wraps an error into a TypeValidationError.\n\t* If the cause is already a TypeValidationError with the same value, it returns the cause.\n\t* Otherwise, it creates a new TypeValidationError.\n\t*\n\t* @param {Object} params - The parameters for wrapping the error.\n\t* @param {unknown} params.value - The value that failed validation.\n\t* @param {unknown} params.cause - The original error or cause of the validation failure.\n\t* @returns {TypeValidationError} A TypeValidationError instance.\n\t*/\n\tstatic wrap({ value, cause }) {\n\t\treturn _TypeValidationError.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError({\n\t\t\tvalue,\n\t\t\tcause\n\t\t});\n\t}\n};\n_a13 = symbol13;\nvar TypeValidationError = _TypeValidationError;\nvar name13 = \"AI_UnsupportedFunctionalityError\";\nvar marker14 = `vercel.ai.error.${name13}`;\nvar symbol14 = Symbol.for(marker14);\nvar _a14;\nvar UnsupportedFunctionalityError = class extends AISDKError {\n\tconstructor({ functionality, message = `'${functionality}' functionality not supported.` }) {\n\t\tsuper({\n\t\t\tname: name13,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a14] = true;\n\t\tthis.functionality = functionality;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker14);\n\t}\n};\n_a14 = symbol14;\nfunction isJSONValue(value) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") return true;\n\tif (Array.isArray(value)) return value.every(isJSONValue);\n\tif (typeof value === \"object\") return Object.entries(value).every(([key, val]) => typeof key === \"string\" && isJSONValue(val));\n\treturn false;\n}\nfunction isJSONArray(value) {\n\treturn Array.isArray(value) && value.every(isJSONValue);\n}\nfunction isJSONObject(value) {\n\treturn value != null && typeof value === \"object\" && Object.entries(value).every(([key, val]) => typeof key === \"string\" && isJSONValue(val));\n}\n//#endregion\nexport { InvalidPromptError as a, LoadAPIKeyError as c, TypeValidationError as d, UnsupportedFunctionalityError as f, isJSONObject as h, InvalidArgumentError as i, NoContentGeneratedError as l, isJSONArray as m, APICallError as n, InvalidResponseDataError as o, getErrorMessage as p, EmptyResponseBodyError as r, JSONParseError as s, AISDKError as t, NoSuchModelError as u };\n\n//# sourceMappingURL=dist-Cm5DZgxA.js.map","import { a as InvalidPromptError, c as LoadAPIKeyError, d as TypeValidationError, f as UnsupportedFunctionalityError, h as isJSONObject, i as InvalidArgumentError$1, l as NoContentGeneratedError, m as isJSONArray, n as APICallError, o as InvalidResponseDataError, p as getErrorMessage$1, r as EmptyResponseBodyError, s as JSONParseError, t as AISDKError, u as NoSuchModelError } from \"./dist-Cm5DZgxA.js\";\nimport { ZodFirstPartyTypeKind } from \"zod/v3\";\nimport { z } from \"zod\";\n//#region \\0rolldown/runtime.js\nvar __create = Object.create;\nvar __defProp$1 = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n\t\tkey = keys[i];\n\t\tif (!__hasOwnProp.call(to, key) && key !== except) __defProp$1(to, key, {\n\t\t\tget: ((k) => from[k]).bind(null, key),\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, \"default\") ? __defProp$1(target, \"default\", {\n\tvalue: mod,\n\tenumerable: true\n}) : target, mod));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/nanoid/5.1.16/f16424b532a5e69aacddcb2977ac17378b6f79695bbd27ead3d90c703848f22f/node_modules/nanoid/non-secure/index.js\nlet customAlphabet = (alphabet, defaultSize = 21) => {\n\treturn (size = defaultSize) => {\n\t\tlet id = \"\";\n\t\tlet i = size | 0;\n\t\twhile (i-- > 0) id += alphabet[Math.random() * alphabet.length | 0];\n\t\treturn id;\n\t};\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider-utils/2.2.8/b5ebb650c869d075671e49b164b6e4defe8f9652b8a95fc120ecfeb885936b4f/node_modules/@ai-sdk/provider-utils/dist/index.mjs\nvar import_secure_json_parse = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst hasBuffer = typeof Buffer !== \"undefined\";\n\tconst suspectProtoRx = /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*:/;\n\tconst suspectConstructorRx = /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\n\tfunction _parse(text, reviver, options) {\n\t\tif (options == null) {\n\t\t\tif (reviver !== null && typeof reviver === \"object\") {\n\t\t\t\toptions = reviver;\n\t\t\t\treviver = void 0;\n\t\t\t}\n\t\t}\n\t\tif (hasBuffer && Buffer.isBuffer(text)) text = text.toString();\n\t\tif (text && text.charCodeAt(0) === 65279) text = text.slice(1);\n\t\tconst obj = JSON.parse(text, reviver);\n\t\tif (obj === null || typeof obj !== \"object\") return obj;\n\t\tconst protoAction = options && options.protoAction || \"error\";\n\t\tconst constructorAction = options && options.constructorAction || \"error\";\n\t\tif (protoAction === \"ignore\" && constructorAction === \"ignore\") return obj;\n\t\tif (protoAction !== \"ignore\" && constructorAction !== \"ignore\") {\n\t\t\tif (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) return obj;\n\t\t} else if (protoAction !== \"ignore\" && constructorAction === \"ignore\") {\n\t\t\tif (suspectProtoRx.test(text) === false) return obj;\n\t\t} else if (suspectConstructorRx.test(text) === false) return obj;\n\t\treturn filter(obj, {\n\t\t\tprotoAction,\n\t\t\tconstructorAction,\n\t\t\tsafe: options && options.safe\n\t\t});\n\t}\n\tfunction filter(obj, { protoAction = \"error\", constructorAction = \"error\", safe } = {}) {\n\t\tlet next = [obj];\n\t\twhile (next.length) {\n\t\t\tconst nodes = next;\n\t\t\tnext = [];\n\t\t\tfor (const node of nodes) {\n\t\t\t\tif (protoAction !== \"ignore\" && Object.prototype.hasOwnProperty.call(node, \"__proto__\")) {\n\t\t\t\t\tif (safe === true) return null;\n\t\t\t\t\telse if (protoAction === \"error\") throw new SyntaxError(\"Object contains forbidden prototype property\");\n\t\t\t\t\tdelete node.__proto__;\n\t\t\t\t}\n\t\t\t\tif (constructorAction !== \"ignore\" && Object.prototype.hasOwnProperty.call(node, \"constructor\") && Object.prototype.hasOwnProperty.call(node.constructor, \"prototype\")) {\n\t\t\t\t\tif (safe === true) return null;\n\t\t\t\t\telse if (constructorAction === \"error\") throw new SyntaxError(\"Object contains forbidden prototype property\");\n\t\t\t\t\tdelete node.constructor;\n\t\t\t\t}\n\t\t\t\tfor (const key in node) {\n\t\t\t\t\tconst value = node[key];\n\t\t\t\t\tif (value && typeof value === \"object\") next.push(value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn obj;\n\t}\n\tfunction parse(text, reviver, options) {\n\t\tconst stackTraceLimit = Error.stackTraceLimit;\n\t\tError.stackTraceLimit = 0;\n\t\ttry {\n\t\t\treturn _parse(text, reviver, options);\n\t\t} finally {\n\t\t\tError.stackTraceLimit = stackTraceLimit;\n\t\t}\n\t}\n\tfunction safeParse(text, reviver) {\n\t\tconst stackTraceLimit = Error.stackTraceLimit;\n\t\tError.stackTraceLimit = 0;\n\t\ttry {\n\t\t\treturn _parse(text, reviver, { safe: true });\n\t\t} catch (_e) {\n\t\t\treturn null;\n\t\t} finally {\n\t\t\tError.stackTraceLimit = stackTraceLimit;\n\t\t}\n\t}\n\tmodule.exports = parse;\n\tmodule.exports.default = parse;\n\tmodule.exports.parse = parse;\n\tmodule.exports.safeParse = safeParse;\n\tmodule.exports.scan = filter;\n})))(), 1);\nfunction convertAsyncIteratorToReadableStream(iterator) {\n\treturn new ReadableStream({\n\t\t/**\n\t\t* Called when the consumer wants to pull more data from the stream.\n\t\t*\n\t\t* @param {ReadableStreamDefaultController<T>} controller - The controller to enqueue data into the stream.\n\t\t* @returns {Promise<void>}\n\t\t*/\n\t\tasync pull(controller) {\n\t\t\ttry {\n\t\t\t\tconst { value, done } = await iterator.next();\n\t\t\t\tif (done) controller.close();\n\t\t\t\telse controller.enqueue(value);\n\t\t\t} catch (error) {\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t* Called when the consumer cancels the stream.\n\t\t*/\n\t\tcancel() {}\n\t});\n}\nasync function delay(delayInMs) {\n\treturn delayInMs == null ? Promise.resolve() : new Promise((resolve2) => setTimeout(resolve2, delayInMs));\n}\nfunction createEventSourceParserStream() {\n\tlet buffer = \"\";\n\tlet event = void 0;\n\tlet data = [];\n\tlet lastEventId = void 0;\n\tlet retry = void 0;\n\tfunction parseLine(line, controller) {\n\t\tif (line === \"\") {\n\t\t\tdispatchEvent(controller);\n\t\t\treturn;\n\t\t}\n\t\tif (line.startsWith(\":\")) return;\n\t\tconst colonIndex = line.indexOf(\":\");\n\t\tif (colonIndex === -1) {\n\t\t\thandleField(line, \"\");\n\t\t\treturn;\n\t\t}\n\t\tconst field = line.slice(0, colonIndex);\n\t\tconst valueStart = colonIndex + 1;\n\t\thandleField(field, valueStart < line.length && line[valueStart] === \" \" ? line.slice(valueStart + 1) : line.slice(valueStart));\n\t}\n\tfunction dispatchEvent(controller) {\n\t\tif (data.length > 0) {\n\t\t\tcontroller.enqueue({\n\t\t\t\tevent,\n\t\t\t\tdata: data.join(\"\\n\"),\n\t\t\t\tid: lastEventId,\n\t\t\t\tretry\n\t\t\t});\n\t\t\tdata = [];\n\t\t\tevent = void 0;\n\t\t\tretry = void 0;\n\t\t}\n\t}\n\tfunction handleField(field, value) {\n\t\tswitch (field) {\n\t\t\tcase \"event\":\n\t\t\t\tevent = value;\n\t\t\t\tbreak;\n\t\t\tcase \"data\":\n\t\t\t\tdata.push(value);\n\t\t\t\tbreak;\n\t\t\tcase \"id\":\n\t\t\t\tlastEventId = value;\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tconst parsedRetry = parseInt(value, 10);\n\t\t\t\tif (!isNaN(parsedRetry)) retry = parsedRetry;\n\t\t}\n\t}\n\treturn new TransformStream({\n\t\ttransform(chunk, controller) {\n\t\t\tconst { lines, incompleteLine } = splitLines(buffer, chunk);\n\t\t\tbuffer = incompleteLine;\n\t\t\tfor (let i = 0; i < lines.length; i++) parseLine(lines[i], controller);\n\t\t},\n\t\tflush(controller) {\n\t\t\tparseLine(buffer, controller);\n\t\t\tdispatchEvent(controller);\n\t\t}\n\t});\n}\nfunction splitLines(buffer, chunk) {\n\tconst lines = [];\n\tlet currentLine = buffer;\n\tfor (let i = 0; i < chunk.length;) {\n\t\tconst char = chunk[i++];\n\t\tif (char === \"\\n\") {\n\t\t\tlines.push(currentLine);\n\t\t\tcurrentLine = \"\";\n\t\t} else if (char === \"\\r\") {\n\t\t\tlines.push(currentLine);\n\t\t\tcurrentLine = \"\";\n\t\t\tif (chunk[i] === \"\\n\") i++;\n\t\t} else currentLine += char;\n\t}\n\treturn {\n\t\tlines,\n\t\tincompleteLine: currentLine\n\t};\n}\nvar createIdGenerator = ({ prefix, size: defaultSize = 16, alphabet = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", separator = \"-\" } = {}) => {\n\tconst generator = customAlphabet(alphabet, defaultSize);\n\tif (prefix == null) return generator;\n\tif (alphabet.includes(separator)) throw new InvalidArgumentError$1({\n\t\targument: \"separator\",\n\t\tmessage: `The separator \"${separator}\" must not be part of the alphabet \"${alphabet}\".`\n\t});\n\treturn (size) => `${prefix}${separator}${generator(size)}`;\n};\nvar generateId = createIdGenerator();\nfunction getErrorMessage(error) {\n\tif (error == null) return \"unknown error\";\n\tif (typeof error === \"string\") return error;\n\tif (error instanceof Error) return error.message;\n\treturn JSON.stringify(error);\n}\nfunction isAbortError(error) {\n\treturn error instanceof Error && (error.name === \"AbortError\" || error.name === \"TimeoutError\");\n}\nvar validatorSymbol = Symbol.for(\"vercel.ai.validator\");\nfunction validator(validate) {\n\treturn {\n\t\t[validatorSymbol]: true,\n\t\tvalidate\n\t};\n}\nfunction isValidator(value) {\n\treturn typeof value === \"object\" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && \"validate\" in value;\n}\nfunction asValidator(value) {\n\treturn isValidator(value) ? value : zodValidator(value);\n}\nfunction zodValidator(zodSchema) {\n\treturn validator((value) => {\n\t\tconst result = zodSchema.safeParse(value);\n\t\treturn result.success ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.data\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: result.error\n\t\t};\n\t});\n}\nfunction safeValidateTypes({ value, schema }) {\n\tconst validator2 = asValidator(schema);\n\ttry {\n\t\tif (validator2.validate == null) return {\n\t\t\tsuccess: true,\n\t\t\tvalue\n\t\t};\n\t\tconst result = validator2.validate(value);\n\t\tif (result.success) return result;\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: TypeValidationError.wrap({\n\t\t\t\tvalue,\n\t\t\t\tcause: result.error\n\t\t\t})\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: TypeValidationError.wrap({\n\t\t\t\tvalue,\n\t\t\t\tcause: error\n\t\t\t})\n\t\t};\n\t}\n}\nfunction safeParseJSON({ text, schema }) {\n\ttry {\n\t\tconst value = import_secure_json_parse.default.parse(text);\n\t\tif (schema == null) return {\n\t\t\tsuccess: true,\n\t\t\tvalue,\n\t\t\trawValue: value\n\t\t};\n\t\tconst validationResult = safeValidateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t\treturn validationResult.success ? {\n\t\t\t...validationResult,\n\t\t\trawValue: value\n\t\t} : validationResult;\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: JSONParseError.isInstance(error) ? error : new JSONParseError({\n\t\t\t\ttext,\n\t\t\t\tcause: error\n\t\t\t})\n\t\t};\n\t}\n}\nvar { btoa, atob } = globalThis;\nfunction convertBase64ToUint8Array(base64String) {\n\tconst latin1string = atob(base64String.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n\treturn Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));\n}\nfunction convertUint8ArrayToBase64(array) {\n\tlet latin1string = \"\";\n\tfor (let i = 0; i < array.length; i++) latin1string += String.fromCodePoint(array[i]);\n\treturn btoa(latin1string);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/Options.js\nconst ignoreOverride = Symbol(\"Let zodToJsonSchema decide on which parser to use\");\nconst defaultOptions = {\n\tname: void 0,\n\t$refStrategy: \"root\",\n\tbasePath: [\"#\"],\n\teffectStrategy: \"input\",\n\tpipeStrategy: \"all\",\n\tdateStrategy: \"format:date-time\",\n\tmapStrategy: \"entries\",\n\tremoveAdditionalStrategy: \"passthrough\",\n\tallowedAdditionalProperties: true,\n\trejectedAdditionalProperties: false,\n\tdefinitionPath: \"definitions\",\n\ttarget: \"jsonSchema7\",\n\tstrictUnions: false,\n\tdefinitions: {},\n\terrorMessages: false,\n\tmarkdownDescription: false,\n\tpatternStrategy: \"escape\",\n\tapplyRegexFlags: false,\n\temailStrategy: \"format:email\",\n\tbase64Strategy: \"contentEncoding:base64\",\n\tnameStrategy: \"ref\",\n\topenAiAnyTypeName: \"OpenAiAnyType\"\n};\nconst getDefaultOptions = (options) => typeof options === \"string\" ? {\n\t...defaultOptions,\n\tname: options\n} : {\n\t...defaultOptions,\n\t...options\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/Refs.js\nconst getRefs = (options) => {\n\tconst _options = getDefaultOptions(options);\n\tconst currentPath = _options.name !== void 0 ? [\n\t\t..._options.basePath,\n\t\t_options.definitionPath,\n\t\t_options.name\n\t] : _options.basePath;\n\treturn {\n\t\t..._options,\n\t\tflags: { hasReferencedOpenAiAnyType: false },\n\t\tcurrentPath,\n\t\tpropertyPath: void 0,\n\t\tseen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {\n\t\t\tdef: def._def,\n\t\t\tpath: [\n\t\t\t\t..._options.basePath,\n\t\t\t\t_options.definitionPath,\n\t\t\t\tname\n\t\t\t],\n\t\t\tjsonSchema: void 0\n\t\t}]))\n\t};\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/errorMessages.js\nfunction addErrorMessage(res, key, errorMessage, refs) {\n\tif (!refs?.errorMessages) return;\n\tif (errorMessage) res.errorMessage = {\n\t\t...res.errorMessage,\n\t\t[key]: errorMessage\n\t};\n}\nfunction setResponseValueAndErrors(res, key, value, errorMessage, refs) {\n\tres[key] = value;\n\taddErrorMessage(res, key, errorMessage, refs);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js\nconst getRelativePath = (pathA, pathB) => {\n\tlet i = 0;\n\tfor (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;\n\treturn [(pathA.length - i).toString(), ...pathB.slice(i)].join(\"/\");\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/any.js\nfunction parseAnyDef(refs) {\n\tif (refs.target !== \"openAi\") return {};\n\tconst anyDefinitionPath = [\n\t\t...refs.basePath,\n\t\trefs.definitionPath,\n\t\trefs.openAiAnyTypeName\n\t];\n\trefs.flags.hasReferencedOpenAiAnyType = true;\n\treturn { $ref: refs.$refStrategy === \"relative\" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join(\"/\") };\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/array.js\nfunction parseArrayDef(def, refs) {\n\tconst res = { type: \"array\" };\n\tif (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"items\"]\n\t});\n\tif (def.minLength) setResponseValueAndErrors(res, \"minItems\", def.minLength.value, def.minLength.message, refs);\n\tif (def.maxLength) setResponseValueAndErrors(res, \"maxItems\", def.maxLength.value, def.maxLength.message, refs);\n\tif (def.exactLength) {\n\t\tsetResponseValueAndErrors(res, \"minItems\", def.exactLength.value, def.exactLength.message, refs);\n\t\tsetResponseValueAndErrors(res, \"maxItems\", def.exactLength.value, def.exactLength.message, refs);\n\t}\n\treturn res;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js\nfunction parseBigintDef(def, refs) {\n\tconst res = {\n\t\ttype: \"integer\",\n\t\tformat: \"int64\"\n\t};\n\tif (!def.checks) return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tif (refs.target === \"jsonSchema7\") {\n\t\t\t\tif (check.inclusive) setResponseValueAndErrors(res, \"minimum\", check.value, check.message, refs);\n\t\t\t\telse setResponseValueAndErrors(res, \"exclusiveMinimum\", check.value, check.message, refs);\n\t\t\t} else {\n\t\t\t\tif (!check.inclusive) res.exclusiveMinimum = true;\n\t\t\t\tsetResponseValueAndErrors(res, \"minimum\", check.value, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tif (refs.target === \"jsonSchema7\") {\n\t\t\t\tif (check.inclusive) setResponseValueAndErrors(res, \"maximum\", check.value, check.message, refs);\n\t\t\t\telse setResponseValueAndErrors(res, \"exclusiveMaximum\", check.value, check.message, refs);\n\t\t\t} else {\n\t\t\t\tif (!check.inclusive) res.exclusiveMaximum = true;\n\t\t\t\tsetResponseValueAndErrors(res, \"maximum\", check.value, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"multipleOf\": setResponseValueAndErrors(res, \"multipleOf\", check.value, check.message, refs);\n\t}\n\treturn res;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js\nfunction parseBooleanDef() {\n\treturn { type: \"boolean\" };\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js\nfunction parseBrandedDef(_def, refs) {\n\treturn parseDef(_def.type._def, refs);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js\nconst parseCatchDef = (def, refs) => {\n\treturn parseDef(def.innerType._def, refs);\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/date.js\nfunction parseDateDef(def, refs, overrideDateStrategy) {\n\tconst strategy = overrideDateStrategy ?? refs.dateStrategy;\n\tif (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };\n\tswitch (strategy) {\n\t\tcase \"string\":\n\t\tcase \"format:date-time\": return {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\"\n\t\t};\n\t\tcase \"format:date\": return {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date\"\n\t\t};\n\t\tcase \"integer\": return integerDateParser(def, refs);\n\t}\n}\nconst integerDateParser = (def, refs) => {\n\tconst res = {\n\t\ttype: \"integer\",\n\t\tformat: \"unix-time\"\n\t};\n\tif (refs.target === \"openApi3\") return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tsetResponseValueAndErrors(res, \"minimum\", check.value, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"max\": setResponseValueAndErrors(res, \"maximum\", check.value, check.message, refs);\n\t}\n\treturn res;\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/default.js\nfunction parseDefaultDef(_def, refs) {\n\treturn {\n\t\t...parseDef(_def.innerType._def, refs),\n\t\tdefault: _def.defaultValue()\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js\nfunction parseEffectsDef(_def, refs) {\n\treturn refs.effectStrategy === \"input\" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js\nfunction parseEnumDef(def) {\n\treturn {\n\t\ttype: \"string\",\n\t\tenum: Array.from(def.values)\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js\nconst isJsonSchema7AllOfType = (type) => {\n\tif (\"type\" in type && type.type === \"string\") return false;\n\treturn \"allOf\" in type;\n};\nfunction parseIntersectionDef(def, refs) {\n\tconst allOf = [parseDef(def.left._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"0\"\n\t\t]\n\t}), parseDef(def.right._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"1\"\n\t\t]\n\t})].filter((x) => !!x);\n\tlet unevaluatedProperties = refs.target === \"jsonSchema2019-09\" ? { unevaluatedProperties: false } : void 0;\n\tconst mergedAllOf = [];\n\tallOf.forEach((schema) => {\n\t\tif (isJsonSchema7AllOfType(schema)) {\n\t\t\tmergedAllOf.push(...schema.allOf);\n\t\t\tif (schema.unevaluatedProperties === void 0) unevaluatedProperties = void 0;\n\t\t} else {\n\t\t\tlet nestedSchema = schema;\n\t\t\tif (\"additionalProperties\" in schema && schema.additionalProperties === false) {\n\t\t\t\tconst { additionalProperties, ...rest } = schema;\n\t\t\t\tnestedSchema = rest;\n\t\t\t} else unevaluatedProperties = void 0;\n\t\t\tmergedAllOf.push(nestedSchema);\n\t\t}\n\t});\n\treturn mergedAllOf.length ? {\n\t\tallOf: mergedAllOf,\n\t\t...unevaluatedProperties\n\t} : void 0;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js\nfunction parseLiteralDef(def, refs) {\n\tconst parsedType = typeof def.value;\n\tif (parsedType !== \"bigint\" && parsedType !== \"number\" && parsedType !== \"boolean\" && parsedType !== \"string\") return { type: Array.isArray(def.value) ? \"array\" : \"object\" };\n\tif (refs.target === \"openApi3\") return {\n\t\ttype: parsedType === \"bigint\" ? \"integer\" : parsedType,\n\t\tenum: [def.value]\n\t};\n\treturn {\n\t\ttype: parsedType === \"bigint\" ? \"integer\" : parsedType,\n\t\tconst: def.value\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/string.js\nlet emojiRegex = void 0;\n/**\n* Generated from the regular expressions found here as of 2024-05-22:\n* https://github.com/colinhacks/zod/blob/master/src/types.ts.\n*\n* Expressions with /i flag have been changed accordingly.\n*/\nconst zodPatterns = {\n\t/**\n\t* `c` was changed to `[cC]` to replicate /i flag\n\t*/\n\tcuid: /^[cC][^\\s-]{8,}$/,\n\tcuid2: /^[0-9a-z]+$/,\n\tulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,\n\t/**\n\t* `a-z` was added to replicate /i flag\n\t*/\n\temail: /^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_'+\\-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$/,\n\t/**\n\t* Constructed a valid Unicode RegExp\n\t*\n\t* Lazily instantiate since this type of regex isn't supported\n\t* in all envs (e.g. React Native).\n\t*\n\t* See:\n\t* https://github.com/colinhacks/zod/issues/2433\n\t* Fix in Zod:\n\t* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b\n\t*/\n\temoji: () => {\n\t\tif (emojiRegex === void 0) emojiRegex = RegExp(\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\", \"u\");\n\t\treturn emojiRegex;\n\t},\n\t/**\n\t* Unused\n\t*/\n\tuuid: /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/,\n\t/**\n\t* Unused\n\t*/\n\tipv4: /^(?:(?: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])$/,\n\tipv4Cidr: /^(?:(?: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])\\/(3[0-2]|[12]?[0-9])$/,\n\t/**\n\t* Unused\n\t*/\n\tipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,\n\tipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,\n\tbase64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,\n\tbase64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,\n\tnanoid: /^[a-zA-Z0-9_-]{21}$/,\n\tjwt: /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/\n};\nfunction parseStringDef(def, refs) {\n\tconst res = { type: \"string\" };\n\tif (def.checks) for (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tsetResponseValueAndErrors(res, \"minLength\", typeof res.minLength === \"number\" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tsetResponseValueAndErrors(res, \"maxLength\", typeof res.maxLength === \"number\" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"email\":\n\t\t\tswitch (refs.emailStrategy) {\n\t\t\t\tcase \"format:email\":\n\t\t\t\t\taddFormat(res, \"email\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"format:idn-email\":\n\t\t\t\t\taddFormat(res, \"idn-email\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"pattern:zod\": addPattern(res, zodPatterns.email, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"url\":\n\t\t\taddFormat(res, \"uri\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"uuid\":\n\t\t\taddFormat(res, \"uuid\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"regex\":\n\t\t\taddPattern(res, check.regex, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cuid\":\n\t\t\taddPattern(res, zodPatterns.cuid, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cuid2\":\n\t\t\taddPattern(res, zodPatterns.cuid2, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"startsWith\":\n\t\t\taddPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"endsWith\":\n\t\t\taddPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"datetime\":\n\t\t\taddFormat(res, \"date-time\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"date\":\n\t\t\taddFormat(res, \"date\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"time\":\n\t\t\taddFormat(res, \"time\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"duration\":\n\t\t\taddFormat(res, \"duration\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"length\":\n\t\t\tsetResponseValueAndErrors(res, \"minLength\", typeof res.minLength === \"number\" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);\n\t\t\tsetResponseValueAndErrors(res, \"maxLength\", typeof res.maxLength === \"number\" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"includes\":\n\t\t\taddPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"ip\":\n\t\t\tif (check.version !== \"v6\") addFormat(res, \"ipv4\", check.message, refs);\n\t\t\tif (check.version !== \"v4\") addFormat(res, \"ipv6\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"base64url\":\n\t\t\taddPattern(res, zodPatterns.base64url, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"jwt\":\n\t\t\taddPattern(res, zodPatterns.jwt, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cidr\":\n\t\t\tif (check.version !== \"v6\") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);\n\t\t\tif (check.version !== \"v4\") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"emoji\":\n\t\t\taddPattern(res, zodPatterns.emoji(), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"ulid\":\n\t\t\taddPattern(res, zodPatterns.ulid, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"base64\":\n\t\t\tswitch (refs.base64Strategy) {\n\t\t\t\tcase \"format:binary\":\n\t\t\t\t\taddFormat(res, \"binary\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"contentEncoding:base64\":\n\t\t\t\t\tsetResponseValueAndErrors(res, \"contentEncoding\", \"base64\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"pattern:zod\": addPattern(res, zodPatterns.base64, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"nanoid\": addPattern(res, zodPatterns.nanoid, check.message, refs);\n\t}\n\treturn res;\n}\nfunction escapeLiteralCheckValue(literal, refs) {\n\treturn refs.patternStrategy === \"escape\" ? escapeNonAlphaNumeric(literal) : literal;\n}\nconst ALPHA_NUMERIC = /* @__PURE__ */ new Set(\"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789\");\nfunction escapeNonAlphaNumeric(source) {\n\tlet result = \"\";\n\tfor (let i = 0; i < source.length; i++) {\n\t\tif (!ALPHA_NUMERIC.has(source[i])) result += \"\\\\\";\n\t\tresult += source[i];\n\t}\n\treturn result;\n}\nfunction addFormat(schema, value, message, refs) {\n\tif (schema.format || schema.anyOf?.some((x) => x.format)) {\n\t\tif (!schema.anyOf) schema.anyOf = [];\n\t\tif (schema.format) {\n\t\t\tschema.anyOf.push({\n\t\t\t\tformat: schema.format,\n\t\t\t\t...schema.errorMessage && refs.errorMessages && { errorMessage: { format: schema.errorMessage.format } }\n\t\t\t});\n\t\t\tdelete schema.format;\n\t\t\tif (schema.errorMessage) {\n\t\t\t\tdelete schema.errorMessage.format;\n\t\t\t\tif (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;\n\t\t\t}\n\t\t}\n\t\tschema.anyOf.push({\n\t\t\tformat: value,\n\t\t\t...message && refs.errorMessages && { errorMessage: { format: message } }\n\t\t});\n\t} else setResponseValueAndErrors(schema, \"format\", value, message, refs);\n}\nfunction addPattern(schema, regex, message, refs) {\n\tif (schema.pattern || schema.allOf?.some((x) => x.pattern)) {\n\t\tif (!schema.allOf) schema.allOf = [];\n\t\tif (schema.pattern) {\n\t\t\tschema.allOf.push({\n\t\t\t\tpattern: schema.pattern,\n\t\t\t\t...schema.errorMessage && refs.errorMessages && { errorMessage: { pattern: schema.errorMessage.pattern } }\n\t\t\t});\n\t\t\tdelete schema.pattern;\n\t\t\tif (schema.errorMessage) {\n\t\t\t\tdelete schema.errorMessage.pattern;\n\t\t\t\tif (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;\n\t\t\t}\n\t\t}\n\t\tschema.allOf.push({\n\t\t\tpattern: stringifyRegExpWithFlags(regex, refs),\n\t\t\t...message && refs.errorMessages && { errorMessage: { pattern: message } }\n\t\t});\n\t} else setResponseValueAndErrors(schema, \"pattern\", stringifyRegExpWithFlags(regex, refs), message, refs);\n}\nfunction stringifyRegExpWithFlags(regex, refs) {\n\tif (!refs.applyRegexFlags || !regex.flags) return regex.source;\n\tconst flags = {\n\t\ti: regex.flags.includes(\"i\"),\n\t\tm: regex.flags.includes(\"m\"),\n\t\ts: regex.flags.includes(\"s\")\n\t};\n\tconst source = flags.i ? regex.source.toLowerCase() : regex.source;\n\tlet pattern = \"\";\n\tlet isEscaped = false;\n\tlet inCharGroup = false;\n\tlet inCharRange = false;\n\tfor (let i = 0; i < source.length; i++) {\n\t\tif (isEscaped) {\n\t\t\tpattern += source[i];\n\t\t\tisEscaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (flags.i) {\n\t\t\tif (inCharGroup) {\n\t\t\t\tif (source[i].match(/[a-z]/)) {\n\t\t\t\t\tif (inCharRange) {\n\t\t\t\t\t\tpattern += source[i];\n\t\t\t\t\t\tpattern += `${source[i - 2]}-${source[i]}`.toUpperCase();\n\t\t\t\t\t\tinCharRange = false;\n\t\t\t\t\t} else if (source[i + 1] === \"-\" && source[i + 2]?.match(/[a-z]/)) {\n\t\t\t\t\t\tpattern += source[i];\n\t\t\t\t\t\tinCharRange = true;\n\t\t\t\t\t} else pattern += `${source[i]}${source[i].toUpperCase()}`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else if (source[i].match(/[a-z]/)) {\n\t\t\t\tpattern += `[${source[i]}${source[i].toUpperCase()}]`;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (flags.m) {\n\t\t\tif (source[i] === \"^\") {\n\t\t\t\tpattern += `(^|(?<=[\\r\\n]))`;\n\t\t\t\tcontinue;\n\t\t\t} else if (source[i] === \"$\") {\n\t\t\t\tpattern += `($|(?=[\\r\\n]))`;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (flags.s && source[i] === \".\") {\n\t\t\tpattern += inCharGroup ? `${source[i]}\\r\\n` : `[${source[i]}\\r\\n]`;\n\t\t\tcontinue;\n\t\t}\n\t\tpattern += source[i];\n\t\tif (source[i] === \"\\\\\") isEscaped = true;\n\t\telse if (inCharGroup && source[i] === \"]\") inCharGroup = false;\n\t\telse if (!inCharGroup && source[i] === \"[\") inCharGroup = true;\n\t}\n\ttry {\n\t\tnew RegExp(pattern);\n\t} catch {\n\t\tconsole.warn(`Could not convert regex pattern at ${refs.currentPath.join(\"/\")} to a flag-independent form! Falling back to the flag-ignorant source`);\n\t\treturn regex.source;\n\t}\n\treturn pattern;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/record.js\nfunction parseRecordDef(def, refs) {\n\tif (refs.target === \"openAi\") console.warn(\"Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.\");\n\tif (refs.target === \"openApi3\" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {\n\t\ttype: \"object\",\n\t\trequired: def.keyType._def.values,\n\t\tproperties: def.keyType._def.values.reduce((acc, key) => ({\n\t\t\t...acc,\n\t\t\t[key]: parseDef(def.valueType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"properties\",\n\t\t\t\t\tkey\n\t\t\t\t]\n\t\t\t}) ?? parseAnyDef(refs)\n\t\t}), {}),\n\t\tadditionalProperties: refs.rejectedAdditionalProperties\n\t};\n\tconst schema = {\n\t\ttype: \"object\",\n\t\tadditionalProperties: parseDef(def.valueType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"additionalProperties\"]\n\t\t}) ?? refs.allowedAdditionalProperties\n\t};\n\tif (refs.target === \"openApi3\") return schema;\n\tif (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {\n\t\tconst { type, ...keyType } = parseStringDef(def.keyType._def, refs);\n\t\treturn {\n\t\t\t...schema,\n\t\t\tpropertyNames: keyType\n\t\t};\n\t} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {\n\t\t...schema,\n\t\tpropertyNames: { enum: def.keyType._def.values }\n\t};\n\telse if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {\n\t\tconst { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);\n\t\treturn {\n\t\t\t...schema,\n\t\t\tpropertyNames: keyType\n\t\t};\n\t}\n\treturn schema;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/map.js\nfunction parseMapDef(def, refs) {\n\tif (refs.mapStrategy === \"record\") return parseRecordDef(def, refs);\n\treturn {\n\t\ttype: \"array\",\n\t\tmaxItems: 125,\n\t\titems: {\n\t\t\ttype: \"array\",\n\t\t\titems: [parseDef(def.keyType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"0\"\n\t\t\t\t]\n\t\t\t}) || parseAnyDef(refs), parseDef(def.valueType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"1\"\n\t\t\t\t]\n\t\t\t}) || parseAnyDef(refs)],\n\t\t\tminItems: 2,\n\t\t\tmaxItems: 2\n\t\t}\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js\nfunction parseNativeEnumDef(def) {\n\tconst object = def.values;\n\tconst actualValues = Object.keys(def.values).filter((key) => {\n\t\treturn typeof object[object[key]] !== \"number\";\n\t}).map((key) => object[key]);\n\tconst parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));\n\treturn {\n\t\ttype: parsedTypes.length === 1 ? parsedTypes[0] === \"string\" ? \"string\" : \"number\" : [\"string\", \"number\"],\n\t\tenum: actualValues\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/never.js\nfunction parseNeverDef(refs) {\n\treturn refs.target === \"openAi\" ? void 0 : { not: parseAnyDef({\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"not\"]\n\t}) };\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/null.js\nfunction parseNullDef(refs) {\n\treturn refs.target === \"openApi3\" ? {\n\t\tenum: [\"null\"],\n\t\tnullable: true\n\t} : { type: \"null\" };\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/union.js\nconst primitiveMappings = {\n\tZodString: \"string\",\n\tZodNumber: \"number\",\n\tZodBigInt: \"integer\",\n\tZodBoolean: \"boolean\",\n\tZodNull: \"null\"\n};\nfunction parseUnionDef(def, refs) {\n\tif (refs.target === \"openApi3\") return asAnyOf(def, refs);\n\tconst options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;\n\tif (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {\n\t\tconst types = options.reduce((types, x) => {\n\t\t\tconst type = primitiveMappings[x._def.typeName];\n\t\t\treturn type && !types.includes(type) ? [...types, type] : types;\n\t\t}, []);\n\t\treturn { type: types.length > 1 ? types : types[0] };\n\t} else if (options.every((x) => x._def.typeName === \"ZodLiteral\" && !x.description)) {\n\t\tconst types = options.reduce((acc, x) => {\n\t\t\tconst type = typeof x._def.value;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"string\":\n\t\t\t\tcase \"number\":\n\t\t\t\tcase \"boolean\": return [...acc, type];\n\t\t\t\tcase \"bigint\": return [...acc, \"integer\"];\n\t\t\t\tcase \"object\": if (x._def.value === null) return [...acc, \"null\"];\n\t\t\t\tdefault: return acc;\n\t\t\t}\n\t\t}, []);\n\t\tif (types.length === options.length) {\n\t\t\tconst uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);\n\t\t\treturn {\n\t\t\t\ttype: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],\n\t\t\t\tenum: options.reduce((acc, x) => {\n\t\t\t\t\treturn acc.includes(x._def.value) ? acc : [...acc, x._def.value];\n\t\t\t\t}, [])\n\t\t\t};\n\t\t}\n\t} else if (options.every((x) => x._def.typeName === \"ZodEnum\")) return {\n\t\ttype: \"string\",\n\t\tenum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x) => !acc.includes(x))], [])\n\t};\n\treturn asAnyOf(def, refs);\n}\nconst asAnyOf = (def, refs) => {\n\tconst anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t`${i}`\n\t\t]\n\t})).filter((x) => !!x && (!refs.strictUnions || typeof x === \"object\" && Object.keys(x).length > 0));\n\treturn anyOf.length ? { anyOf } : void 0;\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js\nfunction parseNullableDef(def, refs) {\n\tif ([\n\t\t\"ZodString\",\n\t\t\"ZodNumber\",\n\t\t\"ZodBigInt\",\n\t\t\"ZodBoolean\",\n\t\t\"ZodNull\"\n\t].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {\n\t\tif (refs.target === \"openApi3\") return {\n\t\t\ttype: primitiveMappings[def.innerType._def.typeName],\n\t\t\tnullable: true\n\t\t};\n\t\treturn { type: [primitiveMappings[def.innerType._def.typeName], \"null\"] };\n\t}\n\tif (refs.target === \"openApi3\") {\n\t\tconst base = parseDef(def.innerType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath]\n\t\t});\n\t\tif (base && \"$ref\" in base) return {\n\t\t\tallOf: [base],\n\t\t\tnullable: true\n\t\t};\n\t\treturn base && {\n\t\t\t...base,\n\t\t\tnullable: true\n\t\t};\n\t}\n\tconst base = parseDef(def.innerType._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t\"0\"\n\t\t]\n\t});\n\treturn base && { anyOf: [base, { type: \"null\" }] };\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/number.js\nfunction parseNumberDef(def, refs) {\n\tconst res = { type: \"number\" };\n\tif (!def.checks) return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"int\":\n\t\t\tres.type = \"integer\";\n\t\t\taddErrorMessage(res, \"type\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"min\":\n\t\t\tif (refs.target === \"jsonSchema7\") {\n\t\t\t\tif (check.inclusive) setResponseValueAndErrors(res, \"minimum\", check.value, check.message, refs);\n\t\t\t\telse setResponseValueAndErrors(res, \"exclusiveMinimum\", check.value, check.message, refs);\n\t\t\t} else {\n\t\t\t\tif (!check.inclusive) res.exclusiveMinimum = true;\n\t\t\t\tsetResponseValueAndErrors(res, \"minimum\", check.value, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tif (refs.target === \"jsonSchema7\") {\n\t\t\t\tif (check.inclusive) setResponseValueAndErrors(res, \"maximum\", check.value, check.message, refs);\n\t\t\t\telse setResponseValueAndErrors(res, \"exclusiveMaximum\", check.value, check.message, refs);\n\t\t\t} else {\n\t\t\t\tif (!check.inclusive) res.exclusiveMaximum = true;\n\t\t\t\tsetResponseValueAndErrors(res, \"maximum\", check.value, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"multipleOf\": setResponseValueAndErrors(res, \"multipleOf\", check.value, check.message, refs);\n\t}\n\treturn res;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/object.js\nfunction parseObjectDef(def, refs) {\n\tconst forceOptionalIntoNullable = refs.target === \"openAi\";\n\tconst result = {\n\t\ttype: \"object\",\n\t\tproperties: {}\n\t};\n\tconst required = [];\n\tconst shape = def.shape();\n\tfor (const propName in shape) {\n\t\tlet propDef = shape[propName];\n\t\tif (propDef === void 0 || propDef._def === void 0) continue;\n\t\tlet propOptional = safeIsOptional(propDef);\n\t\tif (propOptional && forceOptionalIntoNullable) {\n\t\t\tif (propDef._def.typeName === \"ZodOptional\") propDef = propDef._def.innerType;\n\t\t\tif (!propDef.isNullable()) propDef = propDef.nullable();\n\t\t\tpropOptional = false;\n\t\t}\n\t\tconst parsedDef = parseDef(propDef._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"properties\",\n\t\t\t\tpropName\n\t\t\t],\n\t\t\tpropertyPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"properties\",\n\t\t\t\tpropName\n\t\t\t]\n\t\t});\n\t\tif (parsedDef === void 0) continue;\n\t\tresult.properties[propName] = parsedDef;\n\t\tif (!propOptional) required.push(propName);\n\t}\n\tif (required.length) result.required = required;\n\tconst additionalProperties = decideAdditionalProperties(def, refs);\n\tif (additionalProperties !== void 0) result.additionalProperties = additionalProperties;\n\treturn result;\n}\nfunction decideAdditionalProperties(def, refs) {\n\tif (def.catchall._def.typeName !== \"ZodNever\") return parseDef(def.catchall._def, {\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"additionalProperties\"]\n\t});\n\tswitch (def.unknownKeys) {\n\t\tcase \"passthrough\": return refs.allowedAdditionalProperties;\n\t\tcase \"strict\": return refs.rejectedAdditionalProperties;\n\t\tcase \"strip\": return refs.removeAdditionalStrategy === \"strict\" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;\n\t}\n}\nfunction safeIsOptional(schema) {\n\ttry {\n\t\treturn schema.isOptional();\n\t} catch {\n\t\treturn true;\n\t}\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js\nconst parseOptionalDef = (def, refs) => {\n\tif (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);\n\tconst innerSchema = parseDef(def.innerType._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t\"1\"\n\t\t]\n\t});\n\treturn innerSchema ? { anyOf: [{ not: parseAnyDef(refs) }, innerSchema] } : parseAnyDef(refs);\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js\nconst parsePipelineDef = (def, refs) => {\n\tif (refs.pipeStrategy === \"input\") return parseDef(def.in._def, refs);\n\telse if (refs.pipeStrategy === \"output\") return parseDef(def.out._def, refs);\n\tconst a = parseDef(def.in._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"0\"\n\t\t]\n\t});\n\treturn { allOf: [a, parseDef(def.out._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\ta ? \"1\" : \"0\"\n\t\t]\n\t})].filter((x) => x !== void 0) };\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js\nfunction parsePromiseDef(def, refs) {\n\treturn parseDef(def.type._def, refs);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/set.js\nfunction parseSetDef(def, refs) {\n\tconst schema = {\n\t\ttype: \"array\",\n\t\tuniqueItems: true,\n\t\titems: parseDef(def.valueType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"items\"]\n\t\t})\n\t};\n\tif (def.minSize) setResponseValueAndErrors(schema, \"minItems\", def.minSize.value, def.minSize.message, refs);\n\tif (def.maxSize) setResponseValueAndErrors(schema, \"maxItems\", def.maxSize.value, def.maxSize.message, refs);\n\treturn schema;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js\nfunction parseTupleDef(def, refs) {\n\tif (def.rest) return {\n\t\ttype: \"array\",\n\t\tminItems: def.items.length,\n\t\titems: def.items.map((x, i) => parseDef(x._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"items\",\n\t\t\t\t`${i}`\n\t\t\t]\n\t\t})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),\n\t\tadditionalItems: parseDef(def.rest._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"additionalItems\"]\n\t\t})\n\t};\n\telse return {\n\t\ttype: \"array\",\n\t\tminItems: def.items.length,\n\t\tmaxItems: def.items.length,\n\t\titems: def.items.map((x, i) => parseDef(x._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"items\",\n\t\t\t\t`${i}`\n\t\t\t]\n\t\t})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js\nfunction parseUndefinedDef(refs) {\n\treturn { not: parseAnyDef(refs) };\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js\nfunction parseUnknownDef(refs) {\n\treturn parseAnyDef(refs);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js\nconst parseReadonlyDef = (def, refs) => {\n\treturn parseDef(def.innerType._def, refs);\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/selectParser.js\nconst selectParser = (def, typeName, refs) => {\n\tswitch (typeName) {\n\t\tcase ZodFirstPartyTypeKind.ZodString: return parseStringDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNumber: return parseNumberDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodObject: return parseObjectDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBigInt: return parseBigintDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBoolean: return parseBooleanDef();\n\t\tcase ZodFirstPartyTypeKind.ZodDate: return parseDateDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUndefined: return parseUndefinedDef(refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNull: return parseNullDef(refs);\n\t\tcase ZodFirstPartyTypeKind.ZodArray: return parseArrayDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUnion:\n\t\tcase ZodFirstPartyTypeKind.ZodDiscriminatedUnion: return parseUnionDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodIntersection: return parseIntersectionDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodTuple: return parseTupleDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodRecord: return parseRecordDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodLiteral: return parseLiteralDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodEnum: return parseEnumDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodNativeEnum: return parseNativeEnumDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodNullable: return parseNullableDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodLazy: return () => def.getter()._def;\n\t\tcase ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNaN:\n\t\tcase ZodFirstPartyTypeKind.ZodNever: return parseNeverDef(refs);\n\t\tcase ZodFirstPartyTypeKind.ZodEffects: return parseEffectsDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodAny: return parseAnyDef(refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUnknown: return parseUnknownDef(refs);\n\t\tcase ZodFirstPartyTypeKind.ZodDefault: return parseDefaultDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBranded: return parseBrandedDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodReadonly: return parseReadonlyDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodCatch: return parseCatchDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodPipeline: return parsePipelineDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodFunction:\n\t\tcase ZodFirstPartyTypeKind.ZodVoid:\n\t\tcase ZodFirstPartyTypeKind.ZodSymbol: return;\n\t\tdefault: return ((_) => void 0)(typeName);\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/parseDef.js\nfunction parseDef(def, refs, forceResolution = false) {\n\tconst seenItem = refs.seen.get(def);\n\tif (refs.override) {\n\t\tconst overrideResult = refs.override?.(def, refs, seenItem, forceResolution);\n\t\tif (overrideResult !== ignoreOverride) return overrideResult;\n\t}\n\tif (seenItem && !forceResolution) {\n\t\tconst seenSchema = get$ref(seenItem, refs);\n\t\tif (seenSchema !== void 0) return seenSchema;\n\t}\n\tconst newItem = {\n\t\tdef,\n\t\tpath: refs.currentPath,\n\t\tjsonSchema: void 0\n\t};\n\trefs.seen.set(def, newItem);\n\tconst jsonSchemaOrGetter = selectParser(def, def.typeName, refs);\n\tconst jsonSchema = typeof jsonSchemaOrGetter === \"function\" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;\n\tif (jsonSchema) addMeta(def, refs, jsonSchema);\n\tif (refs.postProcess) {\n\t\tconst postProcessResult = refs.postProcess(jsonSchema, def, refs);\n\t\tnewItem.jsonSchema = jsonSchema;\n\t\treturn postProcessResult;\n\t}\n\tnewItem.jsonSchema = jsonSchema;\n\treturn jsonSchema;\n}\nconst get$ref = (item, refs) => {\n\tswitch (refs.$refStrategy) {\n\t\tcase \"root\": return { $ref: item.path.join(\"/\") };\n\t\tcase \"relative\": return { $ref: getRelativePath(refs.currentPath, item.path) };\n\t\tcase \"none\":\n\t\tcase \"seen\":\n\t\t\tif (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {\n\t\t\t\tconsole.warn(`Recursive reference detected at ${refs.currentPath.join(\"/\")}! Defaulting to any`);\n\t\t\t\treturn parseAnyDef(refs);\n\t\t\t}\n\t\t\treturn refs.$refStrategy === \"seen\" ? parseAnyDef(refs) : void 0;\n\t}\n};\nconst addMeta = (def, refs, jsonSchema) => {\n\tif (def.description) {\n\t\tjsonSchema.description = def.description;\n\t\tif (refs.markdownDescription) jsonSchema.markdownDescription = def.description;\n\t}\n\treturn jsonSchema;\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js\nconst zodToJsonSchema = (schema, options) => {\n\tconst refs = getRefs(options);\n\tlet definitions = typeof options === \"object\" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({\n\t\t...acc,\n\t\t[name]: parseDef(schema._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.basePath,\n\t\t\t\trefs.definitionPath,\n\t\t\t\tname\n\t\t\t]\n\t\t}, true) ?? parseAnyDef(refs)\n\t}), {}) : void 0;\n\tconst name = typeof options === \"string\" ? options : options?.nameStrategy === \"title\" ? void 0 : options?.name;\n\tconst main = parseDef(schema._def, name === void 0 ? refs : {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.basePath,\n\t\t\trefs.definitionPath,\n\t\t\tname\n\t\t]\n\t}, false) ?? parseAnyDef(refs);\n\tconst title = typeof options === \"object\" && options.name !== void 0 && options.nameStrategy === \"title\" ? options.name : void 0;\n\tif (title !== void 0) main.title = title;\n\tif (refs.flags.hasReferencedOpenAiAnyType) {\n\t\tif (!definitions) definitions = {};\n\t\tif (!definitions[refs.openAiAnyTypeName]) definitions[refs.openAiAnyTypeName] = {\n\t\t\ttype: [\n\t\t\t\t\"string\",\n\t\t\t\t\"number\",\n\t\t\t\t\"integer\",\n\t\t\t\t\"boolean\",\n\t\t\t\t\"array\",\n\t\t\t\t\"null\"\n\t\t\t],\n\t\t\titems: { $ref: refs.$refStrategy === \"relative\" ? \"1\" : [\n\t\t\t\t...refs.basePath,\n\t\t\t\trefs.definitionPath,\n\t\t\t\trefs.openAiAnyTypeName\n\t\t\t].join(\"/\") }\n\t\t};\n\t}\n\tconst combined = name === void 0 ? definitions ? {\n\t\t...main,\n\t\t[refs.definitionPath]: definitions\n\t} : main : {\n\t\t$ref: [\n\t\t\t...refs.$refStrategy === \"relative\" ? [] : refs.basePath,\n\t\t\trefs.definitionPath,\n\t\t\tname\n\t\t].join(\"/\"),\n\t\t[refs.definitionPath]: {\n\t\t\t...definitions,\n\t\t\t[name]: main\n\t\t}\n\t};\n\tif (refs.target === \"jsonSchema7\") combined.$schema = \"http://json-schema.org/draft-07/schema#\";\n\telse if (refs.target === \"jsonSchema2019-09\" || refs.target === \"openAi\") combined.$schema = \"https://json-schema.org/draft/2019-09/schema#\";\n\tif (refs.target === \"openAi\" && (\"anyOf\" in combined || \"oneOf\" in combined || \"allOf\" in combined || \"type\" in combined && Array.isArray(combined.type))) console.warn(\"Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.\");\n\treturn combined;\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-to-json-schema/3.25.2/11b60cc1af48e6db6bae9c01d6bfb4475dbd524727905fbbc909de63613a66c9/node_modules/zod-to-json-schema/dist/esm/index.js\nvar esm_default = zodToJsonSchema;\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/ui-utils/1.2.11/c6ae54af6e905ace5000fdb9a78bd72873ff36d086fe0a081e4a5ba6c6a22a1b/node_modules/@ai-sdk/ui-utils/dist/index.mjs\nvar textStreamPart = {\n\tcode: \"0\",\n\tname: \"text\",\n\tparse: (value) => {\n\t\tif (typeof value !== \"string\") throw new Error(\"\\\"text\\\" parts expect a string value.\");\n\t\treturn {\n\t\t\ttype: \"text\",\n\t\t\tvalue\n\t\t};\n\t}\n};\nvar errorStreamPart = {\n\tcode: \"3\",\n\tname: \"error\",\n\tparse: (value) => {\n\t\tif (typeof value !== \"string\") throw new Error(\"\\\"error\\\" parts expect a string value.\");\n\t\treturn {\n\t\t\ttype: \"error\",\n\t\t\tvalue\n\t\t};\n\t}\n};\nvar assistantMessageStreamPart = {\n\tcode: \"4\",\n\tname: \"assistant_message\",\n\tparse: (value) => {\n\t\tif (value == null || typeof value !== \"object\" || !(\"id\" in value) || !(\"role\" in value) || !(\"content\" in value) || typeof value.id !== \"string\" || typeof value.role !== \"string\" || value.role !== \"assistant\" || !Array.isArray(value.content) || !value.content.every((item) => item != null && typeof item === \"object\" && \"type\" in item && item.type === \"text\" && \"text\" in item && item.text != null && typeof item.text === \"object\" && \"value\" in item.text && typeof item.text.value === \"string\")) throw new Error(\"\\\"assistant_message\\\" parts expect an object with an \\\"id\\\", \\\"role\\\", and \\\"content\\\" property.\");\n\t\treturn {\n\t\t\ttype: \"assistant_message\",\n\t\t\tvalue\n\t\t};\n\t}\n};\nvar assistantControlDataStreamPart = {\n\tcode: \"5\",\n\tname: \"assistant_control_data\",\n\tparse: (value) => {\n\t\tif (value == null || typeof value !== \"object\" || !(\"threadId\" in value) || !(\"messageId\" in value) || typeof value.threadId !== \"string\" || typeof value.messageId !== \"string\") throw new Error(\"\\\"assistant_control_data\\\" parts expect an object with a \\\"threadId\\\" and \\\"messageId\\\" property.\");\n\t\treturn {\n\t\t\ttype: \"assistant_control_data\",\n\t\t\tvalue: {\n\t\t\t\tthreadId: value.threadId,\n\t\t\t\tmessageId: value.messageId\n\t\t\t}\n\t\t};\n\t}\n};\nvar dataMessageStreamPart = {\n\tcode: \"6\",\n\tname: \"data_message\",\n\tparse: (value) => {\n\t\tif (value == null || typeof value !== \"object\" || !(\"role\" in value) || !(\"data\" in value) || typeof value.role !== \"string\" || value.role !== \"data\") throw new Error(\"\\\"data_message\\\" parts expect an object with a \\\"role\\\" and \\\"data\\\" property.\");\n\t\treturn {\n\t\t\ttype: \"data_message\",\n\t\t\tvalue\n\t\t};\n\t}\n};\nvar assistantStreamParts = [\n\ttextStreamPart,\n\terrorStreamPart,\n\tassistantMessageStreamPart,\n\tassistantControlDataStreamPart,\n\tdataMessageStreamPart\n];\nvar assistantStreamPartsByCode = {\n\t[textStreamPart.code]: textStreamPart,\n\t[errorStreamPart.code]: errorStreamPart,\n\t[assistantMessageStreamPart.code]: assistantMessageStreamPart,\n\t[assistantControlDataStreamPart.code]: assistantControlDataStreamPart,\n\t[dataMessageStreamPart.code]: dataMessageStreamPart\n};\ntextStreamPart.name, textStreamPart.code, errorStreamPart.name, errorStreamPart.code, assistantMessageStreamPart.name, assistantMessageStreamPart.code, assistantControlDataStreamPart.name, assistantControlDataStreamPart.code, dataMessageStreamPart.name, dataMessageStreamPart.code;\nvar validCodes = assistantStreamParts.map((part) => part.code);\nvar parseAssistantStreamPart = (line) => {\n\tconst firstSeparatorIndex = line.indexOf(\":\");\n\tif (firstSeparatorIndex === -1) throw new Error(\"Failed to parse stream string. No separator found.\");\n\tconst prefix = line.slice(0, firstSeparatorIndex);\n\tif (!validCodes.includes(prefix)) throw new Error(`Failed to parse stream string. Invalid code ${prefix}.`);\n\tconst code = prefix;\n\tconst textValue = line.slice(firstSeparatorIndex + 1);\n\tconst jsonValue = JSON.parse(textValue);\n\treturn assistantStreamPartsByCode[code].parse(jsonValue);\n};\nfunction formatAssistantStreamPart(type, value) {\n\tconst streamPart = assistantStreamParts.find((part) => part.name === type);\n\tif (!streamPart) throw new Error(`Invalid stream part type: ${type}`);\n\treturn `${streamPart.code}:${JSON.stringify(value)}\n`;\n}\nfunction fixJson(input) {\n\tconst stack = [\"ROOT\"];\n\tlet lastValidIndex = -1;\n\tlet literalStart = null;\n\tfunction processValueStart(char, i, swapState) {\n\t\tswitch (char) {\n\t\t\tcase \"\\\"\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_STRING\");\n\t\t\t\tbreak;\n\t\t\tcase \"f\":\n\t\t\tcase \"t\":\n\t\t\tcase \"n\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tliteralStart = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_LITERAL\");\n\t\t\t\tbreak;\n\t\t\tcase \"-\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_NUMBER\");\n\t\t\t\tbreak;\n\t\t\tcase \"0\":\n\t\t\tcase \"1\":\n\t\t\tcase \"2\":\n\t\t\tcase \"3\":\n\t\t\tcase \"4\":\n\t\t\tcase \"5\":\n\t\t\tcase \"6\":\n\t\t\tcase \"7\":\n\t\t\tcase \"8\":\n\t\t\tcase \"9\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_NUMBER\");\n\t\t\t\tbreak;\n\t\t\tcase \"{\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_OBJECT_START\");\n\t\t\t\tbreak;\n\t\t\tcase \"[\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_ARRAY_START\");\n\t\t}\n\t}\n\tfunction processAfterObjectValue(char, i) {\n\t\tswitch (char) {\n\t\t\tcase \",\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(\"INSIDE_OBJECT_AFTER_COMMA\");\n\t\t\t\tbreak;\n\t\t\tcase \"}\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t}\n\t}\n\tfunction processAfterArrayValue(char, i) {\n\t\tswitch (char) {\n\t\t\tcase \",\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n\t\t\t\tbreak;\n\t\t\tcase \"]\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t}\n\t}\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst char = input[i];\n\t\tswitch (stack[stack.length - 1]) {\n\t\t\tcase \"ROOT\":\n\t\t\t\tprocessValueStart(char, i, \"FINISH\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_START\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_KEY\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"}\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_COMMA\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_KEY\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_KEY\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_AFTER_KEY\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_KEY\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \":\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_BEFORE_VALUE\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_BEFORE_VALUE\":\n\t\t\t\tprocessValueStart(char, i, \"INSIDE_OBJECT_AFTER_VALUE\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_VALUE\":\n\t\t\t\tprocessAfterObjectValue(char, i);\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"\\\\\":\n\t\t\t\t\t\tstack.push(\"INSIDE_STRING_ESCAPE\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: lastValidIndex = i;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_START\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tprocessValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_AFTER_VALUE\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \",\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: lastValidIndex = i;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_AFTER_COMMA\":\n\t\t\t\tprocessValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING_ESCAPE\":\n\t\t\t\tstack.pop();\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_NUMBER\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"0\":\n\t\t\t\t\tcase \"1\":\n\t\t\t\t\tcase \"2\":\n\t\t\t\t\tcase \"3\":\n\t\t\t\t\tcase \"4\":\n\t\t\t\t\tcase \"5\":\n\t\t\t\t\tcase \"6\":\n\t\t\t\t\tcase \"7\":\n\t\t\t\t\tcase \"8\":\n\t\t\t\t\tcase \"9\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"e\":\n\t\t\t\t\tcase \"E\":\n\t\t\t\t\tcase \"-\":\n\t\t\t\t\tcase \".\": break;\n\t\t\t\t\tcase \",\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"}\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: stack.pop();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_LITERAL\": {\n\t\t\t\tconst partialLiteral = input.substring(literalStart, i + 1);\n\t\t\t\tif (!\"false\".startsWith(partialLiteral) && !\"true\".startsWith(partialLiteral) && !\"null\".startsWith(partialLiteral)) {\n\t\t\t\t\tstack.pop();\n\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\telse if (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t} else lastValidIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tlet result = input.slice(0, lastValidIndex + 1);\n\tfor (let i = stack.length - 1; i >= 0; i--) switch (stack[i]) {\n\t\tcase \"INSIDE_STRING\":\n\t\t\tresult += \"\\\"\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_OBJECT_KEY\":\n\t\tcase \"INSIDE_OBJECT_AFTER_KEY\":\n\t\tcase \"INSIDE_OBJECT_AFTER_COMMA\":\n\t\tcase \"INSIDE_OBJECT_START\":\n\t\tcase \"INSIDE_OBJECT_BEFORE_VALUE\":\n\t\tcase \"INSIDE_OBJECT_AFTER_VALUE\":\n\t\t\tresult += \"}\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_ARRAY_START\":\n\t\tcase \"INSIDE_ARRAY_AFTER_COMMA\":\n\t\tcase \"INSIDE_ARRAY_AFTER_VALUE\":\n\t\t\tresult += \"]\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_LITERAL\": {\n\t\t\tconst partialLiteral = input.substring(literalStart, input.length);\n\t\t\tif (\"true\".startsWith(partialLiteral)) result += \"true\".slice(partialLiteral.length);\n\t\t\telse if (\"false\".startsWith(partialLiteral)) result += \"false\".slice(partialLiteral.length);\n\t\t\telse if (\"null\".startsWith(partialLiteral)) result += \"null\".slice(partialLiteral.length);\n\t\t}\n\t}\n\treturn result;\n}\nfunction parsePartialJson(jsonText) {\n\tif (jsonText === void 0) return {\n\t\tvalue: void 0,\n\t\tstate: \"undefined-input\"\n\t};\n\tlet result = safeParseJSON({ text: jsonText });\n\tif (result.success) return {\n\t\tvalue: result.value,\n\t\tstate: \"successful-parse\"\n\t};\n\tresult = safeParseJSON({ text: fixJson(jsonText) });\n\tif (result.success) return {\n\t\tvalue: result.value,\n\t\tstate: \"repaired-parse\"\n\t};\n\treturn {\n\t\tvalue: void 0,\n\t\tstate: \"failed-parse\"\n\t};\n}\nvar dataStreamParts = [\n\t{\n\t\tcode: \"0\",\n\t\tname: \"text\",\n\t\tparse: (value) => {\n\t\t\tif (typeof value !== \"string\") throw new Error(\"\\\"text\\\" parts expect a string value.\");\n\t\t\treturn {\n\t\t\t\ttype: \"text\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"2\",\n\t\tname: \"data\",\n\t\tparse: (value) => {\n\t\t\tif (!Array.isArray(value)) throw new Error(\"\\\"data\\\" parts expect an array value.\");\n\t\t\treturn {\n\t\t\t\ttype: \"data\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"3\",\n\t\tname: \"error\",\n\t\tparse: (value) => {\n\t\t\tif (typeof value !== \"string\") throw new Error(\"\\\"error\\\" parts expect a string value.\");\n\t\t\treturn {\n\t\t\t\ttype: \"error\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"8\",\n\t\tname: \"message_annotations\",\n\t\tparse: (value) => {\n\t\t\tif (!Array.isArray(value)) throw new Error(\"\\\"message_annotations\\\" parts expect an array value.\");\n\t\t\treturn {\n\t\t\t\ttype: \"message_annotations\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"9\",\n\t\tname: \"tool_call\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"toolCallId\" in value) || typeof value.toolCallId !== \"string\" || !(\"toolName\" in value) || typeof value.toolName !== \"string\" || !(\"args\" in value) || typeof value.args !== \"object\") throw new Error(\"\\\"tool_call\\\" parts expect an object with a \\\"toolCallId\\\", \\\"toolName\\\", and \\\"args\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"tool_call\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"a\",\n\t\tname: \"tool_result\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"toolCallId\" in value) || typeof value.toolCallId !== \"string\" || !(\"result\" in value)) throw new Error(\"\\\"tool_result\\\" parts expect an object with a \\\"toolCallId\\\" and a \\\"result\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"tool_result\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"b\",\n\t\tname: \"tool_call_streaming_start\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"toolCallId\" in value) || typeof value.toolCallId !== \"string\" || !(\"toolName\" in value) || typeof value.toolName !== \"string\") throw new Error(\"\\\"tool_call_streaming_start\\\" parts expect an object with a \\\"toolCallId\\\" and \\\"toolName\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"tool_call_streaming_start\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"c\",\n\t\tname: \"tool_call_delta\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"toolCallId\" in value) || typeof value.toolCallId !== \"string\" || !(\"argsTextDelta\" in value) || typeof value.argsTextDelta !== \"string\") throw new Error(\"\\\"tool_call_delta\\\" parts expect an object with a \\\"toolCallId\\\" and \\\"argsTextDelta\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"tool_call_delta\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"d\",\n\t\tname: \"finish_message\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"finishReason\" in value) || typeof value.finishReason !== \"string\") throw new Error(\"\\\"finish_message\\\" parts expect an object with a \\\"finishReason\\\" property.\");\n\t\t\tconst result = { finishReason: value.finishReason };\n\t\t\tif (\"usage\" in value && value.usage != null && typeof value.usage === \"object\" && \"promptTokens\" in value.usage && \"completionTokens\" in value.usage) result.usage = {\n\t\t\t\tpromptTokens: typeof value.usage.promptTokens === \"number\" ? value.usage.promptTokens : NaN,\n\t\t\t\tcompletionTokens: typeof value.usage.completionTokens === \"number\" ? value.usage.completionTokens : NaN\n\t\t\t};\n\t\t\treturn {\n\t\t\t\ttype: \"finish_message\",\n\t\t\t\tvalue: result\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"e\",\n\t\tname: \"finish_step\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"finishReason\" in value) || typeof value.finishReason !== \"string\") throw new Error(\"\\\"finish_step\\\" parts expect an object with a \\\"finishReason\\\" property.\");\n\t\t\tconst result = {\n\t\t\t\tfinishReason: value.finishReason,\n\t\t\t\tisContinued: false\n\t\t\t};\n\t\t\tif (\"usage\" in value && value.usage != null && typeof value.usage === \"object\" && \"promptTokens\" in value.usage && \"completionTokens\" in value.usage) result.usage = {\n\t\t\t\tpromptTokens: typeof value.usage.promptTokens === \"number\" ? value.usage.promptTokens : NaN,\n\t\t\t\tcompletionTokens: typeof value.usage.completionTokens === \"number\" ? value.usage.completionTokens : NaN\n\t\t\t};\n\t\t\tif (\"isContinued\" in value && typeof value.isContinued === \"boolean\") result.isContinued = value.isContinued;\n\t\t\treturn {\n\t\t\t\ttype: \"finish_step\",\n\t\t\t\tvalue: result\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"f\",\n\t\tname: \"start_step\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"messageId\" in value) || typeof value.messageId !== \"string\") throw new Error(\"\\\"start_step\\\" parts expect an object with an \\\"id\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"start_step\",\n\t\t\t\tvalue: { messageId: value.messageId }\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"g\",\n\t\tname: \"reasoning\",\n\t\tparse: (value) => {\n\t\t\tif (typeof value !== \"string\") throw new Error(\"\\\"reasoning\\\" parts expect a string value.\");\n\t\t\treturn {\n\t\t\t\ttype: \"reasoning\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"h\",\n\t\tname: \"source\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\") throw new Error(\"\\\"source\\\" parts expect a Source object.\");\n\t\t\treturn {\n\t\t\t\ttype: \"source\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"i\",\n\t\tname: \"redacted_reasoning\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"data\" in value) || typeof value.data !== \"string\") throw new Error(\"\\\"redacted_reasoning\\\" parts expect an object with a \\\"data\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"redacted_reasoning\",\n\t\t\t\tvalue: { data: value.data }\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"j\",\n\t\tname: \"reasoning_signature\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"signature\" in value) || typeof value.signature !== \"string\") throw new Error(\"\\\"reasoning_signature\\\" parts expect an object with a \\\"signature\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"reasoning_signature\",\n\t\t\t\tvalue: { signature: value.signature }\n\t\t\t};\n\t\t}\n\t},\n\t{\n\t\tcode: \"k\",\n\t\tname: \"file\",\n\t\tparse: (value) => {\n\t\t\tif (value == null || typeof value !== \"object\" || !(\"data\" in value) || typeof value.data !== \"string\" || !(\"mimeType\" in value) || typeof value.mimeType !== \"string\") throw new Error(\"\\\"file\\\" parts expect an object with a \\\"data\\\" and \\\"mimeType\\\" property.\");\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tvalue\n\t\t\t};\n\t\t}\n\t}\n];\nvar dataStreamPartsByCode = Object.fromEntries(dataStreamParts.map((part) => [part.code, part]));\nObject.fromEntries(dataStreamParts.map((part) => [part.name, part.code]));\nvar validCodes2 = dataStreamParts.map((part) => part.code);\nvar parseDataStreamPart = (line) => {\n\tconst firstSeparatorIndex = line.indexOf(\":\");\n\tif (firstSeparatorIndex === -1) throw new Error(\"Failed to parse stream string. No separator found.\");\n\tconst prefix = line.slice(0, firstSeparatorIndex);\n\tif (!validCodes2.includes(prefix)) throw new Error(`Failed to parse stream string. Invalid code ${prefix}.`);\n\tconst code = prefix;\n\tconst textValue = line.slice(firstSeparatorIndex + 1);\n\tconst jsonValue = JSON.parse(textValue);\n\treturn dataStreamPartsByCode[code].parse(jsonValue);\n};\nfunction formatDataStreamPart(type, value) {\n\tconst streamPart = dataStreamParts.find((part) => part.name === type);\n\tif (!streamPart) throw new Error(`Invalid stream part type: ${type}`);\n\treturn `${streamPart.code}:${JSON.stringify(value)}\n`;\n}\nvar NEWLINE = \"\\n\".charCodeAt(0);\nfunction concatChunks(chunks, totalLength) {\n\tconst concatenatedChunks = new Uint8Array(totalLength);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tconcatenatedChunks.set(chunk, offset);\n\t\toffset += chunk.length;\n\t}\n\tchunks.length = 0;\n\treturn concatenatedChunks;\n}\nasync function processDataStream({ stream, onTextPart, onReasoningPart, onReasoningSignaturePart, onRedactedReasoningPart, onSourcePart, onFilePart, onDataPart, onErrorPart, onToolCallStreamingStartPart, onToolCallDeltaPart, onToolCallPart, onToolResultPart, onMessageAnnotationsPart, onFinishMessagePart, onFinishStepPart, onStartStepPart }) {\n\tconst reader = stream.getReader();\n\tconst decoder = new TextDecoder();\n\tconst chunks = [];\n\tlet totalLength = 0;\n\twhile (true) {\n\t\tconst { value } = await reader.read();\n\t\tif (value) {\n\t\t\tchunks.push(value);\n\t\t\ttotalLength += value.length;\n\t\t\tif (value[value.length - 1] !== NEWLINE) continue;\n\t\t}\n\t\tif (chunks.length === 0) break;\n\t\tconst concatenatedChunks = concatChunks(chunks, totalLength);\n\t\ttotalLength = 0;\n\t\tconst streamParts = decoder.decode(concatenatedChunks, { stream: true }).split(\"\\n\").filter((line) => line !== \"\").map(parseDataStreamPart);\n\t\tfor (const { type, value: value2 } of streamParts) switch (type) {\n\t\t\tcase \"text\":\n\t\t\t\tawait (onTextPart == null ? void 0 : onTextPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"reasoning\":\n\t\t\t\tawait (onReasoningPart == null ? void 0 : onReasoningPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"reasoning_signature\":\n\t\t\t\tawait (onReasoningSignaturePart == null ? void 0 : onReasoningSignaturePart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"redacted_reasoning\":\n\t\t\t\tawait (onRedactedReasoningPart == null ? void 0 : onRedactedReasoningPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tawait (onFilePart == null ? void 0 : onFilePart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"source\":\n\t\t\t\tawait (onSourcePart == null ? void 0 : onSourcePart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"data\":\n\t\t\t\tawait (onDataPart == null ? void 0 : onDataPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"error\":\n\t\t\t\tawait (onErrorPart == null ? void 0 : onErrorPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"message_annotations\":\n\t\t\t\tawait (onMessageAnnotationsPart == null ? void 0 : onMessageAnnotationsPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"tool_call_streaming_start\":\n\t\t\t\tawait (onToolCallStreamingStartPart == null ? void 0 : onToolCallStreamingStartPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"tool_call_delta\":\n\t\t\t\tawait (onToolCallDeltaPart == null ? void 0 : onToolCallDeltaPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"tool_call\":\n\t\t\t\tawait (onToolCallPart == null ? void 0 : onToolCallPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"tool_result\":\n\t\t\t\tawait (onToolResultPart == null ? void 0 : onToolResultPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"finish_message\":\n\t\t\t\tawait (onFinishMessagePart == null ? void 0 : onFinishMessagePart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"finish_step\":\n\t\t\t\tawait (onFinishStepPart == null ? void 0 : onFinishStepPart(value2));\n\t\t\t\tbreak;\n\t\t\tcase \"start_step\":\n\t\t\t\tawait (onStartStepPart == null ? void 0 : onStartStepPart(value2));\n\t\t\t\tbreak;\n\t\t\tdefault: throw new Error(`Unknown stream part type: ${type}`);\n\t\t}\n\t}\n}\nasync function processTextStream({ stream, onTextPart }) {\n\tconst reader = stream.pipeThrough(new TextDecoderStream()).getReader();\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\tawait onTextPart(value);\n\t}\n}\nfunction extractMaxToolInvocationStep(toolInvocations) {\n\treturn toolInvocations == null ? void 0 : toolInvocations.reduce((max, toolInvocation) => {\n\t\tvar _a;\n\t\treturn Math.max(max, (_a = toolInvocation.step) != null ? _a : 0);\n\t}, 0);\n}\nfunction isDeepEqualData(obj1, obj2) {\n\tif (obj1 === obj2) return true;\n\tif (obj1 == null || obj2 == null) return false;\n\tif (typeof obj1 !== \"object\" && typeof obj2 !== \"object\") return obj1 === obj2;\n\tif (obj1.constructor !== obj2.constructor) return false;\n\tif (obj1 instanceof Date && obj2 instanceof Date) return obj1.getTime() === obj2.getTime();\n\tif (Array.isArray(obj1)) {\n\t\tif (obj1.length !== obj2.length) return false;\n\t\tfor (let i = 0; i < obj1.length; i++) if (!isDeepEqualData(obj1[i], obj2[i])) return false;\n\t\treturn true;\n\t}\n\tconst keys1 = Object.keys(obj1);\n\tconst keys2 = Object.keys(obj2);\n\tif (keys1.length !== keys2.length) return false;\n\tfor (const key of keys1) {\n\t\tif (!keys2.includes(key)) return false;\n\t\tif (!isDeepEqualData(obj1[key], obj2[key])) return false;\n\t}\n\treturn true;\n}\n\"\\n\".charCodeAt(0);\nfunction zodSchema(zodSchema2, options) {\n\tvar _a;\n\treturn jsonSchema(esm_default(zodSchema2, {\n\t\t$refStrategy: ((_a = options == null ? void 0 : options.useReferences) != null ? _a : false) ? \"root\" : \"none\",\n\t\ttarget: \"jsonSchema7\"\n\t}), { validate: (value) => {\n\t\tconst result = zodSchema2.safeParse(value);\n\t\treturn result.success ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.data\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: result.error\n\t\t};\n\t} });\n}\nvar schemaSymbol = Symbol.for(\"vercel.ai.schema\");\nfunction jsonSchema(jsonSchema2, { validate } = {}) {\n\treturn {\n\t\t[schemaSymbol]: true,\n\t\t_type: void 0,\n\t\t[validatorSymbol]: true,\n\t\tjsonSchema: jsonSchema2,\n\t\tvalidate\n\t};\n}\nfunction isSchema(value) {\n\treturn typeof value === \"object\" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && \"jsonSchema\" in value && \"validate\" in value;\n}\nfunction asSchema(schema) {\n\treturn isSchema(schema) ? schema : zodSchema(schema);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js\n/** only globals that common to node and browsers are allowed */\nvar _globalThis = typeof globalThis === \"object\" ? globalThis : global;\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/version.js\nvar VERSION = \"1.9.0\";\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/internal/semver.js\nvar re = /^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;\n/**\n* Create a function to test an API version to see if it is compatible with the provided ownVersion.\n*\n* The returned function has the following semantics:\n* - Exact match is always compatible\n* - Major versions must match exactly\n*    - 1.x package cannot use global 2.x package\n*    - 2.x package cannot use global 1.x package\n* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n*    - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n*    - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n* - Patch and build tag differences are not considered at this time\n*\n* @param ownVersion version which should be checked against\n*/\nfunction _makeCompatibilityCheck(ownVersion) {\n\tvar acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);\n\tvar rejectedVersions = /* @__PURE__ */ new Set();\n\tvar myVersionMatch = ownVersion.match(re);\n\tif (!myVersionMatch) return function() {\n\t\treturn false;\n\t};\n\tvar ownVersionParsed = {\n\t\tmajor: +myVersionMatch[1],\n\t\tminor: +myVersionMatch[2],\n\t\tpatch: +myVersionMatch[3],\n\t\tprerelease: myVersionMatch[4]\n\t};\n\tif (ownVersionParsed.prerelease != null) return function isExactmatch(globalVersion) {\n\t\treturn globalVersion === ownVersion;\n\t};\n\tfunction _reject(v) {\n\t\trejectedVersions.add(v);\n\t\treturn false;\n\t}\n\tfunction _accept(v) {\n\t\tacceptedVersions.add(v);\n\t\treturn true;\n\t}\n\treturn function isCompatible(globalVersion) {\n\t\tif (acceptedVersions.has(globalVersion)) return true;\n\t\tif (rejectedVersions.has(globalVersion)) return false;\n\t\tvar globalVersionMatch = globalVersion.match(re);\n\t\tif (!globalVersionMatch) return _reject(globalVersion);\n\t\tvar globalVersionParsed = {\n\t\t\tmajor: +globalVersionMatch[1],\n\t\t\tminor: +globalVersionMatch[2],\n\t\t\tpatch: +globalVersionMatch[3],\n\t\t\tprerelease: globalVersionMatch[4]\n\t\t};\n\t\tif (globalVersionParsed.prerelease != null) return _reject(globalVersion);\n\t\tif (ownVersionParsed.major !== globalVersionParsed.major) return _reject(globalVersion);\n\t\tif (ownVersionParsed.major === 0) {\n\t\t\tif (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) return _accept(globalVersion);\n\t\t\treturn _reject(globalVersion);\n\t\t}\n\t\tif (ownVersionParsed.minor <= globalVersionParsed.minor) return _accept(globalVersion);\n\t\treturn _reject(globalVersion);\n\t};\n}\n/**\n* Test an API version to see if it is compatible with this API.\n*\n* - Exact match is always compatible\n* - Major versions must match exactly\n*    - 1.x package cannot use global 2.x package\n*    - 2.x package cannot use global 1.x package\n* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n*    - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n*    - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n* - Patch and build tag differences are not considered at this time\n*\n* @param version version of the API requesting an instance of the global API\n*/\nvar isCompatible = _makeCompatibilityCheck(VERSION);\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js\nvar major = VERSION.split(\".\")[0];\nvar GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(\"opentelemetry.js.api.\" + major);\nvar _global = _globalThis;\nfunction registerGlobal(type, instance, diag, allowOverride) {\n\tvar _a;\n\tif (allowOverride === void 0) allowOverride = false;\n\tvar api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : { version: VERSION };\n\tif (!allowOverride && api[type]) {\n\t\tvar err = /* @__PURE__ */ new Error(\"@opentelemetry/api: Attempted duplicate registration of API: \" + type);\n\t\tdiag.error(err.stack || err.message);\n\t\treturn false;\n\t}\n\tif (api.version !== \"1.9.0\") {\n\t\tvar err = /* @__PURE__ */ new Error(\"@opentelemetry/api: Registration of version v\" + api.version + \" for \" + type + \" does not match previously registered API v\" + VERSION);\n\t\tdiag.error(err.stack || err.message);\n\t\treturn false;\n\t}\n\tapi[type] = instance;\n\tdiag.debug(\"@opentelemetry/api: Registered a global for \" + type + \" v\" + VERSION + \".\");\n\treturn true;\n}\nfunction getGlobal(type) {\n\tvar _a, _b;\n\tvar globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;\n\tif (!globalVersion || !isCompatible(globalVersion)) return;\n\treturn (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];\n}\nfunction unregisterGlobal(type, diag) {\n\tdiag.debug(\"@opentelemetry/api: Unregistering a global for \" + type + \" v\" + VERSION + \".\");\n\tvar api = _global[GLOBAL_OPENTELEMETRY_API_KEY];\n\tif (api) delete api[type];\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js\nvar __read$3 = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray$3 = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\n/**\n* Component Logger which is meant to be used as part of any component which\n* will add automatically additional namespace in front of the log message.\n* It will then forward all message to global diag logger\n* @example\n* const cLogger = diag.createComponentLogger({ namespace: '@opentelemetry/instrumentation-http' });\n* cLogger.debug('test');\n* // @opentelemetry/instrumentation-http test\n*/\nvar DiagComponentLogger = function() {\n\tfunction DiagComponentLogger(props) {\n\t\tthis._namespace = props.namespace || \"DiagComponentLogger\";\n\t}\n\tDiagComponentLogger.prototype.debug = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"debug\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.error = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"error\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.info = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"info\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.warn = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"warn\", this._namespace, args);\n\t};\n\tDiagComponentLogger.prototype.verbose = function() {\n\t\tvar args = [];\n\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\treturn logProxy(\"verbose\", this._namespace, args);\n\t};\n\treturn DiagComponentLogger;\n}();\nfunction logProxy(funcName, namespace, args) {\n\tvar logger = getGlobal(\"diag\");\n\tif (!logger) return;\n\targs.unshift(namespace);\n\treturn logger[funcName].apply(logger, __spreadArray$3([], __read$3(args), false));\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/diag/types.js\n/**\n* Defines the available internal logging levels for the diagnostic logger, the numeric values\n* of the levels are defined to match the original values from the initial LogLevel to avoid\n* compatibility/migration issues for any implementation that assume the numeric ordering.\n*/\nvar DiagLogLevel;\n(function(DiagLogLevel) {\n\t/** Diagnostic Logging level setting to disable all logging (except and forced logs) */\n\tDiagLogLevel[DiagLogLevel[\"NONE\"] = 0] = \"NONE\";\n\t/** Identifies an error scenario */\n\tDiagLogLevel[DiagLogLevel[\"ERROR\"] = 30] = \"ERROR\";\n\t/** Identifies a warning scenario */\n\tDiagLogLevel[DiagLogLevel[\"WARN\"] = 50] = \"WARN\";\n\t/** General informational log message */\n\tDiagLogLevel[DiagLogLevel[\"INFO\"] = 60] = \"INFO\";\n\t/** General debug log message */\n\tDiagLogLevel[DiagLogLevel[\"DEBUG\"] = 70] = \"DEBUG\";\n\t/**\n\t* Detailed trace level logging should only be used for development, should only be set\n\t* in a development environment.\n\t*/\n\tDiagLogLevel[DiagLogLevel[\"VERBOSE\"] = 80] = \"VERBOSE\";\n\t/** Used to set the logging level to include all logging */\n\tDiagLogLevel[DiagLogLevel[\"ALL\"] = 9999] = \"ALL\";\n})(DiagLogLevel || (DiagLogLevel = {}));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js\nfunction createLogLevelDiagLogger(maxLevel, logger) {\n\tif (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;\n\telse if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;\n\tlogger = logger || {};\n\tfunction _filterFunc(funcName, theLevel) {\n\t\tvar theFunc = logger[funcName];\n\t\tif (typeof theFunc === \"function\" && maxLevel >= theLevel) return theFunc.bind(logger);\n\t\treturn function() {};\n\t}\n\treturn {\n\t\terror: _filterFunc(\"error\", DiagLogLevel.ERROR),\n\t\twarn: _filterFunc(\"warn\", DiagLogLevel.WARN),\n\t\tinfo: _filterFunc(\"info\", DiagLogLevel.INFO),\n\t\tdebug: _filterFunc(\"debug\", DiagLogLevel.DEBUG),\n\t\tverbose: _filterFunc(\"verbose\", DiagLogLevel.VERBOSE)\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/api/diag.js\nvar __read$2 = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray$2 = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\nvar API_NAME$2 = \"diag\";\n/**\n* Singleton object which represents the entry point to the OpenTelemetry internal\n* diagnostic API\n*/\nvar DiagAPI = function() {\n\t/**\n\t* Private internal constructor\n\t* @private\n\t*/\n\tfunction DiagAPI() {\n\t\tfunction _logProxy(funcName) {\n\t\t\treturn function() {\n\t\t\t\tvar args = [];\n\t\t\t\tfor (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];\n\t\t\t\tvar logger = getGlobal(\"diag\");\n\t\t\t\tif (!logger) return;\n\t\t\t\treturn logger[funcName].apply(logger, __spreadArray$2([], __read$2(args), false));\n\t\t\t};\n\t\t}\n\t\tvar self = this;\n\t\tvar setLogger = function(logger, optionsOrLogLevel) {\n\t\t\tvar _a, _b, _c;\n\t\t\tif (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };\n\t\t\tif (logger === self) {\n\t\t\t\tvar err = /* @__PURE__ */ new Error(\"Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation\");\n\t\t\t\tself.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (typeof optionsOrLogLevel === \"number\") optionsOrLogLevel = { logLevel: optionsOrLogLevel };\n\t\t\tvar oldLogger = getGlobal(\"diag\");\n\t\t\tvar newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);\n\t\t\tif (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {\n\t\t\t\tvar stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : \"<failed to generate stacktrace>\";\n\t\t\t\toldLogger.warn(\"Current logger will be overwritten from \" + stack);\n\t\t\t\tnewLogger.warn(\"Current logger will overwrite one already registered from \" + stack);\n\t\t\t}\n\t\t\treturn registerGlobal(\"diag\", newLogger, self, true);\n\t\t};\n\t\tself.setLogger = setLogger;\n\t\tself.disable = function() {\n\t\t\tunregisterGlobal(API_NAME$2, self);\n\t\t};\n\t\tself.createComponentLogger = function(options) {\n\t\t\treturn new DiagComponentLogger(options);\n\t\t};\n\t\tself.verbose = _logProxy(\"verbose\");\n\t\tself.debug = _logProxy(\"debug\");\n\t\tself.info = _logProxy(\"info\");\n\t\tself.warn = _logProxy(\"warn\");\n\t\tself.error = _logProxy(\"error\");\n\t}\n\t/** Get the singleton instance of the DiagAPI API */\n\tDiagAPI.instance = function() {\n\t\tif (!this._instance) this._instance = new DiagAPI();\n\t\treturn this._instance;\n\t};\n\treturn DiagAPI;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/context/context.js\n/** Get a key to uniquely identify a context value */\nfunction createContextKey(description) {\n\treturn Symbol.for(description);\n}\n/** The root context is used as the default parent context when there is no active context */\nvar ROOT_CONTEXT = new (function() {\n\t/**\n\t* Construct a new context which inherits values from an optional parent context.\n\t*\n\t* @param parentContext a context from which to inherit values\n\t*/\n\tfunction BaseContext(parentContext) {\n\t\tvar self = this;\n\t\tself._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();\n\t\tself.getValue = function(key) {\n\t\t\treturn self._currentContext.get(key);\n\t\t};\n\t\tself.setValue = function(key, value) {\n\t\t\tvar context = new BaseContext(self._currentContext);\n\t\t\tcontext._currentContext.set(key, value);\n\t\t\treturn context;\n\t\t};\n\t\tself.deleteValue = function(key) {\n\t\t\tvar context = new BaseContext(self._currentContext);\n\t\t\tcontext._currentContext.delete(key);\n\t\t\treturn context;\n\t\t};\n\t}\n\treturn BaseContext;\n}())();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js\nvar __read$1 = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray$1 = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\nvar NoopContextManager = function() {\n\tfunction NoopContextManager() {}\n\tNoopContextManager.prototype.active = function() {\n\t\treturn ROOT_CONTEXT;\n\t};\n\tNoopContextManager.prototype.with = function(_context, fn, thisArg) {\n\t\tvar args = [];\n\t\tfor (var _i = 3; _i < arguments.length; _i++) args[_i - 3] = arguments[_i];\n\t\treturn fn.call.apply(fn, __spreadArray$1([thisArg], __read$1(args), false));\n\t};\n\tNoopContextManager.prototype.bind = function(_context, target) {\n\t\treturn target;\n\t};\n\tNoopContextManager.prototype.enable = function() {\n\t\treturn this;\n\t};\n\tNoopContextManager.prototype.disable = function() {\n\t\treturn this;\n\t};\n\treturn NoopContextManager;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/api/context.js\nvar __read = function(o, n) {\n\tvar m = typeof Symbol === \"function\" && o[Symbol.iterator];\n\tif (!m) return o;\n\tvar i = m.call(o), r, ar = [], e;\n\ttry {\n\t\twhile ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n\t} catch (error) {\n\t\te = { error };\n\t} finally {\n\t\ttry {\n\t\t\tif (r && !r.done && (m = i[\"return\"])) m.call(i);\n\t\t} finally {\n\t\t\tif (e) throw e.error;\n\t\t}\n\t}\n\treturn ar;\n};\nvar __spreadArray = function(to, from, pack) {\n\tif (pack || arguments.length === 2) {\n\t\tfor (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {\n\t\t\tif (!ar) ar = Array.prototype.slice.call(from, 0, i);\n\t\t\tar[i] = from[i];\n\t\t}\n\t}\n\treturn to.concat(ar || Array.prototype.slice.call(from));\n};\nvar API_NAME$1 = \"context\";\nvar NOOP_CONTEXT_MANAGER = new NoopContextManager();\n/**\n* Singleton object which represents the entry point to the OpenTelemetry Context API\n*/\nvar ContextAPI = function() {\n\t/** Empty private constructor prevents end users from constructing a new instance of the API */\n\tfunction ContextAPI() {}\n\t/** Get the singleton instance of the Context API */\n\tContextAPI.getInstance = function() {\n\t\tif (!this._instance) this._instance = new ContextAPI();\n\t\treturn this._instance;\n\t};\n\t/**\n\t* Set the current context manager.\n\t*\n\t* @returns true if the context manager was successfully registered, else false\n\t*/\n\tContextAPI.prototype.setGlobalContextManager = function(contextManager) {\n\t\treturn registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());\n\t};\n\t/**\n\t* Get the currently active context\n\t*/\n\tContextAPI.prototype.active = function() {\n\t\treturn this._getContextManager().active();\n\t};\n\t/**\n\t* Execute a function with an active context\n\t*\n\t* @param context context to be active during function execution\n\t* @param fn function to execute in a context\n\t* @param thisArg optional receiver to be used for calling fn\n\t* @param args optional arguments forwarded to fn\n\t*/\n\tContextAPI.prototype.with = function(context, fn, thisArg) {\n\t\tvar _a;\n\t\tvar args = [];\n\t\tfor (var _i = 3; _i < arguments.length; _i++) args[_i - 3] = arguments[_i];\n\t\treturn (_a = this._getContextManager()).with.apply(_a, __spreadArray([\n\t\t\tcontext,\n\t\t\tfn,\n\t\t\tthisArg\n\t\t], __read(args), false));\n\t};\n\t/**\n\t* Bind a context to a target function or event emitter\n\t*\n\t* @param context context to bind to the event emitter or function. Defaults to the currently active context\n\t* @param target function or event emitter to bind\n\t*/\n\tContextAPI.prototype.bind = function(context, target) {\n\t\treturn this._getContextManager().bind(context, target);\n\t};\n\tContextAPI.prototype._getContextManager = function() {\n\t\treturn getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;\n\t};\n\t/** Disable and remove the global context manager */\n\tContextAPI.prototype.disable = function() {\n\t\tthis._getContextManager().disable();\n\t\tunregisterGlobal(API_NAME$1, DiagAPI.instance());\n\t};\n\treturn ContextAPI;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js\nvar TraceFlags;\n(function(TraceFlags) {\n\t/** Represents no flag set. */\n\tTraceFlags[TraceFlags[\"NONE\"] = 0] = \"NONE\";\n\t/** Bit to represent whether trace is sampled in trace flags. */\n\tTraceFlags[TraceFlags[\"SAMPLED\"] = 1] = \"SAMPLED\";\n})(TraceFlags || (TraceFlags = {}));\nvar INVALID_SPAN_CONTEXT = {\n\ttraceId: \"00000000000000000000000000000000\",\n\tspanId: \"0000000000000000\",\n\ttraceFlags: TraceFlags.NONE\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js\n/**\n* The NonRecordingSpan is the default {@link Span} that is used when no Span\n* implementation is available. All operations are no-op including context\n* propagation.\n*/\nvar NonRecordingSpan = function() {\n\tfunction NonRecordingSpan(_spanContext) {\n\t\tif (_spanContext === void 0) _spanContext = INVALID_SPAN_CONTEXT;\n\t\tthis._spanContext = _spanContext;\n\t}\n\tNonRecordingSpan.prototype.spanContext = function() {\n\t\treturn this._spanContext;\n\t};\n\tNonRecordingSpan.prototype.setAttribute = function(_key, _value) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.setAttributes = function(_attributes) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.addEvent = function(_name, _attributes) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.addLink = function(_link) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.addLinks = function(_links) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.setStatus = function(_status) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.updateName = function(_name) {\n\t\treturn this;\n\t};\n\tNonRecordingSpan.prototype.end = function(_endTime) {};\n\tNonRecordingSpan.prototype.isRecording = function() {\n\t\treturn false;\n\t};\n\tNonRecordingSpan.prototype.recordException = function(_exception, _time) {};\n\treturn NonRecordingSpan;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js\n/**\n* span key\n*/\nvar SPAN_KEY = createContextKey(\"OpenTelemetry Context Key SPAN\");\n/**\n* Return the span if one exists\n*\n* @param context context to get span from\n*/\nfunction getSpan(context) {\n\treturn context.getValue(SPAN_KEY) || void 0;\n}\n/**\n* Gets the span from the current context, if one exists.\n*/\nfunction getActiveSpan() {\n\treturn getSpan(ContextAPI.getInstance().active());\n}\n/**\n* Set the span on a context\n*\n* @param context context to use as parent\n* @param span span to set active\n*/\nfunction setSpan(context, span) {\n\treturn context.setValue(SPAN_KEY, span);\n}\n/**\n* Remove current span stored in the context\n*\n* @param context context to delete span from\n*/\nfunction deleteSpan(context) {\n\treturn context.deleteValue(SPAN_KEY);\n}\n/**\n* Wrap span context in a NoopSpan and set as span in a new\n* context\n*\n* @param context context to set active span on\n* @param spanContext span context to be wrapped\n*/\nfunction setSpanContext(context, spanContext) {\n\treturn setSpan(context, new NonRecordingSpan(spanContext));\n}\n/**\n* Get the span context of the span if it exists.\n*\n* @param context context to get values from\n*/\nfunction getSpanContext(context) {\n\tvar _a;\n\treturn (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js\nvar VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;\nvar VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;\nfunction isValidTraceId(traceId) {\n\treturn VALID_TRACEID_REGEX.test(traceId) && traceId !== \"00000000000000000000000000000000\";\n}\nfunction isValidSpanId(spanId) {\n\treturn VALID_SPANID_REGEX.test(spanId) && spanId !== \"0000000000000000\";\n}\n/**\n* Returns true if this {@link SpanContext} is valid.\n* @return true if this {@link SpanContext} is valid.\n*/\nfunction isSpanContextValid(spanContext) {\n\treturn isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);\n}\n/**\n* Wrap the given {@link SpanContext} in a new non-recording {@link Span}\n*\n* @param spanContext span context to be wrapped\n* @returns a new non-recording {@link Span} with the provided context\n*/\nfunction wrapSpanContext(spanContext) {\n\treturn new NonRecordingSpan(spanContext);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js\nvar contextApi = ContextAPI.getInstance();\n/**\n* No-op implementations of {@link Tracer}.\n*/\nvar NoopTracer = function() {\n\tfunction NoopTracer() {}\n\tNoopTracer.prototype.startSpan = function(name, options, context) {\n\t\tif (context === void 0) context = contextApi.active();\n\t\tif (Boolean(options === null || options === void 0 ? void 0 : options.root)) return new NonRecordingSpan();\n\t\tvar parentFromContext = context && getSpanContext(context);\n\t\tif (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) return new NonRecordingSpan(parentFromContext);\n\t\telse return new NonRecordingSpan();\n\t};\n\tNoopTracer.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {\n\t\tvar opts;\n\t\tvar ctx;\n\t\tvar fn;\n\t\tif (arguments.length < 2) return;\n\t\telse if (arguments.length === 2) fn = arg2;\n\t\telse if (arguments.length === 3) {\n\t\t\topts = arg2;\n\t\t\tfn = arg3;\n\t\t} else {\n\t\t\topts = arg2;\n\t\t\tctx = arg3;\n\t\t\tfn = arg4;\n\t\t}\n\t\tvar parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();\n\t\tvar span = this.startSpan(name, opts, parentContext);\n\t\tvar contextWithSpanSet = setSpan(parentContext, span);\n\t\treturn contextApi.with(contextWithSpanSet, fn, void 0, span);\n\t};\n\treturn NoopTracer;\n}();\nfunction isSpanContext(spanContext) {\n\treturn typeof spanContext === \"object\" && typeof spanContext[\"spanId\"] === \"string\" && typeof spanContext[\"traceId\"] === \"string\" && typeof spanContext[\"traceFlags\"] === \"number\";\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js\nvar NOOP_TRACER = new NoopTracer();\n/**\n* Proxy tracer provided by the proxy tracer provider\n*/\nvar ProxyTracer = function() {\n\tfunction ProxyTracer(_provider, name, version, options) {\n\t\tthis._provider = _provider;\n\t\tthis.name = name;\n\t\tthis.version = version;\n\t\tthis.options = options;\n\t}\n\tProxyTracer.prototype.startSpan = function(name, options, context) {\n\t\treturn this._getTracer().startSpan(name, options, context);\n\t};\n\tProxyTracer.prototype.startActiveSpan = function(_name, _options, _context, _fn) {\n\t\tvar tracer = this._getTracer();\n\t\treturn Reflect.apply(tracer.startActiveSpan, tracer, arguments);\n\t};\n\t/**\n\t* Try to get a tracer from the proxy tracer provider.\n\t* If the proxy tracer provider has no delegate, return a noop tracer.\n\t*/\n\tProxyTracer.prototype._getTracer = function() {\n\t\tif (this._delegate) return this._delegate;\n\t\tvar tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);\n\t\tif (!tracer) return NOOP_TRACER;\n\t\tthis._delegate = tracer;\n\t\treturn this._delegate;\n\t};\n\treturn ProxyTracer;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js\nvar NOOP_TRACER_PROVIDER = new (function() {\n\tfunction NoopTracerProvider() {}\n\tNoopTracerProvider.prototype.getTracer = function(_name, _version, _options) {\n\t\treturn new NoopTracer();\n\t};\n\treturn NoopTracerProvider;\n}())();\n/**\n* Tracer provider which provides {@link ProxyTracer}s.\n*\n* Before a delegate is set, tracers provided are NoOp.\n*   When a delegate is set, traces are provided from the delegate.\n*   When a delegate is set after tracers have already been provided,\n*   all tracers already provided will use the provided delegate implementation.\n*/\nvar ProxyTracerProvider = function() {\n\tfunction ProxyTracerProvider() {}\n\t/**\n\t* Get a {@link ProxyTracer}\n\t*/\n\tProxyTracerProvider.prototype.getTracer = function(name, version, options) {\n\t\tvar _a;\n\t\treturn (_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options);\n\t};\n\tProxyTracerProvider.prototype.getDelegate = function() {\n\t\tvar _a;\n\t\treturn (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;\n\t};\n\t/**\n\t* Set the delegate tracer provider\n\t*/\n\tProxyTracerProvider.prototype.setDelegate = function(delegate) {\n\t\tthis._delegate = delegate;\n\t};\n\tProxyTracerProvider.prototype.getDelegateTracer = function(name, version, options) {\n\t\tvar _a;\n\t\treturn (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);\n\t};\n\treturn ProxyTracerProvider;\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace/status.js\n/**\n* An enumeration of status codes.\n*/\nvar SpanStatusCode;\n(function(SpanStatusCode) {\n\t/**\n\t* The default status.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"UNSET\"] = 0] = \"UNSET\";\n\t/**\n\t* The operation has been validated by an Application developer or\n\t* Operator to have completed successfully.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"OK\"] = 1] = \"OK\";\n\t/**\n\t* The operation contains an error.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"ERROR\"] = 2] = \"ERROR\";\n})(SpanStatusCode || (SpanStatusCode = {}));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/api/trace.js\nvar API_NAME = \"trace\";\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.0/ee469078ed078052a7533b2805abc7686d72155c80f67e8929d9d1ae6c630f05/node_modules/@opentelemetry/api/build/esm/trace-api.js\n/** Entrypoint for trace API */\nvar trace = function() {\n\t/** Empty private constructor prevents end users from constructing a new instance of the API */\n\tfunction TraceAPI() {\n\t\tthis._proxyTracerProvider = new ProxyTracerProvider();\n\t\tthis.wrapSpanContext = wrapSpanContext;\n\t\tthis.isSpanContextValid = isSpanContextValid;\n\t\tthis.deleteSpan = deleteSpan;\n\t\tthis.getSpan = getSpan;\n\t\tthis.getActiveSpan = getActiveSpan;\n\t\tthis.getSpanContext = getSpanContext;\n\t\tthis.setSpan = setSpan;\n\t\tthis.setSpanContext = setSpanContext;\n\t}\n\t/** Get the singleton instance of the Trace API */\n\tTraceAPI.getInstance = function() {\n\t\tif (!this._instance) this._instance = new TraceAPI();\n\t\treturn this._instance;\n\t};\n\t/**\n\t* Set the current global tracer.\n\t*\n\t* @returns true if the tracer provider was successfully registered, else false\n\t*/\n\tTraceAPI.prototype.setGlobalTracerProvider = function(provider) {\n\t\tvar success = registerGlobal(API_NAME, this._proxyTracerProvider, DiagAPI.instance());\n\t\tif (success) this._proxyTracerProvider.setDelegate(provider);\n\t\treturn success;\n\t};\n\t/**\n\t* Returns the global tracer provider.\n\t*/\n\tTraceAPI.prototype.getTracerProvider = function() {\n\t\treturn getGlobal(API_NAME) || this._proxyTracerProvider;\n\t};\n\t/**\n\t* Returns a tracer from the global tracer provider.\n\t*/\n\tTraceAPI.prototype.getTracer = function(name, version) {\n\t\treturn this.getTracerProvider().getTracer(name, version);\n\t};\n\t/** Remove the global tracer provider */\n\tTraceAPI.prototype.disable = function() {\n\t\tunregisterGlobal(API_NAME, DiagAPI.instance());\n\t\tthis._proxyTracerProvider = new ProxyTracerProvider();\n\t};\n\treturn TraceAPI;\n}().getInstance();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/ai/4.3.19/89972ddf24d98eed06d4822cd08ea28db65e19a600303a1d58851ce02ffe4ba1/node_modules/ai/dist/index.mjs\nvar __defProp = Object.defineProperty;\nvar __export = (target, all) => {\n\tfor (var name17 in all) __defProp(target, name17, {\n\t\tget: all[name17],\n\t\tenumerable: true\n\t});\n};\nfunction createDataStream({ execute, onError = () => \"An error occurred.\" }) {\n\tlet controller;\n\tconst ongoingStreamPromises = [];\n\tconst stream = new ReadableStream({ start(controllerArg) {\n\t\tcontroller = controllerArg;\n\t} });\n\tfunction safeEnqueue(data) {\n\t\ttry {\n\t\t\tcontroller.enqueue(data);\n\t\t} catch (error) {}\n\t}\n\ttry {\n\t\tconst result = execute({\n\t\t\twrite(data) {\n\t\t\t\tsafeEnqueue(data);\n\t\t\t},\n\t\t\twriteData(data) {\n\t\t\t\tsafeEnqueue(formatDataStreamPart(\"data\", [data]));\n\t\t\t},\n\t\t\twriteMessageAnnotation(annotation) {\n\t\t\t\tsafeEnqueue(formatDataStreamPart(\"message_annotations\", [annotation]));\n\t\t\t},\n\t\t\twriteSource(source) {\n\t\t\t\tsafeEnqueue(formatDataStreamPart(\"source\", source));\n\t\t\t},\n\t\t\tmerge(streamArg) {\n\t\t\t\tongoingStreamPromises.push((async () => {\n\t\t\t\t\tconst reader = streamArg.getReader();\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\tif (done) break;\n\t\t\t\t\t\tsafeEnqueue(value);\n\t\t\t\t\t}\n\t\t\t\t})().catch((error) => {\n\t\t\t\t\tsafeEnqueue(formatDataStreamPart(\"error\", onError(error)));\n\t\t\t\t}));\n\t\t\t},\n\t\t\tonError\n\t\t});\n\t\tif (result) ongoingStreamPromises.push(result.catch((error) => {\n\t\t\tsafeEnqueue(formatDataStreamPart(\"error\", onError(error)));\n\t\t}));\n\t} catch (error) {\n\t\tsafeEnqueue(formatDataStreamPart(\"error\", onError(error)));\n\t}\n\tnew Promise(async (resolve) => {\n\t\twhile (ongoingStreamPromises.length > 0) await ongoingStreamPromises.shift();\n\t\tresolve();\n\t}).finally(() => {\n\t\ttry {\n\t\t\tcontroller.close();\n\t\t} catch (error) {}\n\t});\n\treturn stream;\n}\nfunction prepareResponseHeaders(headers, { contentType, dataStreamVersion }) {\n\tconst responseHeaders = new Headers(headers != null ? headers : {});\n\tif (!responseHeaders.has(\"Content-Type\")) responseHeaders.set(\"Content-Type\", contentType);\n\tif (dataStreamVersion !== void 0) responseHeaders.set(\"X-Vercel-AI-Data-Stream\", dataStreamVersion);\n\treturn responseHeaders;\n}\nfunction createDataStreamResponse({ status, statusText, headers, execute, onError }) {\n\treturn new Response(createDataStream({\n\t\texecute,\n\t\tonError\n\t}).pipeThrough(new TextEncoderStream()), {\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: prepareResponseHeaders(headers, {\n\t\t\tcontentType: \"text/plain; charset=utf-8\",\n\t\t\tdataStreamVersion: \"v1\"\n\t\t})\n\t});\n}\nfunction prepareOutgoingHttpHeaders(headers, { contentType, dataStreamVersion }) {\n\tconst outgoingHeaders = {};\n\tif (headers != null) for (const [key, value] of Object.entries(headers)) outgoingHeaders[key] = value;\n\tif (outgoingHeaders[\"Content-Type\"] == null) outgoingHeaders[\"Content-Type\"] = contentType;\n\tif (dataStreamVersion !== void 0) outgoingHeaders[\"X-Vercel-AI-Data-Stream\"] = dataStreamVersion;\n\treturn outgoingHeaders;\n}\nfunction writeToServerResponse({ response, status, statusText, headers, stream }) {\n\tresponse.writeHead(status != null ? status : 200, statusText, headers);\n\tconst reader = stream.getReader();\n\tconst read = async () => {\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\t\t\t\tresponse.write(value);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tresponse.end();\n\t\t}\n\t};\n\tread();\n}\nfunction pipeDataStreamToResponse(response, { status, statusText, headers, execute, onError }) {\n\twriteToServerResponse({\n\t\tresponse,\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: prepareOutgoingHttpHeaders(headers, {\n\t\t\tcontentType: \"text/plain; charset=utf-8\",\n\t\t\tdataStreamVersion: \"v1\"\n\t\t}),\n\t\tstream: createDataStream({\n\t\t\texecute,\n\t\t\tonError\n\t\t}).pipeThrough(new TextEncoderStream())\n\t});\n}\nvar UnsupportedModelVersionError = class extends AISDKError {\n\tconstructor() {\n\t\tsuper({\n\t\t\tname: \"AI_UnsupportedModelVersionError\",\n\t\t\tmessage: `Unsupported model version. AI SDK 4 only supports models that implement specification version \"v1\". Please upgrade to AI SDK 5 to use this model.`\n\t\t});\n\t}\n};\nvar name = \"AI_InvalidArgumentError\";\nvar marker = `vercel.ai.error.${name}`;\nvar symbol = Symbol.for(marker);\nvar _a;\nvar InvalidArgumentError = class extends AISDKError {\n\tconstructor({ parameter, value, message }) {\n\t\tsuper({\n\t\t\tname,\n\t\t\tmessage: `Invalid argument for parameter ${parameter}: ${message}`\n\t\t});\n\t\tthis[_a] = true;\n\t\tthis.parameter = parameter;\n\t\tthis.value = value;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker);\n\t}\n};\n_a = symbol;\nvar name2 = \"AI_RetryError\";\nvar marker2 = `vercel.ai.error.${name2}`;\nvar symbol2 = Symbol.for(marker2);\nvar _a2;\nvar RetryError = class extends AISDKError {\n\tconstructor({ message, reason, errors }) {\n\t\tsuper({\n\t\t\tname: name2,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a2] = true;\n\t\tthis.reason = reason;\n\t\tthis.errors = errors;\n\t\tthis.lastError = errors[errors.length - 1];\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker2);\n\t}\n};\n_a2 = symbol2;\nvar retryWithExponentialBackoff = ({ maxRetries = 2, initialDelayInMs = 2e3, backoffFactor = 2 } = {}) => async (f) => _retryWithExponentialBackoff(f, {\n\tmaxRetries,\n\tdelayInMs: initialDelayInMs,\n\tbackoffFactor\n});\nasync function _retryWithExponentialBackoff(f, { maxRetries, delayInMs, backoffFactor }, errors = []) {\n\ttry {\n\t\treturn await f();\n\t} catch (error) {\n\t\tif (isAbortError(error)) throw error;\n\t\tif (maxRetries === 0) throw error;\n\t\tconst errorMessage = getErrorMessage(error);\n\t\tconst newErrors = [...errors, error];\n\t\tconst tryNumber = newErrors.length;\n\t\tif (tryNumber > maxRetries) throw new RetryError({\n\t\t\tmessage: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,\n\t\t\treason: \"maxRetriesExceeded\",\n\t\t\terrors: newErrors\n\t\t});\n\t\tif (error instanceof Error && APICallError.isInstance(error) && error.isRetryable === true && tryNumber <= maxRetries) {\n\t\t\tawait delay(delayInMs);\n\t\t\treturn _retryWithExponentialBackoff(f, {\n\t\t\t\tmaxRetries,\n\t\t\t\tdelayInMs: backoffFactor * delayInMs,\n\t\t\t\tbackoffFactor\n\t\t\t}, newErrors);\n\t\t}\n\t\tif (tryNumber === 1) throw error;\n\t\tthrow new RetryError({\n\t\t\tmessage: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,\n\t\t\treason: \"errorNotRetryable\",\n\t\t\terrors: newErrors\n\t\t});\n\t}\n}\nfunction prepareRetries({ maxRetries }) {\n\tif (maxRetries != null) {\n\t\tif (!Number.isInteger(maxRetries)) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxRetries\",\n\t\t\tvalue: maxRetries,\n\t\t\tmessage: \"maxRetries must be an integer\"\n\t\t});\n\t\tif (maxRetries < 0) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxRetries\",\n\t\t\tvalue: maxRetries,\n\t\t\tmessage: \"maxRetries must be >= 0\"\n\t\t});\n\t}\n\tconst maxRetriesResult = maxRetries != null ? maxRetries : 2;\n\treturn {\n\t\tmaxRetries: maxRetriesResult,\n\t\tretry: retryWithExponentialBackoff({ maxRetries: maxRetriesResult })\n\t};\n}\nfunction assembleOperationName({ operationId, telemetry }) {\n\treturn {\n\t\t\"operation.name\": `${operationId}${(telemetry == null ? void 0 : telemetry.functionId) != null ? ` ${telemetry.functionId}` : \"\"}`,\n\t\t\"resource.name\": telemetry == null ? void 0 : telemetry.functionId,\n\t\t\"ai.operationId\": operationId,\n\t\t\"ai.telemetry.functionId\": telemetry == null ? void 0 : telemetry.functionId\n\t};\n}\nfunction getBaseTelemetryAttributes({ model, settings, telemetry, headers }) {\n\tvar _a17;\n\treturn {\n\t\t\"ai.model.provider\": model.provider,\n\t\t\"ai.model.id\": model.modelId,\n\t\t...Object.entries(settings).reduce((attributes, [key, value]) => {\n\t\t\tattributes[`ai.settings.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {}),\n\t\t...Object.entries((_a17 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a17 : {}).reduce((attributes, [key, value]) => {\n\t\t\tattributes[`ai.telemetry.metadata.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {}),\n\t\t...Object.entries(headers != null ? headers : {}).reduce((attributes, [key, value]) => {\n\t\t\tif (value !== void 0) attributes[`ai.request.headers.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {})\n\t};\n}\nvar noopTracer = {\n\tstartSpan() {\n\t\treturn noopSpan;\n\t},\n\tstartActiveSpan(name17, arg1, arg2, arg3) {\n\t\tif (typeof arg1 === \"function\") return arg1(noopSpan);\n\t\tif (typeof arg2 === \"function\") return arg2(noopSpan);\n\t\tif (typeof arg3 === \"function\") return arg3(noopSpan);\n\t}\n};\nvar noopSpan = {\n\tspanContext() {\n\t\treturn noopSpanContext;\n\t},\n\tsetAttribute() {\n\t\treturn this;\n\t},\n\tsetAttributes() {\n\t\treturn this;\n\t},\n\taddEvent() {\n\t\treturn this;\n\t},\n\taddLink() {\n\t\treturn this;\n\t},\n\taddLinks() {\n\t\treturn this;\n\t},\n\tsetStatus() {\n\t\treturn this;\n\t},\n\tupdateName() {\n\t\treturn this;\n\t},\n\tend() {\n\t\treturn this;\n\t},\n\tisRecording() {\n\t\treturn false;\n\t},\n\trecordException() {\n\t\treturn this;\n\t}\n};\nvar noopSpanContext = {\n\ttraceId: \"\",\n\tspanId: \"\",\n\ttraceFlags: 0\n};\nfunction getTracer({ isEnabled = false, tracer } = {}) {\n\tif (!isEnabled) return noopTracer;\n\tif (tracer) return tracer;\n\treturn trace.getTracer(\"ai\");\n}\nfunction recordSpan({ name: name17, tracer, attributes, fn, endWhenDone = true }) {\n\treturn tracer.startActiveSpan(name17, { attributes }, async (span) => {\n\t\ttry {\n\t\t\tconst result = await fn(span);\n\t\t\tif (endWhenDone) span.end();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t} finally {\n\t\t\t\tspan.end();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t});\n}\nfunction recordErrorOnSpan(span, error) {\n\tif (error instanceof Error) {\n\t\tspan.recordException({\n\t\t\tname: error.name,\n\t\t\tmessage: error.message,\n\t\t\tstack: error.stack\n\t\t});\n\t\tspan.setStatus({\n\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\tmessage: error.message\n\t\t});\n\t} else span.setStatus({ code: SpanStatusCode.ERROR });\n}\nfunction selectTelemetryAttributes({ telemetry, attributes }) {\n\tif ((telemetry == null ? void 0 : telemetry.isEnabled) !== true) return {};\n\treturn Object.entries(attributes).reduce((attributes2, [key, value]) => {\n\t\tif (value === void 0) return attributes2;\n\t\tif (typeof value === \"object\" && \"input\" in value && typeof value.input === \"function\") {\n\t\t\tif ((telemetry == null ? void 0 : telemetry.recordInputs) === false) return attributes2;\n\t\t\tconst result = value.input();\n\t\t\treturn result === void 0 ? attributes2 : {\n\t\t\t\t...attributes2,\n\t\t\t\t[key]: result\n\t\t\t};\n\t\t}\n\t\tif (typeof value === \"object\" && \"output\" in value && typeof value.output === \"function\") {\n\t\t\tif ((telemetry == null ? void 0 : telemetry.recordOutputs) === false) return attributes2;\n\t\t\tconst result = value.output();\n\t\t\treturn result === void 0 ? attributes2 : {\n\t\t\t\t...attributes2,\n\t\t\t\t[key]: result\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...attributes2,\n\t\t\t[key]: value\n\t\t};\n\t}, {});\n}\nasync function embed({ model, value, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry }) {\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tconst { maxRetries, retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.embed\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.embed\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.value\": { input: () => JSON.stringify(value) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tconst { embedding, usage, rawResponse } = await retry(() => recordSpan({\n\t\t\t\tname: \"ai.embed.doEmbed\",\n\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\toperationId: \"ai.embed.doEmbed\",\n\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\"ai.values\": { input: () => [JSON.stringify(value)] }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttracer,\n\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\tvar _a17;\n\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\tvalues: [value],\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\theaders\n\t\t\t\t\t});\n\t\t\t\t\tconst embedding2 = modelResponse.embeddings[0];\n\t\t\t\t\tconst usage2 = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };\n\t\t\t\t\tdoEmbedSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => modelResponse.embeddings.map((embedding3) => JSON.stringify(embedding3)) },\n\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tembedding: embedding2,\n\t\t\t\t\t\tusage: usage2,\n\t\t\t\t\t\trawResponse: modelResponse.rawResponse\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}));\n\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.embedding\": { output: () => JSON.stringify(embedding) },\n\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn new DefaultEmbedResult({\n\t\t\t\tvalue,\n\t\t\t\tembedding,\n\t\t\t\tusage,\n\t\t\t\trawResponse\n\t\t\t});\n\t\t}\n\t});\n}\nvar DefaultEmbedResult = class {\n\tconstructor(options) {\n\t\tthis.value = options.value;\n\t\tthis.embedding = options.embedding;\n\t\tthis.usage = options.usage;\n\t\tthis.rawResponse = options.rawResponse;\n\t}\n};\nfunction splitArray(array, chunkSize) {\n\tif (chunkSize <= 0) throw new Error(\"chunkSize must be greater than 0\");\n\tconst result = [];\n\tfor (let i = 0; i < array.length; i += chunkSize) result.push(array.slice(i, i + chunkSize));\n\treturn result;\n}\nasync function embedMany({ model, values, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry }) {\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tconst { maxRetries, retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.embedMany\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.embedMany\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.values\": { input: () => values.map((value) => JSON.stringify(value)) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tconst maxEmbeddingsPerCall = model.maxEmbeddingsPerCall;\n\t\t\tif (maxEmbeddingsPerCall == null) {\n\t\t\t\tconst { embeddings: embeddings2, usage } = await retry(() => {\n\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\tname: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.values\": { input: () => values.map((value) => JSON.stringify(value)) }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\t\t\tvar _a17;\n\t\t\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\t\t\tvalues,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst embeddings3 = modelResponse.embeddings;\n\t\t\t\t\t\t\tconst usage2 = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };\n\t\t\t\t\t\t\tdoEmbedSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings3.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tembeddings: embeddings3,\n\t\t\t\t\t\t\t\tusage: usage2\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings2.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\treturn new DefaultEmbedManyResult({\n\t\t\t\t\tvalues,\n\t\t\t\t\tembeddings: embeddings2,\n\t\t\t\t\tusage\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst valueChunks = splitArray(values, maxEmbeddingsPerCall);\n\t\t\tconst embeddings = [];\n\t\t\tlet tokens = 0;\n\t\t\tfor (const chunk of valueChunks) {\n\t\t\t\tconst { embeddings: responseEmbeddings, usage } = await retry(() => {\n\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\tname: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.values\": { input: () => chunk.map((value) => JSON.stringify(value)) }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\t\t\tvar _a17;\n\t\t\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\t\t\tvalues: chunk,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst embeddings2 = modelResponse.embeddings;\n\t\t\t\t\t\t\tconst usage2 = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };\n\t\t\t\t\t\t\tdoEmbedSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings2.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tembeddings: embeddings2,\n\t\t\t\t\t\t\t\tusage: usage2\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tembeddings.push(...responseEmbeddings);\n\t\t\t\ttokens += usage.tokens;\n\t\t\t}\n\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\"ai.usage.tokens\": tokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn new DefaultEmbedManyResult({\n\t\t\t\tvalues,\n\t\t\t\tembeddings,\n\t\t\t\tusage: { tokens }\n\t\t\t});\n\t\t}\n\t});\n}\nvar DefaultEmbedManyResult = class {\n\tconstructor(options) {\n\t\tthis.values = options.values;\n\t\tthis.embeddings = options.embeddings;\n\t\tthis.usage = options.usage;\n\t}\n};\nvar name3 = \"AI_NoImageGeneratedError\";\nvar marker3 = `vercel.ai.error.${name3}`;\nvar symbol3 = Symbol.for(marker3);\nvar _a3;\nvar NoImageGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No image generated.\", cause, responses }) {\n\t\tsuper({\n\t\t\tname: name3,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a3] = true;\n\t\tthis.responses = responses;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker3);\n\t}\n};\n_a3 = symbol3;\nvar DefaultGeneratedFile = class {\n\tconstructor({ data, mimeType }) {\n\t\tconst isUint8Array = data instanceof Uint8Array;\n\t\tthis.base64Data = isUint8Array ? void 0 : data;\n\t\tthis.uint8ArrayData = isUint8Array ? data : void 0;\n\t\tthis.mimeType = mimeType;\n\t}\n\tget base64() {\n\t\tif (this.base64Data == null) this.base64Data = convertUint8ArrayToBase64(this.uint8ArrayData);\n\t\treturn this.base64Data;\n\t}\n\tget uint8Array() {\n\t\tif (this.uint8ArrayData == null) this.uint8ArrayData = convertBase64ToUint8Array(this.base64Data);\n\t\treturn this.uint8ArrayData;\n\t}\n};\nvar DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {\n\tconstructor(options) {\n\t\tsuper(options);\n\t\tthis.type = \"file\";\n\t}\n};\nvar imageMimeTypeSignatures = [\n\t{\n\t\tmimeType: \"image/gif\",\n\t\tbytesPrefix: [\n\t\t\t71,\n\t\t\t73,\n\t\t\t70\n\t\t],\n\t\tbase64Prefix: \"R0lG\"\n\t},\n\t{\n\t\tmimeType: \"image/png\",\n\t\tbytesPrefix: [\n\t\t\t137,\n\t\t\t80,\n\t\t\t78,\n\t\t\t71\n\t\t],\n\t\tbase64Prefix: \"iVBORw\"\n\t},\n\t{\n\t\tmimeType: \"image/jpeg\",\n\t\tbytesPrefix: [255, 216],\n\t\tbase64Prefix: \"/9j/\"\n\t},\n\t{\n\t\tmimeType: \"image/webp\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70\n\t\t],\n\t\tbase64Prefix: \"UklGRg\"\n\t},\n\t{\n\t\tmimeType: \"image/bmp\",\n\t\tbytesPrefix: [66, 77],\n\t\tbase64Prefix: \"Qk\"\n\t},\n\t{\n\t\tmimeType: \"image/tiff\",\n\t\tbytesPrefix: [\n\t\t\t73,\n\t\t\t73,\n\t\t\t42,\n\t\t\t0\n\t\t],\n\t\tbase64Prefix: \"SUkqAA\"\n\t},\n\t{\n\t\tmimeType: \"image/tiff\",\n\t\tbytesPrefix: [\n\t\t\t77,\n\t\t\t77,\n\t\t\t0,\n\t\t\t42\n\t\t],\n\t\tbase64Prefix: \"TU0AKg\"\n\t},\n\t{\n\t\tmimeType: \"image/avif\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t32,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t97,\n\t\t\t118,\n\t\t\t105,\n\t\t\t102\n\t\t],\n\t\tbase64Prefix: \"AAAAIGZ0eXBhdmlm\"\n\t},\n\t{\n\t\tmimeType: \"image/heic\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t32,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t104,\n\t\t\t101,\n\t\t\t105,\n\t\t\t99\n\t\t],\n\t\tbase64Prefix: \"AAAAIGZ0eXBoZWlj\"\n\t}\n];\nvar audioMimeTypeSignatures = [\n\t{\n\t\tmimeType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 251],\n\t\tbase64Prefix: \"//s=\"\n\t},\n\t{\n\t\tmimeType: \"audio/wav\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70\n\t\t],\n\t\tbase64Prefix: \"UklGR\"\n\t},\n\t{\n\t\tmimeType: \"audio/ogg\",\n\t\tbytesPrefix: [\n\t\t\t79,\n\t\t\t103,\n\t\t\t103,\n\t\t\t83\n\t\t],\n\t\tbase64Prefix: \"T2dnUw\"\n\t},\n\t{\n\t\tmimeType: \"audio/flac\",\n\t\tbytesPrefix: [\n\t\t\t102,\n\t\t\t76,\n\t\t\t97,\n\t\t\t67\n\t\t],\n\t\tbase64Prefix: \"ZkxhQw\"\n\t},\n\t{\n\t\tmimeType: \"audio/aac\",\n\t\tbytesPrefix: [\n\t\t\t64,\n\t\t\t21,\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\tbase64Prefix: \"QBUA\"\n\t},\n\t{\n\t\tmimeType: \"audio/mp4\",\n\t\tbytesPrefix: [\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112\n\t\t],\n\t\tbase64Prefix: \"ZnR5cA\"\n\t}\n];\nvar stripID3 = (data) => {\n\tconst bytes = typeof data === \"string\" ? convertBase64ToUint8Array(data) : data;\n\tconst id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;\n\treturn bytes.slice(id3Size + 10);\n};\nfunction stripID3TagsIfPresent(data) {\n\treturn typeof data === \"string\" && data.startsWith(\"SUQz\") || typeof data !== \"string\" && data.length > 10 && data[0] === 73 && data[1] === 68 && data[2] === 51 ? stripID3(data) : data;\n}\nfunction detectMimeType({ data, signatures }) {\n\tconst processedData = stripID3TagsIfPresent(data);\n\tfor (const signature of signatures) if (typeof processedData === \"string\" ? processedData.startsWith(signature.base64Prefix) : processedData.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => processedData[index] === byte)) return signature.mimeType;\n}\nasync function generateImage({ model, prompt, n = 1, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tvar _a17;\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tconst { retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst maxImagesPerCall = (_a17 = model.maxImagesPerCall) != null ? _a17 : 1;\n\tconst callCount = Math.ceil(n / maxImagesPerCall);\n\tconst callImageCounts = Array.from({ length: callCount }, (_, i) => {\n\t\tif (i < callCount - 1) return maxImagesPerCall;\n\t\tconst remainder = n % maxImagesPerCall;\n\t\treturn remainder === 0 ? maxImagesPerCall : remainder;\n\t});\n\tconst results = await Promise.all(callImageCounts.map(async (callImageCount) => retry(() => model.doGenerate({\n\t\tprompt,\n\t\tn: callImageCount,\n\t\tabortSignal,\n\t\theaders,\n\t\tsize,\n\t\taspectRatio,\n\t\tseed,\n\t\tproviderOptions: providerOptions != null ? providerOptions : {}\n\t}))));\n\tconst images = [];\n\tconst warnings = [];\n\tconst responses = [];\n\tfor (const result of results) {\n\t\timages.push(...result.images.map((image) => {\n\t\t\tvar _a18;\n\t\t\treturn new DefaultGeneratedFile({\n\t\t\t\tdata: image,\n\t\t\t\tmimeType: (_a18 = detectMimeType({\n\t\t\t\t\tdata: image,\n\t\t\t\t\tsignatures: imageMimeTypeSignatures\n\t\t\t\t})) != null ? _a18 : \"image/png\"\n\t\t\t});\n\t\t}));\n\t\twarnings.push(...result.warnings);\n\t\tresponses.push(result.response);\n\t}\n\tif (!images.length) throw new NoImageGeneratedError({ responses });\n\treturn new DefaultGenerateImageResult({\n\t\timages,\n\t\twarnings,\n\t\tresponses\n\t});\n}\nvar DefaultGenerateImageResult = class {\n\tconstructor(options) {\n\t\tthis.images = options.images;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t}\n\tget image() {\n\t\treturn this.images[0];\n\t}\n};\nvar name4 = \"AI_NoObjectGeneratedError\";\nvar marker4 = `vercel.ai.error.${name4}`;\nvar symbol4 = Symbol.for(marker4);\nvar _a4;\nvar NoObjectGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No object generated.\", cause, text: text2, response, usage, finishReason }) {\n\t\tsuper({\n\t\t\tname: name4,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a4] = true;\n\t\tthis.text = text2;\n\t\tthis.response = response;\n\t\tthis.usage = usage;\n\t\tthis.finishReason = finishReason;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker4);\n\t}\n};\n_a4 = symbol4;\nvar name5 = \"AI_DownloadError\";\nvar marker5 = `vercel.ai.error.${name5}`;\nvar symbol5 = Symbol.for(marker5);\nvar _a5;\nvar DownloadError = class extends AISDKError {\n\tconstructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {\n\t\tsuper({\n\t\t\tname: name5,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a5] = true;\n\t\tthis.url = url;\n\t\tthis.statusCode = statusCode;\n\t\tthis.statusText = statusText;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker5);\n\t}\n};\n_a5 = symbol5;\nasync function download({ url }) {\n\tvar _a17;\n\tconst urlText = url.toString();\n\ttry {\n\t\tconst response = await fetch(urlText);\n\t\tif (!response.ok) throw new DownloadError({\n\t\t\turl: urlText,\n\t\t\tstatusCode: response.status,\n\t\t\tstatusText: response.statusText\n\t\t});\n\t\treturn {\n\t\t\tdata: new Uint8Array(await response.arrayBuffer()),\n\t\t\tmimeType: (_a17 = response.headers.get(\"content-type\")) != null ? _a17 : void 0\n\t\t};\n\t} catch (error) {\n\t\tif (DownloadError.isInstance(error)) throw error;\n\t\tthrow new DownloadError({\n\t\t\turl: urlText,\n\t\t\tcause: error\n\t\t});\n\t}\n}\nvar name6 = \"AI_InvalidDataContentError\";\nvar marker6 = `vercel.ai.error.${name6}`;\nvar symbol6 = Symbol.for(marker6);\nvar _a6;\nvar InvalidDataContentError = class extends AISDKError {\n\tconstructor({ content, cause, message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.` }) {\n\t\tsuper({\n\t\t\tname: name6,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a6] = true;\n\t\tthis.content = content;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker6);\n\t}\n};\n_a6 = symbol6;\nvar dataContentSchema = z.union([\n\tz.string(),\n\tz.instanceof(Uint8Array),\n\tz.instanceof(ArrayBuffer),\n\tz.custom((value) => {\n\t\tvar _a17, _b;\n\t\treturn (_b = (_a17 = globalThis.Buffer) == null ? void 0 : _a17.isBuffer(value)) != null ? _b : false;\n\t}, { message: \"Must be a Buffer\" })\n]);\nfunction convertDataContentToBase64String(content) {\n\tif (typeof content === \"string\") return content;\n\tif (content instanceof ArrayBuffer) return convertUint8ArrayToBase64(new Uint8Array(content));\n\treturn convertUint8ArrayToBase64(content);\n}\nfunction convertDataContentToUint8Array(content) {\n\tif (content instanceof Uint8Array) return content;\n\tif (typeof content === \"string\") try {\n\t\treturn convertBase64ToUint8Array(content);\n\t} catch (error) {\n\t\tthrow new InvalidDataContentError({\n\t\t\tmessage: \"Invalid data content. Content string is not a base64-encoded media.\",\n\t\t\tcontent,\n\t\t\tcause: error\n\t\t});\n\t}\n\tif (content instanceof ArrayBuffer) return new Uint8Array(content);\n\tthrow new InvalidDataContentError({ content });\n}\nfunction convertUint8ArrayToText(uint8Array) {\n\ttry {\n\t\treturn new TextDecoder().decode(uint8Array);\n\t} catch (error) {\n\t\tthrow new Error(\"Error decoding Uint8Array to text\");\n\t}\n}\nvar name7 = \"AI_InvalidMessageRoleError\";\nvar marker7 = `vercel.ai.error.${name7}`;\nvar symbol7 = Symbol.for(marker7);\nvar _a7;\nvar InvalidMessageRoleError = class extends AISDKError {\n\tconstructor({ role, message = `Invalid message role: '${role}'. Must be one of: \"system\", \"user\", \"assistant\", \"tool\".` }) {\n\t\tsuper({\n\t\t\tname: name7,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a7] = true;\n\t\tthis.role = role;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker7);\n\t}\n};\n_a7 = symbol7;\nfunction splitDataUrl(dataUrl) {\n\ttry {\n\t\tconst [header, base64Content] = dataUrl.split(\",\");\n\t\treturn {\n\t\t\tmimeType: header.split(\";\")[0].split(\":\")[1],\n\t\t\tbase64Content\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tmimeType: void 0,\n\t\t\tbase64Content: void 0\n\t\t};\n\t}\n}\nasync function convertToLanguageModelPrompt({ prompt, modelSupportsImageUrls = true, modelSupportsUrl = () => false, downloadImplementation = download }) {\n\tconst downloadedAssets = await downloadAssets(prompt.messages, downloadImplementation, modelSupportsImageUrls, modelSupportsUrl);\n\treturn [...prompt.system != null ? [{\n\t\trole: \"system\",\n\t\tcontent: prompt.system\n\t}] : [], ...prompt.messages.map((message) => convertToLanguageModelMessage(message, downloadedAssets))];\n}\nfunction convertToLanguageModelMessage(message, downloadedAssets) {\n\tvar _a17, _b, _c, _d, _e, _f;\n\tconst role = message.role;\n\tswitch (role) {\n\t\tcase \"system\": return {\n\t\t\trole: \"system\",\n\t\t\tcontent: message.content,\n\t\t\tproviderMetadata: (_a17 = message.providerOptions) != null ? _a17 : message.experimental_providerMetadata\n\t\t};\n\t\tcase \"user\":\n\t\t\tif (typeof message.content === \"string\") return {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: message.content\n\t\t\t\t}],\n\t\t\t\tproviderMetadata: (_b = message.providerOptions) != null ? _b : message.experimental_providerMetadata\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: message.content.map((part) => convertPartToLanguageModelPart(part, downloadedAssets)).filter((part) => part.type !== \"text\" || part.text !== \"\"),\n\t\t\t\tproviderMetadata: (_c = message.providerOptions) != null ? _c : message.experimental_providerMetadata\n\t\t\t};\n\t\tcase \"assistant\":\n\t\t\tif (typeof message.content === \"string\") return {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: message.content\n\t\t\t\t}],\n\t\t\t\tproviderMetadata: (_d = message.providerOptions) != null ? _d : message.experimental_providerMetadata\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: message.content.filter((part) => part.type !== \"text\" || part.text !== \"\").map((part) => {\n\t\t\t\t\tvar _a18;\n\t\t\t\t\tconst providerOptions = (_a18 = part.providerOptions) != null ? _a18 : part.experimental_providerMetadata;\n\t\t\t\t\tswitch (part.type) {\n\t\t\t\t\t\tcase \"file\": return {\n\t\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\t\tdata: part.data instanceof URL ? part.data : convertDataContentToBase64String(part.data),\n\t\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\t\tmimeType: part.mimeType,\n\t\t\t\t\t\t\tproviderMetadata: providerOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"reasoning\": return {\n\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\tsignature: part.signature,\n\t\t\t\t\t\t\tproviderMetadata: providerOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"redacted-reasoning\": return {\n\t\t\t\t\t\t\ttype: \"redacted-reasoning\",\n\t\t\t\t\t\t\tdata: part.data,\n\t\t\t\t\t\t\tproviderMetadata: providerOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"text\": return {\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\tproviderMetadata: providerOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"tool-call\": return {\n\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\targs: part.args,\n\t\t\t\t\t\t\tproviderMetadata: providerOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tproviderMetadata: (_e = message.providerOptions) != null ? _e : message.experimental_providerMetadata\n\t\t\t};\n\t\tcase \"tool\": return {\n\t\t\trole: \"tool\",\n\t\t\tcontent: message.content.map((part) => {\n\t\t\t\tvar _a18;\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\tresult: part.result,\n\t\t\t\t\tcontent: part.experimental_content,\n\t\t\t\t\tisError: part.isError,\n\t\t\t\t\tproviderMetadata: (_a18 = part.providerOptions) != null ? _a18 : part.experimental_providerMetadata\n\t\t\t\t};\n\t\t\t}),\n\t\t\tproviderMetadata: (_f = message.providerOptions) != null ? _f : message.experimental_providerMetadata\n\t\t};\n\t\tdefault: throw new InvalidMessageRoleError({ role });\n\t}\n}\nasync function downloadAssets(messages, downloadImplementation, modelSupportsImageUrls, modelSupportsUrl) {\n\tconst urls = messages.filter((message) => message.role === \"user\").map((message) => message.content).filter((content) => Array.isArray(content)).flat().filter((part) => part.type === \"image\" || part.type === \"file\").filter((part) => !(part.type === \"image\" && modelSupportsImageUrls === true)).map((part) => part.type === \"image\" ? part.image : part.data).map((part) => typeof part === \"string\" && (part.startsWith(\"http:\") || part.startsWith(\"https:\")) ? new URL(part) : part).filter((image) => image instanceof URL).filter((url) => !modelSupportsUrl(url));\n\tconst downloadedImages = await Promise.all(urls.map(async (url) => ({\n\t\turl,\n\t\tdata: await downloadImplementation({ url })\n\t})));\n\treturn Object.fromEntries(downloadedImages.map(({ url, data }) => [url.toString(), data]));\n}\nfunction convertPartToLanguageModelPart(part, downloadedAssets) {\n\tvar _a17, _b, _c, _d;\n\tif (part.type === \"text\") return {\n\t\ttype: \"text\",\n\t\ttext: part.text,\n\t\tproviderMetadata: (_a17 = part.providerOptions) != null ? _a17 : part.experimental_providerMetadata\n\t};\n\tlet mimeType = part.mimeType;\n\tlet data;\n\tlet content;\n\tlet normalizedData;\n\tconst type = part.type;\n\tswitch (type) {\n\t\tcase \"image\":\n\t\t\tdata = part.image;\n\t\t\tbreak;\n\t\tcase \"file\":\n\t\t\tdata = part.data;\n\t\t\tbreak;\n\t\tdefault: throw new Error(`Unsupported part type: ${type}`);\n\t}\n\ttry {\n\t\tcontent = typeof data === \"string\" ? new URL(data) : data;\n\t} catch (error) {\n\t\tcontent = data;\n\t}\n\tif (content instanceof URL) {\n\t\tif (content.protocol === \"data:\") {\n\t\t\tconst { mimeType: dataUrlMimeType, base64Content } = splitDataUrl(content.toString());\n\t\t\tif (dataUrlMimeType == null || base64Content == null) throw new Error(`Invalid data URL format in part ${type}`);\n\t\t\tmimeType = dataUrlMimeType;\n\t\t\tnormalizedData = convertDataContentToUint8Array(base64Content);\n\t\t} else {\n\t\t\tconst downloadedFile = downloadedAssets[content.toString()];\n\t\t\tif (downloadedFile) {\n\t\t\t\tnormalizedData = downloadedFile.data;\n\t\t\t\tmimeType ??= downloadedFile.mimeType;\n\t\t\t} else normalizedData = content;\n\t\t}\n\t} else normalizedData = convertDataContentToUint8Array(content);\n\tswitch (type) {\n\t\tcase \"image\":\n\t\t\tif (normalizedData instanceof Uint8Array) mimeType = (_b = detectMimeType({\n\t\t\t\tdata: normalizedData,\n\t\t\t\tsignatures: imageMimeTypeSignatures\n\t\t\t})) != null ? _b : mimeType;\n\t\t\treturn {\n\t\t\t\ttype: \"image\",\n\t\t\t\timage: normalizedData,\n\t\t\t\tmimeType,\n\t\t\t\tproviderMetadata: (_c = part.providerOptions) != null ? _c : part.experimental_providerMetadata\n\t\t\t};\n\t\tcase \"file\":\n\t\t\tif (mimeType == null) throw new Error(`Mime type is missing for file part`);\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tdata: normalizedData instanceof Uint8Array ? convertDataContentToBase64String(normalizedData) : normalizedData,\n\t\t\t\tfilename: part.filename,\n\t\t\t\tmimeType,\n\t\t\t\tproviderMetadata: (_d = part.providerOptions) != null ? _d : part.experimental_providerMetadata\n\t\t\t};\n\t}\n}\nfunction prepareCallSettings({ maxTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed }) {\n\tif (maxTokens != null) {\n\t\tif (!Number.isInteger(maxTokens)) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxTokens\",\n\t\t\tvalue: maxTokens,\n\t\t\tmessage: \"maxTokens must be an integer\"\n\t\t});\n\t\tif (maxTokens < 1) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxTokens\",\n\t\t\tvalue: maxTokens,\n\t\t\tmessage: \"maxTokens must be >= 1\"\n\t\t});\n\t}\n\tif (temperature != null) {\n\t\tif (typeof temperature !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"temperature\",\n\t\t\tvalue: temperature,\n\t\t\tmessage: \"temperature must be a number\"\n\t\t});\n\t}\n\tif (topP != null) {\n\t\tif (typeof topP !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"topP\",\n\t\t\tvalue: topP,\n\t\t\tmessage: \"topP must be a number\"\n\t\t});\n\t}\n\tif (topK != null) {\n\t\tif (typeof topK !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"topK\",\n\t\t\tvalue: topK,\n\t\t\tmessage: \"topK must be a number\"\n\t\t});\n\t}\n\tif (presencePenalty != null) {\n\t\tif (typeof presencePenalty !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"presencePenalty\",\n\t\t\tvalue: presencePenalty,\n\t\t\tmessage: \"presencePenalty must be a number\"\n\t\t});\n\t}\n\tif (frequencyPenalty != null) {\n\t\tif (typeof frequencyPenalty !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"frequencyPenalty\",\n\t\t\tvalue: frequencyPenalty,\n\t\t\tmessage: \"frequencyPenalty must be a number\"\n\t\t});\n\t}\n\tif (seed != null) {\n\t\tif (!Number.isInteger(seed)) throw new InvalidArgumentError({\n\t\t\tparameter: \"seed\",\n\t\t\tvalue: seed,\n\t\t\tmessage: \"seed must be an integer\"\n\t\t});\n\t}\n\treturn {\n\t\tmaxTokens,\n\t\ttemperature: temperature != null ? temperature : 0,\n\t\ttopP,\n\t\ttopK,\n\t\tpresencePenalty,\n\t\tfrequencyPenalty,\n\t\tstopSequences: stopSequences != null && stopSequences.length > 0 ? stopSequences : void 0,\n\t\tseed\n\t};\n}\nfunction attachmentsToParts(attachments) {\n\tvar _a17, _b, _c;\n\tconst parts = [];\n\tfor (const attachment of attachments) {\n\t\tlet url;\n\t\ttry {\n\t\t\turl = new URL(attachment.url);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Invalid URL: ${attachment.url}`);\n\t\t}\n\t\tswitch (url.protocol) {\n\t\t\tcase \"http:\":\n\t\t\tcase \"https:\":\n\t\t\t\tif ((_a17 = attachment.contentType) == null ? void 0 : _a17.startsWith(\"image/\")) parts.push({\n\t\t\t\t\ttype: \"image\",\n\t\t\t\t\timage: url\n\t\t\t\t});\n\t\t\t\telse {\n\t\t\t\t\tif (!attachment.contentType) throw new Error(\"If the attachment is not an image, it must specify a content type\");\n\t\t\t\t\tparts.push({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tdata: url,\n\t\t\t\t\t\tmimeType: attachment.contentType\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"data:\": {\n\t\t\t\tlet header;\n\t\t\t\tlet base64Content;\n\t\t\t\tlet mimeType;\n\t\t\t\ttry {\n\t\t\t\t\t[header, base64Content] = attachment.url.split(\",\");\n\t\t\t\t\tmimeType = header.split(\";\")[0].split(\":\")[1];\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(`Error processing data URL: ${attachment.url}`);\n\t\t\t\t}\n\t\t\t\tif (mimeType == null || base64Content == null) throw new Error(`Invalid data URL format: ${attachment.url}`);\n\t\t\t\tif ((_b = attachment.contentType) == null ? void 0 : _b.startsWith(\"image/\")) parts.push({\n\t\t\t\t\ttype: \"image\",\n\t\t\t\t\timage: convertDataContentToUint8Array(base64Content)\n\t\t\t\t});\n\t\t\t\telse if ((_c = attachment.contentType) == null ? void 0 : _c.startsWith(\"text/\")) parts.push({\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: convertUint8ArrayToText(convertDataContentToUint8Array(base64Content))\n\t\t\t\t});\n\t\t\t\telse {\n\t\t\t\t\tif (!attachment.contentType) throw new Error(\"If the attachment is not an image or text, it must specify a content type\");\n\t\t\t\t\tparts.push({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tdata: base64Content,\n\t\t\t\t\t\tmimeType: attachment.contentType\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: throw new Error(`Unsupported URL protocol: ${url.protocol}`);\n\t\t}\n\t}\n\treturn parts;\n}\nvar name8 = \"AI_MessageConversionError\";\nvar marker8 = `vercel.ai.error.${name8}`;\nvar symbol8 = Symbol.for(marker8);\nvar _a8;\nvar MessageConversionError = class extends AISDKError {\n\tconstructor({ originalMessage, message }) {\n\t\tsuper({\n\t\t\tname: name8,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a8] = true;\n\t\tthis.originalMessage = originalMessage;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker8);\n\t}\n};\n_a8 = symbol8;\nfunction convertToCoreMessages(messages, options) {\n\tvar _a17, _b;\n\tconst tools = (_a17 = options == null ? void 0 : options.tools) != null ? _a17 : {};\n\tconst coreMessages = [];\n\tfor (let i = 0; i < messages.length; i++) {\n\t\tconst message = messages[i];\n\t\tconst isLastMessage = i === messages.length - 1;\n\t\tconst { role, content, experimental_attachments } = message;\n\t\tswitch (role) {\n\t\t\tcase \"system\":\n\t\t\t\tcoreMessages.push({\n\t\t\t\t\trole: \"system\",\n\t\t\t\t\tcontent\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"user\":\n\t\t\t\tif (message.parts == null) coreMessages.push({\n\t\t\t\t\trole: \"user\",\n\t\t\t\t\tcontent: experimental_attachments ? [{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: content\n\t\t\t\t\t}, ...attachmentsToParts(experimental_attachments)] : content\n\t\t\t\t});\n\t\t\t\telse {\n\t\t\t\t\tconst textParts = message.parts.filter((part) => part.type === \"text\").map((part) => ({\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: part.text\n\t\t\t\t\t}));\n\t\t\t\t\tcoreMessages.push({\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: experimental_attachments ? [...textParts, ...attachmentsToParts(experimental_attachments)] : textParts\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"assistant\": {\n\t\t\t\tif (message.parts != null) {\n\t\t\t\t\tlet processBlock2 = function() {\n\t\t\t\t\t\tconst content2 = [];\n\t\t\t\t\t\tfor (const part of block) switch (part.type) {\n\t\t\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\t\tcontent2.push(part);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"reasoning\":\n\t\t\t\t\t\t\t\tfor (const detail of part.details) switch (detail.type) {\n\t\t\t\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\t\t\t\tcontent2.push({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\t\t\t\t\ttext: detail.text,\n\t\t\t\t\t\t\t\t\t\t\tsignature: detail.signature\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"redacted\": content2.push({\n\t\t\t\t\t\t\t\t\t\ttype: \"redacted-reasoning\",\n\t\t\t\t\t\t\t\t\t\tdata: detail.data\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"tool-invocation\":\n\t\t\t\t\t\t\t\tcontent2.push({\n\t\t\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\t\t\ttoolCallId: part.toolInvocation.toolCallId,\n\t\t\t\t\t\t\t\t\ttoolName: part.toolInvocation.toolName,\n\t\t\t\t\t\t\t\t\targs: part.toolInvocation.args\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault: throw new Error(`Unsupported part: ${part}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcoreMessages.push({\n\t\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\t\tcontent: content2\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst stepInvocations = block.filter((part) => part.type === \"tool-invocation\").map((part) => part.toolInvocation);\n\t\t\t\t\t\tif (stepInvocations.length > 0) coreMessages.push({\n\t\t\t\t\t\t\trole: \"tool\",\n\t\t\t\t\t\t\tcontent: stepInvocations.map((toolInvocation) => {\n\t\t\t\t\t\t\t\tif (!(\"result\" in toolInvocation)) throw new MessageConversionError({\n\t\t\t\t\t\t\t\t\toriginalMessage: message,\n\t\t\t\t\t\t\t\t\tmessage: \"ToolInvocation must have a result: \" + JSON.stringify(toolInvocation)\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst { toolCallId, toolName, result } = toolInvocation;\n\t\t\t\t\t\t\t\tconst tool2 = tools[toolName];\n\t\t\t\t\t\t\t\treturn (tool2 == null ? void 0 : tool2.experimental_toToolResultContent) != null ? {\n\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\tresult: tool2.experimental_toToolResultContent(result),\n\t\t\t\t\t\t\t\t\texperimental_content: tool2.experimental_toToolResultContent(result)\n\t\t\t\t\t\t\t\t} : {\n\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\tresult\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t});\n\t\t\t\t\t\tblock = [];\n\t\t\t\t\t\tblockHasToolInvocations = false;\n\t\t\t\t\t\tcurrentStep++;\n\t\t\t\t\t};\n\t\t\t\t\tlet currentStep = 0;\n\t\t\t\t\tlet blockHasToolInvocations = false;\n\t\t\t\t\tlet block = [];\n\t\t\t\t\tfor (const part of message.parts) switch (part.type) {\n\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\tif (blockHasToolInvocations) processBlock2();\n\t\t\t\t\t\t\tblock.push(part);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\tcase \"reasoning\":\n\t\t\t\t\t\t\tblock.push(part);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"tool-invocation\":\n\t\t\t\t\t\t\tif (((_b = part.toolInvocation.step) != null ? _b : 0) !== currentStep) processBlock2();\n\t\t\t\t\t\t\tblock.push(part);\n\t\t\t\t\t\t\tblockHasToolInvocations = true;\n\t\t\t\t\t}\n\t\t\t\t\tprocessBlock2();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst toolInvocations = message.toolInvocations;\n\t\t\t\tif (toolInvocations == null || toolInvocations.length === 0) {\n\t\t\t\t\tcoreMessages.push({\n\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\tcontent\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst maxStep = toolInvocations.reduce((max, toolInvocation) => {\n\t\t\t\t\tvar _a18;\n\t\t\t\t\treturn Math.max(max, (_a18 = toolInvocation.step) != null ? _a18 : 0);\n\t\t\t\t}, 0);\n\t\t\t\tfor (let i2 = 0; i2 <= maxStep; i2++) {\n\t\t\t\t\tconst stepInvocations = toolInvocations.filter((toolInvocation) => {\n\t\t\t\t\t\tvar _a18;\n\t\t\t\t\t\treturn ((_a18 = toolInvocation.step) != null ? _a18 : 0) === i2;\n\t\t\t\t\t});\n\t\t\t\t\tif (stepInvocations.length === 0) continue;\n\t\t\t\t\tcoreMessages.push({\n\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\tcontent: [...isLastMessage && content && i2 === 0 ? [{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: content\n\t\t\t\t\t\t}] : [], ...stepInvocations.map(({ toolCallId, toolName, args }) => ({\n\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t}))]\n\t\t\t\t\t});\n\t\t\t\t\tcoreMessages.push({\n\t\t\t\t\t\trole: \"tool\",\n\t\t\t\t\t\tcontent: stepInvocations.map((toolInvocation) => {\n\t\t\t\t\t\t\tif (!(\"result\" in toolInvocation)) throw new MessageConversionError({\n\t\t\t\t\t\t\t\toriginalMessage: message,\n\t\t\t\t\t\t\t\tmessage: \"ToolInvocation must have a result: \" + JSON.stringify(toolInvocation)\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst { toolCallId, toolName, result } = toolInvocation;\n\t\t\t\t\t\t\tconst tool2 = tools[toolName];\n\t\t\t\t\t\t\treturn (tool2 == null ? void 0 : tool2.experimental_toToolResultContent) != null ? {\n\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\tresult: tool2.experimental_toToolResultContent(result),\n\t\t\t\t\t\t\t\texperimental_content: tool2.experimental_toToolResultContent(result)\n\t\t\t\t\t\t\t} : {\n\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\tresult\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t})\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (content && !isLastMessage) coreMessages.push({\n\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\tcontent\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"data\": break;\n\t\t\tdefault: throw new MessageConversionError({\n\t\t\t\toriginalMessage: message,\n\t\t\t\tmessage: `Unsupported role: ${role}`\n\t\t\t});\n\t\t}\n\t}\n\treturn coreMessages;\n}\nvar jsonValueSchema = z.lazy(() => z.union([\n\tz.null(),\n\tz.string(),\n\tz.number(),\n\tz.boolean(),\n\tz.record(z.string(), jsonValueSchema),\n\tz.array(jsonValueSchema)\n]));\nvar providerMetadataSchema = z.record(z.string(), z.record(z.string(), jsonValueSchema));\nvar toolResultContentSchema = z.array(z.union([z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string()\n}), z.object({\n\ttype: z.literal(\"image\"),\n\tdata: z.string(),\n\tmimeType: z.string().optional()\n})]));\nvar textPartSchema = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar imagePartSchema = z.object({\n\ttype: z.literal(\"image\"),\n\timage: z.union([dataContentSchema, z.instanceof(URL)]),\n\tmimeType: z.string().optional(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar filePartSchema = z.object({\n\ttype: z.literal(\"file\"),\n\tdata: z.union([dataContentSchema, z.instanceof(URL)]),\n\tfilename: z.string().optional(),\n\tmimeType: z.string(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar reasoningPartSchema = z.object({\n\ttype: z.literal(\"reasoning\"),\n\ttext: z.string(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar redactedReasoningPartSchema = z.object({\n\ttype: z.literal(\"redacted-reasoning\"),\n\tdata: z.string(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar toolCallPartSchema = z.object({\n\ttype: z.literal(\"tool-call\"),\n\ttoolCallId: z.string(),\n\ttoolName: z.string(),\n\targs: z.unknown(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar toolResultPartSchema = z.object({\n\ttype: z.literal(\"tool-result\"),\n\ttoolCallId: z.string(),\n\ttoolName: z.string(),\n\tresult: z.unknown(),\n\tcontent: toolResultContentSchema.optional(),\n\tisError: z.boolean().optional(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar coreSystemMessageSchema = z.object({\n\trole: z.literal(\"system\"),\n\tcontent: z.string(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar coreUserMessageSchema = z.object({\n\trole: z.literal(\"user\"),\n\tcontent: z.union([z.string(), z.array(z.union([\n\t\ttextPartSchema,\n\t\timagePartSchema,\n\t\tfilePartSchema\n\t]))]),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar coreAssistantMessageSchema = z.object({\n\trole: z.literal(\"assistant\"),\n\tcontent: z.union([z.string(), z.array(z.union([\n\t\ttextPartSchema,\n\t\tfilePartSchema,\n\t\treasoningPartSchema,\n\t\tredactedReasoningPartSchema,\n\t\ttoolCallPartSchema\n\t]))]),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar coreToolMessageSchema = z.object({\n\trole: z.literal(\"tool\"),\n\tcontent: z.array(toolResultPartSchema),\n\tproviderOptions: providerMetadataSchema.optional(),\n\texperimental_providerMetadata: providerMetadataSchema.optional()\n});\nvar coreMessageSchema = z.union([\n\tcoreSystemMessageSchema,\n\tcoreUserMessageSchema,\n\tcoreAssistantMessageSchema,\n\tcoreToolMessageSchema\n]);\nfunction standardizePrompt({ prompt, tools }) {\n\tif (prompt.prompt == null && prompt.messages == null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt or messages must be defined\"\n\t});\n\tif (prompt.prompt != null && prompt.messages != null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt and messages cannot be defined at the same time\"\n\t});\n\tif (prompt.system != null && typeof prompt.system !== \"string\") throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"system must be a string\"\n\t});\n\tif (prompt.prompt != null) {\n\t\tif (typeof prompt.prompt !== \"string\") throw new InvalidPromptError({\n\t\t\tprompt,\n\t\t\tmessage: \"prompt must be a string\"\n\t\t});\n\t\treturn {\n\t\t\ttype: \"prompt\",\n\t\t\tsystem: prompt.system,\n\t\t\tmessages: [{\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: prompt.prompt\n\t\t\t}]\n\t\t};\n\t}\n\tif (prompt.messages != null) {\n\t\tconst messages = detectPromptType(prompt.messages) === \"ui-messages\" ? convertToCoreMessages(prompt.messages, { tools }) : prompt.messages;\n\t\tif (messages.length === 0) throw new InvalidPromptError({\n\t\t\tprompt,\n\t\t\tmessage: \"messages must not be empty\"\n\t\t});\n\t\tconst validationResult = safeValidateTypes({\n\t\t\tvalue: messages,\n\t\t\tschema: z.array(coreMessageSchema)\n\t\t});\n\t\tif (!validationResult.success) throw new InvalidPromptError({\n\t\t\tprompt,\n\t\t\tmessage: [\"message must be a CoreMessage or a UI message\", `Validation error: ${validationResult.error.message}`].join(\"\\n\"),\n\t\t\tcause: validationResult.error\n\t\t});\n\t\treturn {\n\t\t\ttype: \"messages\",\n\t\t\tmessages,\n\t\t\tsystem: prompt.system\n\t\t};\n\t}\n\tthrow new Error(\"unreachable\");\n}\nfunction detectPromptType(prompt) {\n\tif (!Array.isArray(prompt)) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: [\"messages must be an array of CoreMessage or UIMessage\", `Received non-array value: ${JSON.stringify(prompt)}`].join(\"\\n\"),\n\t\tcause: prompt\n\t});\n\tif (prompt.length === 0) return \"messages\";\n\tconst characteristics = prompt.map(detectSingleMessageCharacteristics);\n\tif (characteristics.some((c) => c === \"has-ui-specific-parts\")) return \"ui-messages\";\n\tconst nonMessageIndex = characteristics.findIndex((c) => c !== \"has-core-specific-parts\" && c !== \"message\");\n\tif (nonMessageIndex === -1) return \"messages\";\n\tthrow new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: [\n\t\t\t\"messages must be an array of CoreMessage or UIMessage\",\n\t\t\t`Received message of type: \"${characteristics[nonMessageIndex]}\" at index ${nonMessageIndex}`,\n\t\t\t`messages[${nonMessageIndex}]: ${JSON.stringify(prompt[nonMessageIndex])}`\n\t\t].join(\"\\n\"),\n\t\tcause: prompt\n\t});\n}\nfunction detectSingleMessageCharacteristics(message) {\n\tif (typeof message === \"object\" && message !== null && (message.role === \"function\" || message.role === \"data\" || \"toolInvocations\" in message || \"parts\" in message || \"experimental_attachments\" in message)) return \"has-ui-specific-parts\";\n\telse if (typeof message === \"object\" && message !== null && \"content\" in message && (Array.isArray(message.content) || \"experimental_providerMetadata\" in message || \"providerOptions\" in message)) return \"has-core-specific-parts\";\n\telse if (typeof message === \"object\" && message !== null && \"role\" in message && \"content\" in message && typeof message.content === \"string\" && [\n\t\t\"system\",\n\t\t\"user\",\n\t\t\"assistant\",\n\t\t\"tool\"\n\t].includes(message.role)) return \"message\";\n\telse return \"other\";\n}\nfunction calculateLanguageModelUsage({ promptTokens, completionTokens }) {\n\treturn {\n\t\tpromptTokens,\n\t\tcompletionTokens,\n\t\ttotalTokens: promptTokens + completionTokens\n\t};\n}\nfunction addLanguageModelUsage(usage1, usage2) {\n\treturn {\n\t\tpromptTokens: usage1.promptTokens + usage2.promptTokens,\n\t\tcompletionTokens: usage1.completionTokens + usage2.completionTokens,\n\t\ttotalTokens: usage1.totalTokens + usage2.totalTokens\n\t};\n}\nvar DEFAULT_SCHEMA_PREFIX = \"JSON schema:\";\nvar DEFAULT_SCHEMA_SUFFIX = \"You MUST answer with a JSON object that matches the JSON schema above.\";\nvar DEFAULT_GENERIC_SUFFIX = \"You MUST answer with JSON.\";\nfunction injectJsonInstruction({ prompt, schema, schemaPrefix = schema != null ? DEFAULT_SCHEMA_PREFIX : void 0, schemaSuffix = schema != null ? DEFAULT_SCHEMA_SUFFIX : DEFAULT_GENERIC_SUFFIX }) {\n\treturn [\n\t\tprompt != null && prompt.length > 0 ? prompt : void 0,\n\t\tprompt != null && prompt.length > 0 ? \"\" : void 0,\n\t\tschemaPrefix,\n\t\tschema != null ? JSON.stringify(schema) : void 0,\n\t\tschemaSuffix\n\t].filter((line) => line != null).join(\"\\n\");\n}\nfunction createAsyncIterableStream(source) {\n\tconst stream = source.pipeThrough(new TransformStream());\n\tstream[Symbol.asyncIterator] = () => {\n\t\tconst reader = stream.getReader();\n\t\treturn { async next() {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\treturn done ? {\n\t\t\t\tdone: true,\n\t\t\t\tvalue: void 0\n\t\t\t} : {\n\t\t\t\tdone: false,\n\t\t\t\tvalue\n\t\t\t};\n\t\t} };\n\t};\n\treturn stream;\n}\nvar noSchemaOutputStrategy = {\n\ttype: \"no-schema\",\n\tjsonSchema: void 0,\n\tvalidatePartialResult({ value, textDelta }) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tvalue: {\n\t\t\t\tpartial: value,\n\t\t\t\ttextDelta\n\t\t\t}\n\t\t};\n\t},\n\tvalidateFinalResult(value, context) {\n\t\treturn value === void 0 ? {\n\t\t\tsuccess: false,\n\t\t\terror: new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\ttext: context.text,\n\t\t\t\tresponse: context.response,\n\t\t\t\tusage: context.usage,\n\t\t\t\tfinishReason: context.finishReason\n\t\t\t})\n\t\t} : {\n\t\t\tsuccess: true,\n\t\t\tvalue\n\t\t};\n\t},\n\tcreateElementStream() {\n\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in no-schema mode\" });\n\t}\n};\nvar objectOutputStrategy = (schema) => ({\n\ttype: \"object\",\n\tjsonSchema: schema.jsonSchema,\n\tvalidatePartialResult({ value, textDelta }) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tvalue: {\n\t\t\t\tpartial: value,\n\t\t\t\ttextDelta\n\t\t\t}\n\t\t};\n\t},\n\tvalidateFinalResult(value) {\n\t\treturn safeValidateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t},\n\tcreateElementStream() {\n\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in object mode\" });\n\t}\n});\nvar arrayOutputStrategy = (schema) => {\n\tconst { $schema, ...itemSchema } = schema.jsonSchema;\n\treturn {\n\t\ttype: \"enum\",\n\t\tjsonSchema: {\n\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\ttype: \"object\",\n\t\t\tproperties: { elements: {\n\t\t\t\ttype: \"array\",\n\t\t\t\titems: itemSchema\n\t\t\t} },\n\t\t\trequired: [\"elements\"],\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tvalidatePartialResult({ value, latestObject, isFirstDelta, isFinalDelta }) {\n\t\t\tvar _a17;\n\t\t\tif (!isJSONObject(value) || !isJSONArray(value.elements)) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains an array of elements\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst inputArray = value.elements;\n\t\t\tconst resultArray = [];\n\t\t\tfor (let i = 0; i < inputArray.length; i++) {\n\t\t\t\tconst element = inputArray[i];\n\t\t\t\tconst result = safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema\n\t\t\t\t});\n\t\t\t\tif (i === inputArray.length - 1 && !isFinalDelta) continue;\n\t\t\t\tif (!result.success) return result;\n\t\t\t\tresultArray.push(result.value);\n\t\t\t}\n\t\t\tconst publishedElementCount = (_a17 = latestObject == null ? void 0 : latestObject.length) != null ? _a17 : 0;\n\t\t\tlet textDelta = \"\";\n\t\t\tif (isFirstDelta) textDelta += \"[\";\n\t\t\tif (publishedElementCount > 0) textDelta += \",\";\n\t\t\ttextDelta += resultArray.slice(publishedElementCount).map((element) => JSON.stringify(element)).join(\",\");\n\t\t\tif (isFinalDelta) textDelta += \"]\";\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tpartial: resultArray,\n\t\t\t\t\ttextDelta\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tvalidateFinalResult(value) {\n\t\t\tif (!isJSONObject(value) || !isJSONArray(value.elements)) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains an array of elements\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst inputArray = value.elements;\n\t\t\tfor (const element of inputArray) {\n\t\t\t\tconst result = safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema\n\t\t\t\t});\n\t\t\t\tif (!result.success) return result;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: inputArray\n\t\t\t};\n\t\t},\n\t\tcreateElementStream(originalStream) {\n\t\t\tlet publishedElements = 0;\n\t\t\treturn createAsyncIterableStream(originalStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\tcase \"object\": {\n\t\t\t\t\t\tconst array = chunk.object;\n\t\t\t\t\t\tfor (; publishedElements < array.length; publishedElements++) controller.enqueue(array[publishedElements]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcase \"finish\":\n\t\t\t\t\tcase \"error\": break;\n\t\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t\t}\n\t\t\t} })));\n\t\t}\n\t};\n};\nvar enumOutputStrategy = (enumValues) => {\n\treturn {\n\t\ttype: \"enum\",\n\t\tjsonSchema: {\n\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\ttype: \"object\",\n\t\t\tproperties: { result: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tenum: enumValues\n\t\t\t} },\n\t\t\trequired: [\"result\"],\n\t\t\tadditionalProperties: false\n\t\t},\n\t\tvalidateFinalResult(value) {\n\t\t\tif (!isJSONObject(value) || typeof value.result !== \"string\") return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains a string in the \\\"result\\\" property.\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst result = value.result;\n\t\t\treturn enumValues.includes(result) ? {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: result\n\t\t\t} : {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be a string in the enum\"\n\t\t\t\t})\n\t\t\t};\n\t\t},\n\t\tvalidatePartialResult() {\n\t\t\tthrow new UnsupportedFunctionalityError({ functionality: \"partial results in enum mode\" });\n\t\t},\n\t\tcreateElementStream() {\n\t\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in enum mode\" });\n\t\t}\n\t};\n};\nfunction getOutputStrategy({ output, schema, enumValues }) {\n\tswitch (output) {\n\t\tcase \"object\": return objectOutputStrategy(asSchema(schema));\n\t\tcase \"array\": return arrayOutputStrategy(asSchema(schema));\n\t\tcase \"enum\": return enumOutputStrategy(enumValues);\n\t\tcase \"no-schema\": return noSchemaOutputStrategy;\n\t\tdefault: throw new Error(`Unsupported output: ${output}`);\n\t}\n}\nfunction validateObjectGenerationInput({ output, mode, schema, schemaName, schemaDescription, enumValues }) {\n\tif (output != null && output !== \"object\" && output !== \"array\" && output !== \"enum\" && output !== \"no-schema\") throw new InvalidArgumentError({\n\t\tparameter: \"output\",\n\t\tvalue: output,\n\t\tmessage: \"Invalid output type.\"\n\t});\n\tif (output === \"no-schema\") {\n\t\tif (mode === \"auto\" || mode === \"tool\") throw new InvalidArgumentError({\n\t\t\tparameter: \"mode\",\n\t\t\tvalue: mode,\n\t\t\tmessage: \"Mode must be \\\"json\\\" for no-schema output.\"\n\t\t});\n\t\tif (schema != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is not supported for no-schema output.\"\n\t\t});\n\t\tif (schemaDescription != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaDescription\",\n\t\t\tvalue: schemaDescription,\n\t\t\tmessage: \"Schema description is not supported for no-schema output.\"\n\t\t});\n\t\tif (schemaName != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaName\",\n\t\t\tvalue: schemaName,\n\t\t\tmessage: \"Schema name is not supported for no-schema output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for no-schema output.\"\n\t\t});\n\t}\n\tif (output === \"object\") {\n\t\tif (schema == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is required for object output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for object output.\"\n\t\t});\n\t}\n\tif (output === \"array\") {\n\t\tif (schema == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Element schema is required for array output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for array output.\"\n\t\t});\n\t}\n\tif (output === \"enum\") {\n\t\tif (schema != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is not supported for enum output.\"\n\t\t});\n\t\tif (schemaDescription != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaDescription\",\n\t\t\tvalue: schemaDescription,\n\t\t\tmessage: \"Schema description is not supported for enum output.\"\n\t\t});\n\t\tif (schemaName != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaName\",\n\t\t\tvalue: schemaName,\n\t\t\tmessage: \"Schema name is not supported for enum output.\"\n\t\t});\n\t\tif (enumValues == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are required for enum output.\"\n\t\t});\n\t\tfor (const value of enumValues) if (typeof value !== \"string\") throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue,\n\t\t\tmessage: \"Enum values must be strings.\"\n\t\t});\n\t}\n}\nfunction stringifyForTelemetry(prompt) {\n\tconst processedPrompt = prompt.map((message) => {\n\t\treturn {\n\t\t\t...message,\n\t\t\tcontent: typeof message.content === \"string\" ? message.content : message.content.map(processPart)\n\t\t};\n\t});\n\treturn JSON.stringify(processedPrompt);\n}\nfunction processPart(part) {\n\tif (part.type === \"image\") return {\n\t\t...part,\n\t\timage: part.image instanceof Uint8Array ? convertDataContentToBase64String(part.image) : part.image\n\t};\n\treturn part;\n}\nvar originalGenerateId = createIdGenerator({\n\tprefix: \"aiobj\",\n\tsize: 24\n});\nasync function generateObject({ model, enum: enumValues, schema: inputSchema, schemaName, schemaDescription, mode, output = \"object\", system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, experimental_repairText: repairText, experimental_telemetry: telemetry, experimental_providerMetadata, providerOptions = experimental_providerMetadata, _internal: { generateId: generateId3 = originalGenerateId, currentDate = () => /* @__PURE__ */ new Date() } = {}, ...settings }) {\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tvalidateObjectGenerationInput({\n\t\toutput,\n\t\tmode,\n\t\tschema: inputSchema,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tenumValues\n\t});\n\tconst { maxRetries, retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst outputStrategy = getOutputStrategy({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tenumValues\n\t});\n\tif (outputStrategy.type === \"no-schema\" && mode === void 0) mode = \"json\";\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t\tmaxRetries\n\t\t}\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.generateObject\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.generateObject\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\tsystem,\n\t\t\t\t\tprompt,\n\t\t\t\t\tmessages\n\t\t\t\t}) },\n\t\t\t\t\"ai.schema\": outputStrategy.jsonSchema != null ? { input: () => JSON.stringify(outputStrategy.jsonSchema) } : void 0,\n\t\t\t\t\"ai.schema.name\": schemaName,\n\t\t\t\t\"ai.schema.description\": schemaDescription,\n\t\t\t\t\"ai.settings.output\": outputStrategy.type,\n\t\t\t\t\"ai.settings.mode\": mode\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tvar _a17, _b, _c, _d;\n\t\t\tif (mode === \"auto\" || mode == null) mode = model.defaultObjectGenerationMode;\n\t\t\tlet result;\n\t\t\tlet finishReason;\n\t\t\tlet usage;\n\t\t\tlet warnings;\n\t\t\tlet rawResponse;\n\t\t\tlet response;\n\t\t\tlet request;\n\t\t\tlet logprobs;\n\t\t\tlet resultProviderMetadata;\n\t\t\tswitch (mode) {\n\t\t\t\tcase \"json\": {\n\t\t\t\t\tconst standardizedPrompt = standardizePrompt({\n\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\tsystem: outputStrategy.jsonSchema == null ? injectJsonInstruction({ prompt: system }) : model.supportsStructuredOutputs ? system : injectJsonInstruction({\n\t\t\t\t\t\t\t\tprompt: system,\n\t\t\t\t\t\t\t\tschema: outputStrategy.jsonSchema\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttools: void 0\n\t\t\t\t\t});\n\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: standardizedPrompt,\n\t\t\t\t\t\tmodelSupportsImageUrls: model.supportsImageUrls,\n\t\t\t\t\t\tmodelSupportsUrl: (_a17 = model.supportsUrl) == null ? void 0 : _a17.bind(model)\n\t\t\t\t\t});\n\t\t\t\t\tconst generateResult = await retry(() => recordSpan({\n\t\t\t\t\t\tname: \"ai.generateObject.doGenerate\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.generateObject.doGenerate\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.prompt.format\": { input: () => standardizedPrompt.type },\n\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => JSON.stringify(promptMessages) },\n\t\t\t\t\t\t\t\t\"ai.settings.mode\": mode,\n\t\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": settings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": settings.maxTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": settings.presencePenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": settings.temperature,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": settings.topK,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": settings.topP\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\t\tvar _a18, _b2, _c2, _d2, _e, _f;\n\t\t\t\t\t\t\tconst result2 = await model.doGenerate({\n\t\t\t\t\t\t\t\tmode: {\n\t\t\t\t\t\t\t\t\ttype: \"object-json\",\n\t\t\t\t\t\t\t\t\tschema: outputStrategy.jsonSchema,\n\t\t\t\t\t\t\t\t\tname: schemaName,\n\t\t\t\t\t\t\t\t\tdescription: schemaDescription\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\t\tinputFormat: standardizedPrompt.type,\n\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\tproviderMetadata: providerOptions,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\t\tid: (_b2 = (_a18 = result2.response) == null ? void 0 : _a18.id) != null ? _b2 : generateId3(),\n\t\t\t\t\t\t\t\ttimestamp: (_d2 = (_c2 = result2.response) == null ? void 0 : _c2.timestamp) != null ? _d2 : currentDate(),\n\t\t\t\t\t\t\t\tmodelId: (_f = (_e = result2.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tif (result2.text === void 0) throw new NoObjectGeneratedError({\n\t\t\t\t\t\t\t\tmessage: \"No object generated: the model did not return a response.\",\n\t\t\t\t\t\t\t\tresponse: responseData,\n\t\t\t\t\t\t\t\tusage: calculateLanguageModelUsage(result2.usage),\n\t\t\t\t\t\t\t\tfinishReason: result2.finishReason\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tspan2.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result2.finishReason,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => result2.text },\n\t\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result2.providerMetadata),\n\t\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": result2.usage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": result2.usage.completionTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result2.finishReason],\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.prompt_tokens\": result2.usage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.completion_tokens\": result2.usage.completionTokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...result2,\n\t\t\t\t\t\t\t\tobjectText: result2.text,\n\t\t\t\t\t\t\t\tresponseData\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\tresult = generateResult.objectText;\n\t\t\t\t\tfinishReason = generateResult.finishReason;\n\t\t\t\t\tusage = generateResult.usage;\n\t\t\t\t\twarnings = generateResult.warnings;\n\t\t\t\t\trawResponse = generateResult.rawResponse;\n\t\t\t\t\tlogprobs = generateResult.logprobs;\n\t\t\t\t\tresultProviderMetadata = generateResult.providerMetadata;\n\t\t\t\t\trequest = (_b = generateResult.request) != null ? _b : {};\n\t\t\t\t\tresponse = generateResult.responseData;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool\": {\n\t\t\t\t\tconst standardizedPrompt = standardizePrompt({\n\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttools: void 0\n\t\t\t\t\t});\n\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: standardizedPrompt,\n\t\t\t\t\t\tmodelSupportsImageUrls: model.supportsImageUrls,\n\t\t\t\t\t\tmodelSupportsUrl: (_c = model.supportsUrl) == null ? void 0 : _c.bind(model)\n\t\t\t\t\t});\n\t\t\t\t\tconst inputFormat = standardizedPrompt.type;\n\t\t\t\t\tconst generateResult = await retry(() => recordSpan({\n\t\t\t\t\t\tname: \"ai.generateObject.doGenerate\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.generateObject.doGenerate\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.prompt.format\": { input: () => inputFormat },\n\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\t\"ai.settings.mode\": mode,\n\t\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": settings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": settings.maxTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": settings.presencePenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": settings.temperature,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": settings.topK,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": settings.topP\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\t\tvar _a18, _b2, _c2, _d2, _e, _f, _g, _h;\n\t\t\t\t\t\t\tconst result2 = await model.doGenerate({\n\t\t\t\t\t\t\t\tmode: {\n\t\t\t\t\t\t\t\t\ttype: \"object-tool\",\n\t\t\t\t\t\t\t\t\ttool: {\n\t\t\t\t\t\t\t\t\t\ttype: \"function\",\n\t\t\t\t\t\t\t\t\t\tname: schemaName != null ? schemaName : \"json\",\n\t\t\t\t\t\t\t\t\t\tdescription: schemaDescription != null ? schemaDescription : \"Respond with a JSON object.\",\n\t\t\t\t\t\t\t\t\t\tparameters: outputStrategy.jsonSchema\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\t\tinputFormat,\n\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\tproviderMetadata: providerOptions,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst objectText = (_b2 = (_a18 = result2.toolCalls) == null ? void 0 : _a18[0]) == null ? void 0 : _b2.args;\n\t\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\t\tid: (_d2 = (_c2 = result2.response) == null ? void 0 : _c2.id) != null ? _d2 : generateId3(),\n\t\t\t\t\t\t\t\ttimestamp: (_f = (_e = result2.response) == null ? void 0 : _e.timestamp) != null ? _f : currentDate(),\n\t\t\t\t\t\t\t\tmodelId: (_h = (_g = result2.response) == null ? void 0 : _g.modelId) != null ? _h : model.modelId\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tif (objectText === void 0) throw new NoObjectGeneratedError({\n\t\t\t\t\t\t\t\tmessage: \"No object generated: the tool was not called.\",\n\t\t\t\t\t\t\t\tresponse: responseData,\n\t\t\t\t\t\t\t\tusage: calculateLanguageModelUsage(result2.usage),\n\t\t\t\t\t\t\t\tfinishReason: result2.finishReason\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tspan2.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result2.finishReason,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => objectText },\n\t\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result2.providerMetadata),\n\t\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": result2.usage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": result2.usage.completionTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result2.finishReason],\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": result2.usage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": result2.usage.completionTokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...result2,\n\t\t\t\t\t\t\t\tobjectText,\n\t\t\t\t\t\t\t\tresponseData\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\tresult = generateResult.objectText;\n\t\t\t\t\tfinishReason = generateResult.finishReason;\n\t\t\t\t\tusage = generateResult.usage;\n\t\t\t\t\twarnings = generateResult.warnings;\n\t\t\t\t\trawResponse = generateResult.rawResponse;\n\t\t\t\t\tlogprobs = generateResult.logprobs;\n\t\t\t\t\tresultProviderMetadata = generateResult.providerMetadata;\n\t\t\t\t\trequest = (_d = generateResult.request) != null ? _d : {};\n\t\t\t\t\tresponse = generateResult.responseData;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase void 0: throw new Error(\"Model does not have a default object generation mode.\");\n\t\t\t\tdefault: throw new Error(`Unsupported mode: ${mode}`);\n\t\t\t}\n\t\t\tfunction processResult(result2) {\n\t\t\t\tconst parseResult = safeParseJSON({ text: result2 });\n\t\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\t\tcause: parseResult.error,\n\t\t\t\t\ttext: result2,\n\t\t\t\t\tresponse,\n\t\t\t\t\tusage: calculateLanguageModelUsage(usage),\n\t\t\t\t\tfinishReason\n\t\t\t\t});\n\t\t\t\tconst validationResult = outputStrategy.validateFinalResult(parseResult.value, {\n\t\t\t\t\ttext: result2,\n\t\t\t\t\tresponse,\n\t\t\t\t\tusage: calculateLanguageModelUsage(usage)\n\t\t\t\t});\n\t\t\t\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\t\tcause: validationResult.error,\n\t\t\t\t\ttext: result2,\n\t\t\t\t\tresponse,\n\t\t\t\t\tusage: calculateLanguageModelUsage(usage),\n\t\t\t\t\tfinishReason\n\t\t\t\t});\n\t\t\t\treturn validationResult.value;\n\t\t\t}\n\t\t\tlet object2;\n\t\t\ttry {\n\t\t\t\tobject2 = processResult(result);\n\t\t\t} catch (error) {\n\t\t\t\tif (repairText != null && NoObjectGeneratedError.isInstance(error) && (JSONParseError.isInstance(error.cause) || TypeValidationError.isInstance(error.cause))) {\n\t\t\t\t\tconst repairedText = await repairText({\n\t\t\t\t\t\ttext: result,\n\t\t\t\t\t\terror: error.cause\n\t\t\t\t\t});\n\t\t\t\t\tif (repairedText === null) throw error;\n\t\t\t\t\tobject2 = processResult(repairedText);\n\t\t\t\t} else throw error;\n\t\t\t}\n\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\"ai.usage.promptTokens\": usage.promptTokens,\n\t\t\t\t\t\"ai.usage.completionTokens\": usage.completionTokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn new DefaultGenerateObjectResult({\n\t\t\t\tobject: object2,\n\t\t\t\tfinishReason,\n\t\t\t\tusage: calculateLanguageModelUsage(usage),\n\t\t\t\twarnings,\n\t\t\t\trequest,\n\t\t\t\tresponse: {\n\t\t\t\t\t...response,\n\t\t\t\t\theaders: rawResponse == null ? void 0 : rawResponse.headers,\n\t\t\t\t\tbody: rawResponse == null ? void 0 : rawResponse.body\n\t\t\t\t},\n\t\t\t\tlogprobs,\n\t\t\t\tproviderMetadata: resultProviderMetadata\n\t\t\t});\n\t\t}\n\t});\n}\nvar DefaultGenerateObjectResult = class {\n\tconstructor(options) {\n\t\tthis.object = options.object;\n\t\tthis.finishReason = options.finishReason;\n\t\tthis.usage = options.usage;\n\t\tthis.warnings = options.warnings;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.experimental_providerMetadata = options.providerMetadata;\n\t\tthis.response = options.response;\n\t\tthis.request = options.request;\n\t\tthis.logprobs = options.logprobs;\n\t}\n\ttoJsonResponse(init) {\n\t\tvar _a17;\n\t\treturn new Response(JSON.stringify(this.object), {\n\t\t\tstatus: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,\n\t\t\theaders: prepareResponseHeaders(init == null ? void 0 : init.headers, { contentType: \"application/json; charset=utf-8\" })\n\t\t});\n\t}\n};\nvar DelayedPromise = class {\n\tconstructor() {\n\t\tthis.status = { type: \"pending\" };\n\t\tthis._resolve = void 0;\n\t\tthis._reject = void 0;\n\t}\n\tget value() {\n\t\tif (this.promise) return this.promise;\n\t\tthis.promise = new Promise((resolve, reject) => {\n\t\t\tif (this.status.type === \"resolved\") resolve(this.status.value);\n\t\t\telse if (this.status.type === \"rejected\") reject(this.status.error);\n\t\t\tthis._resolve = resolve;\n\t\t\tthis._reject = reject;\n\t\t});\n\t\treturn this.promise;\n\t}\n\tresolve(value) {\n\t\tvar _a17;\n\t\tthis.status = {\n\t\t\ttype: \"resolved\",\n\t\t\tvalue\n\t\t};\n\t\tif (this.promise) (_a17 = this._resolve) == null || _a17.call(this, value);\n\t}\n\treject(error) {\n\t\tvar _a17;\n\t\tthis.status = {\n\t\t\ttype: \"rejected\",\n\t\t\terror\n\t\t};\n\t\tif (this.promise) (_a17 = this._reject) == null || _a17.call(this, error);\n\t}\n};\nfunction createResolvablePromise() {\n\tlet resolve;\n\tlet reject;\n\treturn {\n\t\tpromise: new Promise((res, rej) => {\n\t\t\tresolve = res;\n\t\t\treject = rej;\n\t\t}),\n\t\tresolve,\n\t\treject\n\t};\n}\nfunction createStitchableStream() {\n\tlet innerStreamReaders = [];\n\tlet controller = null;\n\tlet isClosed = false;\n\tlet waitForNewStream = createResolvablePromise();\n\tconst processPull = async () => {\n\t\tif (isClosed && innerStreamReaders.length === 0) {\n\t\t\tcontroller?.close();\n\t\t\treturn;\n\t\t}\n\t\tif (innerStreamReaders.length === 0) {\n\t\t\twaitForNewStream = createResolvablePromise();\n\t\t\tawait waitForNewStream.promise;\n\t\t\treturn processPull();\n\t\t}\n\t\ttry {\n\t\t\tconst { value, done } = await innerStreamReaders[0].read();\n\t\t\tif (done) {\n\t\t\t\tinnerStreamReaders.shift();\n\t\t\t\tif (innerStreamReaders.length > 0) await processPull();\n\t\t\t\telse if (isClosed) controller?.close();\n\t\t\t} else controller?.enqueue(value);\n\t\t} catch (error) {\n\t\t\tcontroller?.error(error);\n\t\t\tinnerStreamReaders.shift();\n\t\t\tif (isClosed && innerStreamReaders.length === 0) controller?.close();\n\t\t}\n\t};\n\treturn {\n\t\tstream: new ReadableStream({\n\t\t\tstart(controllerParam) {\n\t\t\t\tcontroller = controllerParam;\n\t\t\t},\n\t\t\tpull: processPull,\n\t\t\tasync cancel() {\n\t\t\t\tfor (const reader of innerStreamReaders) await reader.cancel();\n\t\t\t\tinnerStreamReaders = [];\n\t\t\t\tisClosed = true;\n\t\t\t}\n\t\t}),\n\t\taddStream: (innerStream) => {\n\t\t\tif (isClosed) throw new Error(\"Cannot add inner stream: outer stream is closed\");\n\t\t\tinnerStreamReaders.push(innerStream.getReader());\n\t\t\twaitForNewStream.resolve();\n\t\t},\n\t\t/**\n\t\t* Gracefully close the outer stream. This will let the inner streams\n\t\t* finish processing and then close the outer stream.\n\t\t*/\n\t\tclose: () => {\n\t\t\tisClosed = true;\n\t\t\twaitForNewStream.resolve();\n\t\t\tif (innerStreamReaders.length === 0) controller?.close();\n\t\t},\n\t\t/**\n\t\t* Immediately close the outer stream. This will cancel all inner streams\n\t\t* and close the outer stream.\n\t\t*/\n\t\tterminate: () => {\n\t\t\tisClosed = true;\n\t\t\twaitForNewStream.resolve();\n\t\t\tinnerStreamReaders.forEach((reader) => reader.cancel());\n\t\t\tinnerStreamReaders = [];\n\t\t\tcontroller?.close();\n\t\t}\n\t};\n}\nfunction now() {\n\tvar _a17, _b;\n\treturn (_b = (_a17 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a17.now()) != null ? _b : Date.now();\n}\nvar originalGenerateId2 = createIdGenerator({\n\tprefix: \"aiobj\",\n\tsize: 24\n});\nfunction streamObject({ model, schema: inputSchema, schemaName, schemaDescription, mode, output = \"object\", system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, experimental_providerMetadata, providerOptions = experimental_providerMetadata, onError, onFinish, _internal: { generateId: generateId3 = originalGenerateId2, currentDate = () => /* @__PURE__ */ new Date(), now: now2 = now } = {}, ...settings }) {\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tvalidateObjectGenerationInput({\n\t\toutput,\n\t\tmode,\n\t\tschema: inputSchema,\n\t\tschemaName,\n\t\tschemaDescription\n\t});\n\tconst outputStrategy = getOutputStrategy({\n\t\toutput,\n\t\tschema: inputSchema\n\t});\n\tif (outputStrategy.type === \"no-schema\" && mode === void 0) mode = \"json\";\n\treturn new DefaultStreamObjectResult({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings,\n\t\tmaxRetries,\n\t\tabortSignal,\n\t\toutputStrategy,\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tproviderOptions,\n\t\tmode,\n\t\tonError,\n\t\tonFinish,\n\t\tgenerateId: generateId3,\n\t\tcurrentDate,\n\t\tnow: now2\n\t});\n}\nvar DefaultStreamObjectResult = class {\n\tconstructor({ model, headers, telemetry, settings, maxRetries: maxRetriesArg, abortSignal, outputStrategy, system, prompt, messages, schemaName, schemaDescription, providerOptions, mode, onError, onFinish, generateId: generateId3, currentDate, now: now2 }) {\n\t\tthis.objectPromise = new DelayedPromise();\n\t\tthis.usagePromise = new DelayedPromise();\n\t\tthis.providerMetadataPromise = new DelayedPromise();\n\t\tthis.warningsPromise = new DelayedPromise();\n\t\tthis.requestPromise = new DelayedPromise();\n\t\tthis.responsePromise = new DelayedPromise();\n\t\tconst { maxRetries, retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\t\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\t\tmodel,\n\t\t\ttelemetry,\n\t\t\theaders,\n\t\t\tsettings: {\n\t\t\t\t...settings,\n\t\t\t\tmaxRetries\n\t\t\t}\n\t\t});\n\t\tconst tracer = getTracer(telemetry);\n\t\tconst self = this;\n\t\tconst stitchableStream = createStitchableStream();\n\t\tconst eventProcessor = new TransformStream({ transform(chunk, controller) {\n\t\t\tcontroller.enqueue(chunk);\n\t\t\tif (chunk.type === \"error\") onError?.({ error: chunk.error });\n\t\t} });\n\t\tthis.baseStream = stitchableStream.stream.pipeThrough(eventProcessor);\n\t\trecordSpan({\n\t\t\tname: \"ai.streamObject\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.streamObject\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) },\n\t\t\t\t\t\"ai.schema\": outputStrategy.jsonSchema != null ? { input: () => JSON.stringify(outputStrategy.jsonSchema) } : void 0,\n\t\t\t\t\t\"ai.schema.name\": schemaName,\n\t\t\t\t\t\"ai.schema.description\": schemaDescription,\n\t\t\t\t\t\"ai.settings.output\": outputStrategy.type,\n\t\t\t\t\t\"ai.settings.mode\": mode\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tendWhenDone: false,\n\t\t\tfn: async (rootSpan) => {\n\t\t\t\tvar _a17, _b;\n\t\t\t\tif (mode === \"auto\" || mode == null) mode = model.defaultObjectGenerationMode;\n\t\t\t\tlet callOptions;\n\t\t\t\tlet transformer;\n\t\t\t\tswitch (mode) {\n\t\t\t\t\tcase \"json\": {\n\t\t\t\t\t\tconst standardizedPrompt = standardizePrompt({\n\t\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\t\tsystem: outputStrategy.jsonSchema == null ? injectJsonInstruction({ prompt: system }) : model.supportsStructuredOutputs ? system : injectJsonInstruction({\n\t\t\t\t\t\t\t\t\tprompt: system,\n\t\t\t\t\t\t\t\t\tschema: outputStrategy.jsonSchema\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttools: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcallOptions = {\n\t\t\t\t\t\t\tmode: {\n\t\t\t\t\t\t\t\ttype: \"object-json\",\n\t\t\t\t\t\t\t\tschema: outputStrategy.jsonSchema,\n\t\t\t\t\t\t\t\tname: schemaName,\n\t\t\t\t\t\t\t\tdescription: schemaDescription\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\tinputFormat: standardizedPrompt.type,\n\t\t\t\t\t\t\tprompt: await convertToLanguageModelPrompt({\n\t\t\t\t\t\t\t\tprompt: standardizedPrompt,\n\t\t\t\t\t\t\t\tmodelSupportsImageUrls: model.supportsImageUrls,\n\t\t\t\t\t\t\t\tmodelSupportsUrl: (_a17 = model.supportsUrl) == null ? void 0 : _a17.bind(model)\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tproviderMetadata: providerOptions,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t};\n\t\t\t\t\t\ttransformer = { transform: (chunk, controller) => {\n\t\t\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk.textDelta);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\t\t\tcase \"error\": controller.enqueue(chunk);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"tool\": {\n\t\t\t\t\t\tconst standardizedPrompt = standardizePrompt({\n\t\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttools: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcallOptions = {\n\t\t\t\t\t\t\tmode: {\n\t\t\t\t\t\t\t\ttype: \"object-tool\",\n\t\t\t\t\t\t\t\ttool: {\n\t\t\t\t\t\t\t\t\ttype: \"function\",\n\t\t\t\t\t\t\t\t\tname: schemaName != null ? schemaName : \"json\",\n\t\t\t\t\t\t\t\t\tdescription: schemaDescription != null ? schemaDescription : \"Respond with a JSON object.\",\n\t\t\t\t\t\t\t\t\tparameters: outputStrategy.jsonSchema\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\tinputFormat: standardizedPrompt.type,\n\t\t\t\t\t\t\tprompt: await convertToLanguageModelPrompt({\n\t\t\t\t\t\t\t\tprompt: standardizedPrompt,\n\t\t\t\t\t\t\t\tmodelSupportsImageUrls: model.supportsImageUrls,\n\t\t\t\t\t\t\t\tmodelSupportsUrl: (_b = model.supportsUrl) == null ? void 0 : _b.bind(model)\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tproviderMetadata: providerOptions,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t};\n\t\t\t\t\t\ttransformer = { transform(chunk, controller) {\n\t\t\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\t\t\tcase \"tool-call-delta\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk.argsTextDelta);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\t\t\tcase \"error\": controller.enqueue(chunk);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase void 0: throw new Error(\"Model does not have a default object generation mode.\");\n\t\t\t\t\tdefault: throw new Error(`Unsupported mode: ${mode}`);\n\t\t\t\t}\n\t\t\t\tconst { result: { stream, warnings, rawResponse, request }, doStreamSpan, startTimestampMs } = await retry(() => recordSpan({\n\t\t\t\t\tname: \"ai.streamObject.doStream\",\n\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\toperationId: \"ai.streamObject.doStream\",\n\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\"ai.prompt.format\": { input: () => callOptions.inputFormat },\n\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(callOptions.prompt) },\n\t\t\t\t\t\t\t\"ai.settings.mode\": mode,\n\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": settings.frequencyPenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": settings.maxTokens,\n\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": settings.presencePenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.temperature\": settings.temperature,\n\t\t\t\t\t\t\t\"gen_ai.request.top_k\": settings.topK,\n\t\t\t\t\t\t\t\"gen_ai.request.top_p\": settings.topP\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\ttracer,\n\t\t\t\t\tendWhenDone: false,\n\t\t\t\t\tfn: async (doStreamSpan2) => ({\n\t\t\t\t\t\tstartTimestampMs: now2(),\n\t\t\t\t\t\tdoStreamSpan: doStreamSpan2,\n\t\t\t\t\t\tresult: await model.doStream(callOptions)\n\t\t\t\t\t})\n\t\t\t\t}));\n\t\t\t\tself.requestPromise.resolve(request != null ? request : {});\n\t\t\t\tlet usage;\n\t\t\t\tlet finishReason;\n\t\t\t\tlet providerMetadata;\n\t\t\t\tlet object2;\n\t\t\t\tlet error;\n\t\t\t\tlet accumulatedText = \"\";\n\t\t\t\tlet textDelta = \"\";\n\t\t\t\tlet response = {\n\t\t\t\t\tid: generateId3(),\n\t\t\t\t\ttimestamp: currentDate(),\n\t\t\t\t\tmodelId: model.modelId\n\t\t\t\t};\n\t\t\t\tlet latestObjectJson = void 0;\n\t\t\t\tlet latestObject = void 0;\n\t\t\t\tlet isFirstChunk = true;\n\t\t\t\tlet isFirstDelta = true;\n\t\t\t\tconst transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({\n\t\t\t\t\tasync transform(chunk, controller) {\n\t\t\t\t\t\tvar _a18, _b2, _c;\n\t\t\t\t\t\tif (isFirstChunk) {\n\t\t\t\t\t\t\tconst msToFirstChunk = now2() - startTimestampMs;\n\t\t\t\t\t\t\tisFirstChunk = false;\n\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.firstChunk\", { \"ai.stream.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\tdoStreamSpan.setAttributes({ \"ai.stream.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof chunk === \"string\") {\n\t\t\t\t\t\t\taccumulatedText += chunk;\n\t\t\t\t\t\t\ttextDelta += chunk;\n\t\t\t\t\t\t\tconst { value: currentObjectJson, state: parseState } = parsePartialJson(accumulatedText);\n\t\t\t\t\t\t\tif (currentObjectJson !== void 0 && !isDeepEqualData(latestObjectJson, currentObjectJson)) {\n\t\t\t\t\t\t\t\tconst validationResult = outputStrategy.validatePartialResult({\n\t\t\t\t\t\t\t\t\tvalue: currentObjectJson,\n\t\t\t\t\t\t\t\t\ttextDelta,\n\t\t\t\t\t\t\t\t\tlatestObject,\n\t\t\t\t\t\t\t\t\tisFirstDelta,\n\t\t\t\t\t\t\t\t\tisFinalDelta: parseState === \"successful-parse\"\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (validationResult.success && !isDeepEqualData(latestObject, validationResult.value.partial)) {\n\t\t\t\t\t\t\t\t\tlatestObjectJson = currentObjectJson;\n\t\t\t\t\t\t\t\t\tlatestObject = validationResult.value.partial;\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\t\tobject: latestObject\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\ttextDelta: validationResult.value.textDelta\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\ttextDelta = \"\";\n\t\t\t\t\t\t\t\t\tisFirstDelta = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\tresponse = {\n\t\t\t\t\t\t\t\t\tid: (_a18 = chunk.id) != null ? _a18 : response.id,\n\t\t\t\t\t\t\t\t\ttimestamp: (_b2 = chunk.timestamp) != null ? _b2 : response.timestamp,\n\t\t\t\t\t\t\t\t\tmodelId: (_c = chunk.modelId) != null ? _c : response.modelId\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"finish\": {\n\t\t\t\t\t\t\t\tif (textDelta !== \"\") controller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\ttextDelta\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tfinishReason = chunk.finishReason;\n\t\t\t\t\t\t\t\tusage = calculateLanguageModelUsage(chunk.usage);\n\t\t\t\t\t\t\t\tproviderMetadata = chunk.providerMetadata;\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tself.usagePromise.resolve(usage);\n\t\t\t\t\t\t\t\tself.providerMetadataPromise.resolve(providerMetadata);\n\t\t\t\t\t\t\t\tself.responsePromise.resolve({\n\t\t\t\t\t\t\t\t\t...response,\n\t\t\t\t\t\t\t\t\theaders: rawResponse == null ? void 0 : rawResponse.headers\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst validationResult = outputStrategy.validateFinalResult(latestObjectJson, {\n\t\t\t\t\t\t\t\t\ttext: accumulatedText,\n\t\t\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\t\t\tusage\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (validationResult.success) {\n\t\t\t\t\t\t\t\t\tobject2 = validationResult.value;\n\t\t\t\t\t\t\t\t\tself.objectPromise.resolve(object2);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\terror = new NoObjectGeneratedError({\n\t\t\t\t\t\t\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\t\t\t\t\t\t\tcause: validationResult.error,\n\t\t\t\t\t\t\t\t\t\ttext: accumulatedText,\n\t\t\t\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\t\tfinishReason\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tself.objectPromise.reject(error);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdefault: controller.enqueue(chunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tasync flush(controller) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst finalUsage = usage != null ? usage : {\n\t\t\t\t\t\t\t\tpromptTokens: NaN,\n\t\t\t\t\t\t\t\tcompletionTokens: NaN,\n\t\t\t\t\t\t\t\ttotalTokens: NaN\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tdoStreamSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\t\t\t\"ai.response.id\": response.id,\n\t\t\t\t\t\t\t\t\t\"ai.response.model\": response.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": response.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(providerMetadata),\n\t\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": finalUsage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": finalUsage.completionTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [finishReason],\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": response.id,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": response.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": finalUsage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": finalUsage.completionTokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\trootSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": finalUsage.promptTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": finalUsage.completionTokens,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(providerMetadata)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tawait (onFinish == null ? void 0 : onFinish({\n\t\t\t\t\t\t\t\tusage: finalUsage,\n\t\t\t\t\t\t\t\tobject: object2,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t...response,\n\t\t\t\t\t\t\t\t\theaders: rawResponse == null ? void 0 : rawResponse.headers\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twarnings,\n\t\t\t\t\t\t\t\tproviderMetadata,\n\t\t\t\t\t\t\t\texperimental_providerMetadata: providerMetadata\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t} catch (error2) {\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: error2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\trootSpan.end();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tstitchableStream.addStream(transformedStream);\n\t\t\t}\n\t\t}).catch((error) => {\n\t\t\tstitchableStream.addStream(new ReadableStream({ start(controller) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t\tcontroller.close();\n\t\t\t} }));\n\t\t}).finally(() => {\n\t\t\tstitchableStream.close();\n\t\t});\n\t\tthis.outputStrategy = outputStrategy;\n\t}\n\tget object() {\n\t\treturn this.objectPromise.value;\n\t}\n\tget usage() {\n\t\treturn this.usagePromise.value;\n\t}\n\tget experimental_providerMetadata() {\n\t\treturn this.providerMetadataPromise.value;\n\t}\n\tget providerMetadata() {\n\t\treturn this.providerMetadataPromise.value;\n\t}\n\tget warnings() {\n\t\treturn this.warningsPromise.value;\n\t}\n\tget request() {\n\t\treturn this.requestPromise.value;\n\t}\n\tget response() {\n\t\treturn this.responsePromise.value;\n\t}\n\tget partialObjectStream() {\n\t\treturn createAsyncIterableStream(this.baseStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"object\":\n\t\t\t\t\tcontroller.enqueue(chunk.object);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text-delta\":\n\t\t\t\tcase \"finish\":\n\t\t\t\tcase \"error\": break;\n\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t}\n\t\t} })));\n\t}\n\tget elementStream() {\n\t\treturn this.outputStrategy.createElementStream(this.baseStream);\n\t}\n\tget textStream() {\n\t\treturn createAsyncIterableStream(this.baseStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcontroller.enqueue(chunk.textDelta);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"object\":\n\t\t\t\tcase \"finish\":\n\t\t\t\tcase \"error\": break;\n\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t}\n\t\t} })));\n\t}\n\tget fullStream() {\n\t\treturn createAsyncIterableStream(this.baseStream);\n\t}\n\tpipeTextStreamToResponse(response, init) {\n\t\twriteToServerResponse({\n\t\t\tresponse,\n\t\t\tstatus: init == null ? void 0 : init.status,\n\t\t\tstatusText: init == null ? void 0 : init.statusText,\n\t\t\theaders: prepareOutgoingHttpHeaders(init == null ? void 0 : init.headers, { contentType: \"text/plain; charset=utf-8\" }),\n\t\t\tstream: this.textStream.pipeThrough(new TextEncoderStream())\n\t\t});\n\t}\n\ttoTextStreamResponse(init) {\n\t\tvar _a17;\n\t\treturn new Response(this.textStream.pipeThrough(new TextEncoderStream()), {\n\t\t\tstatus: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,\n\t\t\theaders: prepareResponseHeaders(init == null ? void 0 : init.headers, { contentType: \"text/plain; charset=utf-8\" })\n\t\t});\n\t}\n};\nvar name9 = \"AI_NoOutputSpecifiedError\";\nvar marker9 = `vercel.ai.error.${name9}`;\nvar symbol9 = Symbol.for(marker9);\nvar _a9;\nvar NoOutputSpecifiedError = class extends AISDKError {\n\tconstructor({ message = \"No output specified.\" } = {}) {\n\t\tsuper({\n\t\t\tname: name9,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a9] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker9);\n\t}\n};\n_a9 = symbol9;\nvar name10 = \"AI_ToolExecutionError\";\nvar marker10 = `vercel.ai.error.${name10}`;\nvar symbol10 = Symbol.for(marker10);\nvar _a10;\nvar ToolExecutionError = class extends AISDKError {\n\tconstructor({ toolArgs, toolName, toolCallId, cause, message = `Error executing tool ${toolName}: ${getErrorMessage$1(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name10,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a10] = true;\n\t\tthis.toolArgs = toolArgs;\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker10);\n\t}\n};\n_a10 = symbol10;\nfunction isNonEmptyObject(object2) {\n\treturn object2 != null && Object.keys(object2).length > 0;\n}\nfunction prepareToolsAndToolChoice({ tools, toolChoice, activeTools }) {\n\tif (!isNonEmptyObject(tools)) return {\n\t\ttools: void 0,\n\t\ttoolChoice: void 0\n\t};\n\treturn {\n\t\ttools: (activeTools != null ? Object.entries(tools).filter(([name17]) => activeTools.includes(name17)) : Object.entries(tools)).map(([name17, tool2]) => {\n\t\t\tconst toolType = tool2.type;\n\t\t\tswitch (toolType) {\n\t\t\t\tcase void 0:\n\t\t\t\tcase \"function\": return {\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: name17,\n\t\t\t\t\tdescription: tool2.description,\n\t\t\t\t\tparameters: asSchema(tool2.parameters).jsonSchema\n\t\t\t\t};\n\t\t\t\tcase \"provider-defined\": return {\n\t\t\t\t\ttype: \"provider-defined\",\n\t\t\t\t\tname: name17,\n\t\t\t\t\tid: tool2.id,\n\t\t\t\t\targs: tool2.args\n\t\t\t\t};\n\t\t\t\tdefault: throw new Error(`Unsupported tool type: ${toolType}`);\n\t\t\t}\n\t\t}),\n\t\ttoolChoice: toolChoice == null ? { type: \"auto\" } : typeof toolChoice === \"string\" ? { type: toolChoice } : {\n\t\t\ttype: \"tool\",\n\t\t\ttoolName: toolChoice.toolName\n\t\t}\n\t};\n}\nvar lastWhitespaceRegexp = /^([\\s\\S]*?)(\\s+)(\\S*)$/;\nfunction splitOnLastWhitespace(text2) {\n\tconst match = text2.match(lastWhitespaceRegexp);\n\treturn match ? {\n\t\tprefix: match[1],\n\t\twhitespace: match[2],\n\t\tsuffix: match[3]\n\t} : void 0;\n}\nfunction removeTextAfterLastWhitespace(text2) {\n\tconst match = splitOnLastWhitespace(text2);\n\treturn match ? match.prefix + match.whitespace : text2;\n}\nvar name11 = \"AI_InvalidToolArgumentsError\";\nvar marker11 = `vercel.ai.error.${name11}`;\nvar symbol11 = Symbol.for(marker11);\nvar _a11;\nvar InvalidToolArgumentsError = class extends AISDKError {\n\tconstructor({ toolArgs, toolName, cause, message = `Invalid arguments for tool ${toolName}: ${getErrorMessage$1(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name11,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a11] = true;\n\t\tthis.toolArgs = toolArgs;\n\t\tthis.toolName = toolName;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker11);\n\t}\n};\n_a11 = symbol11;\nvar name12 = \"AI_NoSuchToolError\";\nvar marker12 = `vercel.ai.error.${name12}`;\nvar symbol12 = Symbol.for(marker12);\nvar _a12;\nvar NoSuchToolError = class extends AISDKError {\n\tconstructor({ toolName, availableTools = void 0, message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? \"No tools are available.\" : `Available tools: ${availableTools.join(\", \")}.`}` }) {\n\t\tsuper({\n\t\t\tname: name12,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a12] = true;\n\t\tthis.toolName = toolName;\n\t\tthis.availableTools = availableTools;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker12);\n\t}\n};\n_a12 = symbol12;\nvar name13 = \"AI_ToolCallRepairError\";\nvar marker13 = `vercel.ai.error.${name13}`;\nvar symbol13 = Symbol.for(marker13);\nvar _a13;\nvar ToolCallRepairError = class extends AISDKError {\n\tconstructor({ cause, originalError, message = `Error repairing tool call: ${getErrorMessage$1(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name13,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a13] = true;\n\t\tthis.originalError = originalError;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker13);\n\t}\n};\n_a13 = symbol13;\nasync function parseToolCall({ toolCall, tools, repairToolCall, system, messages }) {\n\tif (tools == null) throw new NoSuchToolError({ toolName: toolCall.toolName });\n\ttry {\n\t\treturn await doParseToolCall({\n\t\t\ttoolCall,\n\t\t\ttools\n\t\t});\n\t} catch (error) {\n\t\tif (repairToolCall == null || !(NoSuchToolError.isInstance(error) || InvalidToolArgumentsError.isInstance(error))) throw error;\n\t\tlet repairedToolCall = null;\n\t\ttry {\n\t\t\trepairedToolCall = await repairToolCall({\n\t\t\t\ttoolCall,\n\t\t\t\ttools,\n\t\t\t\tparameterSchema: ({ toolName }) => asSchema(tools[toolName].parameters).jsonSchema,\n\t\t\t\tsystem,\n\t\t\t\tmessages,\n\t\t\t\terror\n\t\t\t});\n\t\t} catch (repairError) {\n\t\t\tthrow new ToolCallRepairError({\n\t\t\t\tcause: repairError,\n\t\t\t\toriginalError: error\n\t\t\t});\n\t\t}\n\t\tif (repairedToolCall == null) throw error;\n\t\treturn await doParseToolCall({\n\t\t\ttoolCall: repairedToolCall,\n\t\t\ttools\n\t\t});\n\t}\n}\nasync function doParseToolCall({ toolCall, tools }) {\n\tconst toolName = toolCall.toolName;\n\tconst tool2 = tools[toolName];\n\tif (tool2 == null) throw new NoSuchToolError({\n\t\ttoolName: toolCall.toolName,\n\t\tavailableTools: Object.keys(tools)\n\t});\n\tconst schema = asSchema(tool2.parameters);\n\tconst parseResult = toolCall.args.trim() === \"\" ? safeValidateTypes({\n\t\tvalue: {},\n\t\tschema\n\t}) : safeParseJSON({\n\t\ttext: toolCall.args,\n\t\tschema\n\t});\n\tif (parseResult.success === false) throw new InvalidToolArgumentsError({\n\t\ttoolName,\n\t\ttoolArgs: toolCall.args,\n\t\tcause: parseResult.error\n\t});\n\treturn {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName,\n\t\targs: parseResult.value\n\t};\n}\nfunction asReasoningText(reasoning) {\n\tconst reasoningText = reasoning.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n\treturn reasoningText.length > 0 ? reasoningText : void 0;\n}\nfunction toResponseMessages({ text: text2 = \"\", files, reasoning, tools, toolCalls, toolResults, messageId, generateMessageId }) {\n\tconst responseMessages = [];\n\tconst content = [];\n\tif (reasoning.length > 0) content.push(...reasoning.map((part) => part.type === \"text\" ? {\n\t\t...part,\n\t\ttype: \"reasoning\"\n\t} : {\n\t\t...part,\n\t\ttype: \"redacted-reasoning\"\n\t}));\n\tif (files.length > 0) content.push(...files.map((file) => ({\n\t\ttype: \"file\",\n\t\tdata: file.base64,\n\t\tmimeType: file.mimeType\n\t})));\n\tif (text2.length > 0) content.push({\n\t\ttype: \"text\",\n\t\ttext: text2\n\t});\n\tif (toolCalls.length > 0) content.push(...toolCalls);\n\tif (content.length > 0) responseMessages.push({\n\t\trole: \"assistant\",\n\t\tcontent,\n\t\tid: messageId\n\t});\n\tif (toolResults.length > 0) responseMessages.push({\n\t\trole: \"tool\",\n\t\tid: generateMessageId(),\n\t\tcontent: toolResults.map((toolResult) => {\n\t\t\tconst tool2 = tools[toolResult.toolName];\n\t\t\treturn (tool2 == null ? void 0 : tool2.experimental_toToolResultContent) != null ? {\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId: toolResult.toolCallId,\n\t\t\t\ttoolName: toolResult.toolName,\n\t\t\t\tresult: tool2.experimental_toToolResultContent(toolResult.result),\n\t\t\t\texperimental_content: tool2.experimental_toToolResultContent(toolResult.result)\n\t\t\t} : {\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId: toolResult.toolCallId,\n\t\t\t\ttoolName: toolResult.toolName,\n\t\t\t\tresult: toolResult.result\n\t\t\t};\n\t\t})\n\t});\n\treturn responseMessages;\n}\nvar originalGenerateId3 = createIdGenerator({\n\tprefix: \"aitxt\",\n\tsize: 24\n});\nvar originalGenerateMessageId = createIdGenerator({\n\tprefix: \"msg\",\n\tsize: 24\n});\nasync function generateText({ model, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, maxSteps = 1, experimental_generateMessageId: generateMessageId = originalGenerateMessageId, experimental_output: output, experimental_continueSteps: continueSteps = false, experimental_telemetry: telemetry, experimental_providerMetadata, providerOptions = experimental_providerMetadata, experimental_activeTools: activeTools, experimental_prepareStep: prepareStep, experimental_repairToolCall: repairToolCall, _internal: { generateId: generateId3 = originalGenerateId3, currentDate = () => /* @__PURE__ */ new Date() } = {}, onStepFinish, ...settings }) {\n\tvar _a17;\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tif (maxSteps < 1) throw new InvalidArgumentError({\n\t\tparameter: \"maxSteps\",\n\t\tvalue: maxSteps,\n\t\tmessage: \"maxSteps must be at least 1\"\n\t});\n\tconst { maxRetries, retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t\tmaxRetries\n\t\t}\n\t});\n\tconst initialPrompt = standardizePrompt({\n\t\tprompt: {\n\t\t\tsystem: (_a17 = output == null ? void 0 : output.injectIntoSystemPrompt({\n\t\t\t\tsystem,\n\t\t\t\tmodel\n\t\t\t})) != null ? _a17 : system,\n\t\t\tprompt,\n\t\t\tmessages\n\t\t},\n\t\ttools\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.generateText\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.generateText\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.model.provider\": model.provider,\n\t\t\t\t\"ai.model.id\": model.modelId,\n\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\tsystem,\n\t\t\t\t\tprompt,\n\t\t\t\t\tmessages\n\t\t\t\t}) },\n\t\t\t\t\"ai.settings.maxSteps\": maxSteps\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tvar _a18, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;\n\t\t\tconst callSettings = prepareCallSettings(settings);\n\t\t\tlet currentModelResponse;\n\t\t\tlet currentToolCalls = [];\n\t\t\tlet currentToolResults = [];\n\t\t\tlet currentReasoningDetails = [];\n\t\t\tlet stepCount = 0;\n\t\t\tconst responseMessages = [];\n\t\t\tlet text2 = \"\";\n\t\t\tconst sources = [];\n\t\t\tconst steps = [];\n\t\t\tlet usage = {\n\t\t\t\tcompletionTokens: 0,\n\t\t\t\tpromptTokens: 0,\n\t\t\t\ttotalTokens: 0\n\t\t\t};\n\t\t\tlet stepType = \"initial\";\n\t\t\tdo {\n\t\t\t\tconst promptFormat = stepCount === 0 ? initialPrompt.type : \"messages\";\n\t\t\t\tconst stepInputMessages = [...initialPrompt.messages, ...responseMessages];\n\t\t\t\tconst prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({\n\t\t\t\t\tmodel,\n\t\t\t\t\tsteps,\n\t\t\t\t\tmaxSteps,\n\t\t\t\t\tstepNumber: stepCount\n\t\t\t\t}));\n\t\t\t\tconst stepToolChoice = (_a18 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _a18 : toolChoice;\n\t\t\t\tconst stepActiveTools = (_b = prepareStepResult == null ? void 0 : prepareStepResult.experimental_activeTools) != null ? _b : activeTools;\n\t\t\t\tconst stepModel = (_c = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _c : model;\n\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\tprompt: {\n\t\t\t\t\t\ttype: promptFormat,\n\t\t\t\t\t\tsystem: initialPrompt.system,\n\t\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t\t},\n\t\t\t\t\tmodelSupportsImageUrls: stepModel.supportsImageUrls,\n\t\t\t\t\tmodelSupportsUrl: (_d = stepModel.supportsUrl) == null ? void 0 : _d.bind(stepModel)\n\t\t\t\t});\n\t\t\t\tconst mode = {\n\t\t\t\t\ttype: \"regular\",\n\t\t\t\t\t...prepareToolsAndToolChoice({\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t\tcurrentModelResponse = await retry(() => recordSpan({\n\t\t\t\t\tname: \"ai.generateText.doGenerate\",\n\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\toperationId: \"ai.generateText.doGenerate\",\n\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\"ai.model.provider\": stepModel.provider,\n\t\t\t\t\t\t\t\"ai.model.id\": stepModel.modelId,\n\t\t\t\t\t\t\t\"ai.prompt.format\": { input: () => promptFormat },\n\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\"ai.prompt.tools\": { input: () => {\n\t\t\t\t\t\t\t\tvar _a19;\n\t\t\t\t\t\t\t\treturn (_a19 = mode.tools) == null ? void 0 : _a19.map((tool2) => JSON.stringify(tool2));\n\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\"ai.prompt.toolChoice\": { input: () => mode.toolChoice != null ? JSON.stringify(mode.toolChoice) : void 0 },\n\t\t\t\t\t\t\t\"gen_ai.system\": stepModel.provider,\n\t\t\t\t\t\t\t\"gen_ai.request.model\": stepModel.modelId,\n\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": settings.frequencyPenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": settings.maxTokens,\n\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": settings.presencePenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.stop_sequences\": settings.stopSequences,\n\t\t\t\t\t\t\t\"gen_ai.request.temperature\": settings.temperature,\n\t\t\t\t\t\t\t\"gen_ai.request.top_k\": settings.topK,\n\t\t\t\t\t\t\t\"gen_ai.request.top_p\": settings.topP\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\ttracer,\n\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\tvar _a19, _b2, _c2, _d2, _e2, _f2;\n\t\t\t\t\t\tconst result = await stepModel.doGenerate({\n\t\t\t\t\t\t\tmode,\n\t\t\t\t\t\t\t...callSettings,\n\t\t\t\t\t\t\tinputFormat: promptFormat,\n\t\t\t\t\t\t\tresponseFormat: output == null ? void 0 : output.responseFormat({ model }),\n\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\tproviderMetadata: providerOptions,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\tid: (_b2 = (_a19 = result.response) == null ? void 0 : _a19.id) != null ? _b2 : generateId3(),\n\t\t\t\t\t\t\ttimestamp: (_d2 = (_c2 = result.response) == null ? void 0 : _c2.timestamp) != null ? _d2 : currentDate(),\n\t\t\t\t\t\t\tmodelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId\n\t\t\t\t\t\t};\n\t\t\t\t\t\tspan2.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result.finishReason,\n\t\t\t\t\t\t\t\t\"ai.response.text\": { output: () => result.text },\n\t\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => JSON.stringify(result.toolCalls) },\n\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result.providerMetadata),\n\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": result.usage.promptTokens,\n\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": result.usage.completionTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result.finishReason],\n\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": result.usage.promptTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": result.usage.completionTokens\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}));\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tresponse: responseData\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tcurrentToolCalls = await Promise.all(((_e = currentModelResponse.toolCalls) != null ? _e : []).map((toolCall) => parseToolCall({\n\t\t\t\t\ttoolCall,\n\t\t\t\t\ttools,\n\t\t\t\t\trepairToolCall,\n\t\t\t\t\tsystem,\n\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t})));\n\t\t\t\tcurrentToolResults = tools == null ? [] : await executeTools({\n\t\t\t\t\ttoolCalls: currentToolCalls,\n\t\t\t\t\ttools,\n\t\t\t\t\ttracer,\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\tabortSignal\n\t\t\t\t});\n\t\t\t\tconst currentUsage = calculateLanguageModelUsage(currentModelResponse.usage);\n\t\t\t\tusage = addLanguageModelUsage(usage, currentUsage);\n\t\t\t\tlet nextStepType = \"done\";\n\t\t\t\tif (++stepCount < maxSteps) {\n\t\t\t\t\tif (continueSteps && currentModelResponse.finishReason === \"length\" && currentToolCalls.length === 0) nextStepType = \"continue\";\n\t\t\t\t\telse if (currentToolCalls.length > 0 && currentToolResults.length === currentToolCalls.length) nextStepType = \"tool-result\";\n\t\t\t\t}\n\t\t\t\tconst originalText = (_f = currentModelResponse.text) != null ? _f : \"\";\n\t\t\t\tconst stepTextLeadingWhitespaceTrimmed = stepType === \"continue\" && text2.trimEnd() !== text2 ? originalText.trimStart() : originalText;\n\t\t\t\tconst stepText = nextStepType === \"continue\" ? removeTextAfterLastWhitespace(stepTextLeadingWhitespaceTrimmed) : stepTextLeadingWhitespaceTrimmed;\n\t\t\t\ttext2 = nextStepType === \"continue\" || stepType === \"continue\" ? text2 + stepText : stepText;\n\t\t\t\tcurrentReasoningDetails = asReasoningDetails(currentModelResponse.reasoning);\n\t\t\t\tsources.push(...(_g = currentModelResponse.sources) != null ? _g : []);\n\t\t\t\tif (stepType === \"continue\") {\n\t\t\t\t\tconst lastMessage = responseMessages[responseMessages.length - 1];\n\t\t\t\t\tif (typeof lastMessage.content === \"string\") lastMessage.content += stepText;\n\t\t\t\t\telse lastMessage.content.push({\n\t\t\t\t\t\ttext: stepText,\n\t\t\t\t\t\ttype: \"text\"\n\t\t\t\t\t});\n\t\t\t\t} else responseMessages.push(...toResponseMessages({\n\t\t\t\t\ttext: text2,\n\t\t\t\t\tfiles: asFiles(currentModelResponse.files),\n\t\t\t\t\treasoning: asReasoningDetails(currentModelResponse.reasoning),\n\t\t\t\t\ttools: tools != null ? tools : {},\n\t\t\t\t\ttoolCalls: currentToolCalls,\n\t\t\t\t\ttoolResults: currentToolResults,\n\t\t\t\t\tmessageId: generateMessageId(),\n\t\t\t\t\tgenerateMessageId\n\t\t\t\t}));\n\t\t\t\tconst currentStepResult = {\n\t\t\t\t\tstepType,\n\t\t\t\t\ttext: stepText,\n\t\t\t\t\treasoning: asReasoningText(currentReasoningDetails),\n\t\t\t\t\treasoningDetails: currentReasoningDetails,\n\t\t\t\t\tfiles: asFiles(currentModelResponse.files),\n\t\t\t\t\tsources: (_h = currentModelResponse.sources) != null ? _h : [],\n\t\t\t\t\ttoolCalls: currentToolCalls,\n\t\t\t\t\ttoolResults: currentToolResults,\n\t\t\t\t\tfinishReason: currentModelResponse.finishReason,\n\t\t\t\t\tusage: currentUsage,\n\t\t\t\t\twarnings: currentModelResponse.warnings,\n\t\t\t\t\tlogprobs: currentModelResponse.logprobs,\n\t\t\t\t\trequest: (_i = currentModelResponse.request) != null ? _i : {},\n\t\t\t\t\tresponse: {\n\t\t\t\t\t\t...currentModelResponse.response,\n\t\t\t\t\t\theaders: (_j = currentModelResponse.rawResponse) == null ? void 0 : _j.headers,\n\t\t\t\t\t\tbody: (_k = currentModelResponse.rawResponse) == null ? void 0 : _k.body,\n\t\t\t\t\t\tmessages: structuredClone(responseMessages)\n\t\t\t\t\t},\n\t\t\t\t\tproviderMetadata: currentModelResponse.providerMetadata,\n\t\t\t\t\texperimental_providerMetadata: currentModelResponse.providerMetadata,\n\t\t\t\t\tisContinued: nextStepType === \"continue\"\n\t\t\t\t};\n\t\t\t\tsteps.push(currentStepResult);\n\t\t\t\tawait (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));\n\t\t\t\tstepType = nextStepType;\n\t\t\t} while (stepType !== \"done\");\n\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.response.finishReason\": currentModelResponse.finishReason,\n\t\t\t\t\t\"ai.response.text\": { output: () => currentModelResponse.text },\n\t\t\t\t\t\"ai.response.toolCalls\": { output: () => JSON.stringify(currentModelResponse.toolCalls) },\n\t\t\t\t\t\"ai.usage.promptTokens\": currentModelResponse.usage.promptTokens,\n\t\t\t\t\t\"ai.usage.completionTokens\": currentModelResponse.usage.completionTokens,\n\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(currentModelResponse.providerMetadata)\n\t\t\t\t}\n\t\t\t}));\n\t\t\treturn new DefaultGenerateTextResult({\n\t\t\t\ttext: text2,\n\t\t\t\tfiles: asFiles(currentModelResponse.files),\n\t\t\t\treasoning: asReasoningText(currentReasoningDetails),\n\t\t\t\treasoningDetails: currentReasoningDetails,\n\t\t\t\tsources,\n\t\t\t\toutputResolver: () => {\n\t\t\t\t\tif (output == null) throw new NoOutputSpecifiedError();\n\t\t\t\t\treturn output.parseOutput({ text: text2 }, {\n\t\t\t\t\t\tresponse: currentModelResponse.response,\n\t\t\t\t\t\tusage,\n\t\t\t\t\t\tfinishReason: currentModelResponse.finishReason\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\ttoolCalls: currentToolCalls,\n\t\t\t\ttoolResults: currentToolResults,\n\t\t\t\tfinishReason: currentModelResponse.finishReason,\n\t\t\t\tusage,\n\t\t\t\twarnings: currentModelResponse.warnings,\n\t\t\t\trequest: (_l = currentModelResponse.request) != null ? _l : {},\n\t\t\t\tresponse: {\n\t\t\t\t\t...currentModelResponse.response,\n\t\t\t\t\theaders: (_m = currentModelResponse.rawResponse) == null ? void 0 : _m.headers,\n\t\t\t\t\tbody: (_n = currentModelResponse.rawResponse) == null ? void 0 : _n.body,\n\t\t\t\t\tmessages: responseMessages\n\t\t\t\t},\n\t\t\t\tlogprobs: currentModelResponse.logprobs,\n\t\t\t\tsteps,\n\t\t\t\tproviderMetadata: currentModelResponse.providerMetadata\n\t\t\t});\n\t\t}\n\t});\n}\nasync function executeTools({ toolCalls, tools, tracer, telemetry, messages, abortSignal }) {\n\treturn (await Promise.all(toolCalls.map(async ({ toolCallId, toolName, args }) => {\n\t\tconst tool2 = tools[toolName];\n\t\tif ((tool2 == null ? void 0 : tool2.execute) == null) return;\n\t\treturn {\n\t\t\ttype: \"tool-result\",\n\t\t\ttoolCallId,\n\t\t\ttoolName,\n\t\t\targs,\n\t\t\tresult: await recordSpan({\n\t\t\t\tname: \"ai.toolCall\",\n\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\toperationId: \"ai.toolCall\",\n\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t\"ai.toolCall.name\": toolName,\n\t\t\t\t\t\t\"ai.toolCall.id\": toolCallId,\n\t\t\t\t\t\t\"ai.toolCall.args\": { output: () => JSON.stringify(args) }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttracer,\n\t\t\t\tfn: async (span) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result2 = await tool2.execute(args, {\n\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\tabortSignal\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: { \"ai.toolCall.result\": { output: () => JSON.stringify(result2) } }\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t} catch (ignored) {}\n\t\t\t\t\t\treturn result2;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t\t\t\tthrow new ToolExecutionError({\n\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\ttoolArgs: args,\n\t\t\t\t\t\t\tcause: error\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t};\n\t}))).filter((result) => result != null);\n}\nvar DefaultGenerateTextResult = class {\n\tconstructor(options) {\n\t\tthis.text = options.text;\n\t\tthis.files = options.files;\n\t\tthis.reasoning = options.reasoning;\n\t\tthis.reasoningDetails = options.reasoningDetails;\n\t\tthis.toolCalls = options.toolCalls;\n\t\tthis.toolResults = options.toolResults;\n\t\tthis.finishReason = options.finishReason;\n\t\tthis.usage = options.usage;\n\t\tthis.warnings = options.warnings;\n\t\tthis.request = options.request;\n\t\tthis.response = options.response;\n\t\tthis.steps = options.steps;\n\t\tthis.experimental_providerMetadata = options.providerMetadata;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.logprobs = options.logprobs;\n\t\tthis.outputResolver = options.outputResolver;\n\t\tthis.sources = options.sources;\n\t}\n\tget experimental_output() {\n\t\treturn this.outputResolver();\n\t}\n};\nfunction asReasoningDetails(reasoning) {\n\tif (reasoning == null) return [];\n\tif (typeof reasoning === \"string\") return [{\n\t\ttype: \"text\",\n\t\ttext: reasoning\n\t}];\n\treturn reasoning;\n}\nfunction asFiles(files) {\n\tvar _a17;\n\treturn (_a17 = files == null ? void 0 : files.map((file) => new DefaultGeneratedFile(file))) != null ? _a17 : [];\n}\nvar output_exports = {};\n__export(output_exports, {\n\tobject: () => object,\n\ttext: () => text\n});\nvar name14 = \"AI_InvalidStreamPartError\";\nvar marker14 = `vercel.ai.error.${name14}`;\nvar symbol14 = Symbol.for(marker14);\nvar _a14;\nvar InvalidStreamPartError = class extends AISDKError {\n\tconstructor({ chunk, message }) {\n\t\tsuper({\n\t\t\tname: name14,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a14] = true;\n\t\tthis.chunk = chunk;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker14);\n\t}\n};\n_a14 = symbol14;\nvar marker15 = `vercel.ai.error.AI_MCPClientError`;\nvar symbol15 = Symbol.for(marker15);\nvar _a15;\nvar MCPClientError = class extends AISDKError {\n\tconstructor({ name: name17 = \"MCPClientError\", message, cause }) {\n\t\tsuper({\n\t\t\tname: name17,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a15] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker15);\n\t}\n};\n_a15 = symbol15;\nvar text = () => ({\n\ttype: \"text\",\n\tresponseFormat: () => ({ type: \"text\" }),\n\tinjectIntoSystemPrompt({ system }) {\n\t\treturn system;\n\t},\n\tparsePartial({ text: text2 }) {\n\t\treturn { partial: text2 };\n\t},\n\tparseOutput({ text: text2 }) {\n\t\treturn text2;\n\t}\n});\nvar object = ({ schema: inputSchema }) => {\n\tconst schema = asSchema(inputSchema);\n\treturn {\n\t\ttype: \"object\",\n\t\tresponseFormat: ({ model }) => ({\n\t\t\ttype: \"json\",\n\t\t\tschema: model.supportsStructuredOutputs ? schema.jsonSchema : void 0\n\t\t}),\n\t\tinjectIntoSystemPrompt({ system, model }) {\n\t\t\treturn model.supportsStructuredOutputs ? system : injectJsonInstruction({\n\t\t\t\tprompt: system,\n\t\t\t\tschema: schema.jsonSchema\n\t\t\t});\n\t\t},\n\t\tparsePartial({ text: text2 }) {\n\t\t\tconst result = parsePartialJson(text2);\n\t\t\tswitch (result.state) {\n\t\t\t\tcase \"failed-parse\":\n\t\t\t\tcase \"undefined-input\": return;\n\t\t\t\tcase \"repaired-parse\":\n\t\t\t\tcase \"successful-parse\": return { partial: result.value };\n\t\t\t\tdefault: {\n\t\t\t\t\tconst _exhaustiveCheck = result.state;\n\t\t\t\t\tthrow new Error(`Unsupported parse state: ${_exhaustiveCheck}`);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tparseOutput({ text: text2 }, context) {\n\t\t\tconst parseResult = safeParseJSON({ text: text2 });\n\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\tcause: parseResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context.response,\n\t\t\t\tusage: context.usage,\n\t\t\t\tfinishReason: context.finishReason\n\t\t\t});\n\t\t\tconst validationResult = safeValidateTypes({\n\t\t\t\tvalue: parseResult.value,\n\t\t\t\tschema\n\t\t\t});\n\t\t\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\tcause: validationResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context.response,\n\t\t\t\tusage: context.usage,\n\t\t\t\tfinishReason: context.finishReason\n\t\t\t});\n\t\t\treturn validationResult.value;\n\t\t}\n\t};\n};\nvar CHUNKING_REGEXPS = {\n\tword: /\\S+\\s+/m,\n\tline: /\\n+/m\n};\nfunction smoothStream({ delayInMs = 10, chunking = \"word\", _internal: { delay: delay2 = delay } = {} } = {}) {\n\tlet detectChunk;\n\tif (typeof chunking === \"function\") detectChunk = (buffer) => {\n\t\tconst match = chunking(buffer);\n\t\tif (match == null) return null;\n\t\tif (!match.length) throw new Error(`Chunking function must return a non-empty string.`);\n\t\tif (!buffer.startsWith(match)) throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: \"${match}\" expected to start with \"${buffer}\"`);\n\t\treturn match;\n\t};\n\telse {\n\t\tconst chunkingRegex = typeof chunking === \"string\" ? CHUNKING_REGEXPS[chunking] : chunking;\n\t\tif (chunkingRegex == null) throw new InvalidArgumentError$1({\n\t\t\targument: \"chunking\",\n\t\t\tmessage: `Chunking must be \"word\" or \"line\" or a RegExp. Received: ${chunking}`\n\t\t});\n\t\tdetectChunk = (buffer) => {\n\t\t\tconst match = chunkingRegex.exec(buffer);\n\t\t\tif (!match) return null;\n\t\t\treturn buffer.slice(0, match.index) + (match == null ? void 0 : match[0]);\n\t\t};\n\t}\n\treturn () => {\n\t\tlet buffer = \"\";\n\t\treturn new TransformStream({ async transform(chunk, controller) {\n\t\t\tif (chunk.type !== \"text-delta\") {\n\t\t\t\tif (buffer.length > 0) {\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\ttextDelta: buffer\n\t\t\t\t\t});\n\t\t\t\t\tbuffer = \"\";\n\t\t\t\t}\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbuffer += chunk.textDelta;\n\t\t\tlet match;\n\t\t\twhile ((match = detectChunk(buffer)) != null) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\ttextDelta: match\n\t\t\t\t});\n\t\t\t\tbuffer = buffer.slice(match.length);\n\t\t\t\tawait delay2(delayInMs);\n\t\t\t}\n\t\t} });\n\t};\n}\nfunction asArray(value) {\n\treturn value === void 0 ? [] : Array.isArray(value) ? value : [value];\n}\nasync function consumeStream({ stream, onError }) {\n\tconst reader = stream.getReader();\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done } = await reader.read();\n\t\t\tif (done) break;\n\t\t}\n\t} catch (error) {\n\t\tonError?.(error);\n\t} finally {\n\t\treader.releaseLock();\n\t}\n}\nfunction mergeStreams(stream1, stream2) {\n\tconst reader1 = stream1.getReader();\n\tconst reader2 = stream2.getReader();\n\tlet lastRead1 = void 0;\n\tlet lastRead2 = void 0;\n\tlet stream1Done = false;\n\tlet stream2Done = false;\n\tasync function readStream1(controller) {\n\t\ttry {\n\t\t\tif (lastRead1 == null) lastRead1 = reader1.read();\n\t\t\tconst result = await lastRead1;\n\t\t\tlastRead1 = void 0;\n\t\t\tif (!result.done) controller.enqueue(result.value);\n\t\t\telse controller.close();\n\t\t} catch (error) {\n\t\t\tcontroller.error(error);\n\t\t}\n\t}\n\tasync function readStream2(controller) {\n\t\ttry {\n\t\t\tif (lastRead2 == null) lastRead2 = reader2.read();\n\t\t\tconst result = await lastRead2;\n\t\t\tlastRead2 = void 0;\n\t\t\tif (!result.done) controller.enqueue(result.value);\n\t\t\telse controller.close();\n\t\t} catch (error) {\n\t\t\tcontroller.error(error);\n\t\t}\n\t}\n\treturn new ReadableStream({\n\t\tasync pull(controller) {\n\t\t\ttry {\n\t\t\t\tif (stream1Done) {\n\t\t\t\t\tawait readStream2(controller);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (stream2Done) {\n\t\t\t\t\tawait readStream1(controller);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (lastRead1 == null) lastRead1 = reader1.read();\n\t\t\t\tif (lastRead2 == null) lastRead2 = reader2.read();\n\t\t\t\tconst { result, reader } = await Promise.race([lastRead1.then((result2) => ({\n\t\t\t\t\tresult: result2,\n\t\t\t\t\treader: reader1\n\t\t\t\t})), lastRead2.then((result2) => ({\n\t\t\t\t\tresult: result2,\n\t\t\t\t\treader: reader2\n\t\t\t\t}))]);\n\t\t\t\tif (!result.done) controller.enqueue(result.value);\n\t\t\t\tif (reader === reader1) {\n\t\t\t\t\tlastRead1 = void 0;\n\t\t\t\t\tif (result.done) {\n\t\t\t\t\t\tawait readStream2(controller);\n\t\t\t\t\t\tstream1Done = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlastRead2 = void 0;\n\t\t\t\t\tif (result.done) {\n\t\t\t\t\t\tstream2Done = true;\n\t\t\t\t\t\tawait readStream1(controller);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t},\n\t\tcancel() {\n\t\t\treader1.cancel();\n\t\t\treader2.cancel();\n\t\t}\n\t});\n}\nfunction runToolsTransformation({ tools, generatorStream, toolCallStreaming, tracer, telemetry, system, messages, abortSignal, repairToolCall }) {\n\tlet toolResultsStreamController = null;\n\tconst toolResultsStream = new ReadableStream({ start(controller) {\n\t\ttoolResultsStreamController = controller;\n\t} });\n\tconst activeToolCalls = {};\n\tconst outstandingToolResults = /* @__PURE__ */ new Set();\n\tlet canClose = false;\n\tlet finishChunk = void 0;\n\tfunction attemptClose() {\n\t\tif (canClose && outstandingToolResults.size === 0) {\n\t\t\tif (finishChunk != null) toolResultsStreamController.enqueue(finishChunk);\n\t\t\ttoolResultsStreamController.close();\n\t\t}\n\t}\n\tconst forwardStream = new TransformStream({\n\t\tasync transform(chunk, controller) {\n\t\t\tconst chunkType = chunk.type;\n\t\t\tswitch (chunkType) {\n\t\t\t\tcase \"text-delta\":\n\t\t\t\tcase \"reasoning\":\n\t\t\t\tcase \"reasoning-signature\":\n\t\t\t\tcase \"redacted-reasoning\":\n\t\t\t\tcase \"source\":\n\t\t\t\tcase \"response-metadata\":\n\t\t\t\tcase \"error\":\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"file\":\n\t\t\t\t\tcontroller.enqueue(new DefaultGeneratedFileWithType({\n\t\t\t\t\t\tdata: chunk.data,\n\t\t\t\t\t\tmimeType: chunk.mimeType\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call-delta\":\n\t\t\t\t\tif (toolCallStreaming) {\n\t\t\t\t\t\tif (!activeToolCalls[chunk.toolCallId]) {\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"tool-call-streaming-start\",\n\t\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: chunk.toolName\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tactiveToolCalls[chunk.toolCallId] = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-call-delta\",\n\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\t\targsTextDelta: chunk.argsTextDelta\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call\":\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst toolCall = await parseToolCall({\n\t\t\t\t\t\t\ttoolCall: chunk,\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontroller.enqueue(toolCall);\n\t\t\t\t\t\tconst tool2 = tools[toolCall.toolName];\n\t\t\t\t\t\tif (tool2.execute != null) {\n\t\t\t\t\t\t\tconst toolExecutionId = generateId();\n\t\t\t\t\t\t\toutstandingToolResults.add(toolExecutionId);\n\t\t\t\t\t\t\trecordSpan({\n\t\t\t\t\t\t\t\tname: \"ai.toolCall\",\n\t\t\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\t\t\toperationId: \"ai.toolCall\",\n\t\t\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\"ai.toolCall.name\": toolCall.toolName,\n\t\t\t\t\t\t\t\t\t\t\"ai.toolCall.id\": toolCall.toolCallId,\n\t\t\t\t\t\t\t\t\t\t\"ai.toolCall.args\": { output: () => JSON.stringify(toolCall.args) }\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\t\tfn: async (span) => tool2.execute(toolCall.args, {\n\t\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\t\t\tabortSignal\n\t\t\t\t\t\t\t\t}).then((result) => {\n\t\t\t\t\t\t\t\t\ttoolResultsStreamController.enqueue({\n\t\t\t\t\t\t\t\t\t\t...toolCall,\n\t\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\t\tresult\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\toutstandingToolResults.delete(toolExecutionId);\n\t\t\t\t\t\t\t\t\tattemptClose();\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tspan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\t\t\tattributes: { \"ai.toolCall.result\": { output: () => JSON.stringify(result) } }\n\t\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\t} catch (ignored) {}\n\t\t\t\t\t\t\t\t}, (error) => {\n\t\t\t\t\t\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t\t\t\t\t\t\ttoolResultsStreamController.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\t\t\terror: new ToolExecutionError({\n\t\t\t\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\t\t\t\t\ttoolArgs: toolCall.args,\n\t\t\t\t\t\t\t\t\t\t\tcause: error\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\toutstandingToolResults.delete(toolExecutionId);\n\t\t\t\t\t\t\t\t\tattemptClose();\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\ttoolResultsStreamController.enqueue({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tfinishChunk = {\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: chunk.finishReason,\n\t\t\t\t\t\tlogprobs: chunk.logprobs,\n\t\t\t\t\t\tusage: calculateLanguageModelUsage(chunk.usage),\n\t\t\t\t\t\texperimental_providerMetadata: chunk.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: throw new Error(`Unhandled chunk type: ${chunkType}`);\n\t\t\t}\n\t\t},\n\t\tflush() {\n\t\t\tcanClose = true;\n\t\t\tattemptClose();\n\t\t}\n\t});\n\treturn new ReadableStream({ async start(controller) {\n\t\treturn Promise.all([generatorStream.pipeThrough(forwardStream).pipeTo(new WritableStream({\n\t\t\twrite(chunk) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tclose() {}\n\t\t})), toolResultsStream.pipeTo(new WritableStream({\n\t\t\twrite(chunk) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tclose() {\n\t\t\t\tcontroller.close();\n\t\t\t}\n\t\t}))]);\n\t} });\n}\nvar originalGenerateId4 = createIdGenerator({\n\tprefix: \"aitxt\",\n\tsize: 24\n});\nvar originalGenerateMessageId2 = createIdGenerator({\n\tprefix: \"msg\",\n\tsize: 24\n});\nfunction streamText({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxSteps = 1, experimental_generateMessageId: generateMessageId = originalGenerateMessageId2, experimental_output: output, experimental_continueSteps: continueSteps = false, experimental_telemetry: telemetry, experimental_providerMetadata, providerOptions = experimental_providerMetadata, experimental_toolCallStreaming = false, toolCallStreaming = experimental_toolCallStreaming, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, onChunk, onError, onFinish, onStepFinish, _internal: { now: now2 = now, generateId: generateId3 = originalGenerateId4, currentDate = () => /* @__PURE__ */ new Date() } = {}, ...settings }) {\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\treturn new DefaultStreamTextResult({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings,\n\t\tmaxRetries,\n\t\tabortSignal,\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\ttools,\n\t\ttoolChoice,\n\t\ttoolCallStreaming,\n\t\ttransforms: asArray(transform),\n\t\tactiveTools,\n\t\trepairToolCall,\n\t\tmaxSteps,\n\t\toutput,\n\t\tcontinueSteps,\n\t\tproviderOptions,\n\t\tonChunk,\n\t\tonError,\n\t\tonFinish,\n\t\tonStepFinish,\n\t\tnow: now2,\n\t\tcurrentDate,\n\t\tgenerateId: generateId3,\n\t\tgenerateMessageId\n\t});\n}\nfunction createOutputTransformStream(output) {\n\tif (!output) return new TransformStream({ transform(chunk, controller) {\n\t\tcontroller.enqueue({\n\t\t\tpart: chunk,\n\t\t\tpartialOutput: void 0\n\t\t});\n\t} });\n\tlet text2 = \"\";\n\tlet textChunk = \"\";\n\tlet lastPublishedJson = \"\";\n\tfunction publishTextChunk({ controller, partialOutput = void 0 }) {\n\t\tcontroller.enqueue({\n\t\t\tpart: {\n\t\t\t\ttype: \"text-delta\",\n\t\t\t\ttextDelta: textChunk\n\t\t\t},\n\t\t\tpartialOutput\n\t\t});\n\t\ttextChunk = \"\";\n\t}\n\treturn new TransformStream({\n\t\ttransform(chunk, controller) {\n\t\t\tif (chunk.type === \"step-finish\") publishTextChunk({ controller });\n\t\t\tif (chunk.type !== \"text-delta\") {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\tpart: chunk,\n\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttext2 += chunk.textDelta;\n\t\t\ttextChunk += chunk.textDelta;\n\t\t\tconst result = output.parsePartial({ text: text2 });\n\t\t\tif (result != null) {\n\t\t\t\tconst currentJson = JSON.stringify(result.partial);\n\t\t\t\tif (currentJson !== lastPublishedJson) {\n\t\t\t\t\tpublishTextChunk({\n\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\tpartialOutput: result.partial\n\t\t\t\t\t});\n\t\t\t\t\tlastPublishedJson = currentJson;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tflush(controller) {\n\t\t\tif (textChunk.length > 0) publishTextChunk({ controller });\n\t\t}\n\t});\n}\nvar DefaultStreamTextResult = class {\n\tconstructor({ model, telemetry, headers, settings, maxRetries: maxRetriesArg, abortSignal, system, prompt, messages, tools, toolChoice, toolCallStreaming, transforms, activeTools, repairToolCall, maxSteps, output, continueSteps, providerOptions, now: now2, currentDate, generateId: generateId3, generateMessageId, onChunk, onError, onFinish, onStepFinish }) {\n\t\tthis.warningsPromise = new DelayedPromise();\n\t\tthis.usagePromise = new DelayedPromise();\n\t\tthis.finishReasonPromise = new DelayedPromise();\n\t\tthis.providerMetadataPromise = new DelayedPromise();\n\t\tthis.textPromise = new DelayedPromise();\n\t\tthis.reasoningPromise = new DelayedPromise();\n\t\tthis.reasoningDetailsPromise = new DelayedPromise();\n\t\tthis.sourcesPromise = new DelayedPromise();\n\t\tthis.filesPromise = new DelayedPromise();\n\t\tthis.toolCallsPromise = new DelayedPromise();\n\t\tthis.toolResultsPromise = new DelayedPromise();\n\t\tthis.requestPromise = new DelayedPromise();\n\t\tthis.responsePromise = new DelayedPromise();\n\t\tthis.stepsPromise = new DelayedPromise();\n\t\tvar _a17;\n\t\tif (maxSteps < 1) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxSteps\",\n\t\t\tvalue: maxSteps,\n\t\t\tmessage: \"maxSteps must be at least 1\"\n\t\t});\n\t\tthis.output = output;\n\t\tlet recordedStepText = \"\";\n\t\tlet recordedContinuationText = \"\";\n\t\tlet recordedFullText = \"\";\n\t\tlet stepReasoning = [];\n\t\tlet stepFiles = [];\n\t\tlet activeReasoningText = void 0;\n\t\tlet recordedStepSources = [];\n\t\tconst recordedSources = [];\n\t\tconst recordedResponse = {\n\t\t\tid: generateId3(),\n\t\t\ttimestamp: currentDate(),\n\t\t\tmodelId: model.modelId,\n\t\t\tmessages: []\n\t\t};\n\t\tlet recordedToolCalls = [];\n\t\tlet recordedToolResults = [];\n\t\tlet recordedFinishReason = void 0;\n\t\tlet recordedUsage = void 0;\n\t\tlet stepType = \"initial\";\n\t\tconst recordedSteps = [];\n\t\tlet rootSpan;\n\t\tconst eventProcessor = new TransformStream({\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\tconst { part } = chunk;\n\t\t\t\tif (part.type === \"text-delta\" || part.type === \"reasoning\" || part.type === \"source\" || part.type === \"tool-call\" || part.type === \"tool-result\" || part.type === \"tool-call-streaming-start\" || part.type === \"tool-call-delta\") await (onChunk == null ? void 0 : onChunk({ chunk: part }));\n\t\t\t\tif (part.type === \"error\") await (onError == null ? void 0 : onError({ error: part.error }));\n\t\t\t\tif (part.type === \"text-delta\") {\n\t\t\t\t\trecordedStepText += part.textDelta;\n\t\t\t\t\trecordedContinuationText += part.textDelta;\n\t\t\t\t\trecordedFullText += part.textDelta;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning\") {\n\t\t\t\t\tif (activeReasoningText == null) {\n\t\t\t\t\t\tactiveReasoningText = {\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: part.textDelta\n\t\t\t\t\t\t};\n\t\t\t\t\t\tstepReasoning.push(activeReasoningText);\n\t\t\t\t\t} else activeReasoningText.text += part.textDelta;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-signature\") {\n\t\t\t\t\tif (activeReasoningText == null) throw new AISDKError({\n\t\t\t\t\t\tname: \"InvalidStreamPart\",\n\t\t\t\t\t\tmessage: \"reasoning-signature without reasoning\"\n\t\t\t\t\t});\n\t\t\t\t\tactiveReasoningText.signature = part.signature;\n\t\t\t\t\tactiveReasoningText = void 0;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"redacted-reasoning\") stepReasoning.push({\n\t\t\t\t\ttype: \"redacted\",\n\t\t\t\t\tdata: part.data\n\t\t\t\t});\n\t\t\t\tif (part.type === \"file\") stepFiles.push(part);\n\t\t\t\tif (part.type === \"source\") {\n\t\t\t\t\trecordedSources.push(part.source);\n\t\t\t\t\trecordedStepSources.push(part.source);\n\t\t\t\t}\n\t\t\t\tif (part.type === \"tool-call\") recordedToolCalls.push(part);\n\t\t\t\tif (part.type === \"tool-result\") recordedToolResults.push(part);\n\t\t\t\tif (part.type === \"step-finish\") {\n\t\t\t\t\tconst stepMessages = toResponseMessages({\n\t\t\t\t\t\ttext: recordedContinuationText,\n\t\t\t\t\t\tfiles: stepFiles,\n\t\t\t\t\t\treasoning: stepReasoning,\n\t\t\t\t\t\ttools: tools != null ? tools : {},\n\t\t\t\t\t\ttoolCalls: recordedToolCalls,\n\t\t\t\t\t\ttoolResults: recordedToolResults,\n\t\t\t\t\t\tmessageId: part.messageId,\n\t\t\t\t\t\tgenerateMessageId\n\t\t\t\t\t});\n\t\t\t\t\tconst currentStep = recordedSteps.length;\n\t\t\t\t\tlet nextStepType = \"done\";\n\t\t\t\t\tif (currentStep + 1 < maxSteps) {\n\t\t\t\t\t\tif (continueSteps && part.finishReason === \"length\" && recordedToolCalls.length === 0) nextStepType = \"continue\";\n\t\t\t\t\t\telse if (recordedToolCalls.length > 0 && recordedToolResults.length === recordedToolCalls.length) nextStepType = \"tool-result\";\n\t\t\t\t\t}\n\t\t\t\t\tconst currentStepResult = {\n\t\t\t\t\t\tstepType,\n\t\t\t\t\t\ttext: recordedStepText,\n\t\t\t\t\t\treasoning: asReasoningText(stepReasoning),\n\t\t\t\t\t\treasoningDetails: stepReasoning,\n\t\t\t\t\t\tfiles: stepFiles,\n\t\t\t\t\t\tsources: recordedStepSources,\n\t\t\t\t\t\ttoolCalls: recordedToolCalls,\n\t\t\t\t\t\ttoolResults: recordedToolResults,\n\t\t\t\t\t\tfinishReason: part.finishReason,\n\t\t\t\t\t\tusage: part.usage,\n\t\t\t\t\t\twarnings: part.warnings,\n\t\t\t\t\t\tlogprobs: part.logprobs,\n\t\t\t\t\t\trequest: part.request,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t...part.response,\n\t\t\t\t\t\t\tmessages: [...recordedResponse.messages, ...stepMessages]\n\t\t\t\t\t\t},\n\t\t\t\t\t\tproviderMetadata: part.experimental_providerMetadata,\n\t\t\t\t\t\texperimental_providerMetadata: part.experimental_providerMetadata,\n\t\t\t\t\t\tisContinued: part.isContinued\n\t\t\t\t\t};\n\t\t\t\t\tawait (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));\n\t\t\t\t\trecordedSteps.push(currentStepResult);\n\t\t\t\t\trecordedToolCalls = [];\n\t\t\t\t\trecordedToolResults = [];\n\t\t\t\t\trecordedStepText = \"\";\n\t\t\t\t\trecordedStepSources = [];\n\t\t\t\t\tstepReasoning = [];\n\t\t\t\t\tstepFiles = [];\n\t\t\t\t\tactiveReasoningText = void 0;\n\t\t\t\t\tif (nextStepType !== \"done\") stepType = nextStepType;\n\t\t\t\t\tif (nextStepType !== \"continue\") {\n\t\t\t\t\t\trecordedResponse.messages.push(...stepMessages);\n\t\t\t\t\t\trecordedContinuationText = \"\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (part.type === \"finish\") {\n\t\t\t\t\trecordedResponse.id = part.response.id;\n\t\t\t\t\trecordedResponse.timestamp = part.response.timestamp;\n\t\t\t\t\trecordedResponse.modelId = part.response.modelId;\n\t\t\t\t\trecordedResponse.headers = part.response.headers;\n\t\t\t\t\trecordedUsage = part.usage;\n\t\t\t\t\trecordedFinishReason = part.finishReason;\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\tvar _a18;\n\t\t\t\ttry {\n\t\t\t\t\tif (recordedSteps.length === 0) return;\n\t\t\t\t\tconst lastStep = recordedSteps[recordedSteps.length - 1];\n\t\t\t\t\tself.warningsPromise.resolve(lastStep.warnings);\n\t\t\t\t\tself.requestPromise.resolve(lastStep.request);\n\t\t\t\t\tself.responsePromise.resolve(lastStep.response);\n\t\t\t\t\tself.toolCallsPromise.resolve(lastStep.toolCalls);\n\t\t\t\t\tself.toolResultsPromise.resolve(lastStep.toolResults);\n\t\t\t\t\tself.providerMetadataPromise.resolve(lastStep.experimental_providerMetadata);\n\t\t\t\t\tself.reasoningPromise.resolve(lastStep.reasoning);\n\t\t\t\t\tself.reasoningDetailsPromise.resolve(lastStep.reasoningDetails);\n\t\t\t\t\tconst finishReason = recordedFinishReason != null ? recordedFinishReason : \"unknown\";\n\t\t\t\t\tconst usage = recordedUsage != null ? recordedUsage : {\n\t\t\t\t\t\tcompletionTokens: NaN,\n\t\t\t\t\t\tpromptTokens: NaN,\n\t\t\t\t\t\ttotalTokens: NaN\n\t\t\t\t\t};\n\t\t\t\t\tself.finishReasonPromise.resolve(finishReason);\n\t\t\t\t\tself.usagePromise.resolve(usage);\n\t\t\t\t\tself.textPromise.resolve(recordedFullText);\n\t\t\t\t\tself.sourcesPromise.resolve(recordedSources);\n\t\t\t\t\tself.filesPromise.resolve(lastStep.files);\n\t\t\t\t\tself.stepsPromise.resolve(recordedSteps);\n\t\t\t\t\tawait (onFinish == null ? void 0 : onFinish({\n\t\t\t\t\t\tfinishReason,\n\t\t\t\t\t\tlogprobs: void 0,\n\t\t\t\t\t\tusage,\n\t\t\t\t\t\ttext: recordedFullText,\n\t\t\t\t\t\treasoning: lastStep.reasoning,\n\t\t\t\t\t\treasoningDetails: lastStep.reasoningDetails,\n\t\t\t\t\t\tfiles: lastStep.files,\n\t\t\t\t\t\tsources: lastStep.sources,\n\t\t\t\t\t\ttoolCalls: lastStep.toolCalls,\n\t\t\t\t\t\ttoolResults: lastStep.toolResults,\n\t\t\t\t\t\trequest: (_a18 = lastStep.request) != null ? _a18 : {},\n\t\t\t\t\t\tresponse: lastStep.response,\n\t\t\t\t\t\twarnings: lastStep.warnings,\n\t\t\t\t\t\tproviderMetadata: lastStep.providerMetadata,\n\t\t\t\t\t\texperimental_providerMetadata: lastStep.experimental_providerMetadata,\n\t\t\t\t\t\tsteps: recordedSteps\n\t\t\t\t\t}));\n\t\t\t\t\trootSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\t\"ai.response.text\": { output: () => recordedFullText },\n\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\t\tvar _a19;\n\t\t\t\t\t\t\t\treturn ((_a19 = lastStep.toolCalls) == null ? void 0 : _a19.length) ? JSON.stringify(lastStep.toolCalls) : void 0;\n\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\"ai.usage.promptTokens\": usage.promptTokens,\n\t\t\t\t\t\t\t\"ai.usage.completionTokens\": usage.completionTokens,\n\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(lastStep.providerMetadata)\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t} finally {\n\t\t\t\t\trootSpan.end();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tconst stitchableStream = createStitchableStream();\n\t\tthis.addStream = stitchableStream.addStream;\n\t\tthis.closeStream = stitchableStream.close;\n\t\tlet stream = stitchableStream.stream;\n\t\tfor (const transform of transforms) stream = stream.pipeThrough(transform({\n\t\t\ttools,\n\t\t\tstopStream() {\n\t\t\t\tstitchableStream.terminate();\n\t\t\t}\n\t\t}));\n\t\tthis.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);\n\t\tconst { maxRetries, retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\t\tconst tracer = getTracer(telemetry);\n\t\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\t\tmodel,\n\t\t\ttelemetry,\n\t\t\theaders,\n\t\t\tsettings: {\n\t\t\t\t...settings,\n\t\t\t\tmaxRetries\n\t\t\t}\n\t\t});\n\t\tconst initialPrompt = standardizePrompt({\n\t\t\tprompt: {\n\t\t\t\tsystem: (_a17 = output == null ? void 0 : output.injectIntoSystemPrompt({\n\t\t\t\t\tsystem,\n\t\t\t\t\tmodel\n\t\t\t\t})) != null ? _a17 : system,\n\t\t\t\tprompt,\n\t\t\t\tmessages\n\t\t\t},\n\t\t\ttools\n\t\t});\n\t\tconst self = this;\n\t\trecordSpan({\n\t\t\tname: \"ai.streamText\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.streamText\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) },\n\t\t\t\t\t\"ai.settings.maxSteps\": maxSteps\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tendWhenDone: false,\n\t\t\tfn: async (rootSpanArg) => {\n\t\t\t\trootSpan = rootSpanArg;\n\t\t\t\tasync function streamStep({ currentStep, responseMessages, usage, stepType: stepType2, previousStepText, hasLeadingWhitespace, messageId }) {\n\t\t\t\t\tvar _a18;\n\t\t\t\t\tconst promptFormat = responseMessages.length === 0 ? initialPrompt.type : \"messages\";\n\t\t\t\t\tconst stepInputMessages = [...initialPrompt.messages, ...responseMessages];\n\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\ttype: promptFormat,\n\t\t\t\t\t\t\tsystem: initialPrompt.system,\n\t\t\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmodelSupportsImageUrls: model.supportsImageUrls,\n\t\t\t\t\t\tmodelSupportsUrl: (_a18 = model.supportsUrl) == null ? void 0 : _a18.bind(model)\n\t\t\t\t\t});\n\t\t\t\t\tconst mode = {\n\t\t\t\t\t\ttype: \"regular\",\n\t\t\t\t\t\t...prepareToolsAndToolChoice({\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\ttoolChoice,\n\t\t\t\t\t\t\tactiveTools\n\t\t\t\t\t\t})\n\t\t\t\t\t};\n\t\t\t\t\tconst { result: { stream: stream2, warnings, rawResponse, request }, doStreamSpan, startTimestampMs } = await retry(() => recordSpan({\n\t\t\t\t\t\tname: \"ai.streamText.doStream\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.streamText.doStream\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.prompt.format\": { input: () => promptFormat },\n\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\t\"ai.prompt.tools\": { input: () => {\n\t\t\t\t\t\t\t\t\tvar _a19;\n\t\t\t\t\t\t\t\t\treturn (_a19 = mode.tools) == null ? void 0 : _a19.map((tool2) => JSON.stringify(tool2));\n\t\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\t\"ai.prompt.toolChoice\": { input: () => mode.toolChoice != null ? JSON.stringify(mode.toolChoice) : void 0 },\n\t\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": settings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": settings.maxTokens,\n\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": settings.presencePenalty,\n\t\t\t\t\t\t\t\t\"gen_ai.request.stop_sequences\": settings.stopSequences,\n\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": settings.temperature,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": settings.topK,\n\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": settings.topP\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tendWhenDone: false,\n\t\t\t\t\t\tfn: async (doStreamSpan2) => ({\n\t\t\t\t\t\t\tstartTimestampMs: now2(),\n\t\t\t\t\t\t\tdoStreamSpan: doStreamSpan2,\n\t\t\t\t\t\t\tresult: await model.doStream({\n\t\t\t\t\t\t\t\tmode,\n\t\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\t\tinputFormat: promptFormat,\n\t\t\t\t\t\t\t\tresponseFormat: output == null ? void 0 : output.responseFormat({ model }),\n\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\tproviderMetadata: providerOptions,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t})\n\t\t\t\t\t}));\n\t\t\t\t\tconst transformedStream = runToolsTransformation({\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\tgeneratorStream: stream2,\n\t\t\t\t\t\ttoolCallStreaming,\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\tabortSignal\n\t\t\t\t\t});\n\t\t\t\t\tconst stepRequest = request != null ? request : {};\n\t\t\t\t\tconst stepToolCalls = [];\n\t\t\t\t\tconst stepToolResults = [];\n\t\t\t\t\tconst stepReasoning2 = [];\n\t\t\t\t\tconst stepFiles2 = [];\n\t\t\t\t\tlet activeReasoningText2 = void 0;\n\t\t\t\t\tlet stepFinishReason = \"unknown\";\n\t\t\t\t\tlet stepUsage = {\n\t\t\t\t\t\tpromptTokens: 0,\n\t\t\t\t\t\tcompletionTokens: 0,\n\t\t\t\t\t\ttotalTokens: 0\n\t\t\t\t\t};\n\t\t\t\t\tlet stepProviderMetadata;\n\t\t\t\t\tlet stepFirstChunk = true;\n\t\t\t\t\tlet stepText = \"\";\n\t\t\t\t\tlet fullStepText = stepType2 === \"continue\" ? previousStepText : \"\";\n\t\t\t\t\tlet stepLogProbs;\n\t\t\t\t\tlet stepResponse = {\n\t\t\t\t\t\tid: generateId3(),\n\t\t\t\t\t\ttimestamp: currentDate(),\n\t\t\t\t\t\tmodelId: model.modelId\n\t\t\t\t\t};\n\t\t\t\t\tlet chunkBuffer = \"\";\n\t\t\t\t\tlet chunkTextPublished = false;\n\t\t\t\t\tlet inWhitespacePrefix = true;\n\t\t\t\t\tlet hasWhitespaceSuffix = false;\n\t\t\t\t\tasync function publishTextChunk({ controller, chunk }) {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\tstepText += chunk.textDelta;\n\t\t\t\t\t\tfullStepText += chunk.textDelta;\n\t\t\t\t\t\tchunkTextPublished = true;\n\t\t\t\t\t\thasWhitespaceSuffix = chunk.textDelta.trimEnd() !== chunk.textDelta;\n\t\t\t\t\t}\n\t\t\t\t\tself.addStream(transformedStream.pipeThrough(new TransformStream({\n\t\t\t\t\t\tasync transform(chunk, controller) {\n\t\t\t\t\t\t\tvar _a19, _b, _c;\n\t\t\t\t\t\t\tif (stepFirstChunk) {\n\t\t\t\t\t\t\t\tconst msToFirstChunk = now2() - startTimestampMs;\n\t\t\t\t\t\t\t\tstepFirstChunk = false;\n\t\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.firstChunk\", { \"ai.response.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes({ \"ai.response.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"step-start\",\n\t\t\t\t\t\t\t\t\tmessageId,\n\t\t\t\t\t\t\t\t\trequest: stepRequest,\n\t\t\t\t\t\t\t\t\twarnings: warnings != null ? warnings : []\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (chunk.type === \"text-delta\" && chunk.textDelta.length === 0) return;\n\t\t\t\t\t\t\tconst chunkType = chunk.type;\n\t\t\t\t\t\t\tswitch (chunkType) {\n\t\t\t\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\t\t\t\tif (continueSteps) {\n\t\t\t\t\t\t\t\t\t\tconst trimmedChunkText = inWhitespacePrefix && hasLeadingWhitespace ? chunk.textDelta.trimStart() : chunk.textDelta;\n\t\t\t\t\t\t\t\t\t\tif (trimmedChunkText.length === 0) break;\n\t\t\t\t\t\t\t\t\t\tinWhitespacePrefix = false;\n\t\t\t\t\t\t\t\t\t\tchunkBuffer += trimmedChunkText;\n\t\t\t\t\t\t\t\t\t\tconst split = splitOnLastWhitespace(chunkBuffer);\n\t\t\t\t\t\t\t\t\t\tif (split != null) {\n\t\t\t\t\t\t\t\t\t\t\tchunkBuffer = split.suffix;\n\t\t\t\t\t\t\t\t\t\t\tawait publishTextChunk({\n\t\t\t\t\t\t\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\t\t\t\t\t\t\tchunk: {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\t\t\t\ttextDelta: split.prefix + split.whitespace\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else await publishTextChunk({\n\t\t\t\t\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\t\t\t\t\tchunk\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"reasoning\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tif (activeReasoningText2 == null) {\n\t\t\t\t\t\t\t\t\t\tactiveReasoningText2 = {\n\t\t\t\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\t\t\t\ttext: chunk.textDelta\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tstepReasoning2.push(activeReasoningText2);\n\t\t\t\t\t\t\t\t\t} else activeReasoningText2.text += chunk.textDelta;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"reasoning-signature\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tif (activeReasoningText2 == null) throw new InvalidStreamPartError({\n\t\t\t\t\t\t\t\t\t\tchunk,\n\t\t\t\t\t\t\t\t\t\tmessage: \"reasoning-signature without reasoning\"\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tactiveReasoningText2.signature = chunk.signature;\n\t\t\t\t\t\t\t\t\tactiveReasoningText2 = void 0;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"redacted-reasoning\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepReasoning2.push({\n\t\t\t\t\t\t\t\t\t\ttype: \"redacted\",\n\t\t\t\t\t\t\t\t\t\tdata: chunk.data\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-call\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepToolCalls.push(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"tool-result\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepToolResults.push(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\t\tstepResponse = {\n\t\t\t\t\t\t\t\t\t\tid: (_a19 = chunk.id) != null ? _a19 : stepResponse.id,\n\t\t\t\t\t\t\t\t\t\ttimestamp: (_b = chunk.timestamp) != null ? _b : stepResponse.timestamp,\n\t\t\t\t\t\t\t\t\t\tmodelId: (_c = chunk.modelId) != null ? _c : stepResponse.modelId\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"finish\": {\n\t\t\t\t\t\t\t\t\tstepUsage = chunk.usage;\n\t\t\t\t\t\t\t\t\tstepFinishReason = chunk.finishReason;\n\t\t\t\t\t\t\t\t\tstepProviderMetadata = chunk.experimental_providerMetadata;\n\t\t\t\t\t\t\t\t\tstepLogProbs = chunk.logprobs;\n\t\t\t\t\t\t\t\t\tconst msToFinish = now2() - startTimestampMs;\n\t\t\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.finish\");\n\t\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes({\n\t\t\t\t\t\t\t\t\t\t\"ai.response.msToFinish\": msToFinish,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.avgCompletionTokensPerSecond\": 1e3 * stepUsage.completionTokens / msToFinish\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\t\t\t\tstepFiles2.push(chunk);\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"source\":\n\t\t\t\t\t\t\t\tcase \"tool-call-streaming-start\":\n\t\t\t\t\t\t\t\tcase \"tool-call-delta\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\tstepFinishReason = \"error\";\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault: throw new Error(`Unknown chunk type: ${chunkType}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tasync flush(controller) {\n\t\t\t\t\t\t\tconst stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : void 0;\n\t\t\t\t\t\t\tlet nextStepType = \"done\";\n\t\t\t\t\t\t\tif (currentStep + 1 < maxSteps) {\n\t\t\t\t\t\t\t\tif (continueSteps && stepFinishReason === \"length\" && stepToolCalls.length === 0) nextStepType = \"continue\";\n\t\t\t\t\t\t\t\telse if (stepToolCalls.length > 0 && stepToolResults.length === stepToolCalls.length) nextStepType = \"tool-result\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (continueSteps && chunkBuffer.length > 0 && (nextStepType !== \"continue\" || stepType2 === \"continue\" && !chunkTextPublished)) {\n\t\t\t\t\t\t\t\tawait publishTextChunk({\n\t\t\t\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\t\t\t\tchunk: {\n\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\ttextDelta: chunkBuffer\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tchunkBuffer = \"\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes(selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": stepFinishReason,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.text\": { output: () => stepText },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => stepToolCallsJson },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.id\": stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.model\": stepResponse.modelId,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": stepResponse.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(stepProviderMetadata),\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": stepUsage.promptTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": stepUsage.completionTokens,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [stepFinishReason],\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": stepResponse.modelId,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": stepUsage.promptTokens,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": stepUsage.completionTokens\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t} catch (error) {} finally {\n\t\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"step-finish\",\n\t\t\t\t\t\t\t\tfinishReason: stepFinishReason,\n\t\t\t\t\t\t\t\tusage: stepUsage,\n\t\t\t\t\t\t\t\tproviderMetadata: stepProviderMetadata,\n\t\t\t\t\t\t\t\texperimental_providerMetadata: stepProviderMetadata,\n\t\t\t\t\t\t\t\tlogprobs: stepLogProbs,\n\t\t\t\t\t\t\t\trequest: stepRequest,\n\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t...stepResponse,\n\t\t\t\t\t\t\t\t\theaders: rawResponse == null ? void 0 : rawResponse.headers\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twarnings,\n\t\t\t\t\t\t\t\tisContinued: nextStepType === \"continue\",\n\t\t\t\t\t\t\t\tmessageId\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst combinedUsage = addLanguageModelUsage(usage, stepUsage);\n\t\t\t\t\t\t\tif (nextStepType === \"done\") {\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\t\t\t\tfinishReason: stepFinishReason,\n\t\t\t\t\t\t\t\t\tusage: combinedUsage,\n\t\t\t\t\t\t\t\t\tproviderMetadata: stepProviderMetadata,\n\t\t\t\t\t\t\t\t\texperimental_providerMetadata: stepProviderMetadata,\n\t\t\t\t\t\t\t\t\tlogprobs: stepLogProbs,\n\t\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t\t...stepResponse,\n\t\t\t\t\t\t\t\t\t\theaders: rawResponse == null ? void 0 : rawResponse.headers\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tself.closeStream();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (stepType2 === \"continue\") {\n\t\t\t\t\t\t\t\t\tconst lastMessage = responseMessages[responseMessages.length - 1];\n\t\t\t\t\t\t\t\t\tif (typeof lastMessage.content === \"string\") lastMessage.content += stepText;\n\t\t\t\t\t\t\t\t\telse lastMessage.content.push({\n\t\t\t\t\t\t\t\t\t\ttext: stepText,\n\t\t\t\t\t\t\t\t\t\ttype: \"text\"\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} else responseMessages.push(...toResponseMessages({\n\t\t\t\t\t\t\t\t\ttext: stepText,\n\t\t\t\t\t\t\t\t\tfiles: stepFiles2,\n\t\t\t\t\t\t\t\t\treasoning: stepReasoning2,\n\t\t\t\t\t\t\t\t\ttools: tools != null ? tools : {},\n\t\t\t\t\t\t\t\t\ttoolCalls: stepToolCalls,\n\t\t\t\t\t\t\t\t\ttoolResults: stepToolResults,\n\t\t\t\t\t\t\t\t\tmessageId,\n\t\t\t\t\t\t\t\t\tgenerateMessageId\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tawait streamStep({\n\t\t\t\t\t\t\t\t\tcurrentStep: currentStep + 1,\n\t\t\t\t\t\t\t\t\tresponseMessages,\n\t\t\t\t\t\t\t\t\tusage: combinedUsage,\n\t\t\t\t\t\t\t\t\tstepType: nextStepType,\n\t\t\t\t\t\t\t\t\tpreviousStepText: fullStepText,\n\t\t\t\t\t\t\t\t\thasLeadingWhitespace: hasWhitespaceSuffix,\n\t\t\t\t\t\t\t\t\tmessageId: nextStepType === \"continue\" ? messageId : generateMessageId()\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})));\n\t\t\t\t}\n\t\t\t\tawait streamStep({\n\t\t\t\t\tcurrentStep: 0,\n\t\t\t\t\tresponseMessages: [],\n\t\t\t\t\tusage: {\n\t\t\t\t\t\tpromptTokens: 0,\n\t\t\t\t\t\tcompletionTokens: 0,\n\t\t\t\t\t\ttotalTokens: 0\n\t\t\t\t\t},\n\t\t\t\t\tpreviousStepText: \"\",\n\t\t\t\t\tstepType: \"initial\",\n\t\t\t\t\thasLeadingWhitespace: false,\n\t\t\t\t\tmessageId: generateMessageId()\n\t\t\t\t});\n\t\t\t}\n\t\t}).catch((error) => {\n\t\t\tself.addStream(new ReadableStream({ start(controller) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t\tcontroller.close();\n\t\t\t} }));\n\t\t\tself.closeStream();\n\t\t});\n\t}\n\tget warnings() {\n\t\treturn this.warningsPromise.value;\n\t}\n\tget usage() {\n\t\treturn this.usagePromise.value;\n\t}\n\tget finishReason() {\n\t\treturn this.finishReasonPromise.value;\n\t}\n\tget experimental_providerMetadata() {\n\t\treturn this.providerMetadataPromise.value;\n\t}\n\tget providerMetadata() {\n\t\treturn this.providerMetadataPromise.value;\n\t}\n\tget text() {\n\t\treturn this.textPromise.value;\n\t}\n\tget reasoning() {\n\t\treturn this.reasoningPromise.value;\n\t}\n\tget reasoningDetails() {\n\t\treturn this.reasoningDetailsPromise.value;\n\t}\n\tget sources() {\n\t\treturn this.sourcesPromise.value;\n\t}\n\tget files() {\n\t\treturn this.filesPromise.value;\n\t}\n\tget toolCalls() {\n\t\treturn this.toolCallsPromise.value;\n\t}\n\tget toolResults() {\n\t\treturn this.toolResultsPromise.value;\n\t}\n\tget request() {\n\t\treturn this.requestPromise.value;\n\t}\n\tget response() {\n\t\treturn this.responsePromise.value;\n\t}\n\tget steps() {\n\t\treturn this.stepsPromise.value;\n\t}\n\t/**\n\tSplit out a new stream from the original stream.\n\tThe original stream is replaced to allow for further splitting,\n\tsince we do not know how many times the stream will be split.\n\t\n\tNote: this leads to buffering the stream content on the server.\n\tHowever, the LLM results are expected to be small enough to not cause issues.\n\t*/\n\tteeStream() {\n\t\tconst [stream1, stream2] = this.baseStream.tee();\n\t\tthis.baseStream = stream2;\n\t\treturn stream1;\n\t}\n\tget textStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ part }, controller) {\n\t\t\tif (part.type === \"text-delta\") controller.enqueue(part.textDelta);\n\t\t} })));\n\t}\n\tget fullStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ part }, controller) {\n\t\t\tcontroller.enqueue(part);\n\t\t} })));\n\t}\n\tasync consumeStream(options) {\n\t\tvar _a17;\n\t\ttry {\n\t\t\tawait consumeStream({\n\t\t\t\tstream: this.fullStream,\n\t\t\t\tonError: options == null ? void 0 : options.onError\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t(_a17 = options == null ? void 0 : options.onError) == null || _a17.call(options, error);\n\t\t}\n\t}\n\tget experimental_partialOutputStream() {\n\t\tif (this.output == null) throw new NoOutputSpecifiedError();\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ partialOutput }, controller) {\n\t\t\tif (partialOutput != null) controller.enqueue(partialOutput);\n\t\t} })));\n\t}\n\ttoDataStreamInternal({ getErrorMessage: getErrorMessage5 = () => \"An error occurred.\", sendUsage = true, sendReasoning = false, sendSources = false, experimental_sendFinish = true }) {\n\t\treturn this.fullStream.pipeThrough(new TransformStream({ transform: async (chunk, controller) => {\n\t\t\tconst chunkType = chunk.type;\n\t\t\tswitch (chunkType) {\n\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"text\", chunk.textDelta));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reasoning\":\n\t\t\t\t\tif (sendReasoning) controller.enqueue(formatDataStreamPart(\"reasoning\", chunk.textDelta));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"redacted-reasoning\":\n\t\t\t\t\tif (sendReasoning) controller.enqueue(formatDataStreamPart(\"redacted_reasoning\", { data: chunk.data }));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"reasoning-signature\":\n\t\t\t\t\tif (sendReasoning) controller.enqueue(formatDataStreamPart(\"reasoning_signature\", { signature: chunk.signature }));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"file\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"file\", {\n\t\t\t\t\t\tmimeType: chunk.mimeType,\n\t\t\t\t\t\tdata: chunk.base64\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"source\":\n\t\t\t\t\tif (sendSources) controller.enqueue(formatDataStreamPart(\"source\", chunk.source));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call-streaming-start\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"tool_call_streaming_start\", {\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call-delta\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"tool_call_delta\", {\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\targsTextDelta: chunk.argsTextDelta\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-call\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"tool_call\", {\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\targs: chunk.args\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-result\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"tool_result\", {\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\tresult: chunk.result\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"error\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"error\", getErrorMessage5(chunk.error)));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"step-start\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"start_step\", { messageId: chunk.messageId }));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"step-finish\":\n\t\t\t\t\tcontroller.enqueue(formatDataStreamPart(\"finish_step\", {\n\t\t\t\t\t\tfinishReason: chunk.finishReason,\n\t\t\t\t\t\tusage: sendUsage ? {\n\t\t\t\t\t\t\tpromptTokens: chunk.usage.promptTokens,\n\t\t\t\t\t\t\tcompletionTokens: chunk.usage.completionTokens\n\t\t\t\t\t\t} : void 0,\n\t\t\t\t\t\tisContinued: chunk.isContinued\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tif (experimental_sendFinish) controller.enqueue(formatDataStreamPart(\"finish_message\", {\n\t\t\t\t\t\tfinishReason: chunk.finishReason,\n\t\t\t\t\t\tusage: sendUsage ? {\n\t\t\t\t\t\t\tpromptTokens: chunk.usage.promptTokens,\n\t\t\t\t\t\t\tcompletionTokens: chunk.usage.completionTokens\n\t\t\t\t\t\t} : void 0\n\t\t\t\t\t}));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: throw new Error(`Unknown chunk type: ${chunkType}`);\n\t\t\t}\n\t\t} }));\n\t}\n\tpipeDataStreamToResponse(response, { status, statusText, headers, data, getErrorMessage: getErrorMessage5, sendUsage, sendReasoning, sendSources, experimental_sendFinish } = {}) {\n\t\twriteToServerResponse({\n\t\t\tresponse,\n\t\t\tstatus,\n\t\t\tstatusText,\n\t\t\theaders: prepareOutgoingHttpHeaders(headers, {\n\t\t\t\tcontentType: \"text/plain; charset=utf-8\",\n\t\t\t\tdataStreamVersion: \"v1\"\n\t\t\t}),\n\t\t\tstream: this.toDataStream({\n\t\t\t\tdata,\n\t\t\t\tgetErrorMessage: getErrorMessage5,\n\t\t\t\tsendUsage,\n\t\t\t\tsendReasoning,\n\t\t\t\tsendSources,\n\t\t\t\texperimental_sendFinish\n\t\t\t})\n\t\t});\n\t}\n\tpipeTextStreamToResponse(response, init) {\n\t\twriteToServerResponse({\n\t\t\tresponse,\n\t\t\tstatus: init == null ? void 0 : init.status,\n\t\t\tstatusText: init == null ? void 0 : init.statusText,\n\t\t\theaders: prepareOutgoingHttpHeaders(init == null ? void 0 : init.headers, { contentType: \"text/plain; charset=utf-8\" }),\n\t\t\tstream: this.textStream.pipeThrough(new TextEncoderStream())\n\t\t});\n\t}\n\ttoDataStream(options) {\n\t\tconst stream = this.toDataStreamInternal({\n\t\t\tgetErrorMessage: options == null ? void 0 : options.getErrorMessage,\n\t\t\tsendUsage: options == null ? void 0 : options.sendUsage,\n\t\t\tsendReasoning: options == null ? void 0 : options.sendReasoning,\n\t\t\tsendSources: options == null ? void 0 : options.sendSources,\n\t\t\texperimental_sendFinish: options == null ? void 0 : options.experimental_sendFinish\n\t\t}).pipeThrough(new TextEncoderStream());\n\t\treturn (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;\n\t}\n\tmergeIntoDataStream(writer, options) {\n\t\twriter.merge(this.toDataStreamInternal({\n\t\t\tgetErrorMessage: writer.onError,\n\t\t\tsendUsage: options == null ? void 0 : options.sendUsage,\n\t\t\tsendReasoning: options == null ? void 0 : options.sendReasoning,\n\t\t\tsendSources: options == null ? void 0 : options.sendSources,\n\t\t\texperimental_sendFinish: options == null ? void 0 : options.experimental_sendFinish\n\t\t}));\n\t}\n\ttoDataStreamResponse({ headers, status, statusText, data, getErrorMessage: getErrorMessage5, sendUsage, sendReasoning, sendSources, experimental_sendFinish } = {}) {\n\t\treturn new Response(this.toDataStream({\n\t\t\tdata,\n\t\t\tgetErrorMessage: getErrorMessage5,\n\t\t\tsendUsage,\n\t\t\tsendReasoning,\n\t\t\tsendSources,\n\t\t\texperimental_sendFinish\n\t\t}), {\n\t\t\tstatus,\n\t\t\tstatusText,\n\t\t\theaders: prepareResponseHeaders(headers, {\n\t\t\t\tcontentType: \"text/plain; charset=utf-8\",\n\t\t\t\tdataStreamVersion: \"v1\"\n\t\t\t})\n\t\t});\n\t}\n\ttoTextStreamResponse(init) {\n\t\tvar _a17;\n\t\treturn new Response(this.textStream.pipeThrough(new TextEncoderStream()), {\n\t\t\tstatus: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,\n\t\t\theaders: prepareResponseHeaders(init == null ? void 0 : init.headers, { contentType: \"text/plain; charset=utf-8\" })\n\t\t});\n\t}\n};\nvar NoSpeechGeneratedError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: \"AI_NoSpeechGeneratedError\",\n\t\t\tmessage: \"No speech audio generated.\"\n\t\t});\n\t\tthis.responses = options.responses;\n\t}\n};\nvar DefaultGeneratedAudioFile = class extends DefaultGeneratedFile {\n\tconstructor({ data, mimeType }) {\n\t\tsuper({\n\t\t\tdata,\n\t\t\tmimeType\n\t\t});\n\t\tlet format = \"mp3\";\n\t\tif (mimeType) {\n\t\t\tconst mimeTypeParts = mimeType.split(\"/\");\n\t\t\tif (mimeTypeParts.length === 2) {\n\t\t\t\tif (mimeType !== \"audio/mpeg\") format = mimeTypeParts[1];\n\t\t\t}\n\t\t}\n\t\tif (!format) throw new Error(\"Audio format must be provided or determinable from mimeType\");\n\t\tthis.format = format;\n\t}\n};\nasync function generateSpeech({ model, text: text2, voice, outputFormat, instructions, speed, providerOptions = {}, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tvar _a17;\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tconst { retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst result = await retry(() => model.doGenerate({\n\t\ttext: text2,\n\t\tvoice,\n\t\toutputFormat,\n\t\tinstructions,\n\t\tspeed,\n\t\tabortSignal,\n\t\theaders,\n\t\tproviderOptions\n\t}));\n\tif (!result.audio || result.audio.length === 0) throw new NoSpeechGeneratedError({ responses: [result.response] });\n\treturn new DefaultSpeechResult({\n\t\taudio: new DefaultGeneratedAudioFile({\n\t\t\tdata: result.audio,\n\t\t\tmimeType: (_a17 = detectMimeType({\n\t\t\t\tdata: result.audio,\n\t\t\t\tsignatures: audioMimeTypeSignatures\n\t\t\t})) != null ? _a17 : \"audio/mp3\"\n\t\t}),\n\t\twarnings: result.warnings,\n\t\tresponses: [result.response],\n\t\tproviderMetadata: result.providerMetadata\n\t});\n}\nvar DefaultSpeechResult = class {\n\tconstructor(options) {\n\t\tvar _a17;\n\t\tthis.audio = options.audio;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = (_a17 = options.providerMetadata) != null ? _a17 : {};\n\t}\n};\nvar NoTranscriptGeneratedError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: \"AI_NoTranscriptGeneratedError\",\n\t\t\tmessage: \"No transcript generated.\"\n\t\t});\n\t\tthis.responses = options.responses;\n\t}\n};\nasync function transcribe({ model, audio, providerOptions = {}, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tif (typeof model === \"string\" || model.specificationVersion !== \"v1\") throw new UnsupportedModelVersionError();\n\tconst { retry } = prepareRetries({ maxRetries: maxRetriesArg });\n\tconst audioData = audio instanceof URL ? (await download({ url: audio })).data : convertDataContentToUint8Array(audio);\n\tconst result = await retry(() => {\n\t\tvar _a17;\n\t\treturn model.doGenerate({\n\t\t\taudio: audioData,\n\t\t\tabortSignal,\n\t\t\theaders,\n\t\t\tproviderOptions,\n\t\t\tmediaType: (_a17 = detectMimeType({\n\t\t\t\tdata: audioData,\n\t\t\t\tsignatures: audioMimeTypeSignatures\n\t\t\t})) != null ? _a17 : \"audio/wav\"\n\t\t});\n\t});\n\tif (!result.text) throw new NoTranscriptGeneratedError({ responses: [result.response] });\n\treturn new DefaultTranscriptionResult({\n\t\ttext: result.text,\n\t\tsegments: result.segments,\n\t\tlanguage: result.language,\n\t\tdurationInSeconds: result.durationInSeconds,\n\t\twarnings: result.warnings,\n\t\tresponses: [result.response],\n\t\tproviderMetadata: result.providerMetadata\n\t});\n}\nvar DefaultTranscriptionResult = class {\n\tconstructor(options) {\n\t\tvar _a17;\n\t\tthis.text = options.text;\n\t\tthis.segments = options.segments;\n\t\tthis.language = options.language;\n\t\tthis.durationInSeconds = options.durationInSeconds;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = (_a17 = options.providerMetadata) != null ? _a17 : {};\n\t}\n};\nfunction mergeObjects(target, source) {\n\tif (target === void 0 && source === void 0) return;\n\tif (target === void 0) return source;\n\tif (source === void 0) return target;\n\tconst result = { ...target };\n\tfor (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) {\n\t\tconst sourceValue = source[key];\n\t\tif (sourceValue === void 0) continue;\n\t\tconst targetValue = key in target ? target[key] : void 0;\n\t\tconst isSourceObject = sourceValue !== null && typeof sourceValue === \"object\" && !Array.isArray(sourceValue) && !(sourceValue instanceof Date) && !(sourceValue instanceof RegExp);\n\t\tconst isTargetObject = targetValue !== null && targetValue !== void 0 && typeof targetValue === \"object\" && !Array.isArray(targetValue) && !(targetValue instanceof Date) && !(targetValue instanceof RegExp);\n\t\tif (isSourceObject && isTargetObject) result[key] = mergeObjects(targetValue, sourceValue);\n\t\telse result[key] = sourceValue;\n\t}\n\treturn result;\n}\nfunction defaultSettingsMiddleware({ settings }) {\n\treturn {\n\t\tmiddlewareVersion: \"v1\",\n\t\ttransformParams: async ({ params }) => {\n\t\t\tvar _a17;\n\t\t\treturn {\n\t\t\t\t...settings,\n\t\t\t\t...params,\n\t\t\t\tproviderMetadata: mergeObjects(settings.providerMetadata, params.providerMetadata),\n\t\t\t\ttemperature: params.temperature === 0 || params.temperature == null ? (_a17 = settings.temperature) != null ? _a17 : 0 : params.temperature\n\t\t\t};\n\t\t}\n\t};\n}\nfunction getPotentialStartIndex(text2, searchedText) {\n\tif (searchedText.length === 0) return null;\n\tconst directIndex = text2.indexOf(searchedText);\n\tif (directIndex !== -1) return directIndex;\n\tfor (let i = text2.length - 1; i >= 0; i--) {\n\t\tconst suffix = text2.substring(i);\n\t\tif (searchedText.startsWith(suffix)) return i;\n\t}\n\treturn null;\n}\nfunction extractReasoningMiddleware({ tagName, separator = \"\\n\", startWithReasoning = false }) {\n\tconst openingTag = `<${tagName}>`;\n\tconst closingTag = `</${tagName}>`;\n\treturn {\n\t\tmiddlewareVersion: \"v1\",\n\t\twrapGenerate: async ({ doGenerate }) => {\n\t\t\tconst { text: rawText, ...rest } = await doGenerate();\n\t\t\tif (rawText == null) return {\n\t\t\t\ttext: rawText,\n\t\t\t\t...rest\n\t\t\t};\n\t\t\tconst text2 = startWithReasoning ? openingTag + rawText : rawText;\n\t\t\tconst regexp = new RegExp(`${openingTag}(.*?)${closingTag}`, \"gs\");\n\t\t\tconst matches = Array.from(text2.matchAll(regexp));\n\t\t\tif (!matches.length) return {\n\t\t\t\ttext: text2,\n\t\t\t\t...rest\n\t\t\t};\n\t\t\tconst reasoning = matches.map((match) => match[1]).join(separator);\n\t\t\tlet textWithoutReasoning = text2;\n\t\t\tfor (let i = matches.length - 1; i >= 0; i--) {\n\t\t\t\tconst match = matches[i];\n\t\t\t\tconst beforeMatch = textWithoutReasoning.slice(0, match.index);\n\t\t\t\tconst afterMatch = textWithoutReasoning.slice(match.index + match[0].length);\n\t\t\t\ttextWithoutReasoning = beforeMatch + (beforeMatch.length > 0 && afterMatch.length > 0 ? separator : \"\") + afterMatch;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...rest,\n\t\t\t\ttext: textWithoutReasoning,\n\t\t\t\treasoning\n\t\t\t};\n\t\t},\n\t\twrapStream: async ({ doStream }) => {\n\t\t\tconst { stream, ...rest } = await doStream();\n\t\t\tlet isFirstReasoning = true;\n\t\t\tlet isFirstText = true;\n\t\t\tlet afterSwitch = false;\n\t\t\tlet isReasoning = startWithReasoning;\n\t\t\tlet buffer = \"\";\n\t\t\treturn {\n\t\t\t\tstream: stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {\n\t\t\t\t\tif (chunk.type !== \"text-delta\") {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tbuffer += chunk.textDelta;\n\t\t\t\t\tfunction publish(text2) {\n\t\t\t\t\t\tif (text2.length > 0) {\n\t\t\t\t\t\t\tconst prefix = afterSwitch && (isReasoning ? !isFirstReasoning : !isFirstText) ? separator : \"\";\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: isReasoning ? \"reasoning\" : \"text-delta\",\n\t\t\t\t\t\t\t\ttextDelta: prefix + text2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tafterSwitch = false;\n\t\t\t\t\t\t\tif (isReasoning) isFirstReasoning = false;\n\t\t\t\t\t\t\telse isFirstText = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst nextTag = isReasoning ? closingTag : openingTag;\n\t\t\t\t\t\tconst startIndex = getPotentialStartIndex(buffer, nextTag);\n\t\t\t\t\t\tif (startIndex == null) {\n\t\t\t\t\t\t\tpublish(buffer);\n\t\t\t\t\t\t\tbuffer = \"\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpublish(buffer.slice(0, startIndex));\n\t\t\t\t\t\tif (startIndex + nextTag.length <= buffer.length) {\n\t\t\t\t\t\t\tbuffer = buffer.slice(startIndex + nextTag.length);\n\t\t\t\t\t\t\tisReasoning = !isReasoning;\n\t\t\t\t\t\t\tafterSwitch = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbuffer = buffer.slice(startIndex);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} while (true);\n\t\t\t\t} })),\n\t\t\t\t...rest\n\t\t\t};\n\t\t}\n\t};\n}\nfunction simulateStreamingMiddleware() {\n\treturn {\n\t\tmiddlewareVersion: \"v1\",\n\t\twrapStream: async ({ doGenerate }) => {\n\t\t\tconst result = await doGenerate();\n\t\t\treturn {\n\t\t\t\tstream: new ReadableStream({ start(controller) {\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"response-metadata\",\n\t\t\t\t\t\t...result.response\n\t\t\t\t\t});\n\t\t\t\t\tif (result.reasoning) {\n\t\t\t\t\t\tif (typeof result.reasoning === \"string\") controller.enqueue({\n\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\ttextDelta: result.reasoning\n\t\t\t\t\t\t});\n\t\t\t\t\t\telse for (const reasoning of result.reasoning) switch (reasoning.type) {\n\t\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\t\t\ttextDelta: reasoning.text\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (reasoning.signature != null) controller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"reasoning-signature\",\n\t\t\t\t\t\t\t\t\tsignature: reasoning.signature\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"redacted\": controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"redacted-reasoning\",\n\t\t\t\t\t\t\t\tdata: reasoning.data\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (result.text) controller.enqueue({\n\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\ttextDelta: result.text\n\t\t\t\t\t});\n\t\t\t\t\tif (result.toolCalls) for (const toolCall of result.toolCalls) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-call-delta\",\n\t\t\t\t\t\t\ttoolCallType: \"function\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\targsTextDelta: toolCall.args\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\t...toolCall\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: result.finishReason,\n\t\t\t\t\t\tusage: result.usage,\n\t\t\t\t\t\tlogprobs: result.logprobs,\n\t\t\t\t\t\tproviderMetadata: result.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} }),\n\t\t\t\trawCall: result.rawCall,\n\t\t\t\trawResponse: result.rawResponse,\n\t\t\t\twarnings: result.warnings\n\t\t\t};\n\t\t}\n\t};\n}\nvar wrapLanguageModel = ({ model, middleware: middlewareArg, modelId, providerId }) => {\n\treturn asArray(middlewareArg).reverse().reduce((wrappedModel, middleware) => {\n\t\treturn doWrap({\n\t\t\tmodel: wrappedModel,\n\t\t\tmiddleware,\n\t\t\tmodelId,\n\t\t\tproviderId\n\t\t});\n\t}, model);\n};\nvar doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream }, modelId, providerId }) => {\n\tvar _a17;\n\tasync function doTransform({ params, type }) {\n\t\treturn transformParams ? await transformParams({\n\t\t\tparams,\n\t\t\ttype\n\t\t}) : params;\n\t}\n\treturn {\n\t\tspecificationVersion: \"v1\",\n\t\tprovider: providerId != null ? providerId : model.provider,\n\t\tmodelId: modelId != null ? modelId : model.modelId,\n\t\tdefaultObjectGenerationMode: model.defaultObjectGenerationMode,\n\t\tsupportsImageUrls: model.supportsImageUrls,\n\t\tsupportsUrl: (_a17 = model.supportsUrl) == null ? void 0 : _a17.bind(model),\n\t\tsupportsStructuredOutputs: model.supportsStructuredOutputs,\n\t\tasync doGenerate(params) {\n\t\t\tconst transformedParams = await doTransform({\n\t\t\t\tparams,\n\t\t\t\ttype: \"generate\"\n\t\t\t});\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\tconst doStream = async () => model.doStream(transformedParams);\n\t\t\treturn wrapGenerate ? wrapGenerate({\n\t\t\t\tdoGenerate,\n\t\t\t\tdoStream,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doGenerate();\n\t\t},\n\t\tasync doStream(params) {\n\t\t\tconst transformedParams = await doTransform({\n\t\t\t\tparams,\n\t\t\t\ttype: \"stream\"\n\t\t\t});\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\tconst doStream = async () => model.doStream(transformedParams);\n\t\t\treturn wrapStream ? wrapStream({\n\t\t\t\tdoGenerate,\n\t\t\t\tdoStream,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doStream();\n\t\t}\n\t};\n};\nvar experimental_wrapLanguageModel = wrapLanguageModel;\nfunction appendClientMessage({ messages, message }) {\n\treturn [...messages.length > 0 && messages[messages.length - 1].id === message.id ? messages.slice(0, -1) : messages, message];\n}\nfunction appendResponseMessages({ messages, responseMessages, _internal: { currentDate = () => /* @__PURE__ */ new Date() } = {} }) {\n\tvar _b;\n\tconst clonedMessages = structuredClone(messages);\n\tfor (const message of responseMessages) {\n\t\tconst role = message.role;\n\t\tconst lastMessage = clonedMessages[clonedMessages.length - 1];\n\t\tconst isLastMessageAssistant = lastMessage.role === \"assistant\";\n\t\tswitch (role) {\n\t\t\tcase \"assistant\": {\n\t\t\t\tlet getToolInvocations2 = function(step) {\n\t\t\t\t\treturn (typeof message.content === \"string\" ? [] : message.content.filter((part) => part.type === \"tool-call\")).map((call) => ({\n\t\t\t\t\t\tstate: \"call\",\n\t\t\t\t\t\tstep,\n\t\t\t\t\t\targs: call.args,\n\t\t\t\t\t\ttoolCallId: call.toolCallId,\n\t\t\t\t\t\ttoolName: call.toolName\n\t\t\t\t\t}));\n\t\t\t\t};\n\t\t\t\tconst parts = [{ type: \"step-start\" }];\n\t\t\t\tlet textContent = \"\";\n\t\t\t\tlet reasoningTextContent = void 0;\n\t\t\t\tif (typeof message.content === \"string\") {\n\t\t\t\t\ttextContent = message.content;\n\t\t\t\t\tparts.push({\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: message.content\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tlet reasoningPart = void 0;\n\t\t\t\t\tfor (const part of message.content) switch (part.type) {\n\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\treasoningPart = void 0;\n\t\t\t\t\t\t\ttextContent += part.text;\n\t\t\t\t\t\t\tparts.push({\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: part.text\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"reasoning\":\n\t\t\t\t\t\t\tif (reasoningPart == null) {\n\t\t\t\t\t\t\t\treasoningPart = {\n\t\t\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\t\t\treasoning: \"\",\n\t\t\t\t\t\t\t\t\tdetails: []\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tparts.push(reasoningPart);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treasoningTextContent = (reasoningTextContent != null ? reasoningTextContent : \"\") + part.text;\n\t\t\t\t\t\t\treasoningPart.reasoning += part.text;\n\t\t\t\t\t\t\treasoningPart.details.push({\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\t\tsignature: part.signature\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"redacted-reasoning\":\n\t\t\t\t\t\t\tif (reasoningPart == null) {\n\t\t\t\t\t\t\t\treasoningPart = {\n\t\t\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\t\t\treasoning: \"\",\n\t\t\t\t\t\t\t\t\tdetails: []\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tparts.push(reasoningPart);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treasoningPart.details.push({\n\t\t\t\t\t\t\t\ttype: \"redacted\",\n\t\t\t\t\t\t\t\tdata: part.data\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"tool-call\": break;\n\t\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\t\tif (part.data instanceof URL) throw new AISDKError({\n\t\t\t\t\t\t\t\tname: \"InvalidAssistantFileData\",\n\t\t\t\t\t\t\t\tmessage: \"File data cannot be a URL\"\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tparts.push({\n\t\t\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\t\t\tmimeType: part.mimeType,\n\t\t\t\t\t\t\t\tdata: convertDataContentToBase64String(part.data)\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isLastMessageAssistant) {\n\t\t\t\t\tconst maxStep = extractMaxToolInvocationStep(lastMessage.toolInvocations);\n\t\t\t\t\tlastMessage.parts ??= [];\n\t\t\t\t\tlastMessage.content = textContent;\n\t\t\t\t\tlastMessage.reasoning = reasoningTextContent;\n\t\t\t\t\tlastMessage.parts.push(...parts);\n\t\t\t\t\tlastMessage.toolInvocations = [...(_b = lastMessage.toolInvocations) != null ? _b : [], ...getToolInvocations2(maxStep === void 0 ? 0 : maxStep + 1)];\n\t\t\t\t\tgetToolInvocations2(maxStep === void 0 ? 0 : maxStep + 1).map((call) => ({\n\t\t\t\t\t\ttype: \"tool-invocation\",\n\t\t\t\t\t\ttoolInvocation: call\n\t\t\t\t\t})).forEach((part) => {\n\t\t\t\t\t\tlastMessage.parts.push(part);\n\t\t\t\t\t});\n\t\t\t\t} else clonedMessages.push({\n\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\tid: message.id,\n\t\t\t\t\tcreatedAt: currentDate(),\n\t\t\t\t\tcontent: textContent,\n\t\t\t\t\treasoning: reasoningTextContent,\n\t\t\t\t\ttoolInvocations: getToolInvocations2(0),\n\t\t\t\t\tparts: [...parts, ...getToolInvocations2(0).map((call) => ({\n\t\t\t\t\t\ttype: \"tool-invocation\",\n\t\t\t\t\t\ttoolInvocation: call\n\t\t\t\t\t}))]\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool\":\n\t\t\t\tlastMessage.toolInvocations ??= [];\n\t\t\t\tif (lastMessage.role !== \"assistant\") throw new Error(`Tool result must follow an assistant message: ${lastMessage.role}`);\n\t\t\t\tlastMessage.parts ??= [];\n\t\t\t\tfor (const contentPart of message.content) {\n\t\t\t\t\tconst toolCall = lastMessage.toolInvocations.find((call) => call.toolCallId === contentPart.toolCallId);\n\t\t\t\t\tconst toolCallPart = lastMessage.parts.find((part) => part.type === \"tool-invocation\" && part.toolInvocation.toolCallId === contentPart.toolCallId);\n\t\t\t\t\tif (!toolCall) throw new Error(\"Tool call not found in previous message\");\n\t\t\t\t\ttoolCall.state = \"result\";\n\t\t\t\t\tconst toolResult = toolCall;\n\t\t\t\t\ttoolResult.result = contentPart.result;\n\t\t\t\t\tif (toolCallPart) toolCallPart.toolInvocation = toolResult;\n\t\t\t\t\telse lastMessage.parts.push({\n\t\t\t\t\t\ttype: \"tool-invocation\",\n\t\t\t\t\t\ttoolInvocation: toolResult\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault: throw new Error(`Unsupported message role: ${role}`);\n\t\t}\n\t}\n\treturn clonedMessages;\n}\nfunction customProvider({ languageModels, textEmbeddingModels, imageModels, fallbackProvider }) {\n\treturn {\n\t\tlanguageModel(modelId) {\n\t\t\tif (languageModels != null && modelId in languageModels) return languageModels[modelId];\n\t\t\tif (fallbackProvider) return fallbackProvider.languageModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"languageModel\"\n\t\t\t});\n\t\t},\n\t\ttextEmbeddingModel(modelId) {\n\t\t\tif (textEmbeddingModels != null && modelId in textEmbeddingModels) return textEmbeddingModels[modelId];\n\t\t\tif (fallbackProvider) return fallbackProvider.textEmbeddingModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"textEmbeddingModel\"\n\t\t\t});\n\t\t},\n\t\timageModel(modelId) {\n\t\t\tif (imageModels != null && modelId in imageModels) return imageModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.imageModel) return fallbackProvider.imageModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"imageModel\"\n\t\t\t});\n\t\t}\n\t};\n}\nvar experimental_customProvider = customProvider;\nvar name16 = \"AI_NoSuchProviderError\";\nvar marker16 = `vercel.ai.error.${name16}`;\nvar symbol16 = Symbol.for(marker16);\nvar _a16;\nvar NoSuchProviderError = class extends NoSuchModelError {\n\tconstructor({ modelId, modelType, providerId, availableProviders, message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})` }) {\n\t\tsuper({\n\t\t\terrorName: name16,\n\t\t\tmodelId,\n\t\t\tmodelType,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a16] = true;\n\t\tthis.providerId = providerId;\n\t\tthis.availableProviders = availableProviders;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker16);\n\t}\n};\n_a16 = symbol16;\nfunction createProviderRegistry(providers, { separator = \":\" } = {}) {\n\tconst registry = new DefaultProviderRegistry({ separator });\n\tfor (const [id, provider] of Object.entries(providers)) registry.registerProvider({\n\t\tid,\n\t\tprovider\n\t});\n\treturn registry;\n}\nvar experimental_createProviderRegistry = createProviderRegistry;\nvar DefaultProviderRegistry = class {\n\tconstructor({ separator }) {\n\t\tthis.providers = {};\n\t\tthis.separator = separator;\n\t}\n\tregisterProvider({ id, provider }) {\n\t\tthis.providers[id] = provider;\n\t}\n\tgetProvider(id) {\n\t\tconst provider = this.providers[id];\n\t\tif (provider == null) throw new NoSuchProviderError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"languageModel\",\n\t\t\tproviderId: id,\n\t\t\tavailableProviders: Object.keys(this.providers)\n\t\t});\n\t\treturn provider;\n\t}\n\tsplitId(id, modelType) {\n\t\tconst index = id.indexOf(this.separator);\n\t\tif (index === -1) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType,\n\t\t\tmessage: `Invalid ${modelType} id for registry: ${id} (must be in the format \"providerId${this.separator}modelId\")`\n\t\t});\n\t\treturn [id.slice(0, index), id.slice(index + this.separator.length)];\n\t}\n\tlanguageModel(id) {\n\t\tvar _a17, _b;\n\t\tconst [providerId, modelId] = this.splitId(id, \"languageModel\");\n\t\tconst model = (_b = (_a17 = this.getProvider(providerId)).languageModel) == null ? void 0 : _b.call(_a17, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"languageModel\"\n\t\t});\n\t\treturn model;\n\t}\n\ttextEmbeddingModel(id) {\n\t\tvar _a17;\n\t\tconst [providerId, modelId] = this.splitId(id, \"textEmbeddingModel\");\n\t\tconst provider = this.getProvider(providerId);\n\t\tconst model = (_a17 = provider.textEmbeddingModel) == null ? void 0 : _a17.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"textEmbeddingModel\"\n\t\t});\n\t\treturn model;\n\t}\n\timageModel(id) {\n\t\tvar _a17;\n\t\tconst [providerId, modelId] = this.splitId(id, \"imageModel\");\n\t\tconst provider = this.getProvider(providerId);\n\t\tconst model = (_a17 = provider.imageModel) == null ? void 0 : _a17.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"imageModel\"\n\t\t});\n\t\treturn model;\n\t}\n};\nfunction tool(tool2) {\n\treturn tool2;\n}\nvar LATEST_PROTOCOL_VERSION = \"2024-11-05\";\nvar SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, \"2024-10-07\"];\nvar ClientOrServerImplementationSchema = z.object({\n\tname: z.string(),\n\tversion: z.string()\n}).passthrough();\nvar BaseParamsSchema = z.object({ _meta: z.optional(z.object({}).passthrough()) }).passthrough();\nvar ResultSchema = BaseParamsSchema;\nvar RequestSchema = z.object({\n\tmethod: z.string(),\n\tparams: z.optional(BaseParamsSchema)\n});\nvar ServerCapabilitiesSchema = z.object({\n\texperimental: z.optional(z.object({}).passthrough()),\n\tlogging: z.optional(z.object({}).passthrough()),\n\tprompts: z.optional(z.object({ listChanged: z.optional(z.boolean()) }).passthrough()),\n\tresources: z.optional(z.object({\n\t\tsubscribe: z.optional(z.boolean()),\n\t\tlistChanged: z.optional(z.boolean())\n\t}).passthrough()),\n\ttools: z.optional(z.object({ listChanged: z.optional(z.boolean()) }).passthrough())\n}).passthrough();\nvar InitializeResultSchema = ResultSchema.extend({\n\tprotocolVersion: z.string(),\n\tcapabilities: ServerCapabilitiesSchema,\n\tserverInfo: ClientOrServerImplementationSchema,\n\tinstructions: z.optional(z.string())\n});\nvar PaginatedResultSchema = ResultSchema.extend({ nextCursor: z.optional(z.string()) });\nvar ToolSchema = z.object({\n\tname: z.string(),\n\tdescription: z.optional(z.string()),\n\tinputSchema: z.object({\n\t\ttype: z.literal(\"object\"),\n\t\tproperties: z.optional(z.object({}).passthrough())\n\t}).passthrough()\n}).passthrough();\nvar ListToolsResultSchema = PaginatedResultSchema.extend({ tools: z.array(ToolSchema) });\nvar TextContentSchema = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string()\n}).passthrough();\nvar ImageContentSchema = z.object({\n\ttype: z.literal(\"image\"),\n\tdata: z.string().base64(),\n\tmimeType: z.string()\n}).passthrough();\nvar ResourceContentsSchema = z.object({\n\t/**\n\t* The URI of this resource.\n\t*/\n\turi: z.string(),\n\t/**\n\t* The MIME type of this resource, if known.\n\t*/\n\tmimeType: z.optional(z.string())\n}).passthrough();\nvar TextResourceContentsSchema = ResourceContentsSchema.extend({ text: z.string() });\nvar BlobResourceContentsSchema = ResourceContentsSchema.extend({ blob: z.string().base64() });\nvar EmbeddedResourceSchema = z.object({\n\ttype: z.literal(\"resource\"),\n\tresource: z.union([TextResourceContentsSchema, BlobResourceContentsSchema])\n}).passthrough();\nvar CallToolResultSchema = ResultSchema.extend({\n\tcontent: z.array(z.union([\n\t\tTextContentSchema,\n\t\tImageContentSchema,\n\t\tEmbeddedResourceSchema\n\t])),\n\tisError: z.boolean().default(false).optional()\n}).or(ResultSchema.extend({ toolResult: z.unknown() }));\nvar JSONRPC_VERSION = \"2.0\";\nvar JSONRPCRequestSchema = z.object({\n\tjsonrpc: z.literal(JSONRPC_VERSION),\n\tid: z.union([z.string(), z.number().int()])\n}).merge(RequestSchema).strict();\nvar JSONRPCResponseSchema = z.object({\n\tjsonrpc: z.literal(JSONRPC_VERSION),\n\tid: z.union([z.string(), z.number().int()]),\n\tresult: ResultSchema\n}).strict();\nvar JSONRPCErrorSchema = z.object({\n\tjsonrpc: z.literal(JSONRPC_VERSION),\n\tid: z.union([z.string(), z.number().int()]),\n\terror: z.object({\n\t\tcode: z.number().int(),\n\t\tmessage: z.string(),\n\t\tdata: z.optional(z.unknown())\n\t})\n}).strict();\nvar JSONRPCNotificationSchema = z.object({ jsonrpc: z.literal(JSONRPC_VERSION) }).merge(z.object({\n\tmethod: z.string(),\n\tparams: z.optional(BaseParamsSchema)\n})).strict();\nvar JSONRPCMessageSchema = z.union([\n\tJSONRPCRequestSchema,\n\tJSONRPCNotificationSchema,\n\tJSONRPCResponseSchema,\n\tJSONRPCErrorSchema\n]);\nvar SseMCPTransport = class {\n\tconstructor({ url, headers }) {\n\t\tthis.connected = false;\n\t\tthis.url = new URL(url);\n\t\tthis.headers = headers;\n\t}\n\tasync start() {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (this.connected) return resolve();\n\t\t\tthis.abortController = new AbortController();\n\t\t\tconst establishConnection = async () => {\n\t\t\t\tvar _a17, _b, _c;\n\t\t\t\ttry {\n\t\t\t\t\tconst headers = new Headers(this.headers);\n\t\t\t\t\theaders.set(\"Accept\", \"text/event-stream\");\n\t\t\t\t\tconst response = await fetch(this.url.href, {\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tsignal: (_a17 = this.abortController) == null ? void 0 : _a17.signal\n\t\t\t\t\t});\n\t\t\t\t\tif (!response.ok || !response.body) {\n\t\t\t\t\t\tconst error = new MCPClientError({ message: `MCP SSE Transport Error: ${response.status} ${response.statusText}` });\n\t\t\t\t\t\t(_b = this.onerror) == null || _b.call(this, error);\n\t\t\t\t\t\treturn reject(error);\n\t\t\t\t\t}\n\t\t\t\t\tconst reader = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(createEventSourceParserStream()).getReader();\n\t\t\t\t\tconst processEvents = async () => {\n\t\t\t\t\t\tvar _a18, _b2, _c2;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\t\t\tif (this.connected) {\n\t\t\t\t\t\t\t\t\t\tthis.connected = false;\n\t\t\t\t\t\t\t\t\t\tthrow new MCPClientError({ message: \"MCP SSE Transport Error: Connection closed unexpectedly\" });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst { event, data } = value;\n\t\t\t\t\t\t\t\tif (event === \"endpoint\") {\n\t\t\t\t\t\t\t\t\tthis.endpoint = new URL(data, this.url);\n\t\t\t\t\t\t\t\t\tif (this.endpoint.origin !== this.url.origin) throw new MCPClientError({ message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}` });\n\t\t\t\t\t\t\t\t\tthis.connected = true;\n\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t} else if (event === \"message\") try {\n\t\t\t\t\t\t\t\t\tconst message = JSONRPCMessageSchema.parse(JSON.parse(data));\n\t\t\t\t\t\t\t\t\t(_a18 = this.onmessage) == null || _a18.call(this, message);\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tconst e = new MCPClientError({\n\t\t\t\t\t\t\t\t\t\tmessage: \"MCP SSE Transport Error: Failed to parse message\",\n\t\t\t\t\t\t\t\t\t\tcause: error\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t(_b2 = this.onerror) == null || _b2.call(this, e);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tif (error instanceof Error && error.name === \"AbortError\") return;\n\t\t\t\t\t\t\t(_c2 = this.onerror) == null || _c2.call(this, error);\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tthis.sseConnection = { close: () => reader.cancel() };\n\t\t\t\t\tprocessEvents();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof Error && error.name === \"AbortError\") return;\n\t\t\t\t\t(_c = this.onerror) == null || _c.call(this, error);\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\t\t\t};\n\t\t\testablishConnection();\n\t\t});\n\t}\n\tasync close() {\n\t\tvar _a17, _b, _c;\n\t\tthis.connected = false;\n\t\t(_a17 = this.sseConnection) == null || _a17.close();\n\t\t(_b = this.abortController) == null || _b.abort();\n\t\t(_c = this.onclose) == null || _c.call(this);\n\t}\n\tasync send(message) {\n\t\tvar _a17, _b, _c;\n\t\tif (!this.endpoint || !this.connected) throw new MCPClientError({ message: \"MCP SSE Transport Error: Not connected\" });\n\t\ttry {\n\t\t\tconst headers = new Headers(this.headers);\n\t\t\theaders.set(\"Content-Type\", \"application/json\");\n\t\t\tconst init = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders,\n\t\t\t\tbody: JSON.stringify(message),\n\t\t\t\tsignal: (_a17 = this.abortController) == null ? void 0 : _a17.signal\n\t\t\t};\n\t\t\tconst response = await fetch(this.endpoint, init);\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text2 = await response.text().catch(() => null);\n\t\t\t\tconst error = new MCPClientError({ message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text2}` });\n\t\t\t\t(_b = this.onerror) == null || _b.call(this, error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t(_c = this.onerror) == null || _c.call(this, error);\n\t\t\treturn;\n\t\t}\n\t}\n};\nfunction createMcpTransport(config) {\n\tif (config.type !== \"sse\") throw new MCPClientError({ message: \"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface.\" });\n\treturn new SseMCPTransport(config);\n}\nfunction isCustomMcpTransport(transport) {\n\treturn \"start\" in transport && typeof transport.start === \"function\" && \"send\" in transport && typeof transport.send === \"function\" && \"close\" in transport && typeof transport.close === \"function\";\n}\nvar CLIENT_VERSION = \"1.0.0\";\nasync function createMCPClient(config) {\n\tconst client = new MCPClient(config);\n\tawait client.init();\n\treturn client;\n}\nvar MCPClient = class {\n\tconstructor({ transport: transportConfig, name: name17 = \"ai-sdk-mcp-client\", onUncaughtError }) {\n\t\tthis.requestMessageId = 0;\n\t\tthis.responseHandlers = /* @__PURE__ */ new Map();\n\t\tthis.serverCapabilities = {};\n\t\tthis.isClosed = true;\n\t\tthis.onUncaughtError = onUncaughtError;\n\t\tif (isCustomMcpTransport(transportConfig)) this.transport = transportConfig;\n\t\telse this.transport = createMcpTransport(transportConfig);\n\t\tthis.transport.onclose = () => this.onClose();\n\t\tthis.transport.onerror = (error) => this.onError(error);\n\t\tthis.transport.onmessage = (message) => {\n\t\t\tif (\"method\" in message) {\n\t\t\t\tthis.onError(new MCPClientError({ message: \"Unsupported message type\" }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.onResponse(message);\n\t\t};\n\t\tthis.clientInfo = {\n\t\t\tname: name17,\n\t\t\tversion: CLIENT_VERSION\n\t\t};\n\t}\n\tasync init() {\n\t\ttry {\n\t\t\tawait this.transport.start();\n\t\t\tthis.isClosed = false;\n\t\t\tconst result = await this.request({\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"initialize\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tprotocolVersion: LATEST_PROTOCOL_VERSION,\n\t\t\t\t\t\tcapabilities: {},\n\t\t\t\t\t\tclientInfo: this.clientInfo\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tresultSchema: InitializeResultSchema\n\t\t\t});\n\t\t\tif (result === void 0) throw new MCPClientError({ message: \"Server sent invalid initialize result\" });\n\t\t\tif (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) throw new MCPClientError({ message: `Server's protocol version is not supported: ${result.protocolVersion}` });\n\t\t\tthis.serverCapabilities = result.capabilities;\n\t\t\tawait this.notification({ method: \"notifications/initialized\" });\n\t\t\treturn this;\n\t\t} catch (error) {\n\t\t\tawait this.close();\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync close() {\n\t\tvar _a17;\n\t\tif (this.isClosed) return;\n\t\tawait ((_a17 = this.transport) == null ? void 0 : _a17.close());\n\t\tthis.onClose();\n\t}\n\tassertCapability(method) {\n\t\tswitch (method) {\n\t\t\tcase \"initialize\": break;\n\t\t\tcase \"tools/list\":\n\t\t\tcase \"tools/call\":\n\t\t\t\tif (!this.serverCapabilities.tools) throw new MCPClientError({ message: `Server does not support tools` });\n\t\t\t\tbreak;\n\t\t\tdefault: throw new MCPClientError({ message: `Unsupported method: ${method}` });\n\t\t}\n\t}\n\tasync request({ request, resultSchema, options }) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (this.isClosed) return reject(new MCPClientError({ message: \"Attempted to send a request from a closed client\" }));\n\t\t\tthis.assertCapability(request.method);\n\t\t\tconst signal = options == null ? void 0 : options.signal;\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst messageId = this.requestMessageId++;\n\t\t\tconst jsonrpcRequest = {\n\t\t\t\t...request,\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid: messageId\n\t\t\t};\n\t\t\tconst cleanup = () => {\n\t\t\t\tthis.responseHandlers.delete(messageId);\n\t\t\t};\n\t\t\tthis.responseHandlers.set(messageId, (response) => {\n\t\t\t\tif (signal == null ? void 0 : signal.aborted) return reject(new MCPClientError({\n\t\t\t\t\tmessage: \"Request was aborted\",\n\t\t\t\t\tcause: signal.reason\n\t\t\t\t}));\n\t\t\t\tif (response instanceof Error) return reject(response);\n\t\t\t\ttry {\n\t\t\t\t\tresolve(resultSchema.parse(response.result));\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(new MCPClientError({\n\t\t\t\t\t\tmessage: \"Failed to parse server response\",\n\t\t\t\t\t\tcause: error\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.transport.send(jsonrpcRequest).catch((error) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(error);\n\t\t\t});\n\t\t});\n\t}\n\tasync listTools({ params, options } = {}) {\n\t\ttry {\n\t\t\treturn this.request({\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"tools/list\",\n\t\t\t\t\tparams\n\t\t\t\t},\n\t\t\t\tresultSchema: ListToolsResultSchema,\n\t\t\t\toptions\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync callTool({ name: name17, args, options }) {\n\t\ttry {\n\t\t\treturn this.request({\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: \"tools/call\",\n\t\t\t\t\tparams: {\n\t\t\t\t\t\tname: name17,\n\t\t\t\t\t\targuments: args\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tresultSchema: CallToolResultSchema,\n\t\t\t\toptions: { signal: options == null ? void 0 : options.abortSignal }\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync notification(notification) {\n\t\tconst jsonrpcNotification = {\n\t\t\t...notification,\n\t\t\tjsonrpc: \"2.0\"\n\t\t};\n\t\tawait this.transport.send(jsonrpcNotification);\n\t}\n\t/**\n\t* Returns a set of AI SDK tools from the MCP server\n\t* @returns A record of tool names to their implementations\n\t*/\n\tasync tools({ schemas = \"automatic\" } = {}) {\n\t\tvar _a17;\n\t\tconst tools = {};\n\t\ttry {\n\t\t\tconst listToolsResult = await this.listTools();\n\t\t\tfor (const { name: name17, description, inputSchema } of listToolsResult.tools) {\n\t\t\t\tif (schemas !== \"automatic\" && !(name17 in schemas)) continue;\n\t\t\t\tconst parameters = schemas === \"automatic\" ? jsonSchema({\n\t\t\t\t\t...inputSchema,\n\t\t\t\t\tproperties: (_a17 = inputSchema.properties) != null ? _a17 : {},\n\t\t\t\t\tadditionalProperties: false\n\t\t\t\t}) : schemas[name17].parameters;\n\t\t\t\tconst self = this;\n\t\t\t\ttools[name17] = tool({\n\t\t\t\t\tdescription,\n\t\t\t\t\tparameters,\n\t\t\t\t\texecute: async (args, options) => {\n\t\t\t\t\t\tvar _a18;\n\t\t\t\t\t\t(_a18 = options == null ? void 0 : options.abortSignal) == null || _a18.throwIfAborted();\n\t\t\t\t\t\treturn self.callTool({\n\t\t\t\t\t\t\tname: name17,\n\t\t\t\t\t\t\targs,\n\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn tools;\n\t\t} catch (error) {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tonClose() {\n\t\tif (this.isClosed) return;\n\t\tthis.isClosed = true;\n\t\tconst error = new MCPClientError({ message: \"Connection closed\" });\n\t\tfor (const handler of this.responseHandlers.values()) handler(error);\n\t\tthis.responseHandlers.clear();\n\t}\n\tonError(error) {\n\t\tif (this.onUncaughtError) this.onUncaughtError(error);\n\t}\n\tonResponse(response) {\n\t\tconst messageId = Number(response.id);\n\t\tconst handler = this.responseHandlers.get(messageId);\n\t\tif (handler === void 0) throw new MCPClientError({ message: `Protocol error: Received a response for an unknown message ID: ${JSON.stringify(response)}` });\n\t\tthis.responseHandlers.delete(messageId);\n\t\thandler(\"result\" in response ? response : new MCPClientError({\n\t\t\tmessage: response.error.message,\n\t\t\tcause: response.error\n\t\t}));\n\t}\n};\nfunction cosineSimilarity(vector1, vector2, options) {\n\tif (vector1.length !== vector2.length) throw new InvalidArgumentError({\n\t\tparameter: \"vector1,vector2\",\n\t\tvalue: {\n\t\t\tvector1Length: vector1.length,\n\t\t\tvector2Length: vector2.length\n\t\t},\n\t\tmessage: `Vectors must have the same length`\n\t});\n\tconst n = vector1.length;\n\tif (n === 0) {\n\t\tif (options == null ? void 0 : options.throwErrorForEmptyVectors) throw new InvalidArgumentError({\n\t\t\tparameter: \"vector1\",\n\t\t\tvalue: vector1,\n\t\t\tmessage: \"Vectors cannot be empty\"\n\t\t});\n\t\treturn 0;\n\t}\n\tlet magnitudeSquared1 = 0;\n\tlet magnitudeSquared2 = 0;\n\tlet dotProduct = 0;\n\tfor (let i = 0; i < n; i++) {\n\t\tconst value1 = vector1[i];\n\t\tconst value2 = vector2[i];\n\t\tmagnitudeSquared1 += value1 * value1;\n\t\tmagnitudeSquared2 += value2 * value2;\n\t\tdotProduct += value1 * value2;\n\t}\n\treturn magnitudeSquared1 === 0 || magnitudeSquared2 === 0 ? 0 : dotProduct / (Math.sqrt(magnitudeSquared1) * Math.sqrt(magnitudeSquared2));\n}\nfunction simulateReadableStream({ chunks, initialDelayInMs = 0, chunkDelayInMs = 0, _internal }) {\n\tvar _a17;\n\tconst delay2 = (_a17 = _internal == null ? void 0 : _internal.delay) != null ? _a17 : delay;\n\tlet index = 0;\n\treturn new ReadableStream({ async pull(controller) {\n\t\tif (index < chunks.length) {\n\t\t\tawait delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);\n\t\t\tcontroller.enqueue(chunks[index++]);\n\t\t} else controller.close();\n\t} });\n}\nfunction AssistantResponse({ threadId, messageId }, process2) {\n\tconst stream = new ReadableStream({\n\t\tasync start(controller) {\n\t\t\tvar _a17;\n\t\t\tconst textEncoder = new TextEncoder();\n\t\t\tconst sendMessage = (message) => {\n\t\t\t\tcontroller.enqueue(textEncoder.encode(formatAssistantStreamPart(\"assistant_message\", message)));\n\t\t\t};\n\t\t\tconst sendDataMessage = (message) => {\n\t\t\t\tcontroller.enqueue(textEncoder.encode(formatAssistantStreamPart(\"data_message\", message)));\n\t\t\t};\n\t\t\tconst sendError = (errorMessage) => {\n\t\t\t\tcontroller.enqueue(textEncoder.encode(formatAssistantStreamPart(\"error\", errorMessage)));\n\t\t\t};\n\t\t\tconst forwardStream = async (stream2) => {\n\t\t\t\tvar _a18, _b;\n\t\t\t\tlet result = void 0;\n\t\t\t\tfor await (const value of stream2) switch (value.event) {\n\t\t\t\t\tcase \"thread.message.created\":\n\t\t\t\t\t\tcontroller.enqueue(textEncoder.encode(formatAssistantStreamPart(\"assistant_message\", {\n\t\t\t\t\t\t\tid: value.data.id,\n\t\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\t\tcontent: [{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: { value: \"\" }\n\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t})));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"thread.message.delta\": {\n\t\t\t\t\t\tconst content = (_a18 = value.data.delta.content) == null ? void 0 : _a18[0];\n\t\t\t\t\t\tif ((content == null ? void 0 : content.type) === \"text\" && ((_b = content.text) == null ? void 0 : _b.value) != null) controller.enqueue(textEncoder.encode(formatAssistantStreamPart(\"text\", content.text.value)));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"thread.run.completed\":\n\t\t\t\t\tcase \"thread.run.requires_action\": result = value.data;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t};\n\t\t\tcontroller.enqueue(textEncoder.encode(formatAssistantStreamPart(\"assistant_control_data\", {\n\t\t\t\tthreadId,\n\t\t\t\tmessageId\n\t\t\t})));\n\t\t\ttry {\n\t\t\t\tawait process2({\n\t\t\t\t\tsendMessage,\n\t\t\t\t\tsendDataMessage,\n\t\t\t\t\tforwardStream\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tsendError((_a17 = error.message) != null ? _a17 : `${error}`);\n\t\t\t} finally {\n\t\t\t\tcontroller.close();\n\t\t\t}\n\t\t},\n\t\tpull(controller) {},\n\t\tcancel() {}\n\t});\n\treturn new Response(stream, {\n\t\tstatus: 200,\n\t\theaders: { \"Content-Type\": \"text/plain; charset=utf-8\" }\n\t});\n}\nvar langchain_adapter_exports = {};\n__export(langchain_adapter_exports, {\n\tmergeIntoDataStream: () => mergeIntoDataStream,\n\ttoDataStream: () => toDataStream,\n\ttoDataStreamResponse: () => toDataStreamResponse\n});\nfunction createCallbacksTransformer(callbacks = {}) {\n\tconst textEncoder = new TextEncoder();\n\tlet aggregatedResponse = \"\";\n\treturn new TransformStream({\n\t\tasync start() {\n\t\t\tif (callbacks.onStart) await callbacks.onStart();\n\t\t},\n\t\tasync transform(message, controller) {\n\t\t\tcontroller.enqueue(textEncoder.encode(message));\n\t\t\taggregatedResponse += message;\n\t\t\tif (callbacks.onToken) await callbacks.onToken(message);\n\t\t\tif (callbacks.onText && typeof message === \"string\") await callbacks.onText(message);\n\t\t},\n\t\tasync flush() {\n\t\t\tif (callbacks.onCompletion) await callbacks.onCompletion(aggregatedResponse);\n\t\t\tif (callbacks.onFinal) await callbacks.onFinal(aggregatedResponse);\n\t\t}\n\t});\n}\nfunction toDataStreamInternal(stream, callbacks) {\n\treturn stream.pipeThrough(new TransformStream({ transform: async (value, controller) => {\n\t\tvar _a17;\n\t\tif (typeof value === \"string\") {\n\t\t\tcontroller.enqueue(value);\n\t\t\treturn;\n\t\t}\n\t\tif (\"event\" in value) {\n\t\t\tif (value.event === \"on_chat_model_stream\") forwardAIMessageChunk((_a17 = value.data) == null ? void 0 : _a17.chunk, controller);\n\t\t\treturn;\n\t\t}\n\t\tforwardAIMessageChunk(value, controller);\n\t} })).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(new TextDecoderStream()).pipeThrough(new TransformStream({ transform: async (chunk, controller) => {\n\t\tcontroller.enqueue(formatDataStreamPart(\"text\", chunk));\n\t} }));\n}\nfunction toDataStream(stream, callbacks) {\n\treturn toDataStreamInternal(stream, callbacks).pipeThrough(new TextEncoderStream());\n}\nfunction toDataStreamResponse(stream, options) {\n\tvar _a17;\n\tconst dataStream = toDataStreamInternal(stream, options == null ? void 0 : options.callbacks).pipeThrough(new TextEncoderStream());\n\tconst data = options == null ? void 0 : options.data;\n\tconst init = options == null ? void 0 : options.init;\n\tconst responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;\n\treturn new Response(responseStream, {\n\t\tstatus: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,\n\t\tstatusText: init == null ? void 0 : init.statusText,\n\t\theaders: prepareResponseHeaders(init == null ? void 0 : init.headers, {\n\t\t\tcontentType: \"text/plain; charset=utf-8\",\n\t\t\tdataStreamVersion: \"v1\"\n\t\t})\n\t});\n}\nfunction mergeIntoDataStream(stream, options) {\n\toptions.dataStream.merge(toDataStreamInternal(stream, options.callbacks));\n}\nfunction forwardAIMessageChunk(chunk, controller) {\n\tif (typeof chunk.content === \"string\") controller.enqueue(chunk.content);\n\telse {\n\t\tconst content = chunk.content;\n\t\tfor (const item of content) if (item.type === \"text\") controller.enqueue(item.text);\n\t}\n}\nvar llamaindex_adapter_exports = {};\n__export(llamaindex_adapter_exports, {\n\tmergeIntoDataStream: () => mergeIntoDataStream2,\n\ttoDataStream: () => toDataStream2,\n\ttoDataStreamResponse: () => toDataStreamResponse2\n});\nfunction toDataStreamInternal2(stream, callbacks) {\n\tconst trimStart = trimStartOfStream();\n\treturn convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]()).pipeThrough(new TransformStream({ async transform(message, controller) {\n\t\tcontroller.enqueue(trimStart(message.delta));\n\t} })).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(new TextDecoderStream()).pipeThrough(new TransformStream({ transform: async (chunk, controller) => {\n\t\tcontroller.enqueue(formatDataStreamPart(\"text\", chunk));\n\t} }));\n}\nfunction toDataStream2(stream, callbacks) {\n\treturn toDataStreamInternal2(stream, callbacks).pipeThrough(new TextEncoderStream());\n}\nfunction toDataStreamResponse2(stream, options = {}) {\n\tvar _a17;\n\tconst { init, data, callbacks } = options;\n\tconst dataStream = toDataStreamInternal2(stream, callbacks).pipeThrough(new TextEncoderStream());\n\tconst responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;\n\treturn new Response(responseStream, {\n\t\tstatus: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,\n\t\tstatusText: init == null ? void 0 : init.statusText,\n\t\theaders: prepareResponseHeaders(init == null ? void 0 : init.headers, {\n\t\t\tcontentType: \"text/plain; charset=utf-8\",\n\t\t\tdataStreamVersion: \"v1\"\n\t\t})\n\t});\n}\nfunction mergeIntoDataStream2(stream, options) {\n\toptions.dataStream.merge(toDataStreamInternal2(stream, options.callbacks));\n}\nfunction trimStartOfStream() {\n\tlet isStreamStart = true;\n\treturn (text2) => {\n\t\tif (isStreamStart) {\n\t\t\ttext2 = text2.trimStart();\n\t\t\tif (text2) isStreamStart = false;\n\t\t}\n\t\treturn text2;\n\t};\n}\nvar StreamData = class {\n\tconstructor() {\n\t\tthis.encoder = new TextEncoder();\n\t\tthis.controller = null;\n\t\tthis.isClosed = false;\n\t\tthis.warningTimeout = null;\n\t\tconst self = this;\n\t\tthis.stream = new ReadableStream({\n\t\t\tstart: async (controller) => {\n\t\t\t\tself.controller = controller;\n\t\t\t},\n\t\t\tpull: (controller) => {},\n\t\t\tcancel: (reason) => {\n\t\t\t\tthis.isClosed = true;\n\t\t\t}\n\t\t});\n\t}\n\tasync close() {\n\t\tif (this.isClosed) throw new Error(\"Data Stream has already been closed.\");\n\t\tif (!this.controller) throw new Error(\"Stream controller is not initialized.\");\n\t\tthis.controller.close();\n\t\tthis.isClosed = true;\n\t\tif (this.warningTimeout) clearTimeout(this.warningTimeout);\n\t}\n\tappend(value) {\n\t\tif (this.isClosed) throw new Error(\"Data Stream has already been closed.\");\n\t\tif (!this.controller) throw new Error(\"Stream controller is not initialized.\");\n\t\tthis.controller.enqueue(this.encoder.encode(formatDataStreamPart(\"data\", [value])));\n\t}\n\tappendMessageAnnotation(value) {\n\t\tif (this.isClosed) throw new Error(\"Data Stream has already been closed.\");\n\t\tif (!this.controller) throw new Error(\"Stream controller is not initialized.\");\n\t\tthis.controller.enqueue(this.encoder.encode(formatDataStreamPart(\"message_annotations\", [value])));\n\t}\n};\n//#endregion\nexport { AISDKError, APICallError, AssistantResponse, DownloadError, EmptyResponseBodyError, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidPromptError, InvalidResponseDataError, InvalidStreamPartError, InvalidToolArgumentsError, JSONParseError, langchain_adapter_exports as LangChainAdapter, llamaindex_adapter_exports as LlamaIndexAdapter, LoadAPIKeyError, MCPClientError, MessageConversionError, NoContentGeneratedError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, output_exports as Output, RetryError, StreamData, ToolCallRepairError, ToolExecutionError, TypeValidationError, UnsupportedFunctionalityError, UnsupportedModelVersionError, appendClientMessage, appendResponseMessages, convertToCoreMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, createIdGenerator, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, experimental_wrapLanguageModel, extractReasoningMiddleware, formatAssistantStreamPart, formatDataStreamPart, generateId, generateObject, generateText, jsonSchema, parseAssistantStreamPart, parseDataStreamPart, pipeDataStreamToResponse, processDataStream, processTextStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, tool, wrapLanguageModel, zodSchema };\n\n//# sourceMappingURL=index.js.map","import * as z4 from \"zod/v4\";\nimport { ZodFirstPartyTypeKind } from \"zod/v3\";\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider/3.0.19/0b1d7b6863750d2561eeffa8e8855a8a3237be133a137f63f15430e10633b053/node_modules/@ai-sdk/provider/dist/index.mjs\nvar marker$1 = \"vercel.ai.error\";\nvar symbol$1 = Symbol.for(marker$1);\nvar _a$1;\nvar _b$1;\nvar AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1) {\n\t/**\n\t* Creates an AI SDK Error.\n\t*\n\t* @param {Object} params - The parameters for creating the error.\n\t* @param {string} params.name - The name of the error.\n\t* @param {string} params.message - The error message.\n\t* @param {unknown} [params.cause] - The underlying cause of the error.\n\t*/\n\tconstructor({ name: name14, message, cause }) {\n\t\tsuper(message);\n\t\tthis[_a$1] = true;\n\t\tthis.name = name14;\n\t\tthis.cause = cause;\n\t}\n\t/**\n\t* Checks if the given error is an AI SDK Error.\n\t* @param {unknown} error - The error to check.\n\t* @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n\t*/\n\tstatic isInstance(error) {\n\t\treturn _AISDKError.hasMarker(error, marker$1);\n\t}\n\tstatic hasMarker(error, marker15) {\n\t\tconst markerSymbol = Symbol.for(marker15);\n\t\treturn error != null && typeof error === \"object\" && markerSymbol in error && typeof error[markerSymbol] === \"boolean\" && error[markerSymbol] === true;\n\t}\n};\nvar name$1 = \"AI_APICallError\";\nvar marker2 = `vercel.ai.error.${name$1}`;\nvar symbol2 = Symbol.for(marker2);\nvar _a2;\nvar _b2;\nvar APICallError = class extends (_b2 = AISDKError, _a2 = symbol2, _b2) {\n\tconstructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {\n\t\tsuper({\n\t\t\tname: name$1,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a2] = true;\n\t\tthis.url = url;\n\t\tthis.requestBodyValues = requestBodyValues;\n\t\tthis.statusCode = statusCode;\n\t\tthis.responseHeaders = responseHeaders;\n\t\tthis.responseBody = responseBody;\n\t\tthis.isRetryable = isRetryable;\n\t\tthis.data = data;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker2);\n\t}\n};\nvar name2 = \"AI_EmptyResponseBodyError\";\nvar marker3 = `vercel.ai.error.${name2}`;\nvar symbol3 = Symbol.for(marker3);\nvar _a3;\nvar _b3;\nvar EmptyResponseBodyError = class extends (_b3 = AISDKError, _a3 = symbol3, _b3) {\n\tconstructor({ message = \"Empty response body\" } = {}) {\n\t\tsuper({\n\t\t\tname: name2,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a3] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker3);\n\t}\n};\nfunction getErrorMessage$1(error) {\n\tif (error == null) return \"unknown error\";\n\tif (typeof error === \"string\") return error;\n\tif (error instanceof Error) return error.message;\n\treturn JSON.stringify(error);\n}\nvar name3 = \"AI_InvalidArgumentError\";\nvar marker4 = `vercel.ai.error.${name3}`;\nvar symbol4 = Symbol.for(marker4);\nvar _a4;\nvar _b4;\nvar InvalidArgumentError = class extends (_b4 = AISDKError, _a4 = symbol4, _b4) {\n\tconstructor({ message, cause, argument }) {\n\t\tsuper({\n\t\t\tname: name3,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a4] = true;\n\t\tthis.argument = argument;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker4);\n\t}\n};\nvar name4 = \"AI_InvalidPromptError\";\nvar marker5 = `vercel.ai.error.${name4}`;\nvar symbol5 = Symbol.for(marker5);\nvar _a5;\nvar _b5;\nvar InvalidPromptError = class extends (_b5 = AISDKError, _a5 = symbol5, _b5) {\n\tconstructor({ prompt, message, cause }) {\n\t\tsuper({\n\t\t\tname: name4,\n\t\t\tmessage: `Invalid prompt: ${message}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a5] = true;\n\t\tthis.prompt = prompt;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker5);\n\t}\n};\nvar name5 = \"AI_InvalidResponseDataError\";\nvar marker6 = `vercel.ai.error.${name5}`;\nvar symbol6 = Symbol.for(marker6);\nvar _a6;\nvar _b6;\nvar InvalidResponseDataError = class extends (_b6 = AISDKError, _a6 = symbol6, _b6) {\n\tconstructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {\n\t\tsuper({\n\t\t\tname: name5,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a6] = true;\n\t\tthis.data = data;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker6);\n\t}\n};\nvar name6 = \"AI_JSONParseError\";\nvar marker7 = `vercel.ai.error.${name6}`;\nvar symbol7 = Symbol.for(marker7);\nvar _a7;\nvar _b7;\nvar JSONParseError = class extends (_b7 = AISDKError, _a7 = symbol7, _b7) {\n\tconstructor({ text, cause }) {\n\t\tsuper({\n\t\t\tname: name6,\n\t\t\tmessage: `JSON parsing failed: Text: ${text}.\nError message: ${getErrorMessage$1(cause)}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a7] = true;\n\t\tthis.text = text;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker7);\n\t}\n};\nvar name7 = \"AI_LoadAPIKeyError\";\nvar marker8 = `vercel.ai.error.${name7}`;\nvar symbol8 = Symbol.for(marker8);\nvar _a8;\nvar _b8;\nvar LoadAPIKeyError = class extends (_b8 = AISDKError, _a8 = symbol8, _b8) {\n\tconstructor({ message }) {\n\t\tsuper({\n\t\t\tname: name7,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a8] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker8);\n\t}\n};\nvar name8 = \"AI_LoadSettingError\";\nvar marker9 = `vercel.ai.error.${name8}`;\nvar symbol9 = Symbol.for(marker9);\nvar _a9;\nvar _b9;\nvar LoadSettingError = class extends (_b9 = AISDKError, _a9 = symbol9, _b9) {\n\tconstructor({ message }) {\n\t\tsuper({\n\t\t\tname: name8,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a9] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker9);\n\t}\n};\nvar name9 = \"AI_NoContentGeneratedError\";\nvar marker10 = `vercel.ai.error.${name9}`;\nvar symbol10 = Symbol.for(marker10);\nvar _a10;\nvar _b10;\nvar NoContentGeneratedError = class extends (_b10 = AISDKError, _a10 = symbol10, _b10) {\n\tconstructor({ message = \"No content generated.\" } = {}) {\n\t\tsuper({\n\t\t\tname: name9,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a10] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker10);\n\t}\n};\nvar name10 = \"AI_NoSuchModelError\";\nvar marker11 = `vercel.ai.error.${name10}`;\nvar symbol11 = Symbol.for(marker11);\nvar _a11;\nvar _b11;\nvar NoSuchModelError = class extends (_b11 = AISDKError, _a11 = symbol11, _b11) {\n\tconstructor({ errorName = name10, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {\n\t\tsuper({\n\t\t\tname: errorName,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a11] = true;\n\t\tthis.modelId = modelId;\n\t\tthis.modelType = modelType;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker11);\n\t}\n};\nvar name11 = \"AI_TooManyEmbeddingValuesForCallError\";\nvar marker12 = `vercel.ai.error.${name11}`;\nvar symbol12 = Symbol.for(marker12);\nvar _a12;\nvar _b12;\nvar TooManyEmbeddingValuesForCallError = class extends (_b12 = AISDKError, _a12 = symbol12, _b12) {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: name11,\n\t\t\tmessage: `Too many values for a single embedding call. The ${options.provider} model \"${options.modelId}\" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`\n\t\t});\n\t\tthis[_a12] = true;\n\t\tthis.provider = options.provider;\n\t\tthis.modelId = options.modelId;\n\t\tthis.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n\t\tthis.values = options.values;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker12);\n\t}\n};\nvar name12 = \"AI_TypeValidationError\";\nvar marker13 = `vercel.ai.error.${name12}`;\nvar symbol13 = Symbol.for(marker13);\nvar _a13;\nvar _b13;\nvar TypeValidationError = class _TypeValidationError extends (_b13 = AISDKError, _a13 = symbol13, _b13) {\n\tconstructor({ value, cause, context }) {\n\t\tlet contextPrefix = \"Type validation failed\";\n\t\tif (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;\n\t\tif ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {\n\t\t\tcontextPrefix += \" (\";\n\t\t\tconst parts = [];\n\t\t\tif (context.entityName) parts.push(context.entityName);\n\t\t\tif (context.entityId) parts.push(`id: \"${context.entityId}\"`);\n\t\t\tcontextPrefix += parts.join(\", \");\n\t\t\tcontextPrefix += \")\";\n\t\t}\n\t\tsuper({\n\t\t\tname: name12,\n\t\t\tmessage: `${contextPrefix}: Value: ${JSON.stringify(value)}.\nError message: ${getErrorMessage$1(cause)}`,\n\t\t\tcause\n\t\t});\n\t\tthis[_a13] = true;\n\t\tthis.value = value;\n\t\tthis.context = context;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker13);\n\t}\n\t/**\n\t* Wraps an error into a TypeValidationError.\n\t* If the cause is already a TypeValidationError with the same value and context, it returns the cause.\n\t* Otherwise, it creates a new TypeValidationError.\n\t*\n\t* @param {Object} params - The parameters for wrapping the error.\n\t* @param {unknown} params.value - The value that failed validation.\n\t* @param {unknown} params.cause - The original error or cause of the validation failure.\n\t* @param {TypeValidationContext} params.context - Optional context about what is being validated.\n\t* @returns {TypeValidationError} A TypeValidationError instance.\n\t*/\n\tstatic wrap({ value, cause, context }) {\n\t\tvar _a15, _b15, _c;\n\t\tif (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a15 = cause.context) == null ? void 0 : _a15.field) === (context == null ? void 0 : context.field) && ((_b15 = cause.context) == null ? void 0 : _b15.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) return cause;\n\t\treturn new _TypeValidationError({\n\t\t\tvalue,\n\t\t\tcause,\n\t\t\tcontext\n\t\t});\n\t}\n};\nvar name13 = \"AI_UnsupportedFunctionalityError\";\nvar marker14 = `vercel.ai.error.${name13}`;\nvar symbol14 = Symbol.for(marker14);\nvar _a14;\nvar _b14;\nvar UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = symbol14, _b14) {\n\tconstructor({ functionality, message = `'${functionality}' functionality not supported.` }) {\n\t\tsuper({\n\t\t\tname: name13,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a14] = true;\n\t\tthis.functionality = functionality;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker14);\n\t}\n};\nfunction isJSONValue(value) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") return true;\n\tif (Array.isArray(value)) return value.every(isJSONValue);\n\tif (typeof value === \"object\") return Object.entries(value).every(([key, val]) => typeof key === \"string\" && (val === void 0 || isJSONValue(val)));\n\treturn false;\n}\nfunction isJSONArray(value) {\n\treturn Array.isArray(value) && value.every(isJSONValue);\n}\nfunction isJSONObject(value) {\n\treturn value != null && typeof value === \"object\" && Object.entries(value).every(([key, val]) => typeof key === \"string\" && (val === void 0 || isJSONValue(val)));\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/eventsource-parser/3.0.8/353c45c343d0acc1586e9cb9ff7be48ebf30a434bf7b8c9762d411b79278d167/node_modules/eventsource-parser/dist/index.js\nvar ParseError = class extends Error {\n\tconstructor(message, options) {\n\t\tsuper(message), this.name = \"ParseError\", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;\n\t}\n};\nconst LF = 10;\nconst CR = 13;\nconst SPACE = 32;\nfunction noop(_arg) {}\nfunction createParser(callbacks) {\n\tif (typeof callbacks == \"function\") throw new TypeError(\"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?\");\n\tconst { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];\n\tlet isFirstChunk = !0, id, data = \"\", dataLines = 0, eventType;\n\tfunction feed(chunk) {\n\t\tif (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {\n\t\t\tconst trailing2 = processLines(chunk);\n\t\t\ttrailing2 !== \"\" && pendingFragments.push(trailing2);\n\t\t\treturn;\n\t\t}\n\t\tif (chunk.indexOf(`\n`) === -1 && chunk.indexOf(\"\\r\") === -1) {\n\t\t\tpendingFragments.push(chunk);\n\t\t\treturn;\n\t\t}\n\t\tpendingFragments.push(chunk);\n\t\tconst input = pendingFragments.join(\"\");\n\t\tpendingFragments.length = 0;\n\t\tconst trailing = processLines(input);\n\t\ttrailing !== \"\" && pendingFragments.push(trailing);\n\t}\n\tfunction processLines(chunk) {\n\t\tlet searchIndex = 0;\n\t\tif (chunk.indexOf(\"\\r\") === -1) {\n\t\t\tlet lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\tfor (; lfIndex !== -1;) {\n\t\t\t\tif (searchIndex === lfIndex) {\n\t\t\t\t\tdataLines > 0 && onEvent({\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tevent: eventType,\n\t\t\t\t\t\tdata\n\t\t\t\t\t}), id = void 0, data = \"\", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst firstCharCode = chunk.charCodeAt(searchIndex);\n\t\t\t\tif (isDataPrefix(chunk, searchIndex, firstCharCode)) {\n\t\t\t\t\tconst valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);\n\t\t\t\t\tif (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {\n\t\t\t\t\t\tonEvent({\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tevent: eventType,\n\t\t\t\t\t\t\tdata: value\n\t\t\t\t\t\t}), id = void 0, data = \"\", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tdata = dataLines === 0 ? value : `${data}\n${value}`, dataLines++;\n\t\t\t\t} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6, lfIndex) || void 0 : parseLine(chunk, searchIndex, lfIndex);\n\t\t\t\tsearchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\t}\n\t\t\treturn chunk.slice(searchIndex);\n\t\t}\n\t\tfor (; searchIndex < chunk.length;) {\n\t\t\tconst crIndex = chunk.indexOf(\"\\r\", searchIndex), lfIndex = chunk.indexOf(`\n`, searchIndex);\n\t\t\tlet lineEnd = -1;\n\t\t\tif (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) break;\n\t\t\tparseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;\n\t\t}\n\t\treturn chunk.slice(searchIndex);\n\t}\n\tfunction parseLine(chunk, start, end) {\n\t\tif (start === end) {\n\t\t\tdispatchEvent();\n\t\t\treturn;\n\t\t}\n\t\tconst firstCharCode = chunk.charCodeAt(start);\n\t\tif (isDataPrefix(chunk, start, firstCharCode)) {\n\t\t\tconst valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);\n\t\t\tdata = dataLines === 0 ? value2 : `${data}\n${value2}`, dataLines++;\n\t\t\treturn;\n\t\t}\n\t\tif (isEventPrefix(chunk, start, firstCharCode)) {\n\t\t\teventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;\n\t\t\treturn;\n\t\t}\n\t\tif (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {\n\t\t\tconst value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);\n\t\t\tid = value2.includes(\"\\0\") ? void 0 : value2;\n\t\t\treturn;\n\t\t}\n\t\tif (firstCharCode === 58) {\n\t\t\tif (onComment) {\n\t\t\t\tconst line2 = chunk.slice(start, end);\n\t\t\t\tonComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(\":\");\n\t\tif (fieldSeparatorIndex === -1) {\n\t\t\tprocessField(line, \"\", line);\n\t\t\treturn;\n\t\t}\n\t\tconst field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1;\n\t\tprocessField(field, line.slice(fieldSeparatorIndex + offset), line);\n\t}\n\tfunction processField(field, value, line) {\n\t\tswitch (field) {\n\t\t\tcase \"event\":\n\t\t\t\teventType = value || void 0;\n\t\t\t\tbreak;\n\t\t\tcase \"data\":\n\t\t\t\tdata = dataLines === 0 ? value : `${data}\n${value}`, dataLines++;\n\t\t\t\tbreak;\n\t\t\tcase \"id\":\n\t\t\t\tid = value.includes(\"\\0\") ? void 0 : value;\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\t/^\\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \\`retry\\` value: \"${value}\"`, {\n\t\t\t\t\ttype: \"invalid-retry\",\n\t\t\t\t\tvalue,\n\t\t\t\t\tline\n\t\t\t\t}));\n\t\t\t\tbreak;\n\t\t\tdefault: onError(new ParseError(`Unknown field \"${field.length > 20 ? `${field.slice(0, 20)}\\u2026` : field}\"`, {\n\t\t\t\ttype: \"unknown-field\",\n\t\t\t\tfield,\n\t\t\t\tvalue,\n\t\t\t\tline\n\t\t\t}));\n\t\t}\n\t}\n\tfunction dispatchEvent() {\n\t\tdataLines > 0 && onEvent({\n\t\t\tid,\n\t\t\tevent: eventType,\n\t\t\tdata\n\t\t}), id = void 0, data = \"\", dataLines = 0, eventType = void 0;\n\t}\n\tfunction reset(options = {}) {\n\t\tif (options.consume && pendingFragments.length > 0) {\n\t\t\tconst incompleteLine = pendingFragments.join(\"\");\n\t\t\tparseLine(incompleteLine, 0, incompleteLine.length);\n\t\t}\n\t\tisFirstChunk = !0, id = void 0, data = \"\", dataLines = 0, eventType = void 0, pendingFragments.length = 0;\n\t}\n\treturn {\n\t\tfeed,\n\t\treset\n\t};\n}\nfunction isDataPrefix(chunk, i, firstCharCode) {\n\treturn firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;\n}\nfunction isEventPrefix(chunk, i, firstCharCode) {\n\treturn firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/eventsource-parser/3.0.8/353c45c343d0acc1586e9cb9ff7be48ebf30a434bf7b8c9762d411b79278d167/node_modules/eventsource-parser/dist/stream.js\nvar EventSourceParserStream = class extends TransformStream {\n\tconstructor({ onError, onRetry, onComment } = {}) {\n\t\tlet parser;\n\t\tsuper({\n\t\t\tstart(controller) {\n\t\t\t\tparser = createParser({\n\t\t\t\t\tonEvent: (event) => {\n\t\t\t\t\t\tcontroller.enqueue(event);\n\t\t\t\t\t},\n\t\t\t\t\tonError(error) {\n\t\t\t\t\t\tonError === \"terminate\" ? controller.error(error) : typeof onError == \"function\" && onError(error);\n\t\t\t\t\t},\n\t\t\t\t\tonRetry,\n\t\t\t\t\tonComment\n\t\t\t\t});\n\t\t\t},\n\t\t\ttransform(chunk) {\n\t\t\t\tparser.feed(chunk);\n\t\t\t}\n\t\t});\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/provider-utils/4.0.61/40e920c8d8fb0bef87fc1b27ba275f44a6173e0fb34f98a2ba36d21a97e815ed/node_modules/@ai-sdk/provider-utils/dist/index.mjs\nfunction combineHeaders(...headers) {\n\treturn headers.reduce((combinedHeaders, currentHeaders) => ({\n\t\t...combinedHeaders,\n\t\t...currentHeaders\n\t}), {});\n}\nfunction convertAsyncIteratorToReadableStream(iterator) {\n\tlet cancelled = false;\n\treturn new ReadableStream({\n\t\t/**\n\t\t* Called when the consumer wants to pull more data from the stream.\n\t\t*\n\t\t* @param {ReadableStreamDefaultController<T>} controller - The controller to enqueue data into the stream.\n\t\t* @returns {Promise<void>}\n\t\t*/\n\t\tasync pull(controller) {\n\t\t\tif (cancelled) return;\n\t\t\ttry {\n\t\t\t\tconst { value, done } = await iterator.next();\n\t\t\t\tif (done) controller.close();\n\t\t\t\telse controller.enqueue(value);\n\t\t\t} catch (error) {\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t* Called when the consumer cancels the stream.\n\t\t*/\n\t\tasync cancel(reason) {\n\t\t\tcancelled = true;\n\t\t\tif (iterator.return) try {\n\t\t\t\tawait iterator.return(reason);\n\t\t\t} catch (e) {}\n\t\t}\n\t});\n}\nasync function delay(delayInMs, options) {\n\tif (delayInMs == null) return;\n\tconst signal = options == null ? void 0 : options.abortSignal;\n\treturn new Promise((resolve2, reject) => {\n\t\tif (signal == null ? void 0 : signal.aborted) {\n\t\t\treject(createAbortError());\n\t\t\treturn;\n\t\t}\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tcleanup();\n\t\t\tresolve2();\n\t\t}, delayInMs);\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeoutId);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t};\n\t\tconst onAbort = () => {\n\t\t\tcleanup();\n\t\t\treject(createAbortError());\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort);\n\t});\n}\nfunction createAbortError() {\n\treturn new DOMException(\"Delay was aborted\", \"AbortError\");\n}\nvar DelayedPromise = class {\n\tconstructor() {\n\t\tthis.status = { type: \"pending\" };\n\t\tthis._resolve = void 0;\n\t\tthis._reject = void 0;\n\t}\n\tget promise() {\n\t\tif (this._promise) return this._promise;\n\t\tthis._promise = new Promise((resolve2, reject) => {\n\t\t\tif (this.status.type === \"resolved\") resolve2(this.status.value);\n\t\t\telse if (this.status.type === \"rejected\") reject(this.status.error);\n\t\t\tthis._resolve = resolve2;\n\t\t\tthis._reject = reject;\n\t\t});\n\t\treturn this._promise;\n\t}\n\tresolve(value) {\n\t\tvar _a2;\n\t\tthis.status = {\n\t\t\ttype: \"resolved\",\n\t\t\tvalue\n\t\t};\n\t\tif (this._promise) (_a2 = this._resolve) == null || _a2.call(this, value);\n\t}\n\treject(error) {\n\t\tvar _a2;\n\t\tthis.status = {\n\t\t\ttype: \"rejected\",\n\t\t\terror\n\t\t};\n\t\tif (this._promise) (_a2 = this._reject) == null || _a2.call(this, error);\n\t}\n\tisResolved() {\n\t\treturn this.status.type === \"resolved\";\n\t}\n\tisRejected() {\n\t\treturn this.status.type === \"rejected\";\n\t}\n\tisPending() {\n\t\treturn this.status.type === \"pending\";\n\t}\n};\nfunction extractResponseHeaders(response) {\n\treturn Object.fromEntries([...response.headers]);\n}\nvar { btoa, atob } = globalThis;\nfunction convertBase64ToUint8Array(base64String) {\n\tconst latin1string = atob(base64String.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n\treturn Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));\n}\nfunction convertUint8ArrayToBase64(array) {\n\tconst chunks = [];\n\tconst chunkSize = 4096;\n\tfor (let i = 0; i < array.length; i += chunkSize) chunks.push(String.fromCodePoint(...array.subarray(i, i + chunkSize)));\n\treturn btoa(chunks.join(\"\"));\n}\nasync function cancelResponseBody(response) {\n\tvar _a2;\n\ttry {\n\t\tawait ((_a2 = response.body) == null ? void 0 : _a2.cancel());\n\t} catch (e) {}\n}\nvar name = \"AI_DownloadError\";\nvar marker = `vercel.ai.error.${name}`;\nvar symbol = Symbol.for(marker);\nvar _a;\nvar _b;\nvar DownloadError = class extends (_b = AISDKError, _a = symbol, _b) {\n\tconstructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {\n\t\tsuper({\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a] = true;\n\t\tthis.url = url;\n\t\tthis.statusCode = statusCode;\n\t\tthis.statusText = statusText;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker);\n\t}\n};\nfunction isBrowserRuntime(globalThisAny = globalThis) {\n\treturn globalThisAny.window != null;\n}\nfunction isSameOrigin(url, baseUrl) {\n\ttry {\n\t\treturn new URL(url).origin === new URL(baseUrl).origin;\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\nfunction validateDownloadUrl(url) {\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch (e) {\n\t\tthrow new DownloadError({\n\t\t\turl,\n\t\t\tmessage: `Invalid URL: ${url}`\n\t\t});\n\t}\n\tif (parsed.protocol === \"data:\") return;\n\tif (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") throw new DownloadError({\n\t\turl,\n\t\tmessage: `URL scheme must be http, https, or data, got ${parsed.protocol}`\n\t});\n\tconst hostname = parsed.hostname.toLowerCase().replace(/\\.+$/, \"\");\n\tif (!hostname) throw new DownloadError({\n\t\turl,\n\t\tmessage: `URL must have a hostname`\n\t});\n\tif (hostname === \"localhost\" || hostname.endsWith(\".local\") || hostname.endsWith(\".localhost\")) throw new DownloadError({\n\t\turl,\n\t\tmessage: `URL with hostname ${hostname} is not allowed`\n\t});\n\tif (hostname.startsWith(\"[\") && hostname.endsWith(\"]\")) {\n\t\tif (isPrivateIPv6(hostname.slice(1, -1))) throw new DownloadError({\n\t\t\turl,\n\t\t\tmessage: `URL with IPv6 address ${hostname} is not allowed`\n\t\t});\n\t\treturn;\n\t}\n\tif (isIPv4(hostname)) {\n\t\tif (isPrivateIPv4(hostname)) throw new DownloadError({\n\t\t\turl,\n\t\t\tmessage: `URL with IP address ${hostname} is not allowed`\n\t\t});\n\t}\n}\nfunction validateDownloadAddress({ address, family, hostname }) {\n\tif (family === 4 ? !isIPv4(address) || isPrivateIPv4(address) : family === 6 ? isPrivateIPv6(address) : true) throw new DownloadError({\n\t\turl: hostname,\n\t\tmessage: `Hostname ${hostname} resolved to disallowed IP address ${address}`\n\t});\n}\nfunction isIPv4(hostname) {\n\tconst parts = hostname.split(\".\");\n\tif (parts.length !== 4) return false;\n\treturn parts.every((part) => {\n\t\tconst num = Number(part);\n\t\treturn Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;\n\t});\n}\nfunction isPrivateIPv4(ip) {\n\tconst [a, b, c] = ip.split(\".\").map(Number);\n\tif (a === 0) return true;\n\tif (a === 10) return true;\n\tif (a === 100 && b >= 64 && b <= 127) return true;\n\tif (a === 127) return true;\n\tif (a === 169 && b === 254) return true;\n\tif (a === 172 && b >= 16 && b <= 31) return true;\n\tif (a === 192 && b === 0 && c === 0) return true;\n\tif (a === 192 && b === 168) return true;\n\tif (a === 198 && (b === 18 || b === 19)) return true;\n\tif (a >= 240) return true;\n\treturn false;\n}\nfunction parseIPv6(ip) {\n\tlet address = ip.toLowerCase();\n\tconst zoneIndex = address.indexOf(\"%\");\n\tif (zoneIndex !== -1) address = address.slice(0, zoneIndex);\n\tconst halves = address.split(\"::\");\n\tif (halves.length > 2) return null;\n\tconst toGroups = (segment) => {\n\t\tif (segment === \"\") return [];\n\t\tconst groups = [];\n\t\tconst parts = segment.split(\":\");\n\t\tfor (let i = 0; i < parts.length; i++) {\n\t\t\tconst part = parts[i];\n\t\t\tif (part.includes(\".\")) {\n\t\t\t\tif (i !== parts.length - 1 || !isIPv4(part)) return null;\n\t\t\t\tconst [a, b, c, d] = part.split(\".\").map(Number);\n\t\t\t\tgroups.push(a << 8 | b, c << 8 | d);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!/^[0-9a-f]{1,4}$/.test(part)) return null;\n\t\t\tgroups.push(parseInt(part, 16));\n\t\t}\n\t\treturn groups;\n\t};\n\tconst head = toGroups(halves[0]);\n\tif (head === null) return null;\n\tif (halves.length === 2) {\n\t\tconst tail = toGroups(halves[1]);\n\t\tif (tail === null) return null;\n\t\tconst fill = 8 - head.length - tail.length;\n\t\tif (fill < 0) return null;\n\t\treturn [\n\t\t\t...head,\n\t\t\t...new Array(fill).fill(0),\n\t\t\t...tail\n\t\t];\n\t}\n\treturn head.length === 8 ? head : null;\n}\nfunction isPrivateIPv6(ip) {\n\tconst groups = parseIPv6(ip);\n\tif (groups === null) return true;\n\tconst topZero = (count) => groups.slice(0, count).every((group) => group === 0);\n\tif (topZero(7) && (groups[7] === 0 || groups[7] === 1)) return true;\n\tif ((groups[0] & 65024) === 64512) return true;\n\tif ((groups[0] & 65472) === 65152) return true;\n\tif ((groups[0] & 65472) === 65216) return true;\n\tif ((groups[0] & 65280) === 65280) return true;\n\tif (topZero(6) || topZero(5) && groups[5] === 65535 || topZero(4) && groups[4] === 65535 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 1) return isPrivateIPv4(`${groups[6] >> 8 & 255}.${groups[6] & 255}.${groups[7] >> 8 & 255}.${groups[7] & 255}`);\n\treturn false;\n}\nfunction createSafeLookup(lookup) {\n\treturn ((hostname, options, callback) => {\n\t\tlookup(hostname, {\n\t\t\t...options,\n\t\t\tall: true\n\t\t}, (error, addresses) => {\n\t\t\tif (error) {\n\t\t\t\tcallback(error);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst [firstAddress] = addresses;\n\t\t\t\tif (firstAddress == null) throw new Error(`Hostname ${hostname} did not resolve to an address`);\n\t\t\t\tfor (const { address, family } of addresses) validateDownloadAddress({\n\t\t\t\t\taddress,\n\t\t\t\t\tfamily,\n\t\t\t\t\thostname\n\t\t\t\t});\n\t\t\t\tif (options.all === true) callback(null, addresses);\n\t\t\t\telse callback(null, firstAddress.address, firstAddress.family);\n\t\t\t} catch (error2) {\n\t\t\t\tcallback(error2 instanceof Error ? error2 : new Error(String(error2)));\n\t\t\t}\n\t\t});\n\t});\n}\nvar safeNodeFetchPromise;\nfunction isNodeRuntime() {\n\tvar _a2, _b2, _c;\n\tconst runtimeProcess = globalThis.process;\n\treturn ((_a2 = runtimeProcess == null ? void 0 : runtimeProcess.release) == null ? void 0 : _a2.name) === \"node\" && ((_b2 = runtimeProcess.versions) == null ? void 0 : _b2.bun) == null && ((_c = runtimeProcess.versions) == null ? void 0 : _c.deno) == null && runtimeProcess.title !== \"workerd\" && globalThis.EdgeRuntime == null;\n}\nasync function getDefaultDownloadFetch() {\n\tif (!isNodeRuntime()) return globalThis.fetch;\n\treturn safeNodeFetchPromise != null ? safeNodeFetchPromise : safeNodeFetchPromise = createSafeNodeFetch();\n}\nasync function createSafeNodeFetch() {\n\tconst [module, { lookup }] = await Promise.all([loadNodeModule(\"node:module\"), loadNodeModule(\"node:dns\")]);\n\tconst { Agent, fetch } = module.createRequire(getCurrentModulePath())(\"undici\");\n\tconst dispatcher = new Agent({ connect: { lookup: createSafeLookup(lookup) } });\n\treturn ((input, init) => fetch(input, {\n\t\t...init,\n\t\tdispatcher\n\t}));\n}\nasync function loadNodeModule(id) {\n\tvar _a2;\n\tconst processWithBuiltins = globalThis.process;\n\tconst builtinModule = (_a2 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a2.call(processWithBuiltins, id);\n\tif (builtinModule == null) throw new Error(`Node.js built-in module ${id} is unavailable`);\n\treturn builtinModule;\n}\nfunction getCurrentModulePath() {\n\tconst originalPrepareStackTrace = Error.prepareStackTrace;\n\ttry {\n\t\tError.prepareStackTrace = (_error, callSites) => callSites;\n\t\tconst error = /* @__PURE__ */ new Error(\"Capture current module path\");\n\t\tError.captureStackTrace(error, getCurrentModulePath);\n\t\tconst [caller] = error.stack;\n\t\tconst fileName = caller == null ? void 0 : caller.getFileName();\n\t\tif (fileName == null) throw new Error(\"Unable to determine the current module path\");\n\t\treturn fileName;\n\t} finally {\n\t\tError.prepareStackTrace = originalPrepareStackTrace;\n\t}\n}\nvar BLOCKED_REQUEST_HEADERS = [\n\t\"connection\",\n\t\"keep-alive\",\n\t\"te\",\n\t\"trailer\",\n\t\"transfer-encoding\",\n\t\"upgrade\",\n\t\"host\",\n\t\"forwarded\",\n\t\"proxy-authorization\",\n\t\"via\",\n\t\"x-forwarded-for\",\n\t\"x-forwarded-host\",\n\t\"x-forwarded-proto\",\n\t\"x-real-ip\",\n\t\"metadata\",\n\t\"metadata-flavor\",\n\t\"x-aws-ec2-metadata-token\",\n\t\"x-metadata-token\",\n\t\"cookie\",\n\t\"set-cookie\"\n];\nfunction sanitizeRequestHeaders(input) {\n\tconst headers = new Headers(input);\n\tfor (const name2 of BLOCKED_REQUEST_HEADERS) headers.delete(name2);\n\treturn headers;\n}\nvar MAX_DOWNLOAD_REDIRECTS = 10;\nvar REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([\n\t301,\n\t302,\n\t303,\n\t307,\n\t308\n]);\nasync function getValidatedFetch(customFetch) {\n\treturn customFetch == null || customFetch === globalThis.fetch ? await getDefaultDownloadFetch() : customFetch;\n}\nasync function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects = MAX_DOWNLOAD_REDIRECTS, fetch: customFetch, trustedOrigin }) {\n\tvar _a2;\n\tlet currentHeaders = headers === void 0 ? void 0 : sanitizeRequestHeaders(headers);\n\tconst perHopInit = (redirect) => {\n\t\tconst init = {\n\t\t\tsignal: abortSignal,\n\t\t\tredirect\n\t\t};\n\t\tif (currentHeaders !== void 0) init.headers = new Headers(currentHeaders);\n\t\treturn init;\n\t};\n\tlet currentUrl = url;\n\tfor (let redirectCount = 0; redirectCount <= maxRedirects; redirectCount++) {\n\t\tconst isTrustedHop = trustedOrigin !== void 0 && isSameOrigin(currentUrl, trustedOrigin);\n\t\tif (!isTrustedHop) validateDownloadUrl(currentUrl);\n\t\tconst fetch = isTrustedHop && customFetch != null ? customFetch : isTrustedHop ? globalThis.fetch : await getValidatedFetch(customFetch);\n\t\tconst response = await fetch(currentUrl, perHopInit(\"manual\"));\n\t\tif (response.type === \"opaqueredirect\") {\n\t\t\tif (!isBrowserRuntime()) throw new DownloadError({\n\t\t\t\turl,\n\t\t\t\tmessage: `Redirect from ${currentUrl} could not be validated and was blocked`\n\t\t\t});\n\t\t\treturn await fetch(currentUrl, perHopInit(\"follow\"));\n\t\t}\n\t\tconst location = (_a2 = response.headers) == null ? void 0 : _a2.get(\"location\");\n\t\tif (REDIRECT_STATUS_CODES.has(response.status) && location) {\n\t\t\tcancelResponseBody(response);\n\t\t\tconst nextUrl = new URL(location, currentUrl).toString();\n\t\t\tif (currentHeaders !== void 0 && !isSameOrigin(nextUrl, currentUrl)) {\n\t\t\t\tconst userAgent = currentHeaders.get(\"user-agent\");\n\t\t\t\tcurrentHeaders = new Headers(userAgent == null ? void 0 : { \"user-agent\": userAgent });\n\t\t\t}\n\t\t\tcurrentUrl = nextUrl;\n\t\t\tcontinue;\n\t\t}\n\t\treturn response;\n\t}\n\tthrow new DownloadError({\n\t\turl,\n\t\tmessage: `Too many redirects (max ${maxRedirects})`\n\t});\n}\nvar DEFAULT_MAX_DOWNLOAD_SIZE = 2147483648;\nasync function readResponseWithSizeLimit({ response, url, maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE }) {\n\tconst contentLength = response.headers.get(\"content-length\");\n\tif (contentLength != null) {\n\t\tconst length = parseInt(contentLength, 10);\n\t\tif (!isNaN(length) && length > maxBytes) {\n\t\t\tawait cancelResponseBody(response);\n\t\t\tthrow new DownloadError({\n\t\t\t\turl,\n\t\t\t\tmessage: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`\n\t\t\t});\n\t\t}\n\t}\n\tconst body = response.body;\n\tif (body == null) return /* @__PURE__ */ new Uint8Array(0);\n\tconst reader = body.getReader();\n\tconst chunks = [];\n\tlet totalBytes = 0;\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\t\t\ttotalBytes += value.length;\n\t\t\tif (totalBytes > maxBytes) throw new DownloadError({\n\t\t\t\turl,\n\t\t\t\tmessage: `Download of ${url} exceeded maximum size of ${maxBytes} bytes.`\n\t\t\t});\n\t\t\tchunks.push(value);\n\t\t}\n\t} finally {\n\t\ttry {\n\t\t\tawait reader.cancel();\n\t\t} catch (e) {} finally {\n\t\t\treader.releaseLock();\n\t\t}\n\t}\n\tconst result = new Uint8Array(totalBytes);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tresult.set(chunk, offset);\n\t\toffset += chunk.length;\n\t}\n\treturn result;\n}\nvar EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL = /* @__PURE__ */ Symbol.for(\"vercel.ai.embeddingModel.maxInputBytesPerCall\");\nvar EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER = /* @__PURE__ */ Symbol.for(\"vercel.ai.embeddingModel.providerOptionsTransformer\");\nvar createIdGenerator = ({ prefix, size = 16, alphabet = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", separator = \"-\" } = {}) => {\n\tconst generator = () => {\n\t\tconst alphabetLength = alphabet.length;\n\t\tconst chars = new Array(size);\n\t\tfor (let i = 0; i < size; i++) chars[i] = alphabet[Math.random() * alphabetLength | 0];\n\t\treturn chars.join(\"\");\n\t};\n\tif (prefix == null) return generator;\n\tif (alphabet.includes(separator)) throw new InvalidArgumentError({\n\t\targument: \"separator\",\n\t\tmessage: `The separator \"${separator}\" must not be part of the alphabet \"${alphabet}\".`\n\t});\n\treturn () => `${prefix}${separator}${generator()}`;\n};\nvar generateId = createIdGenerator();\nfunction getErrorMessage(error) {\n\tif (error == null) return \"unknown error\";\n\tif (typeof error === \"string\") return error;\n\tif (error instanceof Error) return error.message;\n\treturn JSON.stringify(error);\n}\nfunction isAbortError(error) {\n\treturn (error instanceof Error || error instanceof DOMException) && (error.name === \"AbortError\" || error.name === \"ResponseAborted\" || error.name === \"TimeoutError\");\n}\nvar FETCH_FAILED_ERROR_MESSAGES = [\"fetch failed\", \"failed to fetch\"];\nvar RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([\n\t\"ConnectionRefused\",\n\t\"ConnectionClosed\",\n\t\"FailedToOpenSocket\",\n\t\"ECONNRESET\",\n\t\"ECONNREFUSED\",\n\t\"ETIMEDOUT\",\n\t\"EPIPE\",\n\t\"UND_ERR_SOCKET\",\n\t\"UND_ERR_HEADERS_TIMEOUT\",\n\t\"UND_ERR_BODY_TIMEOUT\",\n\t\"UND_ERR_CONNECT_TIMEOUT\"\n]);\nfunction findNetworkError(error) {\n\tconst visited = /* @__PURE__ */ new Set();\n\tlet current = error;\n\twhile (current instanceof Error && !visited.has(current)) {\n\t\tvisited.add(current);\n\t\tconst errorWithCode = current;\n\t\tif (typeof errorWithCode.code === \"string\" && RETRYABLE_NETWORK_ERROR_CODES.has(errorWithCode.code)) return errorWithCode;\n\t\tcurrent = current.cause;\n\t}\n}\nfunction handleFetchError({ error, url, requestBodyValues }) {\n\tif (isAbortError(error)) return error;\n\tif (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {\n\t\tconst cause = error.cause;\n\t\tif (cause != null) return new APICallError({\n\t\t\tmessage: `Cannot connect to API: ${cause.message}`,\n\t\t\tcause,\n\t\t\turl,\n\t\t\trequestBodyValues,\n\t\t\tisRetryable: true\n\t\t});\n\t}\n\tconst networkError = findNetworkError(error);\n\tif (networkError != null) {\n\t\tif (APICallError.isInstance(error)) return new APICallError({\n\t\t\tmessage: error.message,\n\t\t\tcause: error.cause,\n\t\t\turl: error.url,\n\t\t\trequestBodyValues: error.requestBodyValues,\n\t\t\tstatusCode: error.statusCode,\n\t\t\tresponseHeaders: error.responseHeaders,\n\t\t\tresponseBody: error.responseBody,\n\t\t\tdata: error.data,\n\t\t\tisRetryable: true\n\t\t});\n\t\treturn new APICallError({\n\t\t\tmessage: `Cannot connect to API: ${error instanceof Error ? error.message : networkError.message}`,\n\t\t\tcause: error,\n\t\t\turl,\n\t\t\trequestBodyValues,\n\t\t\tisRetryable: true\n\t\t});\n\t}\n\treturn error;\n}\nfunction getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {\n\tvar _a2, _b2, _c;\n\tif (globalThisAny.window) return `runtime/browser`;\n\tif ((_a2 = globalThisAny.navigator) == null ? void 0 : _a2.userAgent) return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;\n\tif ((_c = (_b2 = globalThisAny.process) == null ? void 0 : _b2.versions) == null ? void 0 : _c.node) return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;\n\tif (globalThisAny.EdgeRuntime) return `runtime/vercel-edge`;\n\treturn \"runtime/unknown\";\n}\nfunction normalizeHeaders(headers) {\n\tif (headers == null) return {};\n\tconst normalized = {};\n\tif (headers instanceof Headers) headers.forEach((value, key) => {\n\t\tnormalized[key.toLowerCase()] = value;\n\t});\n\telse {\n\t\tif (!Array.isArray(headers)) headers = Object.entries(headers);\n\t\tfor (const [key, value] of headers) if (value != null) normalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\nfunction withUserAgentSuffix(headers, ...userAgentSuffixParts) {\n\tconst normalizedHeaders = new Headers(normalizeHeaders(headers));\n\tconst currentUserAgentHeader = normalizedHeaders.get(\"user-agent\") || \"\";\n\tnormalizedHeaders.set(\"user-agent\", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(\" \"));\n\treturn Object.fromEntries(normalizedHeaders.entries());\n}\nvar VERSION = \"4.0.61\";\nvar getOriginalFetch = () => globalThis.fetch;\nvar getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin }) => {\n\ttry {\n\t\tconst requestFetch = fetch != null ? fetch : getOriginalFetch();\n\t\tconst requestHeaders = withUserAgentSuffix(credentialedOrigin !== void 0 && !isSameOrigin(url, credentialedOrigin) ? {} : headers, `ai-sdk/provider-utils/${VERSION}`, getRuntimeEnvironmentUserAgent());\n\t\tconst response = validateUrl ? await fetchWithValidatedRedirects({\n\t\t\turl,\n\t\t\theaders: requestHeaders,\n\t\t\tabortSignal,\n\t\t\tfetch,\n\t\t\ttrustedOrigin\n\t\t}) : await requestFetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: requestHeaders,\n\t\t\tsignal: abortSignal\n\t\t});\n\t\tconst responseHeaders = extractResponseHeaders(response);\n\t\tif (!response.ok) {\n\t\t\tlet errorInformation;\n\t\t\ttry {\n\t\t\t\terrorInformation = await failedResponseHandler({\n\t\t\t\t\tresponse,\n\t\t\t\t\turl,\n\t\t\t\t\trequestBodyValues: {}\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t\tthrow new APICallError({\n\t\t\t\t\tmessage: \"Failed to process error response\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tstatusCode: response.status,\n\t\t\t\t\turl,\n\t\t\t\t\tresponseHeaders,\n\t\t\t\t\trequestBodyValues: {}\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow errorInformation.value;\n\t\t}\n\t\ttry {\n\t\t\treturn await successfulResponseHandler({\n\t\t\t\tresponse,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues: {}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t}\n\t\t\tthrow new APICallError({\n\t\t\t\tmessage: \"Failed to process successful response\",\n\t\t\t\tcause: error,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\turl,\n\t\t\t\tresponseHeaders,\n\t\t\t\trequestBodyValues: {}\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tthrow handleFetchError({\n\t\t\terror,\n\t\t\turl,\n\t\t\trequestBodyValues: {}\n\t\t});\n\t}\n};\nfunction isNonNullable(value) {\n\treturn value != null;\n}\nfunction isUrlSupported({ mediaType, url, supportedUrls }) {\n\tmediaType = mediaType.toLowerCase();\n\treturn Object.entries(supportedUrls).map(([key, value]) => {\n\t\tconst mediaType2 = key.toLowerCase();\n\t\treturn mediaType2 === \"*\" || mediaType2 === \"*/*\" ? {\n\t\t\tmediaTypePrefix: \"\",\n\t\t\tregexes: value\n\t\t} : {\n\t\t\tmediaTypePrefix: mediaType2.replace(/\\*/, \"\"),\n\t\t\tregexes: value\n\t\t};\n\t}).filter(({ mediaTypePrefix }) => mediaTypePrefix === \"\" || mediaTypePrefix.endsWith(\"/\") ? mediaType.startsWith(mediaTypePrefix) : mediaType === mediaTypePrefix).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));\n}\nfunction loadOptionalSetting({ settingValue, environmentVariableName }) {\n\tif (typeof settingValue === \"string\") return settingValue;\n\tif (settingValue != null || typeof process === \"undefined\") return;\n\tsettingValue = process.env[environmentVariableName];\n\tif (settingValue == null || typeof settingValue !== \"string\") return;\n\treturn settingValue;\n}\nvar suspectProtoRx = /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*:/;\nvar suspectConstructorRx = /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\nfunction _parse(text) {\n\tconst obj = JSON.parse(text);\n\tif (obj === null || typeof obj !== \"object\") return obj;\n\tif (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) return obj;\n\treturn filter(obj);\n}\nfunction filter(obj) {\n\tlet next = [obj];\n\twhile (next.length) {\n\t\tconst nodes = next;\n\t\tnext = [];\n\t\tfor (const node of nodes) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(node, \"__proto__\")) throw new SyntaxError(\"Object contains forbidden prototype property\");\n\t\t\tif (Object.prototype.hasOwnProperty.call(node, \"constructor\") && node.constructor !== null && typeof node.constructor === \"object\" && Object.prototype.hasOwnProperty.call(node.constructor, \"prototype\")) throw new SyntaxError(\"Object contains forbidden prototype property\");\n\t\t\tfor (const key in node) {\n\t\t\t\tconst value = node[key];\n\t\t\t\tif (value && typeof value === \"object\") next.push(value);\n\t\t\t}\n\t\t}\n\t}\n\treturn obj;\n}\nfunction secureJsonParse(text) {\n\tconst { stackTraceLimit } = Error;\n\ttry {\n\t\tError.stackTraceLimit = 0;\n\t} catch (e) {\n\t\treturn _parse(text);\n\t}\n\ttry {\n\t\treturn _parse(text);\n\t} finally {\n\t\tError.stackTraceLimit = stackTraceLimit;\n\t}\n}\nfunction addAdditionalPropertiesToJsonSchema(jsonSchema2) {\n\tif (jsonSchema2.type === \"object\" || Array.isArray(jsonSchema2.type) && jsonSchema2.type.includes(\"object\")) {\n\t\tconst { additionalProperties } = jsonSchema2;\n\t\tjsonSchema2.additionalProperties = additionalProperties != null && typeof additionalProperties !== \"boolean\" ? visit(additionalProperties) : false;\n\t\tconst { properties } = jsonSchema2;\n\t\tif (properties != null) for (const key of Object.keys(properties)) properties[key] = visit(properties[key]);\n\t}\n\tif (jsonSchema2.items != null) jsonSchema2.items = Array.isArray(jsonSchema2.items) ? jsonSchema2.items.map(visit) : visit(jsonSchema2.items);\n\tif (jsonSchema2.anyOf != null) jsonSchema2.anyOf = jsonSchema2.anyOf.map(visit);\n\tif (jsonSchema2.allOf != null) jsonSchema2.allOf = jsonSchema2.allOf.map(visit);\n\tif (jsonSchema2.oneOf != null) jsonSchema2.oneOf = jsonSchema2.oneOf.map(visit);\n\tconst { definitions } = jsonSchema2;\n\tif (definitions != null) for (const key of Object.keys(definitions)) definitions[key] = visit(definitions[key]);\n\treturn jsonSchema2;\n}\nfunction visit(def) {\n\tif (typeof def === \"boolean\") return def;\n\treturn addAdditionalPropertiesToJsonSchema(def);\n}\nvar ignoreOverride = /* @__PURE__ */ Symbol(\"Let zodToJsonSchema decide on which parser to use\");\nvar defaultOptions = {\n\tname: void 0,\n\t$refStrategy: \"root\",\n\tbasePath: [\"#\"],\n\teffectStrategy: \"input\",\n\tpipeStrategy: \"all\",\n\tdateStrategy: \"format:date-time\",\n\tmapStrategy: \"entries\",\n\tremoveAdditionalStrategy: \"passthrough\",\n\tallowedAdditionalProperties: true,\n\trejectedAdditionalProperties: false,\n\tdefinitionPath: \"definitions\",\n\tstrictUnions: false,\n\tdefinitions: {},\n\terrorMessages: false,\n\tpatternStrategy: \"escape\",\n\tapplyRegexFlags: false,\n\temailStrategy: \"format:email\",\n\tbase64Strategy: \"contentEncoding:base64\",\n\tnameStrategy: \"ref\"\n};\nvar getDefaultOptions = (options) => typeof options === \"string\" ? {\n\t...defaultOptions,\n\tname: options\n} : {\n\t...defaultOptions,\n\t...options\n};\nfunction parseAnyDef() {\n\treturn {};\n}\nfunction parseArrayDef(def, refs) {\n\tvar _a2, _b2, _c;\n\tconst res = { type: \"array\" };\n\tif (((_a2 = def.type) == null ? void 0 : _a2._def) && ((_c = (_b2 = def.type) == null ? void 0 : _b2._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"items\"]\n\t});\n\tif (def.minLength) res.minItems = def.minLength.value;\n\tif (def.maxLength) res.maxItems = def.maxLength.value;\n\tif (def.exactLength) {\n\t\tres.minItems = def.exactLength.value;\n\t\tres.maxItems = def.exactLength.value;\n\t}\n\treturn res;\n}\nfunction parseBigintDef(def) {\n\tconst res = {\n\t\ttype: \"integer\",\n\t\tformat: \"int64\"\n\t};\n\tif (!def.checks) return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tif (check.inclusive) res.minimum = check.value;\n\t\t\telse res.exclusiveMinimum = check.value;\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tif (check.inclusive) res.maximum = check.value;\n\t\t\telse res.exclusiveMaximum = check.value;\n\t\t\tbreak;\n\t\tcase \"multipleOf\": res.multipleOf = check.value;\n\t}\n\treturn res;\n}\nfunction parseBooleanDef() {\n\treturn { type: \"boolean\" };\n}\nfunction parseBrandedDef(_def, refs) {\n\treturn parseDef(_def.type._def, refs);\n}\nvar parseCatchDef = (def, refs) => {\n\treturn parseDef(def.innerType._def, refs);\n};\nfunction parseDateDef(def, refs, overrideDateStrategy) {\n\tconst strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;\n\tif (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };\n\tswitch (strategy) {\n\t\tcase \"string\":\n\t\tcase \"format:date-time\": return {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\"\n\t\t};\n\t\tcase \"format:date\": return {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date\"\n\t\t};\n\t\tcase \"integer\": return integerDateParser(def);\n\t}\n}\nvar integerDateParser = (def) => {\n\tconst res = {\n\t\ttype: \"integer\",\n\t\tformat: \"unix-time\"\n\t};\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tres.minimum = check.value;\n\t\t\tbreak;\n\t\tcase \"max\": res.maximum = check.value;\n\t}\n\treturn res;\n};\nfunction parseDefaultDef(_def, refs) {\n\treturn {\n\t\t...parseDef(_def.innerType._def, refs),\n\t\tdefault: _def.defaultValue()\n\t};\n}\nfunction parseEffectsDef(_def, refs) {\n\treturn refs.effectStrategy === \"input\" ? parseDef(_def.schema._def, refs) : parseAnyDef();\n}\nfunction parseEnumDef(def) {\n\treturn {\n\t\ttype: \"string\",\n\t\tenum: Array.from(def.values)\n\t};\n}\nvar isJsonSchema7AllOfType = (type) => {\n\tif (\"type\" in type && type.type === \"string\") return false;\n\treturn \"allOf\" in type;\n};\nfunction parseIntersectionDef(def, refs) {\n\tconst allOf = [parseDef(def.left._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"0\"\n\t\t]\n\t}), parseDef(def.right._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"1\"\n\t\t]\n\t})].filter((x) => !!x);\n\tconst mergedAllOf = [];\n\tallOf.forEach((schema) => {\n\t\tif (isJsonSchema7AllOfType(schema)) mergedAllOf.push(...schema.allOf);\n\t\telse {\n\t\t\tlet nestedSchema = schema;\n\t\t\tif (\"additionalProperties\" in schema && schema.additionalProperties === false) {\n\t\t\t\tconst { additionalProperties, ...rest } = schema;\n\t\t\t\tnestedSchema = rest;\n\t\t\t}\n\t\t\tmergedAllOf.push(nestedSchema);\n\t\t}\n\t});\n\treturn mergedAllOf.length ? { allOf: mergedAllOf } : void 0;\n}\nfunction parseLiteralDef(def) {\n\tconst parsedType = typeof def.value;\n\tif (parsedType !== \"bigint\" && parsedType !== \"number\" && parsedType !== \"boolean\" && parsedType !== \"string\") return { type: Array.isArray(def.value) ? \"array\" : \"object\" };\n\treturn {\n\t\ttype: parsedType === \"bigint\" ? \"integer\" : parsedType,\n\t\tconst: def.value\n\t};\n}\nvar emojiRegex = void 0;\nvar zodPatterns = {\n\t/**\n\t* `c` was changed to `[cC]` to replicate /i flag\n\t*/\n\tcuid: /^[cC][^\\s-]{8,}$/,\n\tcuid2: /^[0-9a-z]+$/,\n\tulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,\n\t/**\n\t* `a-z` was added to replicate /i flag\n\t*/\n\temail: /^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_'+\\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,}$/,\n\t/**\n\t* Constructed a valid Unicode RegExp\n\t*\n\t* Lazily instantiate since this type of regex isn't supported\n\t* in all envs (e.g. React Native).\n\t*\n\t* See:\n\t* https://github.com/colinhacks/zod/issues/2433\n\t* Fix in Zod:\n\t* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b\n\t*/\n\temoji: () => {\n\t\tif (emojiRegex === void 0) emojiRegex = RegExp(\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\", \"u\");\n\t\treturn emojiRegex;\n\t},\n\t/**\n\t* Unused\n\t*/\n\tuuid: /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/,\n\t/**\n\t* Unused\n\t*/\n\tipv4: /^(?:(?: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])$/,\n\tipv4Cidr: /^(?:(?: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])\\/(3[0-2]|[12]?[0-9])$/,\n\t/**\n\t* Unused\n\t*/\n\tipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,\n\tipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,\n\tbase64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,\n\tbase64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,\n\tnanoid: /^[a-zA-Z0-9_-]{21}$/,\n\tjwt: /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/\n};\nfunction parseStringDef(def, refs) {\n\tconst res = { type: \"string\" };\n\tif (def.checks) for (const check of def.checks) switch (check.kind) {\n\t\tcase \"min\":\n\t\t\tres.minLength = typeof res.minLength === \"number\" ? Math.max(res.minLength, check.value) : check.value;\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tres.maxLength = typeof res.maxLength === \"number\" ? Math.min(res.maxLength, check.value) : check.value;\n\t\t\tbreak;\n\t\tcase \"email\":\n\t\t\tswitch (refs.emailStrategy) {\n\t\t\t\tcase \"format:email\":\n\t\t\t\t\taddFormat(res, \"email\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"format:idn-email\":\n\t\t\t\t\taddFormat(res, \"idn-email\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"pattern:zod\": addPattern(res, zodPatterns.email, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"url\":\n\t\t\taddFormat(res, \"uri\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"uuid\":\n\t\t\taddFormat(res, \"uuid\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"regex\":\n\t\t\taddPattern(res, check.regex, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cuid\":\n\t\t\taddPattern(res, zodPatterns.cuid, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cuid2\":\n\t\t\taddPattern(res, zodPatterns.cuid2, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"startsWith\":\n\t\t\taddPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"endsWith\":\n\t\t\taddPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"datetime\":\n\t\t\taddFormat(res, \"date-time\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"date\":\n\t\t\taddFormat(res, \"date\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"time\":\n\t\t\taddFormat(res, \"time\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"duration\":\n\t\t\taddFormat(res, \"duration\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"length\":\n\t\t\tres.minLength = typeof res.minLength === \"number\" ? Math.max(res.minLength, check.value) : check.value;\n\t\t\tres.maxLength = typeof res.maxLength === \"number\" ? Math.min(res.maxLength, check.value) : check.value;\n\t\t\tbreak;\n\t\tcase \"includes\":\n\t\t\taddPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"ip\":\n\t\t\tif (check.version !== \"v6\") addFormat(res, \"ipv4\", check.message, refs);\n\t\t\tif (check.version !== \"v4\") addFormat(res, \"ipv6\", check.message, refs);\n\t\t\tbreak;\n\t\tcase \"base64url\":\n\t\t\taddPattern(res, zodPatterns.base64url, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"jwt\":\n\t\t\taddPattern(res, zodPatterns.jwt, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"cidr\":\n\t\t\tif (check.version !== \"v6\") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);\n\t\t\tif (check.version !== \"v4\") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"emoji\":\n\t\t\taddPattern(res, zodPatterns.emoji(), check.message, refs);\n\t\t\tbreak;\n\t\tcase \"ulid\":\n\t\t\taddPattern(res, zodPatterns.ulid, check.message, refs);\n\t\t\tbreak;\n\t\tcase \"base64\":\n\t\t\tswitch (refs.base64Strategy) {\n\t\t\t\tcase \"format:binary\":\n\t\t\t\t\taddFormat(res, \"binary\", check.message, refs);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"contentEncoding:base64\":\n\t\t\t\t\tres.contentEncoding = \"base64\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"pattern:zod\": addPattern(res, zodPatterns.base64, check.message, refs);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"nanoid\": addPattern(res, zodPatterns.nanoid, check.message, refs);\n\t}\n\treturn res;\n}\nfunction escapeLiteralCheckValue(literal, refs) {\n\treturn refs.patternStrategy === \"escape\" ? escapeNonAlphaNumeric(literal) : literal;\n}\nvar ALPHA_NUMERIC = /* @__PURE__ */ new Set(\"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789\");\nfunction escapeNonAlphaNumeric(source) {\n\tlet result = \"\";\n\tfor (let i = 0; i < source.length; i++) {\n\t\tif (!ALPHA_NUMERIC.has(source[i])) result += \"\\\\\";\n\t\tresult += source[i];\n\t}\n\treturn result;\n}\nfunction addFormat(schema, value, message, refs) {\n\tvar _a2;\n\tif (schema.format || ((_a2 = schema.anyOf) == null ? void 0 : _a2.some((x) => x.format))) {\n\t\tif (!schema.anyOf) schema.anyOf = [];\n\t\tif (schema.format) {\n\t\t\tschema.anyOf.push({ format: schema.format });\n\t\t\tdelete schema.format;\n\t\t}\n\t\tschema.anyOf.push({\n\t\t\tformat: value,\n\t\t\t...message && refs.errorMessages && { errorMessage: { format: message } }\n\t\t});\n\t} else schema.format = value;\n}\nfunction addPattern(schema, regex, message, refs) {\n\tvar _a2;\n\tif (schema.pattern || ((_a2 = schema.allOf) == null ? void 0 : _a2.some((x) => x.pattern))) {\n\t\tif (!schema.allOf) schema.allOf = [];\n\t\tif (schema.pattern) {\n\t\t\tschema.allOf.push({ pattern: schema.pattern });\n\t\t\tdelete schema.pattern;\n\t\t}\n\t\tschema.allOf.push({\n\t\t\tpattern: stringifyRegExpWithFlags(regex, refs),\n\t\t\t...message && refs.errorMessages && { errorMessage: { pattern: message } }\n\t\t});\n\t} else schema.pattern = stringifyRegExpWithFlags(regex, refs);\n}\nfunction stringifyRegExpWithFlags(regex, refs) {\n\tvar _a2;\n\tif (!refs.applyRegexFlags || !regex.flags) return regex.source;\n\tconst flags = {\n\t\ti: regex.flags.includes(\"i\"),\n\t\tm: regex.flags.includes(\"m\"),\n\t\ts: regex.flags.includes(\"s\")\n\t};\n\tconst source = flags.i ? regex.source.toLowerCase() : regex.source;\n\tlet pattern = \"\";\n\tlet isEscaped = false;\n\tlet inCharGroup = false;\n\tlet inCharRange = false;\n\tfor (let i = 0; i < source.length; i++) {\n\t\tif (isEscaped) {\n\t\t\tpattern += source[i];\n\t\t\tisEscaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (flags.i) {\n\t\t\tif (inCharGroup) {\n\t\t\t\tif (source[i].match(/[a-z]/)) {\n\t\t\t\t\tif (inCharRange) {\n\t\t\t\t\t\tpattern += source[i];\n\t\t\t\t\t\tpattern += `${source[i - 2]}-${source[i]}`.toUpperCase();\n\t\t\t\t\t\tinCharRange = false;\n\t\t\t\t\t} else if (source[i + 1] === \"-\" && ((_a2 = source[i + 2]) == null ? void 0 : _a2.match(/[a-z]/))) {\n\t\t\t\t\t\tpattern += source[i];\n\t\t\t\t\t\tinCharRange = true;\n\t\t\t\t\t} else pattern += `${source[i]}${source[i].toUpperCase()}`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else if (source[i].match(/[a-z]/)) {\n\t\t\t\tpattern += `[${source[i]}${source[i].toUpperCase()}]`;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (flags.m) {\n\t\t\tif (source[i] === \"^\") {\n\t\t\t\tpattern += `(^|(?<=[\\r\n]))`;\n\t\t\t\tcontinue;\n\t\t\t} else if (source[i] === \"$\") {\n\t\t\t\tpattern += `($|(?=[\\r\n]))`;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (flags.s && source[i] === \".\") {\n\t\t\tpattern += inCharGroup ? `${source[i]}\\r\n` : `[${source[i]}\\r\n]`;\n\t\t\tcontinue;\n\t\t}\n\t\tpattern += source[i];\n\t\tif (source[i] === \"\\\\\") isEscaped = true;\n\t\telse if (inCharGroup && source[i] === \"]\") inCharGroup = false;\n\t\telse if (!inCharGroup && source[i] === \"[\") inCharGroup = true;\n\t}\n\ttry {\n\t\tnew RegExp(pattern);\n\t} catch (e) {\n\t\tconsole.warn(`Could not convert regex pattern at ${refs.currentPath.join(\"/\")} to a flag-independent form! Falling back to the flag-ignorant source`);\n\t\treturn regex.source;\n\t}\n\treturn pattern;\n}\nfunction parseRecordDef(def, refs) {\n\tvar _a2, _b2, _c, _d, _e, _f;\n\tconst schema = {\n\t\ttype: \"object\",\n\t\tadditionalProperties: (_a2 = parseDef(def.valueType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"additionalProperties\"]\n\t\t})) != null ? _a2 : refs.allowedAdditionalProperties\n\t};\n\tif (((_b2 = def.keyType) == null ? void 0 : _b2._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {\n\t\tconst { type, ...keyType } = parseStringDef(def.keyType._def, refs);\n\t\treturn {\n\t\t\t...schema,\n\t\t\tpropertyNames: keyType\n\t\t};\n\t} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) return {\n\t\t...schema,\n\t\tpropertyNames: { enum: def.keyType._def.values }\n\t};\n\telse if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {\n\t\tconst { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);\n\t\treturn {\n\t\t\t...schema,\n\t\t\tpropertyNames: keyType\n\t\t};\n\t}\n\treturn schema;\n}\nfunction parseMapDef(def, refs) {\n\tif (refs.mapStrategy === \"record\") return parseRecordDef(def, refs);\n\treturn {\n\t\ttype: \"array\",\n\t\tmaxItems: 125,\n\t\titems: {\n\t\t\ttype: \"array\",\n\t\t\titems: [parseDef(def.keyType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"0\"\n\t\t\t\t]\n\t\t\t}) || parseAnyDef(), parseDef(def.valueType._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.currentPath,\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"items\",\n\t\t\t\t\t\"1\"\n\t\t\t\t]\n\t\t\t}) || parseAnyDef()],\n\t\t\tminItems: 2,\n\t\t\tmaxItems: 2\n\t\t}\n\t};\n}\nfunction parseNativeEnumDef(def) {\n\tconst object = def.values;\n\tconst actualValues = Object.keys(def.values).filter((key) => {\n\t\treturn typeof object[object[key]] !== \"number\";\n\t}).map((key) => object[key]);\n\tconst parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));\n\treturn {\n\t\ttype: parsedTypes.length === 1 ? parsedTypes[0] === \"string\" ? \"string\" : \"number\" : [\"string\", \"number\"],\n\t\tenum: actualValues\n\t};\n}\nfunction parseNeverDef() {\n\treturn { not: parseAnyDef() };\n}\nfunction parseNullDef() {\n\treturn { type: \"null\" };\n}\nvar primitiveMappings = {\n\tZodString: \"string\",\n\tZodNumber: \"number\",\n\tZodBigInt: \"integer\",\n\tZodBoolean: \"boolean\",\n\tZodNull: \"null\"\n};\nfunction parseUnionDef(def, refs) {\n\tconst options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;\n\tif (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {\n\t\tconst types = options.reduce((types2, x) => {\n\t\t\tconst type = primitiveMappings[x._def.typeName];\n\t\t\treturn type && !types2.includes(type) ? [...types2, type] : types2;\n\t\t}, []);\n\t\treturn { type: types.length > 1 ? types : types[0] };\n\t} else if (options.every((x) => x._def.typeName === \"ZodLiteral\" && !x.description)) {\n\t\tconst types = options.reduce((acc, x) => {\n\t\t\tconst type = typeof x._def.value;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"string\":\n\t\t\t\tcase \"number\":\n\t\t\t\tcase \"boolean\": return [...acc, type];\n\t\t\t\tcase \"bigint\": return [...acc, \"integer\"];\n\t\t\t\tcase \"object\": if (x._def.value === null) return [...acc, \"null\"];\n\t\t\t\tdefault: return acc;\n\t\t\t}\n\t\t}, []);\n\t\tif (types.length === options.length) {\n\t\t\tconst uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);\n\t\t\treturn {\n\t\t\t\ttype: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],\n\t\t\t\tenum: options.reduce((acc, x) => {\n\t\t\t\t\treturn acc.includes(x._def.value) ? acc : [...acc, x._def.value];\n\t\t\t\t}, [])\n\t\t\t};\n\t\t}\n\t} else if (options.every((x) => x._def.typeName === \"ZodEnum\")) return {\n\t\ttype: \"string\",\n\t\tenum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x2) => !acc.includes(x2))], [])\n\t};\n\treturn asAnyOf(def, refs);\n}\nvar asAnyOf = (def, refs) => {\n\tconst anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t`${i}`\n\t\t]\n\t})).filter((x) => !!x && (!refs.strictUnions || typeof x === \"object\" && Object.keys(x).length > 0));\n\treturn anyOf.length ? { anyOf } : void 0;\n};\nfunction parseNullableDef(def, refs) {\n\tif ([\n\t\t\"ZodString\",\n\t\t\"ZodNumber\",\n\t\t\"ZodBigInt\",\n\t\t\"ZodBoolean\",\n\t\t\"ZodNull\"\n\t].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) return { type: [primitiveMappings[def.innerType._def.typeName], \"null\"] };\n\tconst base = parseDef(def.innerType._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t\"0\"\n\t\t]\n\t});\n\treturn base && { anyOf: [base, { type: \"null\" }] };\n}\nfunction parseNumberDef(def) {\n\tconst res = { type: \"number\" };\n\tif (!def.checks) return res;\n\tfor (const check of def.checks) switch (check.kind) {\n\t\tcase \"int\":\n\t\t\tres.type = \"integer\";\n\t\t\tbreak;\n\t\tcase \"min\":\n\t\t\tif (check.inclusive) res.minimum = check.value;\n\t\t\telse res.exclusiveMinimum = check.value;\n\t\t\tbreak;\n\t\tcase \"max\":\n\t\t\tif (check.inclusive) res.maximum = check.value;\n\t\t\telse res.exclusiveMaximum = check.value;\n\t\t\tbreak;\n\t\tcase \"multipleOf\": res.multipleOf = check.value;\n\t}\n\treturn res;\n}\nfunction parseObjectDef(def, refs) {\n\tconst result = {\n\t\ttype: \"object\",\n\t\tproperties: {}\n\t};\n\tconst required = [];\n\tconst shape = def.shape();\n\tfor (const propName in shape) {\n\t\tlet propDef = shape[propName];\n\t\tif (propDef === void 0 || propDef._def === void 0) continue;\n\t\tconst propOptional = safeIsOptional(propDef);\n\t\tconst parsedDef = parseDef(propDef._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"properties\",\n\t\t\t\tpropName\n\t\t\t],\n\t\t\tpropertyPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"properties\",\n\t\t\t\tpropName\n\t\t\t]\n\t\t});\n\t\tif (parsedDef === void 0) continue;\n\t\tresult.properties[propName] = parsedDef;\n\t\tif (!propOptional) required.push(propName);\n\t}\n\tif (required.length) result.required = required;\n\tconst additionalProperties = decideAdditionalProperties(def, refs);\n\tif (additionalProperties !== void 0) result.additionalProperties = additionalProperties;\n\treturn result;\n}\nfunction decideAdditionalProperties(def, refs) {\n\tif (def.catchall._def.typeName !== \"ZodNever\") return parseDef(def.catchall._def, {\n\t\t...refs,\n\t\tcurrentPath: [...refs.currentPath, \"additionalProperties\"]\n\t});\n\tswitch (def.unknownKeys) {\n\t\tcase \"passthrough\": return refs.allowedAdditionalProperties;\n\t\tcase \"strict\": return refs.rejectedAdditionalProperties;\n\t\tcase \"strip\": return refs.removeAdditionalStrategy === \"strict\" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;\n\t}\n}\nfunction safeIsOptional(schema) {\n\ttry {\n\t\treturn schema.isOptional();\n\t} catch (e) {\n\t\treturn true;\n\t}\n}\nvar parseOptionalDef = (def, refs) => {\n\tvar _a2;\n\tif (refs.currentPath.toString() === ((_a2 = refs.propertyPath) == null ? void 0 : _a2.toString())) return parseDef(def.innerType._def, refs);\n\tconst innerSchema = parseDef(def.innerType._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"anyOf\",\n\t\t\t\"1\"\n\t\t]\n\t});\n\treturn innerSchema ? { anyOf: [{ not: parseAnyDef() }, innerSchema] } : parseAnyDef();\n};\nvar parsePipelineDef = (def, refs) => {\n\tif (refs.pipeStrategy === \"input\") return parseDef(def.in._def, refs);\n\telse if (refs.pipeStrategy === \"output\") return parseDef(def.out._def, refs);\n\tconst a = parseDef(def.in._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\t\"0\"\n\t\t]\n\t});\n\treturn { allOf: [a, parseDef(def.out._def, {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.currentPath,\n\t\t\t\"allOf\",\n\t\t\ta ? \"1\" : \"0\"\n\t\t]\n\t})].filter((x) => x !== void 0) };\n};\nfunction parsePromiseDef(def, refs) {\n\treturn parseDef(def.type._def, refs);\n}\nfunction parseSetDef(def, refs) {\n\tconst schema = {\n\t\ttype: \"array\",\n\t\tuniqueItems: true,\n\t\titems: parseDef(def.valueType._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"items\"]\n\t\t})\n\t};\n\tif (def.minSize) schema.minItems = def.minSize.value;\n\tif (def.maxSize) schema.maxItems = def.maxSize.value;\n\treturn schema;\n}\nfunction parseTupleDef(def, refs) {\n\tif (def.rest) return {\n\t\ttype: \"array\",\n\t\tminItems: def.items.length,\n\t\titems: def.items.map((x, i) => parseDef(x._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"items\",\n\t\t\t\t`${i}`\n\t\t\t]\n\t\t})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),\n\t\tadditionalItems: parseDef(def.rest._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [...refs.currentPath, \"additionalItems\"]\n\t\t})\n\t};\n\telse return {\n\t\ttype: \"array\",\n\t\tminItems: def.items.length,\n\t\tmaxItems: def.items.length,\n\t\titems: def.items.map((x, i) => parseDef(x._def, {\n\t\t\t...refs,\n\t\t\tcurrentPath: [\n\t\t\t\t...refs.currentPath,\n\t\t\t\t\"items\",\n\t\t\t\t`${i}`\n\t\t\t]\n\t\t})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])\n\t};\n}\nfunction parseUndefinedDef() {\n\treturn { not: parseAnyDef() };\n}\nfunction parseUnknownDef() {\n\treturn parseAnyDef();\n}\nvar parseReadonlyDef = (def, refs) => {\n\treturn parseDef(def.innerType._def, refs);\n};\nvar selectParser = (def, typeName, refs) => {\n\tswitch (typeName) {\n\t\tcase ZodFirstPartyTypeKind.ZodString: return parseStringDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNumber: return parseNumberDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodObject: return parseObjectDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBigInt: return parseBigintDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodBoolean: return parseBooleanDef();\n\t\tcase ZodFirstPartyTypeKind.ZodDate: return parseDateDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUndefined: return parseUndefinedDef();\n\t\tcase ZodFirstPartyTypeKind.ZodNull: return parseNullDef();\n\t\tcase ZodFirstPartyTypeKind.ZodArray: return parseArrayDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodUnion:\n\t\tcase ZodFirstPartyTypeKind.ZodDiscriminatedUnion: return parseUnionDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodIntersection: return parseIntersectionDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodTuple: return parseTupleDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodRecord: return parseRecordDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodLiteral: return parseLiteralDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodEnum: return parseEnumDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodNativeEnum: return parseNativeEnumDef(def);\n\t\tcase ZodFirstPartyTypeKind.ZodNullable: return parseNullableDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodLazy: return () => def.getter()._def;\n\t\tcase ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodNaN:\n\t\tcase ZodFirstPartyTypeKind.ZodNever: return parseNeverDef();\n\t\tcase ZodFirstPartyTypeKind.ZodEffects: return parseEffectsDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodAny: return parseAnyDef();\n\t\tcase ZodFirstPartyTypeKind.ZodUnknown: return parseUnknownDef();\n\t\tcase ZodFirstPartyTypeKind.ZodDefault: return parseDefaultDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodBranded: return parseBrandedDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodReadonly: return parseReadonlyDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodCatch: return parseCatchDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodPipeline: return parsePipelineDef(def, refs);\n\t\tcase ZodFirstPartyTypeKind.ZodFunction:\n\t\tcase ZodFirstPartyTypeKind.ZodVoid:\n\t\tcase ZodFirstPartyTypeKind.ZodSymbol: return;\n\t\tdefault: return /* @__PURE__ */ ((_) => void 0)(typeName);\n\t}\n};\nvar getRelativePath = (pathA, pathB) => {\n\tlet i = 0;\n\tfor (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;\n\treturn [(pathA.length - i).toString(), ...pathB.slice(i)].join(\"/\");\n};\nfunction parseDef(def, refs, forceResolution = false) {\n\tvar _a2;\n\tconst seenItem = refs.seen.get(def);\n\tif (refs.override) {\n\t\tconst overrideResult = (_a2 = refs.override) == null ? void 0 : _a2.call(refs, def, refs, seenItem, forceResolution);\n\t\tif (overrideResult !== ignoreOverride) return overrideResult;\n\t}\n\tif (seenItem && !forceResolution) {\n\t\tconst seenSchema = get$ref(seenItem, refs);\n\t\tif (seenSchema !== void 0) return seenSchema;\n\t}\n\tconst newItem = {\n\t\tdef,\n\t\tpath: refs.currentPath,\n\t\tjsonSchema: void 0\n\t};\n\trefs.seen.set(def, newItem);\n\tconst jsonSchemaOrGetter = selectParser(def, def.typeName, refs);\n\tconst jsonSchema2 = typeof jsonSchemaOrGetter === \"function\" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;\n\tif (jsonSchema2) addMeta(def, refs, jsonSchema2);\n\tif (refs.postProcess) {\n\t\tconst postProcessResult = refs.postProcess(jsonSchema2, def, refs);\n\t\tnewItem.jsonSchema = jsonSchema2;\n\t\treturn postProcessResult;\n\t}\n\tnewItem.jsonSchema = jsonSchema2;\n\treturn jsonSchema2;\n}\nvar get$ref = (item, refs) => {\n\tswitch (refs.$refStrategy) {\n\t\tcase \"root\": return { $ref: item.path.join(\"/\") };\n\t\tcase \"relative\": return { $ref: getRelativePath(refs.currentPath, item.path) };\n\t\tcase \"none\":\n\t\tcase \"seen\":\n\t\t\tif (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {\n\t\t\t\tconsole.warn(`Recursive reference detected at ${refs.currentPath.join(\"/\")}! Defaulting to any`);\n\t\t\t\treturn parseAnyDef();\n\t\t\t}\n\t\t\treturn refs.$refStrategy === \"seen\" ? parseAnyDef() : void 0;\n\t}\n};\nvar addMeta = (def, refs, jsonSchema2) => {\n\tif (def.description) jsonSchema2.description = def.description;\n\treturn jsonSchema2;\n};\nvar getRefs = (options) => {\n\tconst _options = getDefaultOptions(options);\n\tconst currentPath = _options.name !== void 0 ? [\n\t\t..._options.basePath,\n\t\t_options.definitionPath,\n\t\t_options.name\n\t] : _options.basePath;\n\treturn {\n\t\t..._options,\n\t\tcurrentPath,\n\t\tpropertyPath: void 0,\n\t\tseen: new Map(Object.entries(_options.definitions).map(([name2, def]) => [def._def, {\n\t\t\tdef: def._def,\n\t\t\tpath: [\n\t\t\t\t..._options.basePath,\n\t\t\t\t_options.definitionPath,\n\t\t\t\tname2\n\t\t\t],\n\t\t\tjsonSchema: void 0\n\t\t}]))\n\t};\n};\nvar zod3ToJsonSchema = (schema, options) => {\n\tvar _a2;\n\tconst refs = getRefs(options);\n\tlet definitions = typeof options === \"object\" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name3, schema2]) => {\n\t\tvar _a3;\n\t\treturn {\n\t\t\t...acc,\n\t\t\t[name3]: (_a3 = parseDef(schema2._def, {\n\t\t\t\t...refs,\n\t\t\t\tcurrentPath: [\n\t\t\t\t\t...refs.basePath,\n\t\t\t\t\trefs.definitionPath,\n\t\t\t\t\tname3\n\t\t\t\t]\n\t\t\t}, true)) != null ? _a3 : parseAnyDef()\n\t\t};\n\t}, {}) : void 0;\n\tconst name2 = typeof options === \"string\" ? options : (options == null ? void 0 : options.nameStrategy) === \"title\" ? void 0 : options == null ? void 0 : options.name;\n\tconst main = (_a2 = parseDef(schema._def, name2 === void 0 ? refs : {\n\t\t...refs,\n\t\tcurrentPath: [\n\t\t\t...refs.basePath,\n\t\t\trefs.definitionPath,\n\t\t\tname2\n\t\t]\n\t}, false)) != null ? _a2 : parseAnyDef();\n\tconst title = typeof options === \"object\" && options.name !== void 0 && options.nameStrategy === \"title\" ? options.name : void 0;\n\tif (title !== void 0) main.title = title;\n\tconst combined = name2 === void 0 ? definitions ? {\n\t\t...main,\n\t\t[refs.definitionPath]: definitions\n\t} : main : {\n\t\t$ref: [\n\t\t\t...refs.$refStrategy === \"relative\" ? [] : refs.basePath,\n\t\t\trefs.definitionPath,\n\t\t\tname2\n\t\t].join(\"/\"),\n\t\t[refs.definitionPath]: {\n\t\t\t...definitions,\n\t\t\t[name2]: main\n\t\t}\n\t};\n\tcombined.$schema = \"http://json-schema.org/draft-07/schema#\";\n\treturn combined;\n};\nvar schemaSymbol = /* @__PURE__ */ Symbol.for(\"vercel.ai.schema\");\nfunction lazySchema(createSchema) {\n\tlet schema;\n\treturn () => {\n\t\tif (schema == null) schema = createSchema();\n\t\treturn schema;\n\t};\n}\nfunction jsonSchema(jsonSchema2, { validate } = {}) {\n\treturn {\n\t\t[schemaSymbol]: true,\n\t\t_type: void 0,\n\t\tget jsonSchema() {\n\t\t\tif (typeof jsonSchema2 === \"function\") jsonSchema2 = jsonSchema2();\n\t\t\treturn jsonSchema2;\n\t\t},\n\t\tvalidate\n\t};\n}\nfunction isSchema(value) {\n\treturn typeof value === \"object\" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && \"jsonSchema\" in value && \"validate\" in value;\n}\nfunction asSchema(schema) {\n\treturn schema == null ? jsonSchema({\n\t\ttype: \"object\",\n\t\tproperties: {},\n\t\tadditionalProperties: false\n\t}) : isSchema(schema) ? schema : \"~standard\" in schema ? schema[\"~standard\"].vendor === \"zod\" ? zodSchema(schema) : standardSchema(schema) : schema();\n}\nfunction standardSchema(standardSchema2) {\n\treturn jsonSchema(() => {\n\t\tif (!hasStandardJsonSchema(standardSchema2)) throw new Error(`Standard schema vendor '${standardSchema2[\"~standard\"].vendor}' does not support JSON Schema conversion.`);\n\t\treturn addAdditionalPropertiesToJsonSchema(standardSchema2[\"~standard\"].jsonSchema.input({ target: \"draft-07\" }));\n\t}, { validate: async (value) => {\n\t\tconst result = await standardSchema2[\"~standard\"].validate(value);\n\t\treturn \"value\" in result ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.value\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: new TypeValidationError({\n\t\t\t\tvalue,\n\t\t\t\tcause: result.issues\n\t\t\t})\n\t\t};\n\t} });\n}\nfunction hasStandardJsonSchema(schema) {\n\treturn schema[\"~standard\"].jsonSchema != null;\n}\nfunction zod3Schema(zodSchema2, options) {\n\tvar _a2;\n\tconst useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;\n\treturn jsonSchema(() => zod3ToJsonSchema(zodSchema2, { $refStrategy: useReferences ? \"root\" : \"none\" }), { validate: async (value) => {\n\t\tconst result = await zodSchema2.safeParseAsync(value);\n\t\treturn result.success ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.data\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: result.error\n\t\t};\n\t} });\n}\nfunction zod4Schema(zodSchema2, options) {\n\tvar _a2;\n\tconst useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;\n\treturn jsonSchema(() => addAdditionalPropertiesToJsonSchema(z4.toJSONSchema(zodSchema2, {\n\t\ttarget: \"draft-7\",\n\t\tio: \"input\",\n\t\treused: useReferences ? \"ref\" : \"inline\"\n\t})), { validate: async (value) => {\n\t\tconst result = await z4.safeParseAsync(zodSchema2, value);\n\t\treturn result.success ? {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.data\n\t\t} : {\n\t\t\tsuccess: false,\n\t\t\terror: result.error\n\t\t};\n\t} });\n}\nfunction isZod4Schema(zodSchema2) {\n\treturn \"_zod\" in zodSchema2;\n}\nfunction zodSchema(zodSchema2, options) {\n\tif (isZod4Schema(zodSchema2)) return zod4Schema(zodSchema2, options);\n\telse return zod3Schema(zodSchema2, options);\n}\nasync function validateTypes({ value, schema, context }) {\n\tconst result = await safeValidateTypes({\n\t\tvalue,\n\t\tschema,\n\t\tcontext\n\t});\n\tif (!result.success) throw TypeValidationError.wrap({\n\t\tvalue,\n\t\tcause: result.error,\n\t\tcontext\n\t});\n\treturn result.value;\n}\nasync function safeValidateTypes({ value, schema, context }) {\n\tconst actualSchema = asSchema(schema);\n\ttry {\n\t\tif (actualSchema.validate == null) return {\n\t\t\tsuccess: true,\n\t\t\tvalue,\n\t\t\trawValue: value\n\t\t};\n\t\tconst result = await actualSchema.validate(value);\n\t\tif (result.success) return {\n\t\t\tsuccess: true,\n\t\t\tvalue: result.value,\n\t\t\trawValue: value\n\t\t};\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: TypeValidationError.wrap({\n\t\t\t\tvalue,\n\t\t\t\tcause: result.error,\n\t\t\t\tcontext\n\t\t\t}),\n\t\t\trawValue: value\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: TypeValidationError.wrap({\n\t\t\t\tvalue,\n\t\t\t\tcause: error,\n\t\t\t\tcontext\n\t\t\t}),\n\t\t\trawValue: value\n\t\t};\n\t}\n}\nasync function parseJSON({ text, schema }) {\n\ttry {\n\t\tconst value = secureJsonParse(text);\n\t\tif (schema == null) return value;\n\t\treturn validateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t} catch (error) {\n\t\tif (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) throw error;\n\t\tthrow new JSONParseError({\n\t\t\ttext,\n\t\t\tcause: error\n\t\t});\n\t}\n}\nasync function safeParseJSON({ text, schema }) {\n\ttry {\n\t\tconst value = secureJsonParse(text);\n\t\tif (schema == null) return {\n\t\t\tsuccess: true,\n\t\t\tvalue,\n\t\t\trawValue: value\n\t\t};\n\t\treturn await safeValidateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: JSONParseError.isInstance(error) ? error : new JSONParseError({\n\t\t\t\ttext,\n\t\t\t\tcause: error\n\t\t\t}),\n\t\t\trawValue: void 0\n\t\t};\n\t}\n}\nfunction parseJsonEventStream({ stream, schema }) {\n\treturn stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(new TransformStream({ async transform({ data }, controller) {\n\t\tif (data === \"[DONE]\") return;\n\t\tcontroller.enqueue(await safeParseJSON({\n\t\t\ttext: data,\n\t\t\tschema\n\t\t}));\n\t} }));\n}\nvar getOriginalFetch2 = () => globalThis.fetch;\nvar postJsonToApi = async ({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch }) => postToApi({\n\turl,\n\theaders: {\n\t\t\"Content-Type\": \"application/json\",\n\t\t...headers\n\t},\n\tbody: {\n\t\tcontent: JSON.stringify(body),\n\t\tvalues: body\n\t},\n\tfailedResponseHandler,\n\tsuccessfulResponseHandler,\n\tabortSignal,\n\tfetch\n});\nvar postToApi = async ({ url, headers = {}, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch2() }) => {\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: withUserAgentSuffix(headers, `ai-sdk/provider-utils/${VERSION}`, getRuntimeEnvironmentUserAgent()),\n\t\t\tbody: body.content,\n\t\t\tsignal: abortSignal\n\t\t});\n\t\tconst responseHeaders = extractResponseHeaders(response);\n\t\tif (!response.ok) {\n\t\t\tlet errorInformation;\n\t\t\ttry {\n\t\t\t\terrorInformation = await failedResponseHandler({\n\t\t\t\t\tresponse,\n\t\t\t\t\turl,\n\t\t\t\t\trequestBodyValues: body.values\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t\tthrow new APICallError({\n\t\t\t\t\tmessage: \"Failed to process error response\",\n\t\t\t\t\tcause: error,\n\t\t\t\t\tstatusCode: response.status,\n\t\t\t\t\turl,\n\t\t\t\t\tresponseHeaders,\n\t\t\t\t\trequestBodyValues: body.values\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow errorInformation.value;\n\t\t}\n\t\ttry {\n\t\t\treturn await successfulResponseHandler({\n\t\t\t\tresponse,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues: body.values\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tif (isAbortError(error) || APICallError.isInstance(error)) throw error;\n\t\t\t}\n\t\t\tthrow new APICallError({\n\t\t\t\tmessage: \"Failed to process successful response\",\n\t\t\t\tcause: error,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\turl,\n\t\t\t\tresponseHeaders,\n\t\t\t\trequestBodyValues: body.values\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tthrow handleFetchError({\n\t\t\terror,\n\t\t\turl,\n\t\t\trequestBodyValues: body.values\n\t\t});\n\t}\n};\nfunction tool(tool2) {\n\treturn tool2;\n}\nfunction dynamicTool(tool2) {\n\treturn {\n\t\t...tool2,\n\t\ttype: \"dynamic\"\n\t};\n}\nfunction createProviderToolFactoryWithOutputSchema({ id, inputSchema, outputSchema, supportsDeferredResults }) {\n\treturn ({ execute, needsApproval, toModelOutput, onInputStart, onInputDelta, onInputAvailable, ...args }) => tool({\n\t\ttype: \"provider\",\n\t\tid,\n\t\targs,\n\t\tinputSchema,\n\t\toutputSchema,\n\t\texecute,\n\t\tneedsApproval,\n\t\ttoModelOutput,\n\t\tonInputStart,\n\t\tonInputDelta,\n\t\tonInputAvailable,\n\t\tsupportsDeferredResults\n\t});\n}\nasync function resolve(value) {\n\tif (typeof value === \"function\") value = value();\n\treturn value;\n}\nvar retryWithExponentialBackoff = ({ maxRetries = 2, initialDelayInMs = 2e3, backoffFactor = 2, abortSignal, shouldRetry, getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay, createRetryError = ({ message }) => new Error(message) }) => async (f) => retryWithExponentialBackoffInternal(f, {\n\tmaxRetries,\n\tdelayInMs: initialDelayInMs,\n\tbackoffFactor,\n\tabortSignal,\n\tshouldRetry,\n\tgetDelayInMs,\n\tcreateRetryError\n});\nasync function retryWithExponentialBackoffInternal(f, { maxRetries, delayInMs, backoffFactor, abortSignal, shouldRetry, getDelayInMs, createRetryError }, errors = []) {\n\ttry {\n\t\treturn await f();\n\t} catch (error) {\n\t\tif (isAbortError(error)) throw error;\n\t\tif (maxRetries === 0) throw error;\n\t\tconst errorMessage = getErrorMessage(error);\n\t\tconst newErrors = [...errors, error];\n\t\tconst tryNumber = newErrors.length;\n\t\tif (tryNumber > maxRetries) throw createRetryError({\n\t\t\tmessage: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,\n\t\t\treason: \"maxRetriesExceeded\",\n\t\t\terrors: newErrors\n\t\t});\n\t\tif (await shouldRetry(error) && tryNumber <= maxRetries) {\n\t\t\tawait delay(getDelayInMs({\n\t\t\t\terror,\n\t\t\t\texponentialBackoffDelay: delayInMs\n\t\t\t}), { abortSignal });\n\t\t\treturn retryWithExponentialBackoffInternal(f, {\n\t\t\t\tmaxRetries,\n\t\t\t\tdelayInMs: backoffFactor * delayInMs,\n\t\t\t\tbackoffFactor,\n\t\t\t\tabortSignal,\n\t\t\t\tshouldRetry,\n\t\t\t\tgetDelayInMs,\n\t\t\t\tcreateRetryError\n\t\t\t}, newErrors);\n\t\t}\n\t\tif (tryNumber === 1) throw error;\n\t\tthrow createRetryError({\n\t\t\tmessage: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,\n\t\t\treason: \"errorNotRetryable\",\n\t\t\terrors: newErrors\n\t\t});\n\t}\n}\nvar textDecoder = new TextDecoder();\nfunction wrapResponseBodyStream({ stream, url, requestBodyValues, statusCode, responseHeaders }) {\n\tconst reader = stream.getReader();\n\tlet readerReleased = false;\n\tconst releaseReader = () => {\n\t\tif (!readerReleased) {\n\t\t\treader.releaseLock();\n\t\t\treaderReleased = true;\n\t\t}\n\t};\n\treturn new ReadableStream({\n\t\tasync pull(controller) {\n\t\t\ttry {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\treleaseReader();\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else controller.enqueue(value);\n\t\t\t} catch (error) {\n\t\t\t\treleaseReader();\n\t\t\t\tif (isAbortError(error)) {\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcontroller.error(handleFetchError({\n\t\t\t\t\terror: new APICallError({\n\t\t\t\t\t\tmessage: \"Failed to process successful response\",\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\tstatusCode,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tresponseHeaders,\n\t\t\t\t\t\trequestBodyValues\n\t\t\t\t\t}),\n\t\t\t\t\turl,\n\t\t\t\t\trequestBodyValues\n\t\t\t\t}));\n\t\t\t}\n\t\t},\n\t\tasync cancel(reason) {\n\t\t\ttry {\n\t\t\t\tawait reader.cancel(reason);\n\t\t\t} finally {\n\t\t\t\treleaseReader();\n\t\t\t}\n\t\t}\n\t});\n}\nasync function readResponseBodyAsText({ response, url }) {\n\treturn textDecoder.decode(await readResponseWithSizeLimit({\n\t\tresponse,\n\t\turl\n\t}));\n}\nvar createJsonErrorResponseHandler = ({ errorSchema, errorToMessage, isRetryable }) => async ({ response, url, requestBodyValues }) => {\n\tconst responseBody = await readResponseBodyAsText({\n\t\tresponse,\n\t\turl\n\t});\n\tconst responseHeaders = extractResponseHeaders(response);\n\tif (responseBody.trim() === \"\") return {\n\t\tresponseHeaders,\n\t\tvalue: new APICallError({\n\t\t\tmessage: response.statusText,\n\t\t\turl,\n\t\t\trequestBodyValues,\n\t\t\tstatusCode: response.status,\n\t\t\tresponseHeaders,\n\t\t\tresponseBody,\n\t\t\tisRetryable: isRetryable == null ? void 0 : isRetryable(response)\n\t\t})\n\t};\n\ttry {\n\t\tconst parsedError = await parseJSON({\n\t\t\ttext: responseBody,\n\t\t\tschema: errorSchema\n\t\t});\n\t\treturn {\n\t\t\tresponseHeaders,\n\t\t\tvalue: new APICallError({\n\t\t\t\tmessage: errorToMessage(parsedError),\n\t\t\t\turl,\n\t\t\t\trequestBodyValues,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tresponseHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tdata: parsedError,\n\t\t\t\tisRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)\n\t\t\t})\n\t\t};\n\t} catch (parseError) {\n\t\treturn {\n\t\t\tresponseHeaders,\n\t\t\tvalue: new APICallError({\n\t\t\t\tmessage: response.statusText,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tresponseHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tisRetryable: isRetryable == null ? void 0 : isRetryable(response)\n\t\t\t})\n\t\t};\n\t}\n};\nvar createEventSourceResponseHandler = (chunkSchema) => async ({ response, url, requestBodyValues }) => {\n\tconst responseHeaders = extractResponseHeaders(response);\n\tif (response.body == null) throw new EmptyResponseBodyError({});\n\treturn {\n\t\tresponseHeaders,\n\t\tvalue: parseJsonEventStream({\n\t\t\tstream: wrapResponseBodyStream({\n\t\t\t\tstream: response.body,\n\t\t\t\turl,\n\t\t\t\trequestBodyValues,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tresponseHeaders\n\t\t\t}),\n\t\t\tschema: chunkSchema\n\t\t})\n\t};\n};\nvar createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {\n\tconst responseBody = await readResponseBodyAsText({\n\t\tresponse,\n\t\turl\n\t});\n\tconst parsedResult = await safeParseJSON({\n\t\ttext: responseBody,\n\t\tschema: responseSchema\n\t});\n\tconst responseHeaders = extractResponseHeaders(response);\n\tif (!parsedResult.success) throw new APICallError({\n\t\tmessage: \"Invalid JSON response\",\n\t\tcause: parsedResult.error,\n\t\tstatusCode: response.status,\n\t\tresponseHeaders,\n\t\tresponseBody,\n\t\turl,\n\t\trequestBodyValues\n\t});\n\treturn {\n\t\tresponseHeaders,\n\t\tvalue: parsedResult.value,\n\t\trawValue: parsedResult.rawValue\n\t};\n};\nfunction withoutTrailingSlash(url) {\n\treturn url == null ? void 0 : url.replace(/\\/$/, \"\");\n}\nfunction isAsyncIterable(obj) {\n\treturn obj != null && typeof obj[Symbol.asyncIterator] === \"function\";\n}\nasync function* executeTool({ execute, input, options }) {\n\tconst result = execute(input, options);\n\tif (isAsyncIterable(result)) {\n\t\tlet lastOutput;\n\t\tfor await (const output of result) {\n\t\t\tlastOutput = output;\n\t\t\tyield {\n\t\t\t\ttype: \"preliminary\",\n\t\t\t\toutput\n\t\t\t};\n\t\t}\n\t\tyield {\n\t\t\ttype: \"final\",\n\t\t\toutput: lastOutput\n\t\t};\n\t} else yield {\n\t\ttype: \"final\",\n\t\toutput: await result\n\t};\n}\n//#endregion\nexport { LoadSettingError as $, loadOptionalSetting as A, tool as B, getFromApi as C, isUrlSupported as D, isNonNullable as E, resolve as F, AISDKError as G, withUserAgentSuffix as H, retryWithExponentialBackoff as I, InvalidArgumentError as J, APICallError as K, safeParseJSON as L, parseJsonEventStream as M, postJsonToApi as N, jsonSchema as O, readResponseWithSizeLimit as P, LoadAPIKeyError as Q, safeValidateTypes as R, getErrorMessage as S, isAbortError as T, withoutTrailingSlash as U, validateTypes as V, zodSchema as W, InvalidResponseDataError as X, InvalidPromptError as Y, JSONParseError as Z, delay as _, EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as a, getErrorMessage$1 as at, fetchWithValidatedRedirects as b, combineHeaders as c, convertUint8ArrayToBase64 as d, NoContentGeneratedError as et, createEventSourceResponseHandler as f, createProviderToolFactoryWithOutputSchema as g, createJsonResponseHandler as h, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as i, UnsupportedFunctionalityError as it, normalizeHeaders as j, lazySchema as k, convertAsyncIteratorToReadableStream as l, createJsonErrorResponseHandler as m, DelayedPromise as n, TooManyEmbeddingValuesForCallError as nt, asSchema as o, isJSONArray as ot, createIdGenerator as p, EmptyResponseBodyError as q, DownloadError as r, TypeValidationError as rt, cancelResponseBody as s, isJSONObject as st, DEFAULT_MAX_DOWNLOAD_SIZE as t, NoSuchModelError as tt, convertBase64ToUint8Array as u, dynamicTool as v, getRuntimeEnvironmentUserAgent as w, generateId as x, executeTool as y, secureJsonParse as z };\n\n//# sourceMappingURL=dist-B3lfSiDN.js.map","import { $ as LoadSettingError, B as tool, D as isUrlSupported, E as isNonNullable, F as resolve, G as AISDKError, H as withUserAgentSuffix, I as retryWithExponentialBackoff, J as InvalidArgumentError$1, K as APICallError, L as safeParseJSON, M as parseJsonEventStream, O as jsonSchema, P as readResponseWithSizeLimit, Q as LoadAPIKeyError, R as safeValidateTypes, S as getErrorMessage$1, T as isAbortError, V as validateTypes, W as zodSchema, X as InvalidResponseDataError, Y as InvalidPromptError, Z as JSONParseError, _ as delay, a as EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, at as getErrorMessage, b as fetchWithValidatedRedirects, d as convertUint8ArrayToBase64, et as NoContentGeneratedError, i as EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, it as UnsupportedFunctionalityError, j as normalizeHeaders, k as lazySchema, n as DelayedPromise, nt as TooManyEmbeddingValuesForCallError, o as asSchema, ot as isJSONArray, p as createIdGenerator, q as EmptyResponseBodyError, r as DownloadError, rt as TypeValidationError, s as cancelResponseBody, st as isJSONObject, t as DEFAULT_MAX_DOWNLOAD_SIZE, tt as NoSuchModelError, u as convertBase64ToUint8Array, v as dynamicTool, w as getRuntimeEnvironmentUserAgent, x as generateId, y as executeTool } from \"./dist-B3lfSiDN.js\";\nimport { i as gateway, n as GatewayError, r as createGatewayProvider, t as GatewayAuthenticationError } from \"./dist-rhpKBqPL.js\";\nimport { z } from \"zod/v4\";\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/version.js\nconst VERSION$1 = \"1.9.1\";\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/internal/semver.js\nconst re = /^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;\n/**\n* Create a function to test an API version to see if it is compatible with the provided ownVersion.\n*\n* The returned function has the following semantics:\n* - Exact match is always compatible\n* - Major versions must match exactly\n*    - 1.x package cannot use global 2.x package\n*    - 2.x package cannot use global 1.x package\n* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n*    - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n*    - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n* - Patch and build tag differences are not considered at this time\n*\n* @param ownVersion version which should be checked against\n*/\nfunction _makeCompatibilityCheck(ownVersion) {\n\tconst acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);\n\tconst rejectedVersions = /* @__PURE__ */ new Set();\n\tconst myVersionMatch = ownVersion.match(re);\n\tif (!myVersionMatch) return () => false;\n\tconst ownVersionParsed = {\n\t\tmajor: +myVersionMatch[1],\n\t\tminor: +myVersionMatch[2],\n\t\tpatch: +myVersionMatch[3],\n\t\tprerelease: myVersionMatch[4]\n\t};\n\tif (ownVersionParsed.prerelease != null) return function isExactmatch(globalVersion) {\n\t\treturn globalVersion === ownVersion;\n\t};\n\tfunction _reject(v) {\n\t\trejectedVersions.add(v);\n\t\treturn false;\n\t}\n\tfunction _accept(v) {\n\t\tacceptedVersions.add(v);\n\t\treturn true;\n\t}\n\treturn function isCompatible(globalVersion) {\n\t\tif (acceptedVersions.has(globalVersion)) return true;\n\t\tif (rejectedVersions.has(globalVersion)) return false;\n\t\tconst globalVersionMatch = globalVersion.match(re);\n\t\tif (!globalVersionMatch) return _reject(globalVersion);\n\t\tconst globalVersionParsed = {\n\t\t\tmajor: +globalVersionMatch[1],\n\t\t\tminor: +globalVersionMatch[2],\n\t\t\tpatch: +globalVersionMatch[3],\n\t\t\tprerelease: globalVersionMatch[4]\n\t\t};\n\t\tif (globalVersionParsed.prerelease != null) return _reject(globalVersion);\n\t\tif (ownVersionParsed.major !== globalVersionParsed.major) return _reject(globalVersion);\n\t\tif (ownVersionParsed.major === 0) {\n\t\t\tif (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) return _accept(globalVersion);\n\t\t\treturn _reject(globalVersion);\n\t\t}\n\t\tif (ownVersionParsed.minor <= globalVersionParsed.minor) return _accept(globalVersion);\n\t\treturn _reject(globalVersion);\n\t};\n}\n/**\n* Test an API version to see if it is compatible with this API.\n*\n* - Exact match is always compatible\n* - Major versions must match exactly\n*    - 1.x package cannot use global 2.x package\n*    - 2.x package cannot use global 1.x package\n* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n*    - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n*    - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n* - Patch and build tag differences are not considered at this time\n*\n* @param version version of the API requesting an instance of the global API\n*/\nconst isCompatible = _makeCompatibilityCheck(VERSION$1);\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js\nconst major = VERSION$1.split(\".\")[0];\nconst GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);\nconst _global = typeof globalThis === \"object\" ? globalThis : typeof self === \"object\" ? self : typeof window === \"object\" ? window : typeof global === \"object\" ? global : {};\nfunction registerGlobal(type, instance, diag, allowOverride = false) {\n\tvar _a;\n\tconst api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : { version: VERSION$1 };\n\tif (!allowOverride && api[type]) {\n\t\tconst err = /* @__PURE__ */ new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);\n\t\tdiag.error(err.stack || err.message);\n\t\treturn false;\n\t}\n\tif (api.version !== \"1.9.1\") {\n\t\tconst err = /* @__PURE__ */ new Error(`@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION$1}`);\n\t\tdiag.error(err.stack || err.message);\n\t\treturn false;\n\t}\n\tapi[type] = instance;\n\tdiag.debug(`@opentelemetry/api: Registered a global for ${type} v${VERSION$1}.`);\n\treturn true;\n}\nfunction getGlobal(type) {\n\tvar _a, _b;\n\tconst globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;\n\tif (!globalVersion || !isCompatible(globalVersion)) return;\n\treturn (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];\n}\nfunction unregisterGlobal(type, diag) {\n\tdiag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${VERSION$1}.`);\n\tconst api = _global[GLOBAL_OPENTELEMETRY_API_KEY];\n\tif (api) delete api[type];\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js\n/**\n* Component Logger which is meant to be used as part of any component which\n* will add automatically additional namespace in front of the log message.\n* It will then forward all message to global diag logger\n* @example\n* const cLogger = diag.createComponentLogger({ namespace: '@opentelemetry/instrumentation-http' });\n* cLogger.debug('test');\n* // @opentelemetry/instrumentation-http test\n*/\nvar DiagComponentLogger = class {\n\tconstructor(props) {\n\t\tthis._namespace = props.namespace || \"DiagComponentLogger\";\n\t}\n\tdebug(...args) {\n\t\treturn logProxy(\"debug\", this._namespace, args);\n\t}\n\terror(...args) {\n\t\treturn logProxy(\"error\", this._namespace, args);\n\t}\n\tinfo(...args) {\n\t\treturn logProxy(\"info\", this._namespace, args);\n\t}\n\twarn(...args) {\n\t\treturn logProxy(\"warn\", this._namespace, args);\n\t}\n\tverbose(...args) {\n\t\treturn logProxy(\"verbose\", this._namespace, args);\n\t}\n};\nfunction logProxy(funcName, namespace, args) {\n\tconst logger = getGlobal(\"diag\");\n\tif (!logger) return;\n\treturn logger[funcName](namespace, ...args);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/diag/types.js\n/**\n* Defines the available internal logging levels for the diagnostic logger, the numeric values\n* of the levels are defined to match the original values from the initial LogLevel to avoid\n* compatibility/migration issues for any implementation that assume the numeric ordering.\n*/\nvar DiagLogLevel;\n(function(DiagLogLevel) {\n\t/** Diagnostic Logging level setting to disable all logging (except and forced logs) */\n\tDiagLogLevel[DiagLogLevel[\"NONE\"] = 0] = \"NONE\";\n\t/** Identifies an error scenario */\n\tDiagLogLevel[DiagLogLevel[\"ERROR\"] = 30] = \"ERROR\";\n\t/** Identifies a warning scenario */\n\tDiagLogLevel[DiagLogLevel[\"WARN\"] = 50] = \"WARN\";\n\t/** General informational log message */\n\tDiagLogLevel[DiagLogLevel[\"INFO\"] = 60] = \"INFO\";\n\t/** General debug log message */\n\tDiagLogLevel[DiagLogLevel[\"DEBUG\"] = 70] = \"DEBUG\";\n\t/**\n\t* Detailed trace level logging should only be used for development, should only be set\n\t* in a development environment.\n\t*/\n\tDiagLogLevel[DiagLogLevel[\"VERBOSE\"] = 80] = \"VERBOSE\";\n\t/** Used to set the logging level to include all logging */\n\tDiagLogLevel[DiagLogLevel[\"ALL\"] = 9999] = \"ALL\";\n})(DiagLogLevel || (DiagLogLevel = {}));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js\nfunction createLogLevelDiagLogger(maxLevel, logger) {\n\tif (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;\n\telse if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;\n\tlogger = logger || {};\n\tfunction _filterFunc(funcName, theLevel) {\n\t\tconst theFunc = logger[funcName];\n\t\tif (typeof theFunc === \"function\" && maxLevel >= theLevel) return theFunc.bind(logger);\n\t\treturn function() {};\n\t}\n\treturn {\n\t\terror: _filterFunc(\"error\", DiagLogLevel.ERROR),\n\t\twarn: _filterFunc(\"warn\", DiagLogLevel.WARN),\n\t\tinfo: _filterFunc(\"info\", DiagLogLevel.INFO),\n\t\tdebug: _filterFunc(\"debug\", DiagLogLevel.DEBUG),\n\t\tverbose: _filterFunc(\"verbose\", DiagLogLevel.VERBOSE)\n\t};\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/api/diag.js\nconst API_NAME$2 = \"diag\";\n/**\n* Singleton object which represents the entry point to the OpenTelemetry internal\n* diagnostic API\n*\n* @since 1.0.0\n*/\nvar DiagAPI = class DiagAPI {\n\t/** Get the singleton instance of the DiagAPI API */\n\tstatic instance() {\n\t\tif (!this._instance) this._instance = new DiagAPI();\n\t\treturn this._instance;\n\t}\n\t/**\n\t* Private internal constructor\n\t* @private\n\t*/\n\tconstructor() {\n\t\tfunction _logProxy(funcName) {\n\t\t\treturn function(...args) {\n\t\t\t\tconst logger = getGlobal(\"diag\");\n\t\t\t\tif (!logger) return;\n\t\t\t\treturn logger[funcName](...args);\n\t\t\t};\n\t\t}\n\t\tconst self = this;\n\t\tconst setLogger = (logger, optionsOrLogLevel = { logLevel: DiagLogLevel.INFO }) => {\n\t\t\tvar _a, _b, _c;\n\t\t\tif (logger === self) {\n\t\t\t\tconst err = /* @__PURE__ */ new Error(\"Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation\");\n\t\t\t\tself.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (typeof optionsOrLogLevel === \"number\") optionsOrLogLevel = { logLevel: optionsOrLogLevel };\n\t\t\tconst oldLogger = getGlobal(\"diag\");\n\t\t\tconst newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);\n\t\t\tif (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {\n\t\t\t\tconst stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : \"<failed to generate stacktrace>\";\n\t\t\t\toldLogger.warn(`Current logger will be overwritten from ${stack}`);\n\t\t\t\tnewLogger.warn(`Current logger will overwrite one already registered from ${stack}`);\n\t\t\t}\n\t\t\treturn registerGlobal(\"diag\", newLogger, self, true);\n\t\t};\n\t\tself.setLogger = setLogger;\n\t\tself.disable = () => {\n\t\t\tunregisterGlobal(API_NAME$2, self);\n\t\t};\n\t\tself.createComponentLogger = (options) => {\n\t\t\treturn new DiagComponentLogger(options);\n\t\t};\n\t\tself.verbose = _logProxy(\"verbose\");\n\t\tself.debug = _logProxy(\"debug\");\n\t\tself.info = _logProxy(\"info\");\n\t\tself.warn = _logProxy(\"warn\");\n\t\tself.error = _logProxy(\"error\");\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/context/context.js\n/**\n* Get a key to uniquely identify a context value\n*\n* @since 1.0.0\n*/\nfunction createContextKey(description) {\n\treturn Symbol.for(description);\n}\n/**\n* The root context is used as the default parent context when there is no active context\n*\n* @since 1.0.0\n*/\nconst ROOT_CONTEXT = new class BaseContext {\n\t/**\n\t* Construct a new context which inherits values from an optional parent context.\n\t*\n\t* @param parentContext a context from which to inherit values\n\t*/\n\tconstructor(parentContext) {\n\t\tconst self = this;\n\t\tself._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();\n\t\tself.getValue = (key) => self._currentContext.get(key);\n\t\tself.setValue = (key, value) => {\n\t\t\tconst context = new BaseContext(self._currentContext);\n\t\t\tcontext._currentContext.set(key, value);\n\t\t\treturn context;\n\t\t};\n\t\tself.deleteValue = (key) => {\n\t\t\tconst context = new BaseContext(self._currentContext);\n\t\t\tcontext._currentContext.delete(key);\n\t\t\treturn context;\n\t\t};\n\t}\n}();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js\nvar NoopContextManager = class {\n\tactive() {\n\t\treturn ROOT_CONTEXT;\n\t}\n\twith(_context, fn, thisArg, ...args) {\n\t\treturn fn.call(thisArg, ...args);\n\t}\n\tbind(_context, target) {\n\t\treturn target;\n\t}\n\tenable() {\n\t\treturn this;\n\t}\n\tdisable() {\n\t\treturn this;\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/api/context.js\nconst API_NAME$1 = \"context\";\nconst NOOP_CONTEXT_MANAGER = new NoopContextManager();\n/**\n* Singleton object which represents the entry point to the OpenTelemetry Context API\n*\n* @since 1.0.0\n*/\nvar ContextAPI = class ContextAPI {\n\t/** Empty private constructor prevents end users from constructing a new instance of the API */\n\tconstructor() {}\n\t/** Get the singleton instance of the Context API */\n\tstatic getInstance() {\n\t\tif (!this._instance) this._instance = new ContextAPI();\n\t\treturn this._instance;\n\t}\n\t/**\n\t* Set the current context manager.\n\t*\n\t* @returns true if the context manager was successfully registered, else false\n\t*/\n\tsetGlobalContextManager(contextManager) {\n\t\treturn registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());\n\t}\n\t/**\n\t* Get the currently active context\n\t*/\n\tactive() {\n\t\treturn this._getContextManager().active();\n\t}\n\t/**\n\t* Execute a function with an active context\n\t*\n\t* @param context context to be active during function execution\n\t* @param fn function to execute in a context\n\t* @param thisArg optional receiver to be used for calling fn\n\t* @param args optional arguments forwarded to fn\n\t*/\n\twith(context, fn, thisArg, ...args) {\n\t\treturn this._getContextManager().with(context, fn, thisArg, ...args);\n\t}\n\t/**\n\t* Bind a context to a target function or event emitter\n\t*\n\t* @param context context to bind to the event emitter or function. Defaults to the currently active context\n\t* @param target function or event emitter to bind\n\t*/\n\tbind(context, target) {\n\t\treturn this._getContextManager().bind(context, target);\n\t}\n\t_getContextManager() {\n\t\treturn getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;\n\t}\n\t/** Disable and remove the global context manager */\n\tdisable() {\n\t\tthis._getContextManager().disable();\n\t\tunregisterGlobal(API_NAME$1, DiagAPI.instance());\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js\n/**\n* @since 1.0.0\n*/\nvar TraceFlags;\n(function(TraceFlags) {\n\t/** Represents no flag set. */\n\tTraceFlags[TraceFlags[\"NONE\"] = 0] = \"NONE\";\n\t/** Bit to represent whether trace is sampled in trace flags. */\n\tTraceFlags[TraceFlags[\"SAMPLED\"] = 1] = \"SAMPLED\";\n})(TraceFlags || (TraceFlags = {}));\n/**\n* @since 1.0.0\n*/\nconst INVALID_SPAN_CONTEXT = {\n\ttraceId: \"00000000000000000000000000000000\",\n\tspanId: \"0000000000000000\",\n\ttraceFlags: TraceFlags.NONE\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js\n/**\n* The NonRecordingSpan is the default {@link Span} that is used when no Span\n* implementation is available. All operations are no-op including context\n* propagation.\n*/\nvar NonRecordingSpan = class {\n\tconstructor(spanContext = INVALID_SPAN_CONTEXT) {\n\t\tthis._spanContext = spanContext;\n\t}\n\tspanContext() {\n\t\treturn this._spanContext;\n\t}\n\tsetAttribute(_key, _value) {\n\t\treturn this;\n\t}\n\tsetAttributes(_attributes) {\n\t\treturn this;\n\t}\n\taddEvent(_name, _attributes) {\n\t\treturn this;\n\t}\n\taddLink(_link) {\n\t\treturn this;\n\t}\n\taddLinks(_links) {\n\t\treturn this;\n\t}\n\tsetStatus(_status) {\n\t\treturn this;\n\t}\n\tupdateName(_name) {\n\t\treturn this;\n\t}\n\tend(_endTime) {}\n\tisRecording() {\n\t\treturn false;\n\t}\n\trecordException(_exception, _time) {}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js\n/**\n* span key\n*/\nconst SPAN_KEY = createContextKey(\"OpenTelemetry Context Key SPAN\");\n/**\n* Return the span if one exists\n*\n* @param context context to get span from\n*/\nfunction getSpan(context) {\n\treturn context.getValue(SPAN_KEY) || void 0;\n}\n/**\n* Gets the span from the current context, if one exists.\n*/\nfunction getActiveSpan() {\n\treturn getSpan(ContextAPI.getInstance().active());\n}\n/**\n* Set the span on a context\n*\n* @param context context to use as parent\n* @param span span to set active\n*/\nfunction setSpan(context, span) {\n\treturn context.setValue(SPAN_KEY, span);\n}\n/**\n* Remove current span stored in the context\n*\n* @param context context to delete span from\n*/\nfunction deleteSpan(context) {\n\treturn context.deleteValue(SPAN_KEY);\n}\n/**\n* Wrap span context in a NoopSpan and set as span in a new\n* context\n*\n* @param context context to set active span on\n* @param spanContext span context to be wrapped\n*/\nfunction setSpanContext(context, spanContext) {\n\treturn setSpan(context, new NonRecordingSpan(spanContext));\n}\n/**\n* Get the span context of the span if it exists.\n*\n* @param context context to get values from\n*/\nfunction getSpanContext(context) {\n\tvar _a;\n\treturn (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js\nconst isHex = new Uint8Array([\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1,\n\t1\n]);\nfunction isValidHex(id, length) {\n\tif (typeof id !== \"string\" || id.length !== length) return false;\n\tlet r = 0;\n\tfor (let i = 0; i < id.length; i += 4) r += (isHex[id.charCodeAt(i)] | 0) + (isHex[id.charCodeAt(i + 1)] | 0) + (isHex[id.charCodeAt(i + 2)] | 0) + (isHex[id.charCodeAt(i + 3)] | 0);\n\treturn r === length;\n}\n/**\n* @since 1.0.0\n*/\nfunction isValidTraceId(traceId) {\n\treturn isValidHex(traceId, 32) && traceId !== \"00000000000000000000000000000000\";\n}\n/**\n* @since 1.0.0\n*/\nfunction isValidSpanId(spanId) {\n\treturn isValidHex(spanId, 16) && spanId !== \"0000000000000000\";\n}\n/**\n* Returns true if this {@link SpanContext} is valid.\n* @return true if this {@link SpanContext} is valid.\n*\n* @since 1.0.0\n*/\nfunction isSpanContextValid(spanContext) {\n\treturn isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);\n}\n/**\n* Wrap the given {@link SpanContext} in a new non-recording {@link Span}\n*\n* @param spanContext span context to be wrapped\n* @returns a new non-recording {@link Span} with the provided context\n*/\nfunction wrapSpanContext(spanContext) {\n\treturn new NonRecordingSpan(spanContext);\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js\nconst contextApi = ContextAPI.getInstance();\n/**\n* No-op implementations of {@link Tracer}.\n*/\nvar NoopTracer = class {\n\tstartSpan(name, options, context = contextApi.active()) {\n\t\tif (Boolean(options === null || options === void 0 ? void 0 : options.root)) return new NonRecordingSpan();\n\t\tconst parentFromContext = context && getSpanContext(context);\n\t\tif (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) return new NonRecordingSpan(parentFromContext);\n\t\telse return new NonRecordingSpan();\n\t}\n\tstartActiveSpan(name, arg2, arg3, arg4) {\n\t\tlet opts;\n\t\tlet ctx;\n\t\tlet fn;\n\t\tif (arguments.length < 2) return;\n\t\telse if (arguments.length === 2) fn = arg2;\n\t\telse if (arguments.length === 3) {\n\t\t\topts = arg2;\n\t\t\tfn = arg3;\n\t\t} else {\n\t\t\topts = arg2;\n\t\t\tctx = arg3;\n\t\t\tfn = arg4;\n\t\t}\n\t\tconst parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();\n\t\tconst span = this.startSpan(name, opts, parentContext);\n\t\tconst contextWithSpanSet = setSpan(parentContext, span);\n\t\treturn contextApi.with(contextWithSpanSet, fn, void 0, span);\n\t}\n};\nfunction isSpanContext(spanContext) {\n\treturn spanContext !== null && typeof spanContext === \"object\" && \"spanId\" in spanContext && typeof spanContext[\"spanId\"] === \"string\" && \"traceId\" in spanContext && typeof spanContext[\"traceId\"] === \"string\" && \"traceFlags\" in spanContext && typeof spanContext[\"traceFlags\"] === \"number\";\n}\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js\nconst NOOP_TRACER = new NoopTracer();\n/**\n* Proxy tracer provided by the proxy tracer provider\n*\n* @since 1.0.0\n*/\nvar ProxyTracer = class {\n\tconstructor(provider, name, version, options) {\n\t\tthis._provider = provider;\n\t\tthis.name = name;\n\t\tthis.version = version;\n\t\tthis.options = options;\n\t}\n\tstartSpan(name, options, context) {\n\t\treturn this._getTracer().startSpan(name, options, context);\n\t}\n\tstartActiveSpan(_name, _options, _context, _fn) {\n\t\tconst tracer = this._getTracer();\n\t\treturn Reflect.apply(tracer.startActiveSpan, tracer, arguments);\n\t}\n\t/**\n\t* Try to get a tracer from the proxy tracer provider.\n\t* If the proxy tracer provider has no delegate, return a noop tracer.\n\t*/\n\t_getTracer() {\n\t\tif (this._delegate) return this._delegate;\n\t\tconst tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);\n\t\tif (!tracer) return NOOP_TRACER;\n\t\tthis._delegate = tracer;\n\t\treturn this._delegate;\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js\n/**\n* An implementation of the {@link TracerProvider} which returns an impotent\n* Tracer for all calls to `getTracer`.\n*\n* All operations are no-op.\n*/\nvar NoopTracerProvider = class {\n\tgetTracer(_name, _version, _options) {\n\t\treturn new NoopTracer();\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js\nconst NOOP_TRACER_PROVIDER = new NoopTracerProvider();\n/**\n* Tracer provider which provides {@link ProxyTracer}s.\n*\n* Before a delegate is set, tracers provided are NoOp.\n*   When a delegate is set, traces are provided from the delegate.\n*   When a delegate is set after tracers have already been provided,\n*   all tracers already provided will use the provided delegate implementation.\n*\n* @deprecated This will be removed in the next major version.\n* @since 1.0.0\n*/\nvar ProxyTracerProvider = class {\n\t/**\n\t* Get a {@link ProxyTracer}\n\t*/\n\tgetTracer(name, version, options) {\n\t\tvar _a;\n\t\treturn (_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options);\n\t}\n\tgetDelegate() {\n\t\tvar _a;\n\t\treturn (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;\n\t}\n\t/**\n\t* Set the delegate tracer provider\n\t*/\n\tsetDelegate(delegate) {\n\t\tthis._delegate = delegate;\n\t}\n\tgetDelegateTracer(name, version, options) {\n\t\tvar _a;\n\t\treturn (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);\n\t}\n};\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace/status.js\n/**\n* An enumeration of status codes.\n*\n* @since 1.0.0\n*/\nvar SpanStatusCode;\n(function(SpanStatusCode) {\n\t/**\n\t* The default status.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"UNSET\"] = 0] = \"UNSET\";\n\t/**\n\t* The operation has been validated by an Application developer or\n\t* Operator to have completed successfully.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"OK\"] = 1] = \"OK\";\n\t/**\n\t* The operation contains an error.\n\t*/\n\tSpanStatusCode[SpanStatusCode[\"ERROR\"] = 2] = \"ERROR\";\n})(SpanStatusCode || (SpanStatusCode = {}));\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/context-api.js\n/**\n* Entrypoint for context API\n* @since 1.0.0\n*/\nconst context = ContextAPI.getInstance();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/api/trace.js\nconst API_NAME = \"trace\";\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@opentelemetry/api/1.9.1/e2e640b4ddcaaa36008bb5e619de6b2e106b2a2441a690dc97bbd19967c1093c/node_modules/@opentelemetry/api/build/esm/trace-api.js\n/**\n* Entrypoint for trace API\n*\n* @since 1.0.0\n*/\nconst trace = class TraceAPI {\n\t/** Empty private constructor prevents end users from constructing a new instance of the API */\n\tconstructor() {\n\t\tthis._proxyTracerProvider = new ProxyTracerProvider();\n\t\tthis.wrapSpanContext = wrapSpanContext;\n\t\tthis.isSpanContextValid = isSpanContextValid;\n\t\tthis.deleteSpan = deleteSpan;\n\t\tthis.getSpan = getSpan;\n\t\tthis.getActiveSpan = getActiveSpan;\n\t\tthis.getSpanContext = getSpanContext;\n\t\tthis.setSpan = setSpan;\n\t\tthis.setSpanContext = setSpanContext;\n\t}\n\t/** Get the singleton instance of the Trace API */\n\tstatic getInstance() {\n\t\tif (!this._instance) this._instance = new TraceAPI();\n\t\treturn this._instance;\n\t}\n\t/**\n\t* Set the current global tracer.\n\t*\n\t* @returns true if the tracer provider was successfully registered, else false\n\t*/\n\tsetGlobalTracerProvider(provider) {\n\t\tconst success = registerGlobal(API_NAME, this._proxyTracerProvider, DiagAPI.instance());\n\t\tif (success) this._proxyTracerProvider.setDelegate(provider);\n\t\treturn success;\n\t}\n\t/**\n\t* Returns the global tracer provider.\n\t*/\n\tgetTracerProvider() {\n\t\treturn getGlobal(API_NAME) || this._proxyTracerProvider;\n\t}\n\t/**\n\t* Returns a tracer from the global tracer provider.\n\t*/\n\tgetTracer(name, version) {\n\t\treturn this.getTracerProvider().getTracer(name, version);\n\t}\n\t/** Remove the global tracer provider */\n\tdisable() {\n\t\tunregisterGlobal(API_NAME, DiagAPI.instance());\n\t\tthis._proxyTracerProvider = new ProxyTracerProvider();\n\t}\n}.getInstance();\n//#endregion\n//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/ai/6.0.309/77ab473ffcc1c9e993f48ffb118cd82aea3a5fca54de3cc37f43c828c68681af/node_modules/ai/dist/index.mjs\nvar __defProp = Object.defineProperty;\nvar __export = (target, all) => {\n\tfor (var name23 in all) __defProp(target, name23, {\n\t\tget: all[name23],\n\t\tenumerable: true\n\t});\n};\nvar name = \"AI_InvalidArgumentError\";\nvar marker = `vercel.ai.error.${name}`;\nvar symbol = Symbol.for(marker);\nvar _a;\nvar InvalidArgumentError = class extends AISDKError {\n\tconstructor({ parameter, value, message }) {\n\t\tsuper({\n\t\t\tname,\n\t\t\tmessage: `Invalid argument for parameter ${parameter}: ${message}`\n\t\t});\n\t\tthis[_a] = true;\n\t\tthis.parameter = parameter;\n\t\tthis.value = value;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker);\n\t}\n};\n_a = symbol;\nvar name2 = \"AI_InvalidStreamPartError\";\nvar marker2 = `vercel.ai.error.${name2}`;\nvar symbol2 = Symbol.for(marker2);\nvar _a2;\nvar InvalidStreamPartError = class extends AISDKError {\n\tconstructor({ chunk, message }) {\n\t\tsuper({\n\t\t\tname: name2,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a2] = true;\n\t\tthis.chunk = chunk;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker2);\n\t}\n};\n_a2 = symbol2;\nvar name3 = \"AI_InvalidToolApprovalError\";\nvar marker3 = `vercel.ai.error.${name3}`;\nvar symbol3 = Symbol.for(marker3);\nvar _a3;\nvar InvalidToolApprovalError = class extends AISDKError {\n\tconstructor({ approvalId }) {\n\t\tsuper({\n\t\t\tname: name3,\n\t\t\tmessage: `Tool approval response references unknown approvalId: \"${approvalId}\". No matching tool-approval-request found in message history.`\n\t\t});\n\t\tthis[_a3] = true;\n\t\tthis.approvalId = approvalId;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker3);\n\t}\n};\n_a3 = symbol3;\nvar name4 = \"AI_InvalidToolApprovalSignatureError\";\nvar marker4 = `vercel.ai.error.${name4}`;\nvar symbol4 = Symbol.for(marker4);\nvar _a4;\nvar InvalidToolApprovalSignatureError = class extends AISDKError {\n\tconstructor({ approvalId, toolCallId, reason }) {\n\t\tsuper({\n\t\t\tname: name4,\n\t\t\tmessage: `Tool approval signature verification failed for approval \"${approvalId}\" (tool call \"${toolCallId}\"): ${reason}`\n\t\t});\n\t\tthis[_a4] = true;\n\t\tthis.approvalId = approvalId;\n\t\tthis.toolCallId = toolCallId;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker4);\n\t}\n};\n_a4 = symbol4;\nvar name5 = \"AI_InvalidToolInputError\";\nvar marker5 = `vercel.ai.error.${name5}`;\nvar symbol5 = Symbol.for(marker5);\nvar _a5;\nvar InvalidToolInputError = class extends AISDKError {\n\tconstructor({ toolInput, toolName, cause, message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name5,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a5] = true;\n\t\tthis.toolInput = toolInput;\n\t\tthis.toolName = toolName;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker5);\n\t}\n};\n_a5 = symbol5;\nvar name6 = \"AI_ToolCallNotFoundForApprovalError\";\nvar marker6 = `vercel.ai.error.${name6}`;\nvar symbol6 = Symbol.for(marker6);\nvar _a6;\nvar ToolCallNotFoundForApprovalError = class extends AISDKError {\n\tconstructor({ toolCallId, approvalId }) {\n\t\tsuper({\n\t\t\tname: name6,\n\t\t\tmessage: `Tool call \"${toolCallId}\" not found for approval request \"${approvalId}\".`\n\t\t});\n\t\tthis[_a6] = true;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.approvalId = approvalId;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker6);\n\t}\n};\n_a6 = symbol6;\nvar name7 = \"AI_MissingToolResultsError\";\nvar marker7 = `vercel.ai.error.${name7}`;\nvar symbol7 = Symbol.for(marker7);\nvar _a7;\nvar MissingToolResultsError = class extends AISDKError {\n\tconstructor({ toolCallIds }) {\n\t\tsuper({\n\t\t\tname: name7,\n\t\t\tmessage: `Tool result${toolCallIds.length > 1 ? \"s are\" : \" is\"} missing for tool call${toolCallIds.length > 1 ? \"s\" : \"\"} ${toolCallIds.join(\", \")}.`\n\t\t});\n\t\tthis[_a7] = true;\n\t\tthis.toolCallIds = toolCallIds;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker7);\n\t}\n};\n_a7 = symbol7;\nvar name8 = \"AI_NoImageGeneratedError\";\nvar marker8 = `vercel.ai.error.${name8}`;\nvar symbol8 = Symbol.for(marker8);\nvar _a8;\nvar NoImageGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No image generated.\", cause, responses }) {\n\t\tsuper({\n\t\t\tname: name8,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a8] = true;\n\t\tthis.responses = responses;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker8);\n\t}\n};\n_a8 = symbol8;\nvar name9 = \"AI_NoObjectGeneratedError\";\nvar marker9 = `vercel.ai.error.${name9}`;\nvar symbol9 = Symbol.for(marker9);\nvar _a9;\nvar NoObjectGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No object generated.\", cause, text: text2, response, usage, finishReason }) {\n\t\tsuper({\n\t\t\tname: name9,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a9] = true;\n\t\tthis.text = text2;\n\t\tthis.response = response;\n\t\tthis.usage = usage;\n\t\tthis.finishReason = finishReason;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker9);\n\t}\n};\n_a9 = symbol9;\nvar name10 = \"AI_NoOutputGeneratedError\";\nvar marker10 = `vercel.ai.error.${name10}`;\nvar symbol10 = Symbol.for(marker10);\nvar _a10;\nvar NoOutputGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No output generated.\", cause } = {}) {\n\t\tsuper({\n\t\t\tname: name10,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a10] = true;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker10);\n\t}\n};\n_a10 = symbol10;\nvar name11 = \"AI_NoSpeechGeneratedError\";\nvar marker11 = `vercel.ai.error.${name11}`;\nvar symbol11 = Symbol.for(marker11);\nvar _a11;\nvar NoSpeechGeneratedError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: name11,\n\t\t\tmessage: \"No speech audio generated.\"\n\t\t});\n\t\tthis[_a11] = true;\n\t\tthis.responses = options.responses;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker11);\n\t}\n};\n_a11 = symbol11;\nvar name12 = \"AI_NoTranscriptGeneratedError\";\nvar marker12 = `vercel.ai.error.${name12}`;\nvar symbol12 = Symbol.for(marker12);\nvar _a12;\nvar NoTranscriptGeneratedError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: name12,\n\t\t\tmessage: \"No transcript generated.\"\n\t\t});\n\t\tthis[_a12] = true;\n\t\tthis.responses = options.responses;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker12);\n\t}\n};\n_a12 = symbol12;\nvar name13 = \"AI_NoVideoGeneratedError\";\nvar marker13 = `vercel.ai.error.${name13}`;\nvar symbol13 = Symbol.for(marker13);\nvar _a13;\nvar NoVideoGeneratedError = class extends AISDKError {\n\tconstructor({ message = \"No video generated.\", cause, responses }) {\n\t\tsuper({\n\t\t\tname: name13,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a13] = true;\n\t\tthis.responses = responses;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker13);\n\t}\n\t/**\n\t* @deprecated use `isInstance` instead\n\t*/\n\tstatic isNoVideoGeneratedError(error) {\n\t\treturn error instanceof Error && error.name === name13 && typeof error.responses !== \"undefined\" ? true : false;\n\t}\n\t/**\n\t* @deprecated Do not use this method. It will be removed in the next major version.\n\t*/\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tstack: this.stack,\n\t\t\tcause: this.cause,\n\t\t\tresponses: this.responses\n\t\t};\n\t}\n};\n_a13 = symbol13;\nvar name14 = \"AI_NoSuchToolError\";\nvar marker14 = `vercel.ai.error.${name14}`;\nvar symbol14 = Symbol.for(marker14);\nvar _a14;\nvar NoSuchToolError = class extends AISDKError {\n\tconstructor({ toolName, availableTools = void 0, message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? \"No tools are available.\" : `Available tools: ${availableTools.join(\", \")}.`}` }) {\n\t\tsuper({\n\t\t\tname: name14,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a14] = true;\n\t\tthis.toolName = toolName;\n\t\tthis.availableTools = availableTools;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker14);\n\t}\n};\n_a14 = symbol14;\nvar name15 = \"AI_ToolChoiceViolationError\";\nvar marker15 = `vercel.ai.error.${name15}`;\nvar symbol15 = Symbol.for(marker15);\nvar _a15;\nvar ToolChoiceViolationError = class extends AISDKError {\n\tconstructor({ toolChoice, finishReason, provider, modelId, content, message = toolChoice.type === \"required\" ? \"Model response did not contain a tool call even though tool choice was required.\" : `Model response did not contain a call to the required tool '${toolChoice.toolName}'.` }) {\n\t\tsuper({\n\t\t\tname: name15,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a15] = true;\n\t\tthis.toolChoice = toolChoice;\n\t\tthis.finishReason = finishReason;\n\t\tthis.provider = provider;\n\t\tthis.modelId = modelId;\n\t\tthis.content = content;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker15);\n\t}\n};\n_a15 = symbol15;\nvar name16 = \"AI_ToolCallRepairError\";\nvar marker16 = `vercel.ai.error.${name16}`;\nvar symbol16 = Symbol.for(marker16);\nvar _a16;\nvar ToolCallRepairError = class extends AISDKError {\n\tconstructor({ cause, originalError, message = `Error repairing tool call: ${getErrorMessage(cause)}` }) {\n\t\tsuper({\n\t\t\tname: name16,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a16] = true;\n\t\tthis.originalError = originalError;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker16);\n\t}\n};\n_a16 = symbol16;\nvar UnsupportedModelVersionError = class extends AISDKError {\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tname: \"AI_UnsupportedModelVersionError\",\n\t\t\tmessage: `Unsupported model version ${options.version} for provider \"${options.provider}\" and model \"${options.modelId}\". AI SDK 5 only supports models that implement specification version \"v2\".`\n\t\t});\n\t\tthis.version = options.version;\n\t\tthis.provider = options.provider;\n\t\tthis.modelId = options.modelId;\n\t}\n};\nvar name17 = \"AI_UIMessageStreamError\";\nvar marker17 = `vercel.ai.error.${name17}`;\nvar symbol17 = Symbol.for(marker17);\nvar _a17;\nvar UIMessageStreamError = class extends AISDKError {\n\tconstructor({ chunkType, chunkId, message }) {\n\t\tsuper({\n\t\t\tname: name17,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a17] = true;\n\t\tthis.chunkType = chunkType;\n\t\tthis.chunkId = chunkId;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker17);\n\t}\n};\n_a17 = symbol17;\nvar name18 = \"AI_InvalidDataContentError\";\nvar marker18 = `vercel.ai.error.${name18}`;\nvar symbol18 = Symbol.for(marker18);\nvar _a18;\nvar InvalidDataContentError = class extends AISDKError {\n\tconstructor({ content, cause, message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.` }) {\n\t\tsuper({\n\t\t\tname: name18,\n\t\t\tmessage,\n\t\t\tcause\n\t\t});\n\t\tthis[_a18] = true;\n\t\tthis.content = content;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker18);\n\t}\n};\n_a18 = symbol18;\nvar name19 = \"AI_InvalidMessageRoleError\";\nvar marker19 = `vercel.ai.error.${name19}`;\nvar symbol19 = Symbol.for(marker19);\nvar _a19;\nvar InvalidMessageRoleError = class extends AISDKError {\n\tconstructor({ role, message = `Invalid message role: '${role}'. Must be one of: \"system\", \"user\", \"assistant\", \"tool\".` }) {\n\t\tsuper({\n\t\t\tname: name19,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a19] = true;\n\t\tthis.role = role;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker19);\n\t}\n};\n_a19 = symbol19;\nvar name20 = \"AI_MessageConversionError\";\nvar marker20 = `vercel.ai.error.${name20}`;\nvar symbol20 = Symbol.for(marker20);\nvar _a20;\nvar MessageConversionError = class extends AISDKError {\n\tconstructor({ originalMessage, message }) {\n\t\tsuper({\n\t\t\tname: name20,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a20] = true;\n\t\tthis.originalMessage = originalMessage;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker20);\n\t}\n};\n_a20 = symbol20;\nvar name21 = \"AI_RetryError\";\nvar marker21 = `vercel.ai.error.${name21}`;\nvar symbol21 = Symbol.for(marker21);\nvar _a21;\nvar RetryError = class extends AISDKError {\n\tconstructor({ message, reason, errors }) {\n\t\tsuper({\n\t\t\tname: name21,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a21] = true;\n\t\tthis.reason = reason;\n\t\tthis.errors = errors;\n\t\tthis.lastError = errors[errors.length - 1];\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker21);\n\t}\n};\n_a21 = symbol21;\nfunction asArray(value) {\n\treturn value === void 0 ? [] : Array.isArray(value) ? value : [value];\n}\nasync function notify(options) {\n\tfor (const callback of asArray(options.callbacks)) {\n\t\tif (callback == null) continue;\n\t\ttry {\n\t\t\tawait callback(options.event);\n\t\t} catch (_ignored) {}\n\t}\n}\nfunction formatWarning({ warning, provider, model }) {\n\tconst prefix = `AI SDK Warning (${provider} / ${model}):`;\n\tswitch (warning.type) {\n\t\tcase \"unsupported\": {\n\t\t\tlet message = `${prefix} The feature \"${warning.feature}\" is not supported.`;\n\t\t\tif (warning.details) message += ` ${warning.details}`;\n\t\t\treturn message;\n\t\t}\n\t\tcase \"compatibility\": {\n\t\t\tlet message = `${prefix} The feature \"${warning.feature}\" is used in a compatibility mode.`;\n\t\t\tif (warning.details) message += ` ${warning.details}`;\n\t\t\treturn message;\n\t\t}\n\t\tcase \"other\": return `${prefix} ${warning.message}`;\n\t\tdefault: return `${prefix} ${JSON.stringify(warning, null, 2)}`;\n\t}\n}\nvar FIRST_WARNING_INFO_MESSAGE = \"AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.\";\nvar hasLoggedBefore = false;\nvar logWarnings = (options) => {\n\tif (options.warnings.length === 0) return;\n\tconst logger = globalThis.AI_SDK_LOG_WARNINGS;\n\tif (logger === false) return;\n\tif (typeof logger === \"function\") {\n\t\tlogger(options);\n\t\treturn;\n\t}\n\tif (!hasLoggedBefore) {\n\t\thasLoggedBefore = true;\n\t\tconsole.info(FIRST_WARNING_INFO_MESSAGE);\n\t}\n\tfor (const warning of options.warnings) console.warn(formatWarning({\n\t\twarning,\n\t\tprovider: options.provider,\n\t\tmodel: options.model\n\t}));\n};\nfunction logV2CompatibilityWarning({ provider, modelId }) {\n\tlogWarnings({\n\t\twarnings: [{\n\t\t\ttype: \"compatibility\",\n\t\t\tfeature: \"specificationVersion\",\n\t\t\tdetails: `Using v2 specification compatibility mode. Some features may not be available.`\n\t\t}],\n\t\tprovider,\n\t\tmodel: modelId\n\t});\n}\nfunction asEmbeddingModelV3(model) {\n\tif (model.specificationVersion === \"v3\") return model;\n\tlogV2CompatibilityWarning({\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\treturn new Proxy(model, { get(target, prop) {\n\t\tif (prop === \"specificationVersion\") return \"v3\";\n\t\treturn target[prop];\n\t} });\n}\nfunction asImageModelV3(model) {\n\tif (model.specificationVersion === \"v3\") return model;\n\tlogV2CompatibilityWarning({\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\treturn new Proxy(model, { get(target, prop) {\n\t\tif (prop === \"specificationVersion\") return \"v3\";\n\t\treturn target[prop];\n\t} });\n}\nfunction asLanguageModelV3(model) {\n\tif (model.specificationVersion === \"v3\") return model;\n\tlogV2CompatibilityWarning({\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\treturn new Proxy(model, { get(target, prop) {\n\t\tswitch (prop) {\n\t\t\tcase \"specificationVersion\": return \"v3\";\n\t\t\tcase \"doGenerate\": return async (...args) => {\n\t\t\t\tconst result = await target.doGenerate(...args);\n\t\t\t\treturn {\n\t\t\t\t\t...result,\n\t\t\t\t\tfinishReason: convertV2FinishReasonToV3(result.finishReason),\n\t\t\t\t\tusage: convertV2UsageToV3(result.usage)\n\t\t\t\t};\n\t\t\t};\n\t\t\tcase \"doStream\": return async (...args) => {\n\t\t\t\tconst result = await target.doStream(...args);\n\t\t\t\treturn {\n\t\t\t\t\t...result,\n\t\t\t\t\tstream: convertV2StreamToV3(result.stream)\n\t\t\t\t};\n\t\t\t};\n\t\t\tdefault: return target[prop];\n\t\t}\n\t} });\n}\nfunction convertV2StreamToV3(stream) {\n\treturn stream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\tswitch (chunk.type) {\n\t\t\tcase \"finish\":\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t...chunk,\n\t\t\t\t\tfinishReason: convertV2FinishReasonToV3(chunk.finishReason),\n\t\t\t\t\tusage: convertV2UsageToV3(chunk.usage)\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tdefault: controller.enqueue(chunk);\n\t\t}\n\t} }));\n}\nfunction convertV2FinishReasonToV3(finishReason) {\n\treturn {\n\t\tunified: finishReason === \"unknown\" ? \"other\" : finishReason,\n\t\traw: void 0\n\t};\n}\nfunction convertV2UsageToV3(usage) {\n\treturn {\n\t\tinputTokens: {\n\t\t\ttotal: usage.inputTokens,\n\t\t\tnoCache: void 0,\n\t\t\tcacheRead: usage.cachedInputTokens,\n\t\t\tcacheWrite: void 0\n\t\t},\n\t\toutputTokens: {\n\t\t\ttotal: usage.outputTokens,\n\t\t\ttext: void 0,\n\t\t\treasoning: usage.reasoningTokens\n\t\t},\n\t\traw: usage.totalTokens == null ? void 0 : { totalTokens: usage.totalTokens }\n\t};\n}\nfunction asSpeechModelV3(model) {\n\tif (model.specificationVersion === \"v3\") return model;\n\tlogV2CompatibilityWarning({\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\treturn new Proxy(model, { get(target, prop) {\n\t\tif (prop === \"specificationVersion\") return \"v3\";\n\t\treturn target[prop];\n\t} });\n}\nfunction asTranscriptionModelV3(model) {\n\tif (model.specificationVersion === \"v3\") return model;\n\tlogV2CompatibilityWarning({\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t});\n\treturn new Proxy(model, { get(target, prop) {\n\t\tif (prop === \"specificationVersion\") return \"v3\";\n\t\treturn target[prop];\n\t} });\n}\nfunction resolveLanguageModel(model) {\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v3\" && model.specificationVersion !== \"v2\") {\n\t\t\tconst unsupportedModel = model;\n\t\t\tthrow new UnsupportedModelVersionError({\n\t\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\t\tprovider: unsupportedModel.provider,\n\t\t\t\tmodelId: unsupportedModel.modelId\n\t\t\t});\n\t\t}\n\t\treturn asLanguageModelV3(model);\n\t}\n\treturn getGlobalProvider().languageModel(model);\n}\nfunction resolveEmbeddingModel(model) {\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v3\" && model.specificationVersion !== \"v2\") {\n\t\t\tconst unsupportedModel = model;\n\t\t\tthrow new UnsupportedModelVersionError({\n\t\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\t\tprovider: unsupportedModel.provider,\n\t\t\t\tmodelId: unsupportedModel.modelId\n\t\t\t});\n\t\t}\n\t\treturn asEmbeddingModelV3(model);\n\t}\n\treturn getGlobalProvider().embeddingModel(model);\n}\nfunction resolveTranscriptionModel(model) {\n\tvar _a23, _b;\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v3\" && model.specificationVersion !== \"v2\") {\n\t\t\tconst unsupportedModel = model;\n\t\t\tthrow new UnsupportedModelVersionError({\n\t\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\t\tprovider: unsupportedModel.provider,\n\t\t\t\tmodelId: unsupportedModel.modelId\n\t\t\t});\n\t\t}\n\t\treturn asTranscriptionModelV3(model);\n\t}\n\treturn (_b = (_a23 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b.call(_a23, model);\n}\nfunction resolveSpeechModel(model) {\n\tvar _a23, _b;\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v3\" && model.specificationVersion !== \"v2\") {\n\t\t\tconst unsupportedModel = model;\n\t\t\tthrow new UnsupportedModelVersionError({\n\t\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\t\tprovider: unsupportedModel.provider,\n\t\t\t\tmodelId: unsupportedModel.modelId\n\t\t\t});\n\t\t}\n\t\treturn asSpeechModelV3(model);\n\t}\n\treturn (_b = (_a23 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a23, model);\n}\nfunction resolveImageModel(model) {\n\tif (typeof model !== \"string\") {\n\t\tif (model.specificationVersion !== \"v3\" && model.specificationVersion !== \"v2\") {\n\t\t\tconst unsupportedModel = model;\n\t\t\tthrow new UnsupportedModelVersionError({\n\t\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\t\tprovider: unsupportedModel.provider,\n\t\t\t\tmodelId: unsupportedModel.modelId\n\t\t\t});\n\t\t}\n\t\treturn asImageModelV3(model);\n\t}\n\treturn getGlobalProvider().imageModel(model);\n}\nfunction resolveVideoModel(model) {\n\tif (typeof model === \"string\") {\n\t\tconst videoModel = getGlobalProvider().videoModel;\n\t\tif (!videoModel) throw new Error(\"The default provider does not support video models. Please use a Experimental_VideoModelV3 object from a provider (e.g., vertex.video(\\\"model-id\\\")).\");\n\t\treturn videoModel(model);\n\t}\n\tif (model.specificationVersion !== \"v3\") {\n\t\tconst unsupportedModel = model;\n\t\tthrow new UnsupportedModelVersionError({\n\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\tprovider: unsupportedModel.provider,\n\t\t\tmodelId: unsupportedModel.modelId\n\t\t});\n\t}\n\treturn model;\n}\nfunction resolveRerankingModel(model) {\n\tif (typeof model === \"string\") {\n\t\tconst rerankingModel = getGlobalProvider().rerankingModel;\n\t\tif (!rerankingModel) throw new Error(\"The default provider does not support reranking models. Please use a RerankingModel object from a provider (e.g., gateway.rerankingModel(\\\"model-id\\\")).\");\n\t\treturn rerankingModel(model);\n\t}\n\tif (model.specificationVersion !== \"v3\") {\n\t\tconst unsupportedModel = model;\n\t\tthrow new UnsupportedModelVersionError({\n\t\t\tversion: unsupportedModel.specificationVersion,\n\t\t\tprovider: unsupportedModel.provider,\n\t\t\tmodelId: unsupportedModel.modelId\n\t\t});\n\t}\n\treturn model;\n}\nfunction getGlobalProvider() {\n\tvar _a23;\n\treturn (_a23 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a23 : gateway;\n}\nfunction getTotalTimeoutMs(timeout) {\n\tif (timeout == null) return;\n\tif (typeof timeout === \"number\") return timeout;\n\treturn timeout.totalMs;\n}\nfunction getStepTimeoutMs(timeout) {\n\tif (timeout == null || typeof timeout === \"number\") return;\n\treturn timeout.stepMs;\n}\nfunction getChunkTimeoutMs(timeout) {\n\tif (timeout == null || typeof timeout === \"number\") return;\n\treturn timeout.chunkMs;\n}\nvar imageMediaTypeSignatures = [\n\t{\n\t\tmediaType: \"image/gif\",\n\t\tbytesPrefix: [\n\t\t\t71,\n\t\t\t73,\n\t\t\t70\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/png\",\n\t\tbytesPrefix: [\n\t\t\t137,\n\t\t\t80,\n\t\t\t78,\n\t\t\t71\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/jpeg\",\n\t\tbytesPrefix: [255, 216]\n\t},\n\t{\n\t\tmediaType: \"image/webp\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\t87,\n\t\t\t69,\n\t\t\t66,\n\t\t\t80\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/bmp\",\n\t\tbytesPrefix: [66, 77]\n\t},\n\t{\n\t\tmediaType: \"image/tiff\",\n\t\tbytesPrefix: [\n\t\t\t73,\n\t\t\t73,\n\t\t\t42,\n\t\t\t0\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/tiff\",\n\t\tbytesPrefix: [\n\t\t\t77,\n\t\t\t77,\n\t\t\t0,\n\t\t\t42\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/avif\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t32,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t97,\n\t\t\t118,\n\t\t\t105,\n\t\t\t102\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"image/heic\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t32,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t104,\n\t\t\t101,\n\t\t\t105,\n\t\t\t99\n\t\t]\n\t}\n];\nvar audioMediaTypeSignatures = [\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 251]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 250]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 243]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 242]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 227]\n\t},\n\t{\n\t\tmediaType: \"audio/mpeg\",\n\t\tbytesPrefix: [255, 226]\n\t},\n\t{\n\t\tmediaType: \"audio/wav\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\t87,\n\t\t\t65,\n\t\t\t86,\n\t\t\t69\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/ogg\",\n\t\tbytesPrefix: [\n\t\t\t79,\n\t\t\t103,\n\t\t\t103,\n\t\t\t83\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/flac\",\n\t\tbytesPrefix: [\n\t\t\t102,\n\t\t\t76,\n\t\t\t97,\n\t\t\t67\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/aac\",\n\t\tbytesPrefix: [\n\t\t\t64,\n\t\t\t21,\n\t\t\t0,\n\t\t\t0\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/mp4\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tnull,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"audio/webm\",\n\t\tbytesPrefix: [\n\t\t\t26,\n\t\t\t69,\n\t\t\t223,\n\t\t\t163\n\t\t]\n\t}\n];\nvar videoMediaTypeSignatures = [\n\t{\n\t\tmediaType: \"video/mp4\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\tnull,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"video/webm\",\n\t\tbytesPrefix: [\n\t\t\t26,\n\t\t\t69,\n\t\t\t223,\n\t\t\t163\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"video/quicktime\",\n\t\tbytesPrefix: [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t20,\n\t\t\t102,\n\t\t\t116,\n\t\t\t121,\n\t\t\t112,\n\t\t\t113,\n\t\t\t116\n\t\t]\n\t},\n\t{\n\t\tmediaType: \"video/x-msvideo\",\n\t\tbytesPrefix: [\n\t\t\t82,\n\t\t\t73,\n\t\t\t70,\n\t\t\t70\n\t\t]\n\t}\n];\nvar DEFAULT_SNIFF_BYTES = 18;\nvar ID3_SCAN_BYTES = 131084;\nfunction decodePrefix(data, maxBytes) {\n\tif (typeof data !== \"string\") return data.length > maxBytes ? data.subarray(0, maxBytes) : data;\n\tconst maxChars = Math.ceil(maxBytes / 3) * 4;\n\tconst bytes = convertBase64ToUint8Array(data.substring(0, Math.min(data.length, maxChars)));\n\treturn bytes.length > maxBytes ? bytes.subarray(0, maxBytes) : bytes;\n}\nfunction hasID3(bytes) {\n\treturn bytes.length > 10 && bytes[0] === 73 && bytes[1] === 68 && bytes[2] === 51;\n}\nvar stripID3 = (bytes) => {\n\tconst id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;\n\treturn bytes.subarray(id3Size + 10);\n};\nfunction detectMediaType({ data, signatures }) {\n\tlet bytes = decodePrefix(data, DEFAULT_SNIFF_BYTES);\n\tif (hasID3(bytes)) bytes = stripID3(decodePrefix(data, ID3_SCAN_BYTES));\n\tfor (const signature of signatures) if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => byte === null || bytes[index] === byte)) return signature.mediaType;\n}\nvar VERSION = \"6.0.309\";\nvar download = async ({ url, maxBytes, abortSignal }) => {\n\tvar _a23;\n\tconst urlText = url.toString();\n\ttry {\n\t\tconst headers = withUserAgentSuffix({}, `ai-sdk/${VERSION}`, getRuntimeEnvironmentUserAgent());\n\t\tconst response = await fetchWithValidatedRedirects({\n\t\t\turl: urlText,\n\t\t\theaders,\n\t\t\tabortSignal\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tawait cancelResponseBody(response);\n\t\t\tthrow new DownloadError({\n\t\t\t\turl: urlText,\n\t\t\t\tstatusCode: response.status,\n\t\t\t\tstatusText: response.statusText\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tdata: await readResponseWithSizeLimit({\n\t\t\t\tresponse,\n\t\t\t\turl: urlText,\n\t\t\t\tmaxBytes: maxBytes != null ? maxBytes : DEFAULT_MAX_DOWNLOAD_SIZE\n\t\t\t}),\n\t\t\tmediaType: (_a23 = response.headers.get(\"content-type\")) != null ? _a23 : void 0\n\t\t};\n\t} catch (error) {\n\t\tif (DownloadError.isInstance(error)) throw error;\n\t\tthrow new DownloadError({\n\t\t\turl: urlText,\n\t\t\tcause: error\n\t\t});\n\t}\n};\nvar createDefaultDownloadFunction = (download2 = download, abortSignal) => (requestedDownloads) => Promise.all(requestedDownloads.map(async (requestedDownload) => requestedDownload.isUrlSupportedByModel ? null : await download2({\n\t...requestedDownload,\n\tabortSignal\n})));\nfunction mergeObjects(base, overrides) {\n\tif (base === void 0 && overrides === void 0) return;\n\tif (base === void 0) return overrides;\n\tif (overrides === void 0) return base;\n\tconst result = { ...base };\n\tfor (const key in overrides) {\n\t\tif (key === \"__proto__\" || key === \"constructor\" || key === \"prototype\") continue;\n\t\tif (Object.prototype.hasOwnProperty.call(overrides, key)) {\n\t\t\tconst overridesValue = overrides[key];\n\t\t\tif (overridesValue === void 0) continue;\n\t\t\tconst baseValue = key in base ? base[key] : void 0;\n\t\t\tconst isSourceObject = overridesValue !== null && typeof overridesValue === \"object\" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);\n\t\t\tconst isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === \"object\" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);\n\t\t\tif (isSourceObject && isTargetObject) result[key] = mergeObjects(baseValue, overridesValue);\n\t\t\telse result[key] = overridesValue;\n\t\t}\n\t}\n\treturn result;\n}\nfunction splitDataUrl(dataUrl) {\n\ttry {\n\t\tconst [header, base64Content] = dataUrl.split(\",\");\n\t\treturn {\n\t\t\tmediaType: header.split(\";\")[0].split(\":\")[1],\n\t\t\tbase64Content\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tmediaType: void 0,\n\t\t\tbase64Content: void 0\n\t\t};\n\t}\n}\nvar dataContentSchema = z.union([\n\tz.string(),\n\tz.instanceof(Uint8Array),\n\tz.instanceof(ArrayBuffer),\n\tz.custom((value) => {\n\t\tvar _a23, _b;\n\t\treturn (_b = (_a23 = globalThis.Buffer) == null ? void 0 : _a23.isBuffer(value)) != null ? _b : false;\n\t}, { message: \"Must be a Buffer\" })\n]);\nfunction convertToLanguageModelV3DataContent(content) {\n\tlet originalUrl;\n\tif (content instanceof Uint8Array) return {\n\t\tdata: content,\n\t\tmediaType: void 0\n\t};\n\tif (content instanceof ArrayBuffer) return {\n\t\tdata: new Uint8Array(content),\n\t\tmediaType: void 0\n\t};\n\tif (typeof content === \"string\") try {\n\t\tconst url = new URL(content);\n\t\toriginalUrl = url.toString() !== content ? content : void 0;\n\t\tcontent = url;\n\t} catch (error) {}\n\tif (content instanceof URL && content.protocol === \"data:\") {\n\t\tconst { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(content.toString());\n\t\tif (dataUrlMediaType == null || base64Content == null) throw new AISDKError({\n\t\t\tname: \"InvalidDataContentError\",\n\t\t\tmessage: `Invalid data URL format in content ${content.toString()}`\n\t\t});\n\t\treturn {\n\t\t\tdata: base64Content,\n\t\t\tmediaType: dataUrlMediaType\n\t\t};\n\t}\n\treturn {\n\t\tdata: content,\n\t\tmediaType: void 0,\n\t\t...originalUrl != null ? { originalUrl } : {}\n\t};\n}\nfunction convertDataContentToBase64String(content) {\n\tif (typeof content === \"string\") return content;\n\tif (content instanceof ArrayBuffer) return convertUint8ArrayToBase64(new Uint8Array(content));\n\treturn convertUint8ArrayToBase64(content);\n}\nfunction convertDataContentToUint8Array(content) {\n\tif (content instanceof Uint8Array) return content;\n\tif (typeof content === \"string\") try {\n\t\treturn convertBase64ToUint8Array(content);\n\t} catch (error) {\n\t\tthrow new InvalidDataContentError({\n\t\t\tmessage: \"Invalid data content. Content string is not a base64-encoded media.\",\n\t\t\tcontent,\n\t\t\tcause: error\n\t\t});\n\t}\n\tif (content instanceof ArrayBuffer) return new Uint8Array(content);\n\tthrow new InvalidDataContentError({ content });\n}\nasync function convertToLanguageModelPrompt({ prompt, supportedUrls, download: download2, abortSignal }) {\n\tconst downloadedAssets = await downloadAssets(prompt.messages, download2 != null ? download2 : createDefaultDownloadFunction(void 0, abortSignal), supportedUrls);\n\tconst messages = [...prompt.system != null ? typeof prompt.system === \"string\" ? [{\n\t\trole: \"system\",\n\t\tcontent: prompt.system\n\t}] : asArray(prompt.system).map((message) => ({\n\t\trole: \"system\",\n\t\tcontent: message.content,\n\t\tproviderOptions: message.providerOptions\n\t})) : [], ...prompt.messages.map((message) => convertToLanguageModelMessage({\n\t\tmessage,\n\t\tdownloadedAssets\n\t}))];\n\tconst combinedMessages = [];\n\tfor (const message of messages) {\n\t\tif (message.role !== \"tool\") {\n\t\t\tcombinedMessages.push(message);\n\t\t\tcontinue;\n\t\t}\n\t\tconst lastCombinedMessage = combinedMessages.at(-1);\n\t\tif ((lastCombinedMessage == null ? void 0 : lastCombinedMessage.role) === \"tool\") {\n\t\t\tconst lastContentPart = lastCombinedMessage.content.at(-1);\n\t\t\tif (lastContentPart != null && lastCombinedMessage.providerOptions != null) lastContentPart.providerOptions = mergeObjects(lastCombinedMessage.providerOptions, lastContentPart.providerOptions);\n\t\t\tlastCombinedMessage.content.push(...message.content);\n\t\t\tlastCombinedMessage.providerOptions = message.providerOptions;\n\t\t} else combinedMessages.push(message);\n\t}\n\tconst toolCallIds = /* @__PURE__ */ new Set();\n\tfor (const message of combinedMessages) switch (message.role) {\n\t\tcase \"assistant\":\n\t\t\tfor (const content of message.content) if (content.type === \"tool-call\" && !content.providerExecuted) toolCallIds.add(content.toolCallId);\n\t\t\tbreak;\n\t\tcase \"tool\":\n\t\t\tfor (const content of message.content) if (content.type === \"tool-result\") toolCallIds.delete(content.toolCallId);\n\t\t\tbreak;\n\t\tcase \"user\":\n\t\tcase \"system\": if (toolCallIds.size > 0) throw new MissingToolResultsError({ toolCallIds: Array.from(toolCallIds) });\n\t}\n\tif (toolCallIds.size > 0) throw new MissingToolResultsError({ toolCallIds: Array.from(toolCallIds) });\n\treturn combinedMessages.filter((message) => message.role !== \"tool\" || message.content.length > 0);\n}\nfunction convertToLanguageModelMessage({ message, downloadedAssets }) {\n\tconst role = message.role;\n\tswitch (role) {\n\t\tcase \"system\": return {\n\t\t\trole: \"system\",\n\t\t\tcontent: message.content,\n\t\t\tproviderOptions: message.providerOptions\n\t\t};\n\t\tcase \"user\":\n\t\t\tif (typeof message.content === \"string\") return {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: message.content\n\t\t\t\t}],\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: message.content.map((part) => convertPartToLanguageModelPart(part, downloadedAssets)).filter((part) => part.type !== \"text\" || part.text !== \"\"),\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\tcase \"assistant\":\n\t\t\tif (typeof message.content === \"string\") return {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: message.content\n\t\t\t\t}],\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: message.content.filter((part) => part.type !== \"text\" || part.text !== \"\" || part.providerOptions != null).filter((part) => part.type !== \"tool-approval-request\").map((part) => {\n\t\t\t\t\tconst providerOptions = part.providerOptions;\n\t\t\t\t\tswitch (part.type) {\n\t\t\t\t\t\tcase \"file\": {\n\t\t\t\t\t\t\tconst { data, mediaType } = convertToLanguageModelV3DataContent(part.data);\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\t\t\tmediaType: mediaType != null ? mediaType : part.mediaType,\n\t\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"reasoning\": return {\n\t\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"text\": return {\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"tool-call\": return {\n\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t\tproviderExecuted: part.providerExecuted,\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcase \"tool-result\": return {\n\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\toutput: mapToolResultOutput({\n\t\t\t\t\t\t\t\toutput: part.output,\n\t\t\t\t\t\t\t\tdownloadedAssets\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tproviderOptions: message.providerOptions\n\t\t\t};\n\t\tcase \"tool\": return {\n\t\t\trole: \"tool\",\n\t\t\tcontent: message.content.filter((part) => part.type !== \"tool-approval-response\" || part.providerExecuted).map((part) => {\n\t\t\t\tswitch (part.type) {\n\t\t\t\t\tcase \"tool-result\": return {\n\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\toutput: mapToolResultOutput({\n\t\t\t\t\t\t\toutput: part.output,\n\t\t\t\t\t\t\tdownloadedAssets\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tproviderOptions: part.providerOptions\n\t\t\t\t\t};\n\t\t\t\t\tcase \"tool-approval-response\": return {\n\t\t\t\t\t\ttype: \"tool-approval-response\",\n\t\t\t\t\t\tapprovalId: part.approvalId,\n\t\t\t\t\t\tapproved: part.approved,\n\t\t\t\t\t\treason: part.reason\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}),\n\t\t\tproviderOptions: message.providerOptions\n\t\t};\n\t\tdefault: throw new InvalidMessageRoleError({ role });\n\t}\n}\nasync function downloadAssets(messages, download2, supportedUrls) {\n\tvar _a23;\n\tconst downloadableFiles = [];\n\tfor (const message of messages) {\n\t\tif (message.role === \"user\" && Array.isArray(message.content)) {\n\t\t\tfor (const part of message.content) if (part.type === \"image\" || part.type === \"file\") downloadableFiles.push({\n\t\t\t\tdata: part.type === \"image\" ? part.image : part.data,\n\t\t\t\tmediaType: (_a23 = part.mediaType) != null ? _a23 : part.type === \"image\" ? \"image/*\" : void 0\n\t\t\t});\n\t\t}\n\t\tif (message.role === \"tool\" || message.role === \"assistant\") {\n\t\t\tif (!Array.isArray(message.content)) continue;\n\t\t\tfor (const part of message.content) {\n\t\t\t\tif (part.type !== \"tool-result\") continue;\n\t\t\t\tif (part.output.type !== \"content\") continue;\n\t\t\t\tfor (const contentPart of part.output.value) if (contentPart.type === \"image-url\" || contentPart.type === \"file-url\") downloadableFiles.push({\n\t\t\t\t\tdata: new URL(contentPart.url),\n\t\t\t\t\tmediaType: contentPart.type === \"image-url\" ? \"image/*\" : contentPart.mediaType\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tconst plannedDownloads = downloadableFiles.map((part) => {\n\t\tconst mediaType = part.mediaType;\n\t\tconst { data } = convertToLanguageModelV3DataContent(part.data);\n\t\treturn {\n\t\t\tmediaType,\n\t\t\tdata\n\t\t};\n\t}).filter((part) => part.data instanceof URL).map((part) => ({\n\t\turl: part.data,\n\t\tisUrlSupportedByModel: part.mediaType != null && isUrlSupported({\n\t\t\turl: part.data.toString(),\n\t\t\tmediaType: part.mediaType,\n\t\t\tsupportedUrls\n\t\t})\n\t}));\n\tconst downloadedFiles = await download2(plannedDownloads);\n\treturn Object.fromEntries(downloadedFiles.map((file, index) => file == null ? null : [plannedDownloads[index].url.toString(), {\n\t\tdata: file.data,\n\t\tmediaType: file.mediaType\n\t}]).filter((file) => file != null));\n}\nfunction convertPartToLanguageModelPart(part, downloadedAssets) {\n\tvar _a23;\n\tif (part.type === \"text\") return {\n\t\ttype: \"text\",\n\t\ttext: part.text,\n\t\tproviderOptions: part.providerOptions\n\t};\n\tlet originalData;\n\tconst type = part.type;\n\tswitch (type) {\n\t\tcase \"image\":\n\t\t\toriginalData = part.image;\n\t\t\tbreak;\n\t\tcase \"file\":\n\t\t\toriginalData = part.data;\n\t\t\tbreak;\n\t\tdefault: throw new Error(`Unsupported part type: ${type}`);\n\t}\n\tconst { data: convertedData, mediaType: convertedMediaType, originalUrl } = convertToLanguageModelV3DataContent(originalData);\n\tlet mediaType = convertedMediaType != null ? convertedMediaType : part.mediaType;\n\tlet data = convertedData;\n\tif (data instanceof URL) {\n\t\tconst downloadedFile = downloadedAssets[data.toString()];\n\t\tif (downloadedFile) {\n\t\t\tdata = downloadedFile.data;\n\t\t\tmediaType ??= downloadedFile.mediaType;\n\t\t}\n\t}\n\tswitch (type) {\n\t\tcase \"image\":\n\t\t\tif (data instanceof Uint8Array || typeof data === \"string\") mediaType = (_a23 = detectMediaType({\n\t\t\t\tdata,\n\t\t\t\tsignatures: imageMediaTypeSignatures\n\t\t\t})) != null ? _a23 : mediaType;\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tmediaType: mediaType != null ? mediaType : \"image/*\",\n\t\t\t\tfilename: void 0,\n\t\t\t\tdata,\n\t\t\t\t...data instanceof URL && originalUrl != null ? { originalUrl } : {},\n\t\t\t\tproviderOptions: part.providerOptions\n\t\t\t};\n\t\tcase \"file\":\n\t\t\tif (mediaType == null) throw new Error(`Media type is missing for file part`);\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tmediaType,\n\t\t\t\tfilename: part.filename,\n\t\t\t\tdata,\n\t\t\t\t...data instanceof URL && originalUrl != null ? { originalUrl } : {},\n\t\t\t\tproviderOptions: part.providerOptions\n\t\t\t};\n\t}\n}\nfunction mapToolResultOutput({ output, downloadedAssets }) {\n\tif (output.type !== \"content\") return output;\n\treturn {\n\t\ttype: \"content\",\n\t\tvalue: output.value.map((item) => {\n\t\t\tvar _a23, _b;\n\t\t\tif (item.type === \"image-url\") {\n\t\t\t\tconst downloadedFile = downloadedAssets[new URL(item.url).toString()];\n\t\t\t\tif (downloadedFile) return {\n\t\t\t\t\ttype: \"image-data\",\n\t\t\t\t\tdata: convertDataContentToBase64String(downloadedFile.data),\n\t\t\t\t\tmediaType: (_a23 = downloadedFile.mediaType) != null ? _a23 : \"image/*\",\n\t\t\t\t\tproviderOptions: item.providerOptions\n\t\t\t\t};\n\t\t\t\treturn item;\n\t\t\t}\n\t\t\tif (item.type === \"file-url\") {\n\t\t\t\tconst downloadedFile = downloadedAssets[new URL(item.url).toString()];\n\t\t\t\tif (downloadedFile) return {\n\t\t\t\t\ttype: \"file-data\",\n\t\t\t\t\tdata: convertDataContentToBase64String(downloadedFile.data),\n\t\t\t\t\tmediaType: (_b = downloadedFile.mediaType) != null ? _b : \"application/octet-stream\",\n\t\t\t\t\tproviderOptions: item.providerOptions\n\t\t\t\t};\n\t\t\t\treturn item;\n\t\t\t}\n\t\t\tif (item.type !== \"media\") return item;\n\t\t\tif (item.mediaType.startsWith(\"image/\")) return {\n\t\t\t\ttype: \"image-data\",\n\t\t\t\tdata: item.data,\n\t\t\t\tmediaType: item.mediaType\n\t\t\t};\n\t\t\treturn {\n\t\t\t\ttype: \"file-data\",\n\t\t\t\tdata: item.data,\n\t\t\t\tmediaType: item.mediaType\n\t\t\t};\n\t\t})\n\t};\n}\nasync function createToolModelOutput({ toolCallId, input, output, tool: tool2, errorMode }) {\n\tif (errorMode === \"text\") return {\n\t\ttype: \"error-text\",\n\t\tvalue: getErrorMessage(output)\n\t};\n\telse if (errorMode === \"json\") return {\n\t\ttype: \"error-json\",\n\t\tvalue: toJSONValue(output)\n\t};\n\tif (tool2 == null ? void 0 : tool2.toModelOutput) return await tool2.toModelOutput({\n\t\ttoolCallId,\n\t\tinput,\n\t\toutput\n\t});\n\treturn typeof output === \"string\" ? {\n\t\ttype: \"text\",\n\t\tvalue: output\n\t} : {\n\t\ttype: \"json\",\n\t\tvalue: toJSONValue(output)\n\t};\n}\nfunction toJSONValue(value) {\n\treturn value === void 0 ? null : value;\n}\nfunction prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences }) {\n\tif (maxOutputTokens != null) {\n\t\tif (!Number.isInteger(maxOutputTokens)) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxOutputTokens\",\n\t\t\tvalue: maxOutputTokens,\n\t\t\tmessage: \"maxOutputTokens must be an integer\"\n\t\t});\n\t\tif (maxOutputTokens < 1) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxOutputTokens\",\n\t\t\tvalue: maxOutputTokens,\n\t\t\tmessage: \"maxOutputTokens must be >= 1\"\n\t\t});\n\t}\n\tif (temperature != null) {\n\t\tif (typeof temperature !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"temperature\",\n\t\t\tvalue: temperature,\n\t\t\tmessage: \"temperature must be a number\"\n\t\t});\n\t}\n\tif (topP != null) {\n\t\tif (typeof topP !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"topP\",\n\t\t\tvalue: topP,\n\t\t\tmessage: \"topP must be a number\"\n\t\t});\n\t}\n\tif (topK != null) {\n\t\tif (typeof topK !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"topK\",\n\t\t\tvalue: topK,\n\t\t\tmessage: \"topK must be a number\"\n\t\t});\n\t}\n\tif (presencePenalty != null) {\n\t\tif (typeof presencePenalty !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"presencePenalty\",\n\t\t\tvalue: presencePenalty,\n\t\t\tmessage: \"presencePenalty must be a number\"\n\t\t});\n\t}\n\tif (frequencyPenalty != null) {\n\t\tif (typeof frequencyPenalty !== \"number\") throw new InvalidArgumentError({\n\t\t\tparameter: \"frequencyPenalty\",\n\t\t\tvalue: frequencyPenalty,\n\t\t\tmessage: \"frequencyPenalty must be a number\"\n\t\t});\n\t}\n\tif (seed != null) {\n\t\tif (!Number.isInteger(seed)) throw new InvalidArgumentError({\n\t\t\tparameter: \"seed\",\n\t\t\tvalue: seed,\n\t\t\tmessage: \"seed must be an integer\"\n\t\t});\n\t}\n\treturn {\n\t\tmaxOutputTokens,\n\t\ttemperature,\n\t\ttopP,\n\t\ttopK,\n\t\tpresencePenalty,\n\t\tfrequencyPenalty,\n\t\tstopSequences,\n\t\tseed\n\t};\n}\nfunction isNonEmptyObject(object2) {\n\treturn object2 != null && Object.keys(object2).length > 0;\n}\nasync function prepareToolsAndToolChoice({ tools, toolChoice, activeTools }) {\n\tif (!isNonEmptyObject(tools)) return {\n\t\ttools: void 0,\n\t\ttoolChoice: void 0\n\t};\n\tconst filteredTools = activeTools != null ? Object.entries(tools).filter(([name23]) => activeTools.includes(name23)) : Object.entries(tools);\n\tconst languageModelTools = [];\n\tfor (const [name23, tool2] of filteredTools) {\n\t\tconst toolType = tool2.type;\n\t\tswitch (toolType) {\n\t\t\tcase void 0:\n\t\t\tcase \"dynamic\":\n\t\t\tcase \"function\":\n\t\t\t\tlanguageModelTools.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: name23,\n\t\t\t\t\tdescription: tool2.description,\n\t\t\t\t\tinputSchema: await asSchema(tool2.inputSchema).jsonSchema,\n\t\t\t\t\t...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},\n\t\t\t\t\tproviderOptions: tool2.providerOptions,\n\t\t\t\t\t...tool2.strict != null ? { strict: tool2.strict } : {}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"provider\":\n\t\t\t\tlanguageModelTools.push({\n\t\t\t\t\ttype: \"provider\",\n\t\t\t\t\tname: name23,\n\t\t\t\t\tid: tool2.id,\n\t\t\t\t\targs: tool2.args\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tdefault: throw new Error(`Unsupported tool type: ${toolType}`);\n\t\t}\n\t}\n\treturn {\n\t\ttools: languageModelTools,\n\t\ttoolChoice: toolChoice == null ? { type: \"auto\" } : typeof toolChoice === \"string\" ? { type: toolChoice } : {\n\t\t\ttype: \"tool\",\n\t\t\ttoolName: toolChoice.toolName\n\t\t}\n\t};\n}\nvar jsonValueSchema = z.lazy(() => z.union([\n\tz.null(),\n\tz.string(),\n\tz.number(),\n\tz.boolean(),\n\tz.record(z.string(), jsonValueSchema.optional()),\n\tz.array(jsonValueSchema)\n]));\nvar providerMetadataSchema = z.record(z.string(), z.record(z.string(), jsonValueSchema.optional()));\nvar textPartSchema = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar imagePartSchema = z.object({\n\ttype: z.literal(\"image\"),\n\timage: z.union([dataContentSchema, z.instanceof(URL)]),\n\tmediaType: z.string().optional(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar filePartSchema = z.object({\n\ttype: z.literal(\"file\"),\n\tdata: z.union([dataContentSchema, z.instanceof(URL)]),\n\tfilename: z.string().optional(),\n\tmediaType: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar reasoningPartSchema = z.object({\n\ttype: z.literal(\"reasoning\"),\n\ttext: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar toolCallPartSchema = z.object({\n\ttype: z.literal(\"tool-call\"),\n\ttoolCallId: z.string(),\n\ttoolName: z.string(),\n\tinput: z.unknown(),\n\tproviderOptions: providerMetadataSchema.optional(),\n\tproviderExecuted: z.boolean().optional()\n});\nvar outputSchema = z.discriminatedUnion(\"type\", [\n\tz.object({\n\t\ttype: z.literal(\"text\"),\n\t\tvalue: z.string(),\n\t\tproviderOptions: providerMetadataSchema.optional()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"json\"),\n\t\tvalue: jsonValueSchema,\n\t\tproviderOptions: providerMetadataSchema.optional()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"execution-denied\"),\n\t\treason: z.string().optional(),\n\t\tproviderOptions: providerMetadataSchema.optional()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"error-text\"),\n\t\tvalue: z.string(),\n\t\tproviderOptions: providerMetadataSchema.optional()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"error-json\"),\n\t\tvalue: jsonValueSchema,\n\t\tproviderOptions: providerMetadataSchema.optional()\n\t}),\n\tz.object({\n\t\ttype: z.literal(\"content\"),\n\t\tvalue: z.array(z.union([\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"text\"),\n\t\t\t\ttext: z.string(),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"media\"),\n\t\t\t\tdata: z.string(),\n\t\t\t\tmediaType: z.string()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"file-data\"),\n\t\t\t\tdata: z.string(),\n\t\t\t\tmediaType: z.string(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"file-url\"),\n\t\t\t\turl: z.string(),\n\t\t\t\tmediaType: z.string().optional(),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"file-id\"),\n\t\t\t\tfileId: z.union([z.string(), z.record(z.string(), z.string())]),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"image-data\"),\n\t\t\t\tdata: z.string(),\n\t\t\t\tmediaType: z.string(),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"image-url\"),\n\t\t\t\turl: z.string(),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"image-file-id\"),\n\t\t\t\tfileId: z.union([z.string(), z.record(z.string(), z.string())]),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"custom\"),\n\t\t\t\tproviderOptions: providerMetadataSchema.optional()\n\t\t\t})\n\t\t]))\n\t})\n]);\nvar toolResultPartSchema = z.object({\n\ttype: z.literal(\"tool-result\"),\n\ttoolCallId: z.string(),\n\ttoolName: z.string(),\n\toutput: outputSchema,\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar toolApprovalRequestSchema = z.object({\n\ttype: z.literal(\"tool-approval-request\"),\n\tapprovalId: z.string(),\n\ttoolCallId: z.string(),\n\tsignature: z.string().optional(),\n\tinputSchemaInput: z.unknown().optional()\n});\nvar toolApprovalResponseSchema = z.object({\n\ttype: z.literal(\"tool-approval-response\"),\n\tapprovalId: z.string(),\n\tapproved: z.boolean(),\n\treason: z.string().optional()\n});\nvar systemModelMessageSchema = z.object({\n\trole: z.literal(\"system\"),\n\tcontent: z.string(),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar userModelMessageSchema = z.object({\n\trole: z.literal(\"user\"),\n\tcontent: z.union([z.string(), z.array(z.union([\n\t\ttextPartSchema,\n\t\timagePartSchema,\n\t\tfilePartSchema\n\t]))]),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar assistantModelMessageSchema = z.object({\n\trole: z.literal(\"assistant\"),\n\tcontent: z.union([z.string(), z.array(z.union([\n\t\ttextPartSchema,\n\t\tfilePartSchema,\n\t\treasoningPartSchema,\n\t\ttoolCallPartSchema,\n\t\ttoolResultPartSchema,\n\t\ttoolApprovalRequestSchema\n\t]))]),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar toolModelMessageSchema = z.object({\n\trole: z.literal(\"tool\"),\n\tcontent: z.array(z.union([toolResultPartSchema, toolApprovalResponseSchema])),\n\tproviderOptions: providerMetadataSchema.optional()\n});\nvar modelMessageSchema = z.union([\n\tsystemModelMessageSchema,\n\tuserModelMessageSchema,\n\tassistantModelMessageSchema,\n\ttoolModelMessageSchema\n]);\nasync function standardizePrompt({ allowSystemInMessages, system, prompt, messages }) {\n\tif (prompt == null && messages == null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt or messages must be defined\"\n\t});\n\tif (prompt != null && messages != null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt and messages cannot be defined at the same time\"\n\t});\n\tif (typeof system !== \"string\" && !asArray(system).every((message) => message.role === \"system\")) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"system must be a string, SystemModelMessage, or array of SystemModelMessage\"\n\t});\n\tif (prompt != null && typeof prompt === \"string\") messages = [{\n\t\trole: \"user\",\n\t\tcontent: prompt\n\t}];\n\telse if (prompt != null && Array.isArray(prompt)) messages = prompt;\n\telse if (messages == null) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"prompt or messages must be defined\"\n\t});\n\tif (messages.length === 0) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"messages must not be empty\"\n\t});\n\tif (messages.some((message) => message.role === \"system\")) {\n\t\tif (allowSystemInMessages === false) throw new InvalidPromptError({\n\t\t\tprompt,\n\t\t\tmessage: \"System messages are not allowed in the prompt or messages fields. Use the system option instead.\"\n\t\t});\n\t\tif (allowSystemInMessages === void 0) console.warn(\"AI SDK Warning: System messages in the prompt or messages fields can be a security risk because they may enable prompt injection attacks. Use the system option instead when possible. Set allowSystemInMessages to true to suppress this warning, or false to throw an error.\");\n\t}\n\tconst validationResult = await safeValidateTypes({\n\t\tvalue: messages,\n\t\tschema: z.array(modelMessageSchema)\n\t});\n\tif (!validationResult.success) throw new InvalidPromptError({\n\t\tprompt,\n\t\tmessage: \"The messages do not match the ModelMessage[] schema.\",\n\t\tcause: validationResult.error\n\t});\n\treturn {\n\t\tmessages,\n\t\tsystem\n\t};\n}\nfunction wrapGatewayError(error) {\n\tif (!GatewayAuthenticationError.isInstance(error)) return error;\n\tconst isProductionEnv = (process == null ? void 0 : \"production\") === \"production\";\n\tconst moreInfoURL = \"https://ai-sdk.dev/unauthenticated-ai-gateway\";\n\tif (isProductionEnv) return new AISDKError({\n\t\tname: \"GatewayError\",\n\t\tmessage: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`\n\t});\n\treturn Object.assign(/* @__PURE__ */ new Error(`\\x1B[1m\\x1B[31mUnauthenticated request to AI Gateway.\\x1B[0m\n\nTo authenticate, set the \\x1B[33mAI_GATEWAY_API_KEY\\x1B[0m environment variable with your API key.\n\nAlternatively, you can use a provider module instead of the AI Gateway.\n\nLearn more: \\x1B[34m${moreInfoURL}\\x1B[0m\n\n`), { name: \"GatewayAuthenticationError\" });\n}\nfunction assembleOperationName({ operationId, telemetry }) {\n\treturn {\n\t\t\"operation.name\": `${operationId}${(telemetry == null ? void 0 : telemetry.functionId) != null ? ` ${telemetry.functionId}` : \"\"}`,\n\t\t\"resource.name\": telemetry == null ? void 0 : telemetry.functionId,\n\t\t\"ai.operationId\": operationId,\n\t\t\"ai.telemetry.functionId\": telemetry == null ? void 0 : telemetry.functionId\n\t};\n}\nfunction getBaseTelemetryAttributes({ model, settings, telemetry, headers }) {\n\tvar _a23;\n\treturn {\n\t\t\"ai.model.provider\": model.provider,\n\t\t\"ai.model.id\": model.modelId,\n\t\t...Object.entries(settings).reduce((attributes, [key, value]) => {\n\t\t\tif (key === \"timeout\") {\n\t\t\t\tconst totalTimeoutMs = getTotalTimeoutMs(value);\n\t\t\t\tif (totalTimeoutMs != null) attributes[`ai.settings.${key}`] = totalTimeoutMs;\n\t\t\t} else attributes[`ai.settings.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {}),\n\t\t...Object.entries((_a23 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a23 : {}).reduce((attributes, [key, value]) => {\n\t\t\tattributes[`ai.telemetry.metadata.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {}),\n\t\t...Object.entries(headers != null ? headers : {}).reduce((attributes, [key, value]) => {\n\t\t\tif (value !== void 0) attributes[`ai.request.headers.${key}`] = value;\n\t\t\treturn attributes;\n\t\t}, {})\n\t};\n}\nvar noopTracer = {\n\tstartSpan() {\n\t\treturn noopSpan;\n\t},\n\tstartActiveSpan(name23, arg1, arg2, arg3) {\n\t\tif (typeof arg1 === \"function\") return arg1(noopSpan);\n\t\tif (typeof arg2 === \"function\") return arg2(noopSpan);\n\t\tif (typeof arg3 === \"function\") return arg3(noopSpan);\n\t}\n};\nvar noopSpan = {\n\tspanContext() {\n\t\treturn noopSpanContext;\n\t},\n\tsetAttribute() {\n\t\treturn this;\n\t},\n\tsetAttributes() {\n\t\treturn this;\n\t},\n\taddEvent() {\n\t\treturn this;\n\t},\n\taddLink() {\n\t\treturn this;\n\t},\n\taddLinks() {\n\t\treturn this;\n\t},\n\tsetStatus() {\n\t\treturn this;\n\t},\n\tupdateName() {\n\t\treturn this;\n\t},\n\tend() {\n\t\treturn this;\n\t},\n\tisRecording() {\n\t\treturn false;\n\t},\n\trecordException() {\n\t\treturn this;\n\t}\n};\nvar noopSpanContext = {\n\ttraceId: \"\",\n\tspanId: \"\",\n\ttraceFlags: 0\n};\nfunction getTracer({ isEnabled = false, tracer } = {}) {\n\tif (!isEnabled) return noopTracer;\n\tif (tracer) return tracer;\n\treturn trace.getTracer(\"ai\");\n}\nasync function recordSpan({ name: name23, tracer, attributes, fn, endWhenDone = true, endOnError = endWhenDone }) {\n\treturn tracer.startActiveSpan(name23, { attributes: await attributes }, async (span) => {\n\t\tconst ctx = context.active();\n\t\ttry {\n\t\t\tconst result = await context.with(ctx, () => fn(span));\n\t\t\tif (endWhenDone) span.end();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t} finally {\n\t\t\t\tif (endOnError) span.end();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t});\n}\nfunction recordErrorOnSpan(span, error) {\n\tif (error instanceof Error) {\n\t\tspan.recordException({\n\t\t\tname: error.name,\n\t\t\tmessage: error.message,\n\t\t\tstack: error.stack\n\t\t});\n\t\tspan.setStatus({\n\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\tmessage: error.message\n\t\t});\n\t} else span.setStatus({ code: SpanStatusCode.ERROR });\n}\nfunction isPrimitiveAttributeValue(value) {\n\treturn typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\nfunction sanitizeAttributeValue(value) {\n\tif (!Array.isArray(value)) return value;\n\tconst primitiveTypes = new Set(value.filter(isPrimitiveAttributeValue).map((item) => typeof item));\n\tif (primitiveTypes.size !== 1) return;\n\tconst [primitiveType] = primitiveTypes;\n\tif (primitiveType === \"string\") return value.filter((item) => typeof item === \"string\");\n\tif (primitiveType === \"number\") return value.filter((item) => typeof item === \"number\");\n\treturn value.filter((item) => typeof item === \"boolean\");\n}\nasync function selectTelemetryAttributes({ telemetry, attributes }) {\n\tif ((telemetry == null ? void 0 : telemetry.isEnabled) !== true) return {};\n\tconst resultAttributes = {};\n\tfor (const [key, value] of Object.entries(attributes)) {\n\t\tif (value == null) continue;\n\t\tif (typeof value === \"object\" && \"input\" in value && typeof value.input === \"function\") {\n\t\t\tif ((telemetry == null ? void 0 : telemetry.recordInputs) === false) continue;\n\t\t\tconst result = await value.input();\n\t\t\tif (result != null) {\n\t\t\t\tconst sanitized2 = sanitizeAttributeValue(result);\n\t\t\t\tif (sanitized2 != null) resultAttributes[key] = sanitized2;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof value === \"object\" && \"output\" in value && typeof value.output === \"function\") {\n\t\t\tif ((telemetry == null ? void 0 : telemetry.recordOutputs) === false) continue;\n\t\t\tconst result = await value.output();\n\t\t\tif (result != null) {\n\t\t\t\tconst sanitized2 = sanitizeAttributeValue(result);\n\t\t\t\tif (sanitized2 != null) resultAttributes[key] = sanitized2;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst sanitized = sanitizeAttributeValue(value);\n\t\tif (sanitized != null) resultAttributes[key] = sanitized;\n\t}\n\treturn resultAttributes;\n}\nfunction stringifyForTelemetry(prompt) {\n\treturn JSON.stringify(prompt.map((message) => ({\n\t\t...message,\n\t\tcontent: typeof message.content === \"string\" ? message.content : message.content.map((part) => part.type === \"file\" ? {\n\t\t\t...part,\n\t\t\tdata: part.data instanceof Uint8Array ? convertDataContentToBase64String(part.data) : part.data\n\t\t} : part)\n\t})));\n}\nfunction registerTelemetryIntegration(integration) {\n\tif (!globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) globalThis.AI_SDK_TELEMETRY_INTEGRATIONS = [];\n\tglobalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(integration);\n}\nfunction getGlobalTelemetryIntegrations() {\n\tvar _a23;\n\treturn (_a23 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a23 : [];\n}\nfunction bindTelemetryIntegration(integration) {\n\tvar _a23, _b, _c, _d, _e, _f;\n\treturn {\n\t\tonStart: (_a23 = integration.onStart) == null ? void 0 : _a23.bind(integration),\n\t\tonStepStart: (_b = integration.onStepStart) == null ? void 0 : _b.bind(integration),\n\t\tonToolCallStart: (_c = integration.onToolCallStart) == null ? void 0 : _c.bind(integration),\n\t\tonToolCallFinish: (_d = integration.onToolCallFinish) == null ? void 0 : _d.bind(integration),\n\t\tonStepFinish: (_e = integration.onStepFinish) == null ? void 0 : _e.bind(integration),\n\t\tonFinish: (_f = integration.onFinish) == null ? void 0 : _f.bind(integration)\n\t};\n}\nfunction getGlobalTelemetryIntegration() {\n\tconst globalIntegrations = getGlobalTelemetryIntegrations();\n\treturn (integrations) => {\n\t\tconst localIntegrations = asArray(integrations);\n\t\tconst allIntegrations = [...globalIntegrations, ...localIntegrations];\n\t\tfunction createTelemetryComposite(getListenerFromIntegration) {\n\t\t\tconst listeners = allIntegrations.map(getListenerFromIntegration).filter(Boolean);\n\t\t\treturn async (event) => {\n\t\t\t\tfor (const listener of listeners) try {\n\t\t\t\t\tawait listener(event);\n\t\t\t\t} catch (_ignored) {}\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tonStart: createTelemetryComposite((integration) => integration.onStart),\n\t\t\tonStepStart: createTelemetryComposite((integration) => integration.onStepStart),\n\t\t\tonToolCallStart: createTelemetryComposite((integration) => integration.onToolCallStart),\n\t\t\tonToolCallFinish: createTelemetryComposite((integration) => integration.onToolCallFinish),\n\t\t\tonStepFinish: createTelemetryComposite((integration) => integration.onStepFinish),\n\t\t\tonFinish: createTelemetryComposite((integration) => integration.onFinish)\n\t\t};\n\t};\n}\nfunction asLanguageModelUsage(usage) {\n\treturn {\n\t\tinputTokens: usage.inputTokens.total,\n\t\tinputTokenDetails: {\n\t\t\tnoCacheTokens: usage.inputTokens.noCache,\n\t\t\tcacheReadTokens: usage.inputTokens.cacheRead,\n\t\t\tcacheWriteTokens: usage.inputTokens.cacheWrite\n\t\t},\n\t\toutputTokens: usage.outputTokens.total,\n\t\toutputTokenDetails: {\n\t\t\ttextTokens: usage.outputTokens.text,\n\t\t\treasoningTokens: usage.outputTokens.reasoning\n\t\t},\n\t\ttotalTokens: addTokenCounts(usage.inputTokens.total, usage.outputTokens.total),\n\t\traw: usage.raw,\n\t\treasoningTokens: usage.outputTokens.reasoning,\n\t\tcachedInputTokens: usage.inputTokens.cacheRead\n\t};\n}\nfunction createNullLanguageModelUsage() {\n\treturn {\n\t\tinputTokens: void 0,\n\t\tinputTokenDetails: {\n\t\t\tnoCacheTokens: void 0,\n\t\t\tcacheReadTokens: void 0,\n\t\t\tcacheWriteTokens: void 0\n\t\t},\n\t\toutputTokens: void 0,\n\t\toutputTokenDetails: {\n\t\t\ttextTokens: void 0,\n\t\t\treasoningTokens: void 0\n\t\t},\n\t\ttotalTokens: void 0,\n\t\traw: void 0\n\t};\n}\nfunction addLanguageModelUsage(usage1, usage2) {\n\tvar _a23, _b, _c, _d, _e, _f, _g, _h, _i, _j;\n\tconst raw = isNullLanguageModelUsage(usage1) ? usage2.raw : isNullLanguageModelUsage(usage2) ? usage1.raw : void 0;\n\treturn {\n\t\tinputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),\n\t\tinputTokenDetails: {\n\t\t\tnoCacheTokens: addTokenCounts((_a23 = usage1.inputTokenDetails) == null ? void 0 : _a23.noCacheTokens, (_b = usage2.inputTokenDetails) == null ? void 0 : _b.noCacheTokens),\n\t\t\tcacheReadTokens: addTokenCounts((_c = usage1.inputTokenDetails) == null ? void 0 : _c.cacheReadTokens, (_d = usage2.inputTokenDetails) == null ? void 0 : _d.cacheReadTokens),\n\t\t\tcacheWriteTokens: addTokenCounts((_e = usage1.inputTokenDetails) == null ? void 0 : _e.cacheWriteTokens, (_f = usage2.inputTokenDetails) == null ? void 0 : _f.cacheWriteTokens)\n\t\t},\n\t\toutputTokens: addTokenCounts(usage1.outputTokens, usage2.outputTokens),\n\t\toutputTokenDetails: {\n\t\t\ttextTokens: addTokenCounts((_g = usage1.outputTokenDetails) == null ? void 0 : _g.textTokens, (_h = usage2.outputTokenDetails) == null ? void 0 : _h.textTokens),\n\t\t\treasoningTokens: addTokenCounts((_i = usage1.outputTokenDetails) == null ? void 0 : _i.reasoningTokens, (_j = usage2.outputTokenDetails) == null ? void 0 : _j.reasoningTokens)\n\t\t},\n\t\ttotalTokens: addTokenCounts(usage1.totalTokens, usage2.totalTokens),\n\t\treasoningTokens: addTokenCounts(usage1.reasoningTokens, usage2.reasoningTokens),\n\t\tcachedInputTokens: addTokenCounts(usage1.cachedInputTokens, usage2.cachedInputTokens),\n\t\t...raw == null ? {} : { raw }\n\t};\n}\nfunction isNullLanguageModelUsage(usage) {\n\tvar _a23, _b, _c, _d, _e;\n\treturn usage.inputTokens == null && ((_a23 = usage.inputTokenDetails) == null ? void 0 : _a23.noCacheTokens) == null && ((_b = usage.inputTokenDetails) == null ? void 0 : _b.cacheReadTokens) == null && ((_c = usage.inputTokenDetails) == null ? void 0 : _c.cacheWriteTokens) == null && usage.outputTokens == null && ((_d = usage.outputTokenDetails) == null ? void 0 : _d.textTokens) == null && ((_e = usage.outputTokenDetails) == null ? void 0 : _e.reasoningTokens) == null && usage.totalTokens == null && usage.raw == null;\n}\nfunction addTokenCounts(tokenCount1, tokenCount2) {\n\treturn tokenCount1 == null && tokenCount2 == null ? void 0 : (tokenCount1 != null ? tokenCount1 : 0) + (tokenCount2 != null ? tokenCount2 : 0);\n}\nfunction addImageModelUsage(usage1, usage2) {\n\treturn {\n\t\tinputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),\n\t\toutputTokens: addTokenCounts(usage1.outputTokens, usage2.outputTokens),\n\t\ttotalTokens: addTokenCounts(usage1.totalTokens, usage2.totalTokens)\n\t};\n}\nfunction getRetryDelayInMs({ error, exponentialBackoffDelay }) {\n\tconst headers = APICallError.isInstance(error) ? error.responseHeaders : APICallError.isInstance(error.cause) ? error.cause.responseHeaders : void 0;\n\tif (!headers) return exponentialBackoffDelay;\n\tlet ms;\n\tconst retryAfterMs = headers[\"retry-after-ms\"];\n\tif (retryAfterMs) {\n\t\tconst timeoutMs = parseFloat(retryAfterMs);\n\t\tif (!Number.isNaN(timeoutMs)) ms = timeoutMs;\n\t}\n\tconst retryAfter = headers[\"retry-after\"];\n\tif (retryAfter && ms === void 0) {\n\t\tconst timeoutSeconds = parseFloat(retryAfter);\n\t\tif (!Number.isNaN(timeoutSeconds)) ms = timeoutSeconds * 1e3;\n\t\telse ms = Date.parse(retryAfter) - Date.now();\n\t}\n\tif (ms != null && !Number.isNaN(ms) && 0 <= ms && (ms < 6e4 || ms < exponentialBackoffDelay)) return ms;\n\treturn exponentialBackoffDelay;\n}\nvar retryWithExponentialBackoffRespectingRetryHeaders = ({ maxRetries = 2, initialDelayInMs = 2e3, backoffFactor = 2, abortSignal, additionalRetryableError } = {}) => retryWithExponentialBackoff({\n\tmaxRetries,\n\tinitialDelayInMs,\n\tbackoffFactor,\n\tabortSignal,\n\tshouldRetry: async (error) => error instanceof Error && (APICallError.isInstance(error) && error.isRetryable === true || GatewayError.isInstance(error) && error.isRetryable === true) || additionalRetryableError != null && await additionalRetryableError(error),\n\tgetDelayInMs: ({ error, exponentialBackoffDelay }) => getRetryDelayInMs({\n\t\terror,\n\t\texponentialBackoffDelay\n\t}),\n\tcreateRetryError: ({ message, reason, errors }) => new RetryError({\n\t\tmessage,\n\t\treason,\n\t\terrors\n\t})\n});\nfunction prepareRetries({ maxRetries, abortSignal, additionalRetryableError }) {\n\tif (maxRetries != null) {\n\t\tif (!Number.isInteger(maxRetries)) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxRetries\",\n\t\t\tvalue: maxRetries,\n\t\t\tmessage: \"maxRetries must be an integer\"\n\t\t});\n\t\tif (maxRetries < 0) throw new InvalidArgumentError({\n\t\t\tparameter: \"maxRetries\",\n\t\t\tvalue: maxRetries,\n\t\t\tmessage: \"maxRetries must be >= 0\"\n\t\t});\n\t}\n\tconst maxRetriesResult = maxRetries != null ? maxRetries : 2;\n\treturn {\n\t\tmaxRetries: maxRetriesResult,\n\t\tretry: retryWithExponentialBackoffRespectingRetryHeaders({\n\t\t\tmaxRetries: maxRetriesResult,\n\t\t\tabortSignal,\n\t\t\tadditionalRetryableError\n\t\t})\n\t};\n}\nfunction setAbortTimeout({ abortController, label, timeoutMs }) {\n\tif (abortController == null || timeoutMs == null) return;\n\treturn setTimeout(() => abortController.abort(new DOMException(`${label} timeout of ${timeoutMs}ms exceeded`, \"TimeoutError\")), timeoutMs);\n}\nfunction collectToolApprovals({ messages }) {\n\tconst lastMessage = messages.at(-1);\n\tif ((lastMessage == null ? void 0 : lastMessage.role) != \"tool\") return {\n\t\tapprovedToolApprovals: [],\n\t\tdeniedToolApprovals: []\n\t};\n\tconst toolCallsByToolCallId = {};\n\tfor (const message of messages) if (message.role === \"assistant\" && typeof message.content !== \"string\") {\n\t\tconst content = message.content;\n\t\tfor (const part of content) if (part.type === \"tool-call\") toolCallsByToolCallId[part.toolCallId] = part;\n\t}\n\tconst toolApprovalRequestsByApprovalId = {};\n\tfor (const message of messages) if (message.role === \"assistant\" && typeof message.content !== \"string\") {\n\t\tconst content = message.content;\n\t\tfor (const part of content) if (part.type === \"tool-approval-request\") toolApprovalRequestsByApprovalId[part.approvalId] = part;\n\t}\n\tconst toolResults = {};\n\tfor (const part of lastMessage.content) if (part.type === \"tool-result\") toolResults[part.toolCallId] = part;\n\tconst approvedToolApprovals = [];\n\tconst deniedToolApprovals = [];\n\tconst approvalResponses = lastMessage.content.filter((part) => part.type === \"tool-approval-response\");\n\tfor (const approvalResponse of approvalResponses) {\n\t\tconst approvalRequest = toolApprovalRequestsByApprovalId[approvalResponse.approvalId];\n\t\tif (approvalRequest == null) throw new InvalidToolApprovalError({ approvalId: approvalResponse.approvalId });\n\t\tif (toolResults[approvalRequest.toolCallId] != null) continue;\n\t\tconst toolCall = toolCallsByToolCallId[approvalRequest.toolCallId];\n\t\tif (toolCall == null) throw new ToolCallNotFoundForApprovalError({\n\t\t\ttoolCallId: approvalRequest.toolCallId,\n\t\t\tapprovalId: approvalRequest.approvalId\n\t\t});\n\t\tconst approval = {\n\t\t\tapprovalRequest,\n\t\t\tapprovalResponse,\n\t\t\ttoolCall\n\t\t};\n\t\tif (approvalResponse.approved) approvedToolApprovals.push(approval);\n\t\telse deniedToolApprovals.push(approval);\n\t}\n\treturn {\n\t\tapprovedToolApprovals,\n\t\tdeniedToolApprovals\n\t};\n}\nfunction now() {\n\tvar _a23, _b;\n\treturn (_b = (_a23 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a23.now()) != null ? _b : Date.now();\n}\nasync function executeToolCall({ toolCall, tools, tracer, telemetry, messages, abortSignal, experimental_context, stepNumber, model, onPreliminaryToolResult, onToolCallStart, onToolCallFinish }) {\n\tvar _a23;\n\tconst { toolName, toolCallId, input } = toolCall;\n\tconst tool2 = tools == null ? void 0 : tools[toolName];\n\tif ((tool2 == null ? void 0 : tool2.execute) == null) return;\n\tconst baseCallbackEvent = {\n\t\tstepNumber,\n\t\tmodel,\n\t\ttoolCall,\n\t\tmessages,\n\t\tabortSignal,\n\t\tfunctionId: telemetry == null ? void 0 : telemetry.functionId,\n\t\tmetadata: telemetry == null ? void 0 : telemetry.metadata,\n\t\texperimental_context\n\t};\n\treturn recordSpan({\n\t\tname: \"ai.toolCall\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.toolCall\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...Object.fromEntries(Object.entries((_a23 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a23 : {}).map(([key, value]) => [`ai.telemetry.metadata.${key}`, value])),\n\t\t\t\t\"ai.toolCall.name\": toolName,\n\t\t\t\t\"ai.toolCall.id\": toolCallId,\n\t\t\t\t\"ai.toolCall.args\": { output: () => JSON.stringify(input) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tlet output;\n\t\t\tawait notify({\n\t\t\t\tevent: baseCallbackEvent,\n\t\t\t\tcallbacks: onToolCallStart\n\t\t\t});\n\t\t\tconst startTime = now();\n\t\t\ttry {\n\t\t\t\tconst stream = executeTool({\n\t\t\t\t\texecute: tool2.execute.bind(tool2),\n\t\t\t\t\tinput,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tfor await (const part of stream) if (part.type === \"preliminary\") onPreliminaryToolResult?.({\n\t\t\t\t\t...toolCall,\n\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\toutput: part.output,\n\t\t\t\t\tpreliminary: true\n\t\t\t\t});\n\t\t\t\telse output = part.output;\n\t\t\t} catch (error) {\n\t\t\t\tconst durationMs2 = now() - startTime;\n\t\t\t\tawait notify({\n\t\t\t\t\tevent: {\n\t\t\t\t\t\t...baseCallbackEvent,\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tdurationMs: durationMs2\n\t\t\t\t\t},\n\t\t\t\t\tcallbacks: onToolCallFinish\n\t\t\t\t});\n\t\t\t\trecordErrorOnSpan(span, error);\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\ttoolCallId,\n\t\t\t\t\ttoolName,\n\t\t\t\t\tinput,\n\t\t\t\t\terror,\n\t\t\t\t\tdynamic: tool2.type === \"dynamic\",\n\t\t\t\t\t...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},\n\t\t\t\t\t...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst durationMs = now() - startTime;\n\t\t\tawait notify({\n\t\t\t\tevent: {\n\t\t\t\t\t...baseCallbackEvent,\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\toutput,\n\t\t\t\t\tdurationMs\n\t\t\t\t},\n\t\t\t\tcallbacks: onToolCallFinish\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: { \"ai.toolCall.result\": { output: () => JSON.stringify(output) } }\n\t\t\t\t}));\n\t\t\t} catch (ignored) {}\n\t\t\treturn {\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId,\n\t\t\t\ttoolName,\n\t\t\t\tinput,\n\t\t\t\toutput,\n\t\t\t\tdynamic: tool2.type === \"dynamic\",\n\t\t\t\t...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},\n\t\t\t\t...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t};\n\t\t}\n\t});\n}\nfunction extractReasoningContent(content) {\n\tconst parts = content.filter((content2) => content2.type === \"reasoning\");\n\treturn parts.length === 0 ? void 0 : parts.map((content2) => content2.text).join(\"\\n\");\n}\nfunction extractTextContent(content) {\n\tconst parts = content.filter((content2) => content2.type === \"text\");\n\tif (parts.length === 0) return;\n\treturn parts.map((content2) => content2.text).join(\"\");\n}\nfunction filterActiveTools({ tools, activeTools }) {\n\tif (tools == null || activeTools == null) return tools;\n\treturn Object.fromEntries(Object.entries(tools).filter(([name23]) => activeTools.includes(name23)));\n}\nvar DefaultGeneratedFile = class {\n\tconstructor({ data, mediaType }) {\n\t\tconst isUint8Array = data instanceof Uint8Array;\n\t\tthis.base64Data = isUint8Array ? void 0 : data;\n\t\tthis.uint8ArrayData = isUint8Array ? data : void 0;\n\t\tthis.mediaType = mediaType;\n\t}\n\tget base64() {\n\t\tif (this.base64Data == null) this.base64Data = convertUint8ArrayToBase64(this.uint8ArrayData);\n\t\treturn this.base64Data;\n\t}\n\tget uint8Array() {\n\t\tif (this.uint8ArrayData == null) this.uint8ArrayData = convertBase64ToUint8Array(this.base64Data);\n\t\treturn this.uint8ArrayData;\n\t}\n};\nvar DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {\n\tconstructor() {\n\t\tsuper(...arguments);\n\t\tthis.type = \"file\";\n\t}\n};\nasync function isApprovalNeeded({ tool: tool2, toolCall, messages, experimental_context }) {\n\tif (tool2.needsApproval == null) return false;\n\tif (typeof tool2.needsApproval === \"boolean\") return tool2.needsApproval;\n\treturn await tool2.needsApproval(toolCall.input, {\n\t\ttoolCallId: toolCall.toolCallId,\n\t\tmessages,\n\t\texperimental_context\n\t});\n}\nfunction isToolExecutionAllowedFinishReason(finishReason) {\n\treturn finishReason === \"stop\" || finishReason === \"tool-calls\";\n}\nvar encoder = new TextEncoder();\nfunction canonicalJSON(value) {\n\tif (value === null || value === void 0) return JSON.stringify(value);\n\tif (typeof value !== \"object\") return JSON.stringify(value);\n\tif (Array.isArray(value)) return `[${value.map(canonicalJSON).join(\",\")}]`;\n\treturn `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`).join(\",\")}}`;\n}\nfunction toBase64url(bytes) {\n\treturn convertUint8ArrayToBase64(bytes).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/g, \"\");\n}\nfunction fromBase64url(str) {\n\treturn convertBase64ToUint8Array(str);\n}\nasync function importKey(secret) {\n\tconst keyData = typeof secret === \"string\" ? encoder.encode(secret) : secret;\n\treturn crypto.subtle.importKey(\"raw\", keyData, {\n\t\tname: \"HMAC\",\n\t\thash: \"SHA-256\"\n\t}, false, [\"sign\", \"verify\"]);\n}\nasync function hashInput(input) {\n\tconst canonical = canonicalJSON(input);\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", encoder.encode(canonical));\n\treturn toBase64url(new Uint8Array(digest));\n}\nfunction buildPayload(approvalId, toolCallId, toolName, inputDigest) {\n\treturn encoder.encode(`${approvalId}\n${toolCallId}\n${toolName}\n${inputDigest}`);\n}\nasync function signToolApproval({ secret, approvalId, toolCallId, toolName, input }) {\n\tconst key = await importKey(secret);\n\tconst payload = buildPayload(approvalId, toolCallId, toolName, await hashInput(input));\n\tconst sig = await crypto.subtle.sign(\"HMAC\", key, payload);\n\treturn toBase64url(new Uint8Array(sig));\n}\nasync function verifyToolApprovalSignature({ secret, signature, approvalId, toolCallId, toolName, input }) {\n\tconst key = await importKey(secret);\n\tconst payload = buildPayload(approvalId, toolCallId, toolName, await hashInput(input));\n\tconst sigBytes = fromBase64url(signature);\n\treturn crypto.subtle.verify(\"HMAC\", key, sigBytes, payload);\n}\nasync function maybeSignApproval({ secret, approvalId, toolCallId, toolName, input }) {\n\tif (secret == null) return void 0;\n\treturn signToolApproval({\n\t\tsecret,\n\t\tapprovalId,\n\t\ttoolCallId,\n\t\ttoolName,\n\t\tinput\n\t});\n}\nfunction isDeepEqualData(obj1, obj2) {\n\tif (obj1 === obj2) return true;\n\tif (obj1 == null || obj2 == null) return false;\n\tif (typeof obj1 !== \"object\" && typeof obj2 !== \"object\") return obj1 === obj2;\n\tif (obj1.constructor !== obj2.constructor) return false;\n\tif (obj1 instanceof Date && obj2 instanceof Date) return obj1.getTime() === obj2.getTime();\n\tif (Array.isArray(obj1)) {\n\t\tif (obj1.length !== obj2.length) return false;\n\t\tfor (let i = 0; i < obj1.length; i++) if (!isDeepEqualData(obj1[i], obj2[i])) return false;\n\t\treturn true;\n\t}\n\tconst keys1 = Object.keys(obj1);\n\tconst keys2 = Object.keys(obj2);\n\tif (keys1.length !== keys2.length) return false;\n\tfor (const key of keys1) {\n\t\tif (!keys2.includes(key)) return false;\n\t\tif (!isDeepEqualData(obj1[key], obj2[key])) return false;\n\t}\n\treturn true;\n}\nasync function validateApprovedToolApprovals({ approvedToolApprovals, tools, messages, experimental_context, toolApprovalSecret }) {\n\tvar _a23;\n\tconst approved = [];\n\tconst denied = [];\n\tconst invalid = [];\n\tfor (const approval of approvedToolApprovals) {\n\t\tconst { toolCall, approvalRequest } = approval;\n\t\tconst tool2 = tools == null ? void 0 : tools[toolCall.toolName];\n\t\tif (toolApprovalSecret != null) {\n\t\t\tif (approvalRequest.signature == null) throw new InvalidToolApprovalSignatureError({\n\t\t\t\tapprovalId: approvalRequest.approvalId,\n\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\treason: \"missing signature\"\n\t\t\t});\n\t\t\tif (!await verifyToolApprovalSignature({\n\t\t\t\tsecret: toolApprovalSecret,\n\t\t\t\tsignature: approvalRequest.signature,\n\t\t\t\tapprovalId: approvalRequest.approvalId,\n\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\tinput: toolCall.input\n\t\t\t})) throw new InvalidToolApprovalSignatureError({\n\t\t\t\tapprovalId: approvalRequest.approvalId,\n\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\treason: \"invalid signature\"\n\t\t\t});\n\t\t}\n\t\tif (tool2 != null && typeof tool2.execute === \"function\" && tool2.inputSchema != null) {\n\t\t\tconst hasInputSchemaInput = Object.prototype.hasOwnProperty.call(approvalRequest, \"inputSchemaInput\");\n\t\t\tconst validation = await safeValidateTypes({\n\t\t\t\tvalue: hasInputSchemaInput ? approvalRequest.inputSchemaInput : toolCall.input,\n\t\t\t\tschema: asSchema(tool2.inputSchema)\n\t\t\t});\n\t\t\tlet validationError;\n\t\t\tif (!validation.success) validationError = validation.error;\n\t\t\telse if (!isDeepEqualData(validation.value, toolCall.input)) validationError = /* @__PURE__ */ new Error(\"Approved tool input does not match the validated schema output.\");\n\t\t\tif (validationError != null) {\n\t\t\t\tinvalid.push({\n\t\t\t\t\t...approval,\n\t\t\t\t\terror: new InvalidToolInputError({\n\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\ttoolInput: JSON.stringify(toolCall.input),\n\t\t\t\t\t\tcause: validationError\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (tool2 != null && await isApprovalNeeded({\n\t\t\ttool: tool2,\n\t\t\ttoolCall,\n\t\t\tmessages,\n\t\t\texperimental_context\n\t\t})) approved.push(approval);\n\t\telse denied.push({\n\t\t\t...approval,\n\t\t\tapprovalResponse: {\n\t\t\t\t...approval.approvalResponse,\n\t\t\t\tapproved: false,\n\t\t\t\treason: (_a23 = approval.approvalResponse.reason) != null ? _a23 : `Tool \"${toolCall.toolName}\" does not require approval`\n\t\t\t}\n\t\t});\n\t}\n\treturn {\n\t\tapprovedToolApprovals: approved,\n\t\tdeniedToolApprovals: denied,\n\t\tinvalidToolApprovals: invalid\n\t};\n}\nvar output_exports = {};\n__export(output_exports, {\n\tarray: () => array,\n\tchoice: () => choice,\n\tjson: () => json,\n\tobject: () => object,\n\ttext: () => text\n});\nfunction fixJson(input) {\n\tconst stack = [\"ROOT\"];\n\tlet lastValidIndex = -1;\n\tlet literalStart = null;\n\tlet unicodeEscapeDigits = 0;\n\tfunction isHexDigit(char) {\n\t\treturn char >= \"0\" && char <= \"9\" || char >= \"A\" && char <= \"F\" || char >= \"a\" && char <= \"f\";\n\t}\n\tfunction processValueStart(char, i, swapState) {\n\t\tswitch (char) {\n\t\t\tcase \"\\\"\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_STRING\");\n\t\t\t\tbreak;\n\t\t\tcase \"f\":\n\t\t\tcase \"t\":\n\t\t\tcase \"n\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tliteralStart = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_LITERAL\");\n\t\t\t\tbreak;\n\t\t\tcase \"-\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_NUMBER\");\n\t\t\t\tbreak;\n\t\t\tcase \"0\":\n\t\t\tcase \"1\":\n\t\t\tcase \"2\":\n\t\t\tcase \"3\":\n\t\t\tcase \"4\":\n\t\t\tcase \"5\":\n\t\t\tcase \"6\":\n\t\t\tcase \"7\":\n\t\t\tcase \"8\":\n\t\t\tcase \"9\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_NUMBER\");\n\t\t\t\tbreak;\n\t\t\tcase \"{\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_OBJECT_START\");\n\t\t\t\tbreak;\n\t\t\tcase \"[\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(swapState);\n\t\t\t\tstack.push(\"INSIDE_ARRAY_START\");\n\t\t}\n\t}\n\tfunction processAfterObjectValue(char, i) {\n\t\tswitch (char) {\n\t\t\tcase \",\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(\"INSIDE_OBJECT_AFTER_COMMA\");\n\t\t\t\tbreak;\n\t\t\tcase \"}\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t}\n\t}\n\tfunction processAfterArrayValue(char, i) {\n\t\tswitch (char) {\n\t\t\tcase \",\":\n\t\t\t\tstack.pop();\n\t\t\t\tstack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n\t\t\t\tbreak;\n\t\t\tcase \"]\":\n\t\t\t\tlastValidIndex = i;\n\t\t\t\tstack.pop();\n\t\t}\n\t}\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst char = input[i];\n\t\tswitch (stack[stack.length - 1]) {\n\t\t\tcase \"ROOT\":\n\t\t\t\tprocessValueStart(char, i, \"FINISH\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_START\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_KEY\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"}\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_COMMA\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_KEY\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_KEY\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_AFTER_KEY\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_KEY\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \":\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_OBJECT_BEFORE_VALUE\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_BEFORE_VALUE\":\n\t\t\t\tprocessValueStart(char, i, \"INSIDE_OBJECT_AFTER_VALUE\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_OBJECT_AFTER_VALUE\":\n\t\t\t\tprocessAfterObjectValue(char, i);\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"\\\"\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"\\\\\":\n\t\t\t\t\t\tstack.push(\"INSIDE_STRING_ESCAPE\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: lastValidIndex = i;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_START\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tprocessValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_AFTER_VALUE\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \",\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tstack.push(\"INSIDE_ARRAY_AFTER_COMMA\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: lastValidIndex = i;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_ARRAY_AFTER_COMMA\":\n\t\t\t\tprocessValueStart(char, i, \"INSIDE_ARRAY_AFTER_VALUE\");\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING_ESCAPE\":\n\t\t\t\tstack.pop();\n\t\t\t\tif (char === \"u\") {\n\t\t\t\t\tunicodeEscapeDigits = 0;\n\t\t\t\t\tstack.push(\"INSIDE_STRING_UNICODE_ESCAPE\");\n\t\t\t\t} else lastValidIndex = i;\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_STRING_UNICODE_ESCAPE\":\n\t\t\t\tif (isHexDigit(char)) {\n\t\t\t\t\tunicodeEscapeDigits++;\n\t\t\t\t\tif (unicodeEscapeDigits === 4) {\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_NUMBER\":\n\t\t\t\tswitch (char) {\n\t\t\t\t\tcase \"0\":\n\t\t\t\t\tcase \"1\":\n\t\t\t\t\tcase \"2\":\n\t\t\t\t\tcase \"3\":\n\t\t\t\t\tcase \"4\":\n\t\t\t\t\tcase \"5\":\n\t\t\t\t\tcase \"6\":\n\t\t\t\t\tcase \"7\":\n\t\t\t\t\tcase \"8\":\n\t\t\t\t\tcase \"9\":\n\t\t\t\t\t\tlastValidIndex = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"e\":\n\t\t\t\t\tcase \"E\":\n\t\t\t\t\tcase \"-\":\n\t\t\t\t\tcase \".\": break;\n\t\t\t\t\tcase \",\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"}\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"]\":\n\t\t\t\t\t\tstack.pop();\n\t\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault: stack.pop();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"INSIDE_LITERAL\": {\n\t\t\t\tconst partialLiteral = input.substring(literalStart, i + 1);\n\t\t\t\tif (!\"false\".startsWith(partialLiteral) && !\"true\".startsWith(partialLiteral) && !\"null\".startsWith(partialLiteral)) {\n\t\t\t\t\tstack.pop();\n\t\t\t\t\tif (stack[stack.length - 1] === \"INSIDE_OBJECT_AFTER_VALUE\") processAfterObjectValue(char, i);\n\t\t\t\t\telse if (stack[stack.length - 1] === \"INSIDE_ARRAY_AFTER_VALUE\") processAfterArrayValue(char, i);\n\t\t\t\t} else lastValidIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tlet result = input.slice(0, lastValidIndex + 1);\n\tfor (let i = stack.length - 1; i >= 0; i--) switch (stack[i]) {\n\t\tcase \"INSIDE_STRING\":\n\t\t\tresult += \"\\\"\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_OBJECT_KEY\":\n\t\tcase \"INSIDE_OBJECT_AFTER_KEY\":\n\t\tcase \"INSIDE_OBJECT_AFTER_COMMA\":\n\t\tcase \"INSIDE_OBJECT_START\":\n\t\tcase \"INSIDE_OBJECT_BEFORE_VALUE\":\n\t\tcase \"INSIDE_OBJECT_AFTER_VALUE\":\n\t\t\tresult += \"}\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_ARRAY_START\":\n\t\tcase \"INSIDE_ARRAY_AFTER_COMMA\":\n\t\tcase \"INSIDE_ARRAY_AFTER_VALUE\":\n\t\t\tresult += \"]\";\n\t\t\tbreak;\n\t\tcase \"INSIDE_LITERAL\": {\n\t\t\tconst partialLiteral = input.substring(literalStart, input.length);\n\t\t\tif (\"true\".startsWith(partialLiteral)) result += \"true\".slice(partialLiteral.length);\n\t\t\telse if (\"false\".startsWith(partialLiteral)) result += \"false\".slice(partialLiteral.length);\n\t\t\telse if (\"null\".startsWith(partialLiteral)) result += \"null\".slice(partialLiteral.length);\n\t\t}\n\t}\n\treturn result;\n}\nasync function parsePartialJson(jsonText) {\n\tif (jsonText === void 0) return {\n\t\tvalue: void 0,\n\t\tstate: \"undefined-input\"\n\t};\n\tlet result = await safeParseJSON({ text: jsonText });\n\tif (result.success) return {\n\t\tvalue: result.value,\n\t\tstate: \"successful-parse\"\n\t};\n\tresult = await safeParseJSON({ text: fixJson(jsonText) });\n\tif (result.success) return {\n\t\tvalue: result.value,\n\t\tstate: \"repaired-parse\"\n\t};\n\treturn {\n\t\tvalue: void 0,\n\t\tstate: \"failed-parse\"\n\t};\n}\nvar text = () => ({\n\tname: \"text\",\n\tresponseFormat: Promise.resolve({ type: \"text\" }),\n\tasync parseCompleteOutput({ text: text2 }) {\n\t\treturn text2;\n\t},\n\tasync parsePartialOutput({ text: text2 }) {\n\t\treturn { partial: text2 };\n\t},\n\tcreateElementStreamTransform() {}\n});\nvar object = ({ schema: inputSchema, name: name23, description }) => {\n\tconst schema = asSchema(inputSchema);\n\treturn {\n\t\tname: \"object\",\n\t\tresponseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({\n\t\t\ttype: \"json\",\n\t\t\tschema: jsonSchema2,\n\t\t\t...name23 != null && { name: name23 },\n\t\t\t...description != null && { description }\n\t\t})),\n\t\tasync parseCompleteOutput({ text: text2 }, context2) {\n\t\t\tconst parseResult = await safeParseJSON({ text: text2 });\n\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\tcause: parseResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\tconst validationResult = await safeValidateTypes({\n\t\t\t\tvalue: parseResult.value,\n\t\t\t\tschema\n\t\t\t});\n\t\t\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\tcause: validationResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\treturn validationResult.value;\n\t\t},\n\t\tasync parsePartialOutput({ text: text2 }) {\n\t\t\tconst result = await parsePartialJson(text2);\n\t\t\tswitch (result.state) {\n\t\t\t\tcase \"failed-parse\":\n\t\t\t\tcase \"undefined-input\": return;\n\t\t\t\tcase \"repaired-parse\":\n\t\t\t\tcase \"successful-parse\": return { partial: result.value };\n\t\t\t}\n\t\t},\n\t\tcreateElementStreamTransform() {}\n\t};\n};\nvar array = ({ element: inputElementSchema, name: name23, description }) => {\n\tconst elementSchema = asSchema(inputElementSchema);\n\treturn {\n\t\tname: \"array\",\n\t\tresponseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {\n\t\t\tconst { $schema, ...itemSchema } = jsonSchema2;\n\t\t\treturn {\n\t\t\t\ttype: \"json\",\n\t\t\t\tschema: {\n\t\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tproperties: { elements: {\n\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\titems: itemSchema\n\t\t\t\t\t} },\n\t\t\t\t\trequired: [\"elements\"],\n\t\t\t\t\tadditionalProperties: false\n\t\t\t\t},\n\t\t\t\t...name23 != null && { name: name23 },\n\t\t\t\t...description != null && { description }\n\t\t\t};\n\t\t}),\n\t\tasync parseCompleteOutput({ text: text2 }, context2) {\n\t\t\tconst parseResult = await safeParseJSON({ text: text2 });\n\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\tcause: parseResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\tconst outerValue = parseResult.value;\n\t\t\tif (outerValue == null || typeof outerValue !== \"object\" || !(\"elements\" in outerValue) || !Array.isArray(outerValue.elements)) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\tcause: new TypeValidationError({\n\t\t\t\t\tvalue: outerValue,\n\t\t\t\t\tcause: \"response must be an object with an elements array\"\n\t\t\t\t}),\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\tconst validatedElements = [];\n\t\t\tfor (const element of outerValue.elements) {\n\t\t\t\tconst validationResult = await safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema: elementSchema\n\t\t\t\t});\n\t\t\t\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\t\tcause: validationResult.error,\n\t\t\t\t\ttext: text2,\n\t\t\t\t\tresponse: context2.response,\n\t\t\t\t\tusage: context2.usage,\n\t\t\t\t\tfinishReason: context2.finishReason\n\t\t\t\t});\n\t\t\t\tvalidatedElements.push(validationResult.value);\n\t\t\t}\n\t\t\treturn validatedElements;\n\t\t},\n\t\tasync parsePartialOutput({ text: text2 }) {\n\t\t\tconst result = await parsePartialJson(text2);\n\t\t\tswitch (result.state) {\n\t\t\t\tcase \"failed-parse\":\n\t\t\t\tcase \"undefined-input\": return;\n\t\t\t\tcase \"repaired-parse\":\n\t\t\t\tcase \"successful-parse\": {\n\t\t\t\t\tconst outerValue = result.value;\n\t\t\t\t\tif (outerValue == null || typeof outerValue !== \"object\" || !(\"elements\" in outerValue) || !Array.isArray(outerValue.elements)) return;\n\t\t\t\t\tconst rawElements = result.state === \"repaired-parse\" && outerValue.elements.length > 0 ? outerValue.elements.slice(0, -1) : outerValue.elements;\n\t\t\t\t\tconst parsedElements = [];\n\t\t\t\t\tfor (const rawElement of rawElements) {\n\t\t\t\t\t\tconst validationResult = await safeValidateTypes({\n\t\t\t\t\t\t\tvalue: rawElement,\n\t\t\t\t\t\t\tschema: elementSchema\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (validationResult.success) parsedElements.push(validationResult.value);\n\t\t\t\t\t}\n\t\t\t\t\treturn { partial: parsedElements };\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcreateElementStreamTransform() {\n\t\t\tlet publishedElements = 0;\n\t\t\treturn new TransformStream({ transform({ partialOutput }, controller) {\n\t\t\t\tif (partialOutput != null) for (; publishedElements < partialOutput.length; publishedElements++) controller.enqueue(partialOutput[publishedElements]);\n\t\t\t} });\n\t\t}\n\t};\n};\nvar choice = ({ options: choiceOptions, name: name23, description }) => {\n\treturn {\n\t\tname: \"choice\",\n\t\tresponseFormat: Promise.resolve({\n\t\t\ttype: \"json\",\n\t\t\tschema: {\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { result: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tenum: choiceOptions\n\t\t\t\t} },\n\t\t\t\trequired: [\"result\"],\n\t\t\t\tadditionalProperties: false\n\t\t\t},\n\t\t\t...name23 != null && { name: name23 },\n\t\t\t...description != null && { description }\n\t\t}),\n\t\tasync parseCompleteOutput({ text: text2 }, context2) {\n\t\t\tconst parseResult = await safeParseJSON({ text: text2 });\n\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\tcause: parseResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\tconst outerValue = parseResult.value;\n\t\t\tif (outerValue == null || typeof outerValue !== \"object\" || !(\"result\" in outerValue) || typeof outerValue.result !== \"string\" || !choiceOptions.includes(outerValue.result)) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\tcause: new TypeValidationError({\n\t\t\t\t\tvalue: outerValue,\n\t\t\t\t\tcause: \"response must be an object that contains a choice value.\"\n\t\t\t\t}),\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\treturn outerValue.result;\n\t\t},\n\t\tasync parsePartialOutput({ text: text2 }) {\n\t\t\tconst result = await parsePartialJson(text2);\n\t\t\tswitch (result.state) {\n\t\t\t\tcase \"failed-parse\":\n\t\t\t\tcase \"undefined-input\": return;\n\t\t\t\tcase \"repaired-parse\":\n\t\t\t\tcase \"successful-parse\": {\n\t\t\t\t\tconst outerValue = result.value;\n\t\t\t\t\tif (outerValue == null || typeof outerValue !== \"object\" || !(\"result\" in outerValue) || typeof outerValue.result !== \"string\") return;\n\t\t\t\t\tconst potentialMatches = choiceOptions.filter((choiceOption) => choiceOption.startsWith(outerValue.result));\n\t\t\t\t\tif (result.state === \"successful-parse\") return potentialMatches.includes(outerValue.result) ? { partial: outerValue.result } : void 0;\n\t\t\t\t\telse return potentialMatches.length === 1 ? { partial: potentialMatches[0] } : void 0;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcreateElementStreamTransform() {}\n\t};\n};\nvar json = ({ name: name23, description } = {}) => {\n\treturn {\n\t\tname: \"json\",\n\t\tresponseFormat: Promise.resolve({\n\t\t\ttype: \"json\",\n\t\t\t...name23 != null && { name: name23 },\n\t\t\t...description != null && { description }\n\t\t}),\n\t\tasync parseCompleteOutput({ text: text2 }, context2) {\n\t\t\tconst parseResult = await safeParseJSON({ text: text2 });\n\t\t\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: could not parse the response.\",\n\t\t\t\tcause: parseResult.error,\n\t\t\t\ttext: text2,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t});\n\t\t\treturn parseResult.value;\n\t\t},\n\t\tasync parsePartialOutput({ text: text2 }) {\n\t\t\tconst result = await parsePartialJson(text2);\n\t\t\tswitch (result.state) {\n\t\t\t\tcase \"failed-parse\":\n\t\t\t\tcase \"undefined-input\": return;\n\t\t\t\tcase \"repaired-parse\":\n\t\t\t\tcase \"successful-parse\": return result.value === void 0 ? void 0 : { partial: result.value };\n\t\t\t}\n\t\t},\n\t\tcreateElementStreamTransform() {}\n\t};\n};\nvar inputSchemaInputSymbol = Symbol(\"ai-sdk-tool-call-input-schema-input\");\nfunction setToolCallInputSchemaInput(toolCall, inputSchemaInput) {\n\tObject.defineProperty(toolCall, inputSchemaInputSymbol, { value: inputSchemaInput });\n\treturn toolCall;\n}\nfunction getToolCallInputSchemaInput(toolCall) {\n\treturn inputSchemaInputSymbol in toolCall ? { value: toolCall[inputSchemaInputSymbol] } : void 0;\n}\nasync function parseToolCall({ toolCall, tools, repairToolCall, system, messages }) {\n\ttry {\n\t\tif (tools == null) {\n\t\t\tif (toolCall.providerExecuted && toolCall.dynamic) return await parseProviderExecutedDynamicToolCall(toolCall);\n\t\t\tthrow new NoSuchToolError({ toolName: toolCall.toolName });\n\t\t}\n\t\ttry {\n\t\t\treturn await doParseToolCall({\n\t\t\t\ttoolCall,\n\t\t\t\ttools\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (repairToolCall == null || !(NoSuchToolError.isInstance(error) || InvalidToolInputError.isInstance(error))) throw error;\n\t\t\tlet repairedToolCall = null;\n\t\t\ttry {\n\t\t\t\trepairedToolCall = await repairToolCall({\n\t\t\t\t\ttoolCall,\n\t\t\t\t\ttools,\n\t\t\t\t\tinputSchema: async ({ toolName }) => {\n\t\t\t\t\t\tconst { inputSchema } = tools[toolName];\n\t\t\t\t\t\treturn await asSchema(inputSchema).jsonSchema;\n\t\t\t\t\t},\n\t\t\t\t\tsystem,\n\t\t\t\t\tmessages,\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t} catch (repairError) {\n\t\t\t\tthrow new ToolCallRepairError({\n\t\t\t\t\tcause: repairError,\n\t\t\t\t\toriginalError: error\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (repairedToolCall == null) throw error;\n\t\t\treturn await doParseToolCall({\n\t\t\t\ttoolCall: repairedToolCall,\n\t\t\t\ttools\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tconst parsedInput = await safeParseJSON({ text: toolCall.input });\n\t\tconst input = parsedInput.success ? parsedInput.value : toolCall.input;\n\t\tconst tool2 = tools == null ? void 0 : tools[toolCall.toolName];\n\t\treturn {\n\t\t\ttype: \"tool-call\",\n\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\ttoolName: toolCall.toolName,\n\t\t\tinput,\n\t\t\tdynamic: true,\n\t\t\tinvalid: true,\n\t\t\terror,\n\t\t\ttitle: tool2 == null ? void 0 : tool2.title,\n\t\t\tproviderExecuted: toolCall.providerExecuted,\n\t\t\tproviderMetadata: toolCall.providerMetadata,\n\t\t\t...(tool2 == null ? void 0 : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}\n\t\t};\n\t}\n}\nasync function parseProviderExecutedDynamicToolCall(toolCall) {\n\tconst parseResult = toolCall.input.trim() === \"\" ? {\n\t\tsuccess: true,\n\t\tvalue: {}\n\t} : await safeParseJSON({ text: toolCall.input });\n\tif (parseResult.success === false) throw new InvalidToolInputError({\n\t\ttoolName: toolCall.toolName,\n\t\ttoolInput: toolCall.input,\n\t\tcause: parseResult.error\n\t});\n\treturn {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName: toolCall.toolName,\n\t\tinput: parseResult.value,\n\t\tproviderExecuted: true,\n\t\tdynamic: true,\n\t\tproviderMetadata: toolCall.providerMetadata\n\t};\n}\nasync function doParseToolCall({ toolCall, tools }) {\n\tconst toolName = toolCall.toolName;\n\tconst tool2 = tools[toolName];\n\tif (tool2 == null) {\n\t\tif (toolCall.providerExecuted && toolCall.dynamic) return await parseProviderExecutedDynamicToolCall(toolCall);\n\t\tthrow new NoSuchToolError({\n\t\t\ttoolName: toolCall.toolName,\n\t\t\tavailableTools: Object.keys(tools)\n\t\t});\n\t}\n\tconst schema = asSchema(tool2.inputSchema);\n\tconst parseResult = toolCall.input.trim() === \"\" ? await safeValidateTypes({\n\t\tvalue: {},\n\t\tschema\n\t}) : await safeParseJSON({\n\t\ttext: toolCall.input,\n\t\tschema\n\t});\n\tif (parseResult.success === false) throw new InvalidToolInputError({\n\t\ttoolName,\n\t\ttoolInput: toolCall.input,\n\t\tcause: parseResult.error\n\t});\n\treturn setToolCallInputSchemaInput(tool2.type === \"dynamic\" ? {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName: toolCall.toolName,\n\t\tinput: parseResult.value,\n\t\tproviderExecuted: toolCall.providerExecuted,\n\t\tproviderMetadata: toolCall.providerMetadata,\n\t\t...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},\n\t\tdynamic: true,\n\t\ttitle: tool2.title\n\t} : {\n\t\ttype: \"tool-call\",\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName,\n\t\tinput: parseResult.value,\n\t\tproviderExecuted: toolCall.providerExecuted,\n\t\tproviderMetadata: toolCall.providerMetadata,\n\t\t...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},\n\t\ttitle: tool2.title\n\t}, parseResult.rawValue);\n}\nfunction prepareStepCallSettings({ callSettings, stepSettings }) {\n\tvar _a23, _b, _c, _d, _e, _f, _g, _h;\n\treturn prepareCallSettings({\n\t\tmaxOutputTokens: (_a23 = stepSettings == null ? void 0 : stepSettings.maxOutputTokens) != null ? _a23 : callSettings.maxOutputTokens,\n\t\ttemperature: (_b = stepSettings == null ? void 0 : stepSettings.temperature) != null ? _b : callSettings.temperature,\n\t\ttopP: (_c = stepSettings == null ? void 0 : stepSettings.topP) != null ? _c : callSettings.topP,\n\t\ttopK: (_d = stepSettings == null ? void 0 : stepSettings.topK) != null ? _d : callSettings.topK,\n\t\tpresencePenalty: (_e = stepSettings == null ? void 0 : stepSettings.presencePenalty) != null ? _e : callSettings.presencePenalty,\n\t\tfrequencyPenalty: (_f = stepSettings == null ? void 0 : stepSettings.frequencyPenalty) != null ? _f : callSettings.frequencyPenalty,\n\t\tstopSequences: (_g = stepSettings == null ? void 0 : stepSettings.stopSequences) != null ? _g : callSettings.stopSequences,\n\t\tseed: (_h = stepSettings == null ? void 0 : stepSettings.seed) != null ? _h : callSettings.seed\n\t});\n}\nvar DefaultStepResult = class {\n\tconstructor({ stepNumber, model, functionId, metadata, experimental_context, content, finishReason, rawFinishReason, usage, warnings, request, response, providerMetadata }) {\n\t\tthis.stepNumber = stepNumber;\n\t\tthis.model = model;\n\t\tthis.functionId = functionId;\n\t\tthis.metadata = metadata;\n\t\tthis.experimental_context = experimental_context;\n\t\tthis.content = content;\n\t\tthis.finishReason = finishReason;\n\t\tthis.rawFinishReason = rawFinishReason;\n\t\tthis.usage = usage;\n\t\tthis.warnings = warnings;\n\t\tthis.request = request;\n\t\tthis.response = response;\n\t\tthis.providerMetadata = providerMetadata;\n\t}\n\tget text() {\n\t\treturn this.content.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n\t}\n\tget reasoning() {\n\t\treturn this.content.filter((part) => part.type === \"reasoning\");\n\t}\n\tget reasoningText() {\n\t\treturn this.reasoning.length === 0 ? void 0 : this.reasoning.map((part) => part.text).join(\"\");\n\t}\n\tget files() {\n\t\treturn this.content.filter((part) => part.type === \"file\").map((part) => part.file);\n\t}\n\tget sources() {\n\t\treturn this.content.filter((part) => part.type === \"source\");\n\t}\n\tget toolCalls() {\n\t\treturn this.content.filter((part) => part.type === \"tool-call\");\n\t}\n\tget staticToolCalls() {\n\t\treturn this.toolCalls.filter((toolCall) => toolCall.dynamic !== true);\n\t}\n\tget dynamicToolCalls() {\n\t\treturn this.toolCalls.filter((toolCall) => toolCall.dynamic === true);\n\t}\n\tget toolResults() {\n\t\treturn this.content.filter((part) => part.type === \"tool-result\");\n\t}\n\tget staticToolResults() {\n\t\treturn this.toolResults.filter((toolResult) => toolResult.dynamic !== true);\n\t}\n\tget dynamicToolResults() {\n\t\treturn this.toolResults.filter((toolResult) => toolResult.dynamic === true);\n\t}\n};\nfunction stepCountIs(stepCount) {\n\treturn ({ steps }) => steps.length === stepCount;\n}\nfunction isLoopFinished() {\n\treturn () => false;\n}\nfunction hasToolCall(toolName) {\n\treturn ({ steps }) => {\n\t\tvar _a23, _b, _c;\n\t\treturn (_c = (_b = (_a23 = steps[steps.length - 1]) == null ? void 0 : _a23.toolCalls) == null ? void 0 : _b.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;\n\t};\n}\nasync function isStopConditionMet({ stopConditions, steps }) {\n\treturn (await Promise.all(stopConditions.map((condition) => condition({ steps })))).some((result) => result);\n}\nasync function toResponseMessages({ content: inputContent, tools }) {\n\tconst responseMessages = [];\n\tconst toolCallOrder = /* @__PURE__ */ new Map();\n\tconst content = [];\n\tfor (const part of inputContent) {\n\t\tif (part.type === \"source\") continue;\n\t\tif ((part.type === \"tool-result\" || part.type === \"tool-error\") && !part.providerExecuted) continue;\n\t\tif (part.type === \"text\" && part.text.length === 0) continue;\n\t\tswitch (part.type) {\n\t\t\tcase \"text\":\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: part.text,\n\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"reasoning\":\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\ttext: part.text,\n\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tdata: part.file.base64,\n\t\t\t\t\tmediaType: part.file.mediaType,\n\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"tool-call\":\n\t\t\t\tif (!toolCallOrder.has(part.toolCallId)) toolCallOrder.set(part.toolCallId, toolCallOrder.size);\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\tinput: part.invalid && typeof part.input !== \"object\" ? {} : part.input,\n\t\t\t\t\tproviderExecuted: part.providerExecuted,\n\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"tool-result\": {\n\t\t\t\tconst output = await createToolModelOutput({\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\tinput: part.input,\n\t\t\t\t\ttool: tools == null ? void 0 : tools[part.toolName],\n\t\t\t\t\toutput: part.output,\n\t\t\t\t\terrorMode: \"none\"\n\t\t\t\t});\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\toutput,\n\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool-error\": {\n\t\t\t\tconst output = await createToolModelOutput({\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\tinput: part.input,\n\t\t\t\t\ttool: tools == null ? void 0 : tools[part.toolName],\n\t\t\t\t\toutput: part.error,\n\t\t\t\t\terrorMode: \"json\"\n\t\t\t\t});\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\toutput,\n\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"tool-approval-request\":\n\t\t\t\tconst inputSchemaInput = getToolCallInputSchemaInput(part.toolCall);\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\t\tapprovalId: part.approvalId,\n\t\t\t\t\ttoolCallId: part.toolCall.toolCallId,\n\t\t\t\t\t...part.signature != null ? { signature: part.signature } : {},\n\t\t\t\t\t...inputSchemaInput != null && !isDeepEqualData(inputSchemaInput.value, part.toolCall.input) ? { inputSchemaInput: inputSchemaInput.value } : {}\n\t\t\t\t});\n\t\t}\n\t}\n\tif (content.length > 0) responseMessages.push({\n\t\trole: \"assistant\",\n\t\tcontent\n\t});\n\tconst toolResultContent = [];\n\tfor (const part of inputContent) {\n\t\tif (!(part.type === \"tool-result\" || part.type === \"tool-error\") || part.providerExecuted) continue;\n\t\tconst output = await createToolModelOutput({\n\t\t\ttoolCallId: part.toolCallId,\n\t\t\tinput: part.input,\n\t\t\ttool: tools == null ? void 0 : tools[part.toolName],\n\t\t\toutput: part.type === \"tool-result\" ? part.output : part.error,\n\t\t\terrorMode: part.type === \"tool-error\" ? \"text\" : \"none\"\n\t\t});\n\t\ttoolResultContent.push({\n\t\t\ttype: \"tool-result\",\n\t\t\ttoolCallId: part.toolCallId,\n\t\t\ttoolName: part.toolName,\n\t\t\toutput,\n\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t});\n\t}\n\tif (toolResultContent.length > 0) responseMessages.push({\n\t\trole: \"tool\",\n\t\tcontent: sortToolResultContentByToolCallOrder({\n\t\t\ttoolResultContent,\n\t\t\ttoolCallOrder\n\t\t})\n\t});\n\treturn responseMessages;\n}\nfunction sortToolResultContentByToolCallOrder({ toolResultContent, toolCallOrder }) {\n\tconst sortedToolResults = toolResultContent.filter((part) => part.type === \"tool-result\").map((part, index) => ({\n\t\tpart,\n\t\tindex\n\t})).sort((a, b) => {\n\t\tconst aOrder = toolCallOrder.get(a.part.toolCallId);\n\t\tconst bOrder = toolCallOrder.get(b.part.toolCallId);\n\t\tif (aOrder == null && bOrder == null) return a.index - b.index;\n\t\tif (aOrder == null) return 1;\n\t\tif (bOrder == null) return -1;\n\t\treturn aOrder - bOrder || a.index - b.index;\n\t}).map(({ part }) => part);\n\tlet toolResultIndex = 0;\n\treturn toolResultContent.map((part) => part.type === \"tool-result\" ? sortedToolResults[toolResultIndex++] : part);\n}\nfunction mergeAbortSignals(...signals) {\n\tconst validSignals = signals.filter((signal) => signal != null);\n\tif (validSignals.length === 0) return;\n\tif (validSignals.length === 1) return validSignals[0];\n\tconst controller = new AbortController();\n\tfor (const signal of validSignals) {\n\t\tif (signal.aborted) {\n\t\t\tcontroller.abort(signal.reason);\n\t\t\treturn controller.signal;\n\t\t}\n\t\tsignal.addEventListener(\"abort\", () => {\n\t\t\tcontroller.abort(signal.reason);\n\t\t}, { once: true });\n\t}\n\treturn controller.signal;\n}\nvar originalGenerateId = createIdGenerator({\n\tprefix: \"aitxt\",\n\tsize: 24\n});\nasync function generateText({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen = stepCountIs(1), experimental_output, output = experimental_output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools = experimental_activeTools, experimental_prepareStep, prepareStep = experimental_prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download2, experimental_context, experimental_toolApprovalSecret, experimental_include: include, _internal: { generateId: generateId2 = originalGenerateId } = {}, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }) {\n\tconst model = resolveLanguageModel(modelArg);\n\tconst createGlobalTelemetry = getGlobalTelemetryIntegration();\n\tconst stopConditions = asArray(stopWhen);\n\tconst totalTimeoutMs = getTotalTimeoutMs(timeout);\n\tconst stepTimeoutMs = getStepTimeoutMs(timeout);\n\tconst stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;\n\tconst mergedAbortSignal = mergeAbortSignals(abortSignal, totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0, stepAbortController == null ? void 0 : stepAbortController.signal);\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal: mergedAbortSignal\n\t});\n\tconst callSettings = prepareCallSettings(settings);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: {\n\t\t\t...callSettings,\n\t\t\tmaxRetries\n\t\t}\n\t});\n\tconst modelInfo = {\n\t\tprovider: model.provider,\n\t\tmodelId: model.modelId\n\t};\n\tconst initialPrompt = await standardizePrompt({\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tallowSystemInMessages\n\t});\n\tconst globalTelemetry = createGlobalTelemetry(telemetry == null ? void 0 : telemetry.integrations);\n\tawait notify({\n\t\tevent: {\n\t\t\tmodel: modelInfo,\n\t\t\tsystem,\n\t\t\tprompt,\n\t\t\tmessages,\n\t\t\ttools,\n\t\t\ttoolChoice,\n\t\t\tactiveTools,\n\t\t\tmaxOutputTokens: callSettings.maxOutputTokens,\n\t\t\ttemperature: callSettings.temperature,\n\t\t\ttopP: callSettings.topP,\n\t\t\ttopK: callSettings.topK,\n\t\t\tpresencePenalty: callSettings.presencePenalty,\n\t\t\tfrequencyPenalty: callSettings.frequencyPenalty,\n\t\t\tstopSequences: callSettings.stopSequences,\n\t\t\tseed: callSettings.seed,\n\t\t\tmaxRetries,\n\t\t\ttimeout,\n\t\t\theaders,\n\t\t\tproviderOptions,\n\t\t\tstopWhen,\n\t\t\toutput,\n\t\t\tabortSignal,\n\t\t\tinclude,\n\t\t\tfunctionId: telemetry == null ? void 0 : telemetry.functionId,\n\t\t\tmetadata: telemetry == null ? void 0 : telemetry.metadata,\n\t\t\texperimental_context\n\t\t},\n\t\tcallbacks: [onStart, globalTelemetry.onStart]\n\t});\n\tconst tracer = getTracer(telemetry);\n\ttry {\n\t\treturn await recordSpan({\n\t\t\tname: \"ai.generateText\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.generateText\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.model.provider\": model.provider,\n\t\t\t\t\t\"ai.model.id\": model.modelId,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) }\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tfn: async (span) => {\n\t\t\t\tvar _a23, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;\n\t\t\t\tconst initialMessages = initialPrompt.messages;\n\t\t\t\tconst responseMessages = [];\n\t\t\t\tconst { approvedToolApprovals, deniedToolApprovals: collectedDeniedToolApprovals } = collectToolApprovals({ messages: initialMessages });\n\t\t\t\tconst { approvedToolApprovals: localApprovedToolApprovals, deniedToolApprovals: revalidationDeniedToolApprovals, invalidToolApprovals } = await validateApprovedToolApprovals({\n\t\t\t\t\tapprovedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),\n\t\t\t\t\ttools,\n\t\t\t\t\tmessages: initialMessages,\n\t\t\t\t\texperimental_context,\n\t\t\t\t\ttoolApprovalSecret: experimental_toolApprovalSecret\n\t\t\t\t});\n\t\t\t\tconst deniedToolApprovals = [...collectedDeniedToolApprovals, ...revalidationDeniedToolApprovals];\n\t\t\t\tif (deniedToolApprovals.length > 0 || localApprovedToolApprovals.length > 0 || invalidToolApprovals.length > 0) {\n\t\t\t\t\tconst toolOutputs = await executeTools({\n\t\t\t\t\t\ttoolCalls: localApprovedToolApprovals.map((toolApproval) => toolApproval.toolCall),\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tmessages: initialMessages,\n\t\t\t\t\t\tabortSignal: mergedAbortSignal,\n\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\tstepNumber: 0,\n\t\t\t\t\t\tmodel: modelInfo,\n\t\t\t\t\t\tonToolCallStart: [onToolCallStart, globalTelemetry.onToolCallStart],\n\t\t\t\t\t\tonToolCallFinish: [onToolCallFinish, globalTelemetry.onToolCallFinish]\n\t\t\t\t\t});\n\t\t\t\t\tconst toolContent = [];\n\t\t\t\t\tfor (const output2 of toolOutputs) {\n\t\t\t\t\t\tconst modelOutput = await createToolModelOutput({\n\t\t\t\t\t\t\ttoolCallId: output2.toolCallId,\n\t\t\t\t\t\t\tinput: output2.input,\n\t\t\t\t\t\t\ttool: tools == null ? void 0 : tools[output2.toolName],\n\t\t\t\t\t\t\toutput: output2.type === \"tool-result\" ? output2.output : output2.error,\n\t\t\t\t\t\t\terrorMode: output2.type === \"tool-error\" ? \"text\" : \"none\"\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttoolContent.push({\n\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\ttoolCallId: output2.toolCallId,\n\t\t\t\t\t\t\ttoolName: output2.toolName,\n\t\t\t\t\t\t\toutput: modelOutput\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tfor (const toolApproval of invalidToolApprovals) toolContent.push({\n\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\ttoolName: toolApproval.toolCall.toolName,\n\t\t\t\t\t\toutput: await createToolModelOutput({\n\t\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\t\tinput: toolApproval.toolCall.input,\n\t\t\t\t\t\t\ttool: tools == null ? void 0 : tools[toolApproval.toolCall.toolName],\n\t\t\t\t\t\t\toutput: toolApproval.error,\n\t\t\t\t\t\t\terrorMode: \"text\"\n\t\t\t\t\t\t})\n\t\t\t\t\t});\n\t\t\t\t\tfor (const toolApproval of deniedToolApprovals) toolContent.push({\n\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\ttoolName: toolApproval.toolCall.toolName,\n\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\ttype: \"execution-denied\",\n\t\t\t\t\t\t\treason: toolApproval.approvalResponse.reason,\n\t\t\t\t\t\t\t...toolApproval.toolCall.providerExecuted && { providerOptions: { openai: { approvalId: toolApproval.approvalResponse.approvalId } } }\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tresponseMessages.push({\n\t\t\t\t\t\trole: \"tool\",\n\t\t\t\t\t\tcontent: toolContent\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst callSettings2 = prepareCallSettings(settings);\n\t\t\t\tlet currentModelResponse;\n\t\t\t\tlet clientToolCalls = [];\n\t\t\t\tlet clientToolOutputs = [];\n\t\t\t\tconst steps = [];\n\t\t\t\tconst pendingDeferredToolCalls = /* @__PURE__ */ new Map();\n\t\t\t\tdo {\n\t\t\t\t\tif (steps.length > 0) mergedAbortSignal?.throwIfAborted();\n\t\t\t\t\tconst stepTimeoutId = setAbortTimeout({\n\t\t\t\t\t\tabortController: stepAbortController,\n\t\t\t\t\t\tlabel: \"Step\",\n\t\t\t\t\t\ttimeoutMs: stepTimeoutMs\n\t\t\t\t\t});\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst stepInputMessages = [...initialMessages, ...responseMessages];\n\t\t\t\t\t\tconst prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tsteps,\n\t\t\t\t\t\t\tstepNumber: steps.length,\n\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst stepModel = resolveLanguageModel((_a23 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a23 : model);\n\t\t\t\t\t\tconst stepModelInfo = {\n\t\t\t\t\t\t\tprovider: stepModel.provider,\n\t\t\t\t\t\t\tmodelId: stepModel.modelId\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\t\tsystem: (_b = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b : initialPrompt.system,\n\t\t\t\t\t\t\t\tmessages: (_c = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c : stepInputMessages\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tsupportedUrls: await stepModel.supportedUrls,\n\t\t\t\t\t\t\tdownload: download2,\n\t\t\t\t\t\t\tabortSignal: mergedAbortSignal\n\t\t\t\t\t\t});\n\t\t\t\t\t\texperimental_context = (_d = prepareStepResult == null ? void 0 : prepareStepResult.experimental_context) != null ? _d : experimental_context;\n\t\t\t\t\t\tconst stepActiveTools = (_e = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _e : activeTools;\n\t\t\t\t\t\tconst stepToolSet = filterActiveTools({\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst { toolChoice: stepToolChoice, tools: stepTools } = await prepareToolsAndToolChoice({\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\ttoolChoice: (_f = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _f : toolChoice,\n\t\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst stepMessages = (_g = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _g : stepInputMessages;\n\t\t\t\t\t\tconst stepSystem = (_h = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _h : initialPrompt.system;\n\t\t\t\t\t\tconst stepProviderOptions = mergeObjects(providerOptions, prepareStepResult == null ? void 0 : prepareStepResult.providerOptions);\n\t\t\t\t\t\tconst stepCallSettings = prepareStepCallSettings({\n\t\t\t\t\t\t\tcallSettings: callSettings2,\n\t\t\t\t\t\t\tstepSettings: prepareStepResult\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait notify({\n\t\t\t\t\t\t\tevent: {\n\t\t\t\t\t\t\t\tstepNumber: steps.length,\n\t\t\t\t\t\t\t\tmodel: stepModelInfo,\n\t\t\t\t\t\t\t\tsystem: stepSystem,\n\t\t\t\t\t\t\t\tmessages: stepMessages,\n\t\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\t\t\tactiveTools: stepActiveTools,\n\t\t\t\t\t\t\t\tsteps: [...steps],\n\t\t\t\t\t\t\t\tproviderOptions: stepProviderOptions,\n\t\t\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tstopWhen,\n\t\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\tinclude,\n\t\t\t\t\t\t\t\tfunctionId: telemetry == null ? void 0 : telemetry.functionId,\n\t\t\t\t\t\t\t\tmetadata: telemetry == null ? void 0 : telemetry.metadata,\n\t\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcallbacks: [onStepStart, globalTelemetry.onStepStart]\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcurrentModelResponse = await retry(() => recordSpan({\n\t\t\t\t\t\t\tname: \"ai.generateText.doGenerate\",\n\t\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\t\toperationId: \"ai.generateText.doGenerate\",\n\t\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\t\"ai.model.provider\": stepModel.provider,\n\t\t\t\t\t\t\t\t\t\"ai.model.id\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\t\t\"ai.prompt.tools\": { input: () => stepTools == null ? void 0 : stepTools.map((tool2) => JSON.stringify(tool2)) },\n\t\t\t\t\t\t\t\t\t\"ai.prompt.toolChoice\": { input: () => stepToolChoice != null ? JSON.stringify(stepToolChoice) : void 0 },\n\t\t\t\t\t\t\t\t\t\"gen_ai.system\": stepModel.provider,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.model\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": stepCallSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": stepCallSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": stepCallSettings.presencePenalty,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.stop_sequences\": stepCallSettings.stopSequences,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": stepCallSettings.temperature,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": stepCallSettings.topK,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": stepCallSettings.topP\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\t\t\tvar _a24, _b2, _c2, _d2, _e2, _f2, _g2, _h2;\n\t\t\t\t\t\t\t\tconst result = await stepModel.doGenerate({\n\t\t\t\t\t\t\t\t\t...stepCallSettings,\n\t\t\t\t\t\t\t\t\ttools: stepTools,\n\t\t\t\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\t\t\t\tresponseFormat: await (output == null ? void 0 : output.responseFormat),\n\t\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\t\tproviderOptions: stepProviderOptions,\n\t\t\t\t\t\t\t\t\tabortSignal: mergedAbortSignal,\n\t\t\t\t\t\t\t\t\theaders: headersWithUserAgent\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\t\t\tid: (_b2 = (_a24 = result.response) == null ? void 0 : _a24.id) != null ? _b2 : generateId2(),\n\t\t\t\t\t\t\t\t\ttimestamp: (_d2 = (_c2 = result.response) == null ? void 0 : _c2.timestamp) != null ? _d2 : /* @__PURE__ */ new Date(),\n\t\t\t\t\t\t\t\t\tmodelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId,\n\t\t\t\t\t\t\t\t\theaders: (_g2 = result.response) == null ? void 0 : _g2.headers,\n\t\t\t\t\t\t\t\t\tbody: (_h2 = result.response) == null ? void 0 : _h2.body\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tconst usage = asLanguageModelUsage(result.usage);\n\t\t\t\t\t\t\t\tspan2.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result.finishReason.unified,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.text\": { output: () => extractTextContent(result.content) },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.reasoning\": { output: () => extractReasoningContent(result.content) },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst toolCalls = asToolCalls(result.content);\n\t\t\t\t\t\t\t\t\t\t\treturn toolCalls == null ? void 0 : JSON.stringify(toolCalls);\n\t\t\t\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result.providerMetadata),\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": result.usage.inputTokens.total,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.noCacheTokens\": result.usage.inputTokens.noCache,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheReadTokens\": result.usage.inputTokens.cacheRead,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheWriteTokens\": result.usage.inputTokens.cacheWrite,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": result.usage.outputTokens.total,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokenDetails.textTokens\": result.usage.outputTokens.text,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokenDetails.reasoningTokens\": result.usage.outputTokens.reasoning,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": usage.totalTokens,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": result.usage.outputTokens.reasoning,\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": result.usage.inputTokens.cacheRead,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result.finishReason.unified],\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": result.usage.inputTokens.total,\n\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": result.usage.outputTokens.total\n\t\t\t\t\t\t\t\t\t}\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\t\t...result,\n\t\t\t\t\t\t\t\t\tresponse: responseData\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst stepToolCalls = await Promise.all(currentModelResponse.content.filter((part) => part.type === \"tool-call\").map((toolCall) => parseToolCall({\n\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\ttools: stepToolSet,\n\t\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tmessages: stepInputMessages\n\t\t\t\t\t\t})));\n\t\t\t\t\t\tconst enforcedToolChoice = (stepToolChoice == null ? void 0 : stepToolChoice.type) === \"required\" || (stepToolChoice == null ? void 0 : stepToolChoice.type) === \"tool\" ? stepToolChoice : void 0;\n\t\t\t\t\t\tif (enforcedToolChoice != null && !stepToolCalls.some((toolCall) => enforcedToolChoice.type === \"required\" || toolCall.toolName === enforcedToolChoice.toolName)) throw new ToolChoiceViolationError({\n\t\t\t\t\t\t\ttoolChoice: enforcedToolChoice,\n\t\t\t\t\t\t\tfinishReason: currentModelResponse.finishReason.unified,\n\t\t\t\t\t\t\tprovider: stepModel.provider,\n\t\t\t\t\t\t\tmodelId: stepModel.modelId,\n\t\t\t\t\t\t\tcontent: currentModelResponse.content\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst toolApprovalRequests = {};\n\t\t\t\t\t\tfor (const toolCall of stepToolCalls) {\n\t\t\t\t\t\t\tif (toolCall.invalid) continue;\n\t\t\t\t\t\t\tconst tool2 = stepToolSet == null ? void 0 : stepToolSet[toolCall.toolName];\n\t\t\t\t\t\t\tif (tool2 == null) continue;\n\t\t\t\t\t\t\tif (tool2.onInputStart != null) await tool2.onInputStart({\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\t\tabortSignal: mergedAbortSignal,\n\t\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (tool2.onInputAvailable != null) await tool2.onInputAvailable({\n\t\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\t\tabortSignal: mergedAbortSignal,\n\t\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (await isApprovalNeeded({\n\t\t\t\t\t\t\t\ttool: tool2,\n\t\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t\t})) {\n\t\t\t\t\t\t\t\tconst approvalId = generateId2();\n\t\t\t\t\t\t\t\tconst signature = await maybeSignApproval({\n\t\t\t\t\t\t\t\t\tsecret: experimental_toolApprovalSecret,\n\t\t\t\t\t\t\t\t\tapprovalId,\n\t\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\t\t\tinput: toolCall.input\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\ttoolApprovalRequests[toolCall.toolCallId] = {\n\t\t\t\t\t\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\t\t\t\t\t\tapprovalId,\n\t\t\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\t\t\t...signature != null ? { signature } : {}\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst invalidToolCalls = stepToolCalls.filter((toolCall) => toolCall.invalid && toolCall.dynamic && !toolCall.providerExecuted);\n\t\t\t\t\t\tclientToolOutputs = [];\n\t\t\t\t\t\tfor (const toolCall of invalidToolCalls) clientToolOutputs.push({\n\t\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\terror: getErrorMessage$1(toolCall.error),\n\t\t\t\t\t\t\tdynamic: true\n\t\t\t\t\t\t});\n\t\t\t\t\t\tclientToolCalls = stepToolCalls.filter((toolCall) => !toolCall.providerExecuted);\n\t\t\t\t\t\tif (stepToolSet != null && isToolExecutionAllowedFinishReason(currentModelResponse.finishReason.unified)) clientToolOutputs.push(...await executeTools({\n\t\t\t\t\t\t\ttoolCalls: clientToolCalls.filter((toolCall) => !toolCall.invalid && toolApprovalRequests[toolCall.toolCallId] == null),\n\t\t\t\t\t\t\ttools: stepToolSet,\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\tabortSignal: mergedAbortSignal,\n\t\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\t\tstepNumber: steps.length,\n\t\t\t\t\t\t\tmodel: stepModelInfo,\n\t\t\t\t\t\t\tonToolCallStart: [onToolCallStart, globalTelemetry.onToolCallStart],\n\t\t\t\t\t\t\tonToolCallFinish: [onToolCallFinish, globalTelemetry.onToolCallFinish]\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tfor (const toolCall of stepToolCalls) {\n\t\t\t\t\t\t\tif (!toolCall.providerExecuted) continue;\n\t\t\t\t\t\t\tconst tool2 = stepToolSet == null ? void 0 : stepToolSet[toolCall.toolName];\n\t\t\t\t\t\t\tif ((tool2 == null ? void 0 : tool2.type) === \"provider\" && tool2.supportsDeferredResults) {\n\t\t\t\t\t\t\t\tif (!currentModelResponse.content.some((part) => part.type === \"tool-result\" && part.toolCallId === toolCall.toolCallId)) pendingDeferredToolCalls.set(toolCall.toolCallId, { toolName: toolCall.toolName });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const part of currentModelResponse.content) if (part.type === \"tool-result\") pendingDeferredToolCalls.delete(part.toolCallId);\n\t\t\t\t\t\tconst stepContent = asContent({\n\t\t\t\t\t\t\tcontent: currentModelResponse.content,\n\t\t\t\t\t\t\ttoolCalls: stepToolCalls,\n\t\t\t\t\t\t\ttoolOutputs: clientToolOutputs,\n\t\t\t\t\t\t\ttoolApprovalRequests: Object.values(toolApprovalRequests),\n\t\t\t\t\t\t\ttools: stepToolSet\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponseMessages.push(...await toResponseMessages({\n\t\t\t\t\t\t\tcontent: stepContent,\n\t\t\t\t\t\t\ttools: stepToolSet\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst stepRequest = ((_i = include == null ? void 0 : include.requestBody) != null ? _i : true) ? (_j = currentModelResponse.request) != null ? _j : {} : {\n\t\t\t\t\t\t\t...currentModelResponse.request,\n\t\t\t\t\t\t\tbody: void 0\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stepResponse = {\n\t\t\t\t\t\t\t...currentModelResponse.response,\n\t\t\t\t\t\t\tmessages: structuredClone(responseMessages),\n\t\t\t\t\t\t\tbody: ((_k = include == null ? void 0 : include.responseBody) != null ? _k : true) ? (_l = currentModelResponse.response) == null ? void 0 : _l.body : void 0\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stepNumber = steps.length;\n\t\t\t\t\t\tconst currentStepResult = new DefaultStepResult({\n\t\t\t\t\t\t\tstepNumber,\n\t\t\t\t\t\t\tmodel: stepModelInfo,\n\t\t\t\t\t\t\tfunctionId: telemetry == null ? void 0 : telemetry.functionId,\n\t\t\t\t\t\t\tmetadata: telemetry == null ? void 0 : telemetry.metadata,\n\t\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\t\tcontent: stepContent,\n\t\t\t\t\t\t\tfinishReason: currentModelResponse.finishReason.unified,\n\t\t\t\t\t\t\trawFinishReason: currentModelResponse.finishReason.raw,\n\t\t\t\t\t\t\tusage: asLanguageModelUsage(currentModelResponse.usage),\n\t\t\t\t\t\t\twarnings: currentModelResponse.warnings,\n\t\t\t\t\t\t\tproviderMetadata: currentModelResponse.providerMetadata,\n\t\t\t\t\t\t\trequest: stepRequest,\n\t\t\t\t\t\t\tresponse: stepResponse\n\t\t\t\t\t\t});\n\t\t\t\t\t\tlogWarnings({\n\t\t\t\t\t\t\twarnings: (_m = currentModelResponse.warnings) != null ? _m : [],\n\t\t\t\t\t\t\tprovider: stepModelInfo.provider,\n\t\t\t\t\t\t\tmodel: stepModelInfo.modelId\n\t\t\t\t\t\t});\n\t\t\t\t\t\tsteps.push(currentStepResult);\n\t\t\t\t\t\tawait notify({\n\t\t\t\t\t\t\tevent: currentStepResult,\n\t\t\t\t\t\t\tcallbacks: [onStepFinish, globalTelemetry.onStepFinish]\n\t\t\t\t\t\t});\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (stepTimeoutId != null) clearTimeout(stepTimeoutId);\n\t\t\t\t\t}\n\t\t\t\t} while ((clientToolCalls.length > 0 && clientToolOutputs.length === clientToolCalls.length || pendingDeferredToolCalls.size > 0) && !await isStopConditionMet({\n\t\t\t\t\tstopConditions,\n\t\t\t\t\tsteps\n\t\t\t\t}));\n\t\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.response.finishReason\": currentModelResponse.finishReason.unified,\n\t\t\t\t\t\t\"ai.response.text\": { output: () => extractTextContent(currentModelResponse.content) },\n\t\t\t\t\t\t\"ai.response.reasoning\": { output: () => extractReasoningContent(currentModelResponse.content) },\n\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\tconst toolCalls = asToolCalls(currentModelResponse.content);\n\t\t\t\t\t\t\treturn toolCalls == null ? void 0 : JSON.stringify(toolCalls);\n\t\t\t\t\t\t} },\n\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(currentModelResponse.providerMetadata)\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tconst lastStep = steps[steps.length - 1];\n\t\t\t\tconst totalUsage = steps.reduce((totalUsage2, step) => {\n\t\t\t\t\treturn addLanguageModelUsage(totalUsage2, step.usage);\n\t\t\t\t}, {\n\t\t\t\t\tinputTokens: void 0,\n\t\t\t\t\toutputTokens: void 0,\n\t\t\t\t\ttotalTokens: void 0,\n\t\t\t\t\treasoningTokens: void 0,\n\t\t\t\t\tcachedInputTokens: void 0\n\t\t\t\t});\n\t\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.usage.inputTokens\": totalUsage.inputTokens,\n\t\t\t\t\t\t\"ai.usage.inputTokenDetails.noCacheTokens\": (_n = totalUsage.inputTokenDetails) == null ? void 0 : _n.noCacheTokens,\n\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheReadTokens\": (_o = totalUsage.inputTokenDetails) == null ? void 0 : _o.cacheReadTokens,\n\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheWriteTokens\": (_p = totalUsage.inputTokenDetails) == null ? void 0 : _p.cacheWriteTokens,\n\t\t\t\t\t\t\"ai.usage.outputTokens\": totalUsage.outputTokens,\n\t\t\t\t\t\t\"ai.usage.outputTokenDetails.textTokens\": (_q = totalUsage.outputTokenDetails) == null ? void 0 : _q.textTokens,\n\t\t\t\t\t\t\"ai.usage.outputTokenDetails.reasoningTokens\": (_r = totalUsage.outputTokenDetails) == null ? void 0 : _r.reasoningTokens,\n\t\t\t\t\t\t\"ai.usage.totalTokens\": totalUsage.totalTokens,\n\t\t\t\t\t\t\"ai.usage.reasoningTokens\": (_s = totalUsage.outputTokenDetails) == null ? void 0 : _s.reasoningTokens,\n\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": (_t = totalUsage.inputTokenDetails) == null ? void 0 : _t.cacheReadTokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tawait notify({\n\t\t\t\t\tevent: {\n\t\t\t\t\t\tstepNumber: lastStep.stepNumber,\n\t\t\t\t\t\tmodel: lastStep.model,\n\t\t\t\t\t\tfunctionId: lastStep.functionId,\n\t\t\t\t\t\tmetadata: lastStep.metadata,\n\t\t\t\t\t\texperimental_context: lastStep.experimental_context,\n\t\t\t\t\t\tfinishReason: lastStep.finishReason,\n\t\t\t\t\t\trawFinishReason: lastStep.rawFinishReason,\n\t\t\t\t\t\tusage: lastStep.usage,\n\t\t\t\t\t\tcontent: lastStep.content,\n\t\t\t\t\t\ttext: lastStep.text,\n\t\t\t\t\t\treasoningText: lastStep.reasoningText,\n\t\t\t\t\t\treasoning: lastStep.reasoning,\n\t\t\t\t\t\tfiles: lastStep.files,\n\t\t\t\t\t\tsources: lastStep.sources,\n\t\t\t\t\t\ttoolCalls: lastStep.toolCalls,\n\t\t\t\t\t\tstaticToolCalls: lastStep.staticToolCalls,\n\t\t\t\t\t\tdynamicToolCalls: lastStep.dynamicToolCalls,\n\t\t\t\t\t\ttoolResults: lastStep.toolResults,\n\t\t\t\t\t\tstaticToolResults: lastStep.staticToolResults,\n\t\t\t\t\t\tdynamicToolResults: lastStep.dynamicToolResults,\n\t\t\t\t\t\trequest: lastStep.request,\n\t\t\t\t\t\tresponse: lastStep.response,\n\t\t\t\t\t\twarnings: lastStep.warnings,\n\t\t\t\t\t\tproviderMetadata: lastStep.providerMetadata,\n\t\t\t\t\t\tsteps,\n\t\t\t\t\t\ttotalUsage\n\t\t\t\t\t},\n\t\t\t\t\tcallbacks: [onFinish, globalTelemetry.onFinish]\n\t\t\t\t});\n\t\t\t\tlet resolvedOutput;\n\t\t\t\tif (lastStep.finishReason === \"stop\" || lastStep.finishReason !== \"tool-calls\" && lastStep.text.length > 0) resolvedOutput = await (output != null ? output : text()).parseCompleteOutput({ text: lastStep.text }, {\n\t\t\t\t\tresponse: lastStep.response,\n\t\t\t\t\tusage: lastStep.usage,\n\t\t\t\t\tfinishReason: lastStep.finishReason\n\t\t\t\t});\n\t\t\t\treturn new DefaultGenerateTextResult({\n\t\t\t\t\tsteps,\n\t\t\t\t\ttotalUsage,\n\t\t\t\t\toutput: resolvedOutput\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t} catch (error) {\n\t\tthrow wrapGatewayError(error);\n\t}\n}\nasync function executeTools({ toolCalls, tools, tracer, telemetry, messages, abortSignal, experimental_context, stepNumber, model, onToolCallStart, onToolCallFinish }) {\n\treturn (await Promise.all(toolCalls.map(async (toolCall) => executeToolCall({\n\t\ttoolCall,\n\t\ttools,\n\t\ttracer,\n\t\ttelemetry,\n\t\tmessages,\n\t\tabortSignal,\n\t\texperimental_context,\n\t\tstepNumber,\n\t\tmodel,\n\t\tonToolCallStart,\n\t\tonToolCallFinish\n\t})))).filter((output) => output != null);\n}\nvar DefaultGenerateTextResult = class {\n\tconstructor(options) {\n\t\tthis.steps = options.steps;\n\t\tthis._output = options.output;\n\t\tthis.totalUsage = options.totalUsage;\n\t}\n\tget finalStep() {\n\t\treturn this.steps[this.steps.length - 1];\n\t}\n\tget content() {\n\t\treturn this.finalStep.content;\n\t}\n\tget text() {\n\t\treturn this.finalStep.text;\n\t}\n\tget files() {\n\t\treturn this.finalStep.files;\n\t}\n\tget reasoningText() {\n\t\treturn this.finalStep.reasoningText;\n\t}\n\tget reasoning() {\n\t\treturn this.finalStep.reasoning;\n\t}\n\tget toolCalls() {\n\t\treturn this.finalStep.toolCalls;\n\t}\n\tget staticToolCalls() {\n\t\treturn this.finalStep.staticToolCalls;\n\t}\n\tget dynamicToolCalls() {\n\t\treturn this.finalStep.dynamicToolCalls;\n\t}\n\tget toolResults() {\n\t\treturn this.finalStep.toolResults;\n\t}\n\tget staticToolResults() {\n\t\treturn this.finalStep.staticToolResults;\n\t}\n\tget dynamicToolResults() {\n\t\treturn this.finalStep.dynamicToolResults;\n\t}\n\tget sources() {\n\t\treturn this.finalStep.sources;\n\t}\n\tget finishReason() {\n\t\treturn this.finalStep.finishReason;\n\t}\n\tget rawFinishReason() {\n\t\treturn this.finalStep.rawFinishReason;\n\t}\n\tget warnings() {\n\t\treturn this.finalStep.warnings;\n\t}\n\tget providerMetadata() {\n\t\treturn this.finalStep.providerMetadata;\n\t}\n\tget response() {\n\t\treturn this.finalStep.response;\n\t}\n\tget request() {\n\t\treturn this.finalStep.request;\n\t}\n\tget usage() {\n\t\treturn this.finalStep.usage;\n\t}\n\tget experimental_output() {\n\t\treturn this.output;\n\t}\n\tget output() {\n\t\tif (this._output == null) throw new NoOutputGeneratedError();\n\t\treturn this._output;\n\t}\n};\nfunction asToolCalls(content) {\n\tconst parts = content.filter((part) => part.type === \"tool-call\");\n\tif (parts.length === 0) return;\n\treturn parts.map((toolCall) => ({\n\t\ttoolCallId: toolCall.toolCallId,\n\t\ttoolName: toolCall.toolName,\n\t\tinput: toolCall.input\n\t}));\n}\nfunction asContent({ content, toolCalls, toolOutputs, toolApprovalRequests, tools }) {\n\tconst contentParts = [];\n\tfor (const part of content) switch (part.type) {\n\t\tcase \"text\":\n\t\tcase \"reasoning\":\n\t\tcase \"source\":\n\t\t\tcontentParts.push(part);\n\t\t\tbreak;\n\t\tcase \"file\":\n\t\t\tcontentParts.push({\n\t\t\t\ttype: \"file\",\n\t\t\t\tfile: new DefaultGeneratedFile(part),\n\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"tool-call\":\n\t\t\tcontentParts.push(toolCalls.find((toolCall) => toolCall.toolCallId === part.toolCallId));\n\t\t\tbreak;\n\t\tcase \"tool-result\": {\n\t\t\tconst toolCall = toolCalls.find((toolCall2) => toolCall2.toolCallId === part.toolCallId);\n\t\t\tif (toolCall == null) {\n\t\t\t\tconst tool2 = tools == null ? void 0 : tools[part.toolName];\n\t\t\t\tif (!((tool2 == null ? void 0 : tool2.type) === \"provider\" && tool2.supportsDeferredResults)) throw new Error(`Tool call ${part.toolCallId} not found.`);\n\t\t\t\tif (part.isError) contentParts.push({\n\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\tinput: void 0,\n\t\t\t\t\terror: part.result,\n\t\t\t\t\tproviderExecuted: true,\n\t\t\t\t\tdynamic: part.dynamic,\n\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t...(tool2 == null ? void 0 : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}\n\t\t\t\t});\n\t\t\t\telse contentParts.push({\n\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\tinput: void 0,\n\t\t\t\t\toutput: part.result,\n\t\t\t\t\tproviderExecuted: true,\n\t\t\t\t\tdynamic: part.dynamic,\n\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t...(tool2 == null ? void 0 : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (part.isError) contentParts.push({\n\t\t\t\ttype: \"tool-error\",\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\ttoolName: part.toolName,\n\t\t\t\tinput: toolCall.input,\n\t\t\t\terror: part.result,\n\t\t\t\tproviderExecuted: true,\n\t\t\t\tdynamic: toolCall.dynamic,\n\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t});\n\t\t\telse contentParts.push({\n\t\t\t\ttype: \"tool-result\",\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\ttoolName: part.toolName,\n\t\t\t\tinput: toolCall.input,\n\t\t\t\toutput: part.result,\n\t\t\t\tproviderExecuted: true,\n\t\t\t\tdynamic: toolCall.dynamic,\n\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tcase \"tool-approval-request\": {\n\t\t\tconst toolCall = toolCalls.find((toolCall2) => toolCall2.toolCallId === part.toolCallId);\n\t\t\tif (toolCall == null) throw new ToolCallNotFoundForApprovalError({\n\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\tapprovalId: part.approvalId\n\t\t\t});\n\t\t\tcontentParts.push({\n\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\tapprovalId: part.approvalId,\n\t\t\t\ttoolCall\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn [\n\t\t...contentParts,\n\t\t...toolOutputs,\n\t\t...toolApprovalRequests\n\t];\n}\nfunction prepareHeaders(headers, defaultHeaders) {\n\tconst responseHeaders = new Headers(headers != null ? headers : {});\n\tfor (const [key, value] of Object.entries(defaultHeaders)) if (!responseHeaders.has(key)) responseHeaders.set(key, value);\n\treturn responseHeaders;\n}\nfunction createTextStreamResponse({ status, statusText, headers, textStream }) {\n\treturn new Response(textStream.pipeThrough(new TextEncoderStream()), {\n\t\tstatus: status != null ? status : 200,\n\t\tstatusText,\n\t\theaders: prepareHeaders(headers, { \"content-type\": \"text/plain; charset=utf-8\" })\n\t});\n}\nfunction writeToServerResponse({ response, status, statusText, headers, stream }) {\n\tconst statusCode = status != null ? status : 200;\n\tif (statusText !== void 0) response.writeHead(statusCode, statusText, headers);\n\telse response.writeHead(statusCode, headers);\n\tconst reader = stream.getReader();\n\tlet clientDisconnected = false;\n\tlet onDisconnect;\n\tconst handleClose = () => {\n\t\tif (response.writableFinished) return;\n\t\tclientDisconnected = true;\n\t\tonDisconnect?.();\n\t\treader.cancel(/* @__PURE__ */ new Error(\"Client disconnected.\")).catch(() => {});\n\t};\n\tresponse.once(\"close\", handleClose);\n\tif (response.destroyed) handleClose();\n\tconst read = async () => {\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done || clientDisconnected || response.destroyed) break;\n\t\t\t\tif (!response.write(value)) {\n\t\t\t\t\tawait new Promise((resolve3) => {\n\t\t\t\t\t\tonDisconnect = resolve3;\n\t\t\t\t\t\tresponse.once(\"drain\", resolve3);\n\t\t\t\t\t});\n\t\t\t\t\tonDisconnect = void 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tresponse.off(\"close\", handleClose);\n\t\t\tif (clientDisconnected || response.destroyed) reader.cancel().catch(() => {});\n\t\t\telse response.end();\n\t\t}\n\t};\n\treturn read();\n}\nfunction pipeTextStreamToResponse({ response, status, statusText, headers, textStream }) {\n\treturn writeToServerResponse({\n\t\tresponse,\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: Object.fromEntries(prepareHeaders(headers, { \"content-type\": \"text/plain; charset=utf-8\" }).entries()),\n\t\tstream: textStream.pipeThrough(new TextEncoderStream())\n\t});\n}\nvar STREAM_OPEN_COMMENT = \": stream-open\\n\\n\";\nvar KEEP_ALIVE_COMMENT = \": keep-alive\\n\\n\";\nfunction createSseStreamWithKeepAlive({ stream, keepAliveMs }) {\n\tif (keepAliveMs == null) return stream;\n\tif (!Number.isFinite(keepAliveMs) || keepAliveMs <= 0 || keepAliveMs > 2147483647) throw new Error(\"keepAliveMs must be a positive finite timer duration no greater than 2147483647\");\n\tconst reader = stream.getReader();\n\tlet keepAliveTimeout;\n\tlet isCancelled = false;\n\tconst clearKeepAliveTimeout = () => {\n\t\tclearTimeout(keepAliveTimeout);\n\t\tkeepAliveTimeout = void 0;\n\t};\n\tconst scheduleKeepAlive = (controller) => {\n\t\tclearKeepAliveTimeout();\n\t\tkeepAliveTimeout = setTimeout(() => {\n\t\t\tif (isCancelled) return;\n\t\t\tif (controller.desiredSize != null && controller.desiredSize > 0) controller.enqueue(KEEP_ALIVE_COMMENT);\n\t\t\tscheduleKeepAlive(controller);\n\t\t}, keepAliveMs);\n\t};\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\tcontroller.enqueue(STREAM_OPEN_COMMENT);\n\t\t\tscheduleKeepAlive(controller);\n\t\t},\n\t\tpull(controller) {\n\t\t\treturn reader.read().then((result) => {\n\t\t\t\tclearKeepAliveTimeout();\n\t\t\t\tif (isCancelled) return;\n\t\t\t\tif (result.done) controller.close();\n\t\t\t\telse {\n\t\t\t\t\tcontroller.enqueue(result.value);\n\t\t\t\t\tscheduleKeepAlive(controller);\n\t\t\t\t}\n\t\t\t}, (error) => {\n\t\t\t\tclearKeepAliveTimeout();\n\t\t\t\tif (!isCancelled) throw error;\n\t\t\t});\n\t\t},\n\t\tasync cancel(reason) {\n\t\t\tisCancelled = true;\n\t\t\tclearKeepAliveTimeout();\n\t\t\tawait reader.cancel(reason);\n\t\t}\n\t});\n}\nvar JsonToSseTransformStream = class extends TransformStream {\n\tconstructor() {\n\t\tsuper({\n\t\t\ttransform(part, controller) {\n\t\t\t\tcontroller.enqueue(`data: ${JSON.stringify(part)}\n\n`);\n\t\t\t},\n\t\t\tflush(controller) {\n\t\t\t\tcontroller.enqueue(\"data: [DONE]\\n\\n\");\n\t\t\t}\n\t\t});\n\t}\n};\nvar UI_MESSAGE_STREAM_HEADERS = {\n\t\"content-type\": \"text/event-stream\",\n\t\"cache-control\": \"no-cache\",\n\tconnection: \"keep-alive\",\n\t\"x-vercel-ai-ui-message-stream\": \"v1\",\n\t\"x-accel-buffering\": \"no\"\n};\nfunction createUIMessageStreamResponse({ status, statusText, headers, stream, keepAliveMs, consumeSseStream }) {\n\tlet sseStream = createSseStreamWithKeepAlive({\n\t\tstream: stream.pipeThrough(new JsonToSseTransformStream()),\n\t\tkeepAliveMs\n\t});\n\tif (consumeSseStream) {\n\t\tconst [stream1, stream2] = sseStream.tee();\n\t\tsseStream = stream1;\n\t\tconsumeSseStream({ stream: stream2 });\n\t}\n\treturn new Response(sseStream.pipeThrough(new TextEncoderStream()), {\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: prepareHeaders(headers, UI_MESSAGE_STREAM_HEADERS)\n\t});\n}\nfunction getResponseUIMessageId({ originalMessages, responseMessageId }) {\n\tif (originalMessages == null) return;\n\tconst lastMessage = originalMessages[originalMessages.length - 1];\n\treturn (lastMessage == null ? void 0 : lastMessage.role) === \"assistant\" ? lastMessage.id : typeof responseMessageId === \"function\" ? responseMessageId() : responseMessageId;\n}\nvar toolMetadataSchema = z.record(z.string(), jsonValueSchema.optional());\nvar uiMessageChunkSchema = lazySchema(() => zodSchema(z.union([\n\tz.looseObject({\n\t\ttype: z.literal(\"text-start\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"text-delta\"),\n\t\tid: z.string(),\n\t\tdelta: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"text-end\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"error\"),\n\t\terrorText: z.string()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-start\"),\n\t\ttoolCallId: z.string(),\n\t\ttoolName: z.string(),\n\t\tinputEncoding: z.enum([\"json\", \"text\"]).optional(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\ttoolMetadata: toolMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional(),\n\t\ttitle: z.string().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-delta\"),\n\t\ttoolCallId: z.string(),\n\t\tinputTextDelta: z.string()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-available\"),\n\t\ttoolCallId: z.string(),\n\t\ttoolName: z.string(),\n\t\tinput: z.unknown(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\ttoolMetadata: toolMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional(),\n\t\ttitle: z.string().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-input-error\"),\n\t\ttoolCallId: z.string(),\n\t\ttoolName: z.string(),\n\t\tinput: z.unknown(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\ttoolMetadata: toolMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional(),\n\t\terrorText: z.string(),\n\t\ttitle: z.string().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-approval-request\"),\n\t\tapprovalId: z.string(),\n\t\ttoolCallId: z.string(),\n\t\tapprovalDescriptor: z.unknown().optional(),\n\t\tinputSchemaInput: z.unknown().optional(),\n\t\tsignature: z.string().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-output-available\"),\n\t\ttoolCallId: z.string(),\n\t\toutput: z.unknown(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\ttoolMetadata: toolMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional(),\n\t\tpreliminary: z.boolean().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-output-error\"),\n\t\ttoolCallId: z.string(),\n\t\terrorText: z.string(),\n\t\tproviderExecuted: z.boolean().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional(),\n\t\ttoolMetadata: toolMetadataSchema.optional(),\n\t\tdynamic: z.boolean().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"tool-output-denied\"),\n\t\ttoolCallId: z.string()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"reasoning-start\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"reasoning-delta\"),\n\t\tid: z.string(),\n\t\tdelta: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"reasoning-end\"),\n\t\tid: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"source-url\"),\n\t\tsourceId: z.string(),\n\t\turl: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"source-document\"),\n\t\tsourceId: z.string(),\n\t\tmediaType: z.string(),\n\t\ttitle: z.string(),\n\t\tfilename: z.string().optional(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"file\"),\n\t\turl: z.string(),\n\t\tmediaType: z.string(),\n\t\tproviderMetadata: providerMetadataSchema.optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.custom((value) => typeof value === \"string\" && value.startsWith(\"data-\"), { message: \"Type must start with \\\"data-\\\"\" }),\n\t\tid: z.string().optional(),\n\t\tdata: z.unknown(),\n\t\ttransient: z.boolean().optional()\n\t}),\n\tz.looseObject({ type: z.literal(\"start-step\") }),\n\tz.looseObject({ type: z.literal(\"finish-step\") }),\n\tz.looseObject({\n\t\ttype: z.literal(\"start\"),\n\t\tmessageId: z.string().optional(),\n\t\tmessageMetadata: z.unknown().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"finish\"),\n\t\tfinishReason: z.enum([\n\t\t\t\"stop\",\n\t\t\t\"length\",\n\t\t\t\"content-filter\",\n\t\t\t\"tool-calls\",\n\t\t\t\"error\",\n\t\t\t\"other\"\n\t\t]).optional(),\n\t\tmessageMetadata: z.unknown().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"abort\"),\n\t\treason: z.string().optional()\n\t}),\n\tz.looseObject({\n\t\ttype: z.literal(\"message-metadata\"),\n\t\tmessageMetadata: z.unknown()\n\t})\n])));\nfunction isDataUIMessageChunk(chunk) {\n\treturn chunk.type.startsWith(\"data-\");\n}\nfunction createIdMap() {\n\treturn /* @__PURE__ */ Object.create(null);\n}\nfunction isDataUIPart(part) {\n\treturn part.type.startsWith(\"data-\");\n}\nfunction isTextUIPart(part) {\n\treturn part.type === \"text\";\n}\nfunction isFileUIPart(part) {\n\treturn part.type === \"file\";\n}\nfunction isReasoningUIPart(part) {\n\treturn part.type === \"reasoning\";\n}\nfunction isStaticToolUIPart(part) {\n\treturn part.type.startsWith(\"tool-\");\n}\nfunction isDynamicToolUIPart(part) {\n\treturn part.type === \"dynamic-tool\";\n}\nfunction isToolUIPart(part) {\n\treturn isStaticToolUIPart(part) || isDynamicToolUIPart(part);\n}\nvar isToolOrDynamicToolUIPart = isToolUIPart;\nfunction getStaticToolName(part) {\n\treturn part.type.split(\"-\").slice(1).join(\"-\");\n}\nfunction getToolName(part) {\n\treturn isDynamicToolUIPart(part) ? part.toolName : getStaticToolName(part);\n}\nvar getToolOrDynamicToolName = getToolName;\nfunction createStreamingUIMessageState({ lastMessage, messageId }) {\n\tvar _a23;\n\tconst message = (lastMessage == null ? void 0 : lastMessage.role) === \"assistant\" ? lastMessage : {\n\t\tid: messageId,\n\t\tmetadata: void 0,\n\t\trole: \"assistant\",\n\t\tparts: []\n\t};\n\tconst partialToolCalls = createIdMap();\n\tconst lastStepStartIndex = message.parts.findLastIndex((part) => part.type === \"step-start\");\n\tlet staticToolIndex = 0;\n\tfor (const part of message.parts.slice(lastStepStartIndex + 1)) {\n\t\tif (!isToolUIPart(part)) continue;\n\t\tconst index = staticToolIndex;\n\t\tif (isStaticToolUIPart(part)) staticToolIndex++;\n\t\tif (part.state !== \"input-streaming\") continue;\n\t\tpartialToolCalls[part.toolCallId] = {\n\t\t\ttext: (_a23 = part.rawInput) != null ? _a23 : \"\",\n\t\t\tinputEncoding: part.inputEncoding,\n\t\t\tindex,\n\t\t\ttoolName: part.type === \"dynamic-tool\" ? part.toolName : getStaticToolName(part),\n\t\t\tdynamic: part.type === \"dynamic-tool\",\n\t\t\ttitle: part.title,\n\t\t\ttoolMetadata: part.toolMetadata\n\t\t};\n\t}\n\treturn {\n\t\tmessage,\n\t\tactiveTextParts: createIdMap(),\n\t\tactiveReasoningParts: createIdMap(),\n\t\tpartialToolCalls\n\t};\n}\nfunction processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas, runUpdateMessageJob, onError, onToolCall, onData, resetStateOnMessageIdChange = false, resetStateOnFirstMessageStart = false }) {\n\tlet isFirstMessageStart = true;\n\treturn stream.pipeThrough(new TransformStream({ async transform(chunk, controller) {\n\t\tawait runUpdateMessageJob(async ({ state, write }) => {\n\t\t\tvar _a23, _b, _c, _d, _e, _f, _g, _h, _i;\n\t\t\tfunction getCurrentStepParts() {\n\t\t\t\tconst parts = state.message.parts;\n\t\t\t\tlet currentStepStartIndex = parts.length - 1;\n\t\t\t\twhile (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== \"step-start\") currentStepStartIndex--;\n\t\t\t\treturn parts.slice(currentStepStartIndex + 1);\n\t\t\t}\n\t\t\tfunction getCurrentStepToolInvocations() {\n\t\t\t\treturn getCurrentStepParts().filter(isToolUIPart);\n\t\t\t}\n\t\t\tfunction getToolInvocation(toolCallId) {\n\t\t\t\tlet toolInvocation = getCurrentStepToolInvocations().find((invocation) => invocation.toolCallId === toolCallId);\n\t\t\t\tif (toolInvocation == null) {\n\t\t\t\t\tconst parts = state.message.parts;\n\t\t\t\t\tfor (let i = parts.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tconst part = parts[i];\n\t\t\t\t\t\tif (isToolUIPart(part) && part.toolCallId === toolCallId) {\n\t\t\t\t\t\t\ttoolInvocation = part;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (toolInvocation == null) throw new UIMessageStreamError({\n\t\t\t\t\tchunkType: \"tool-invocation\",\n\t\t\t\t\tchunkId: toolCallId,\n\t\t\t\t\tmessage: `No tool invocation found for tool call ID \"${toolCallId}\".`\n\t\t\t\t});\n\t\t\t\treturn toolInvocation;\n\t\t\t}\n\t\t\tfunction updateToolPart(options, existingPart) {\n\t\t\t\tvar _a24;\n\t\t\t\tconst part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);\n\t\t\t\tconst anyOptions = options;\n\t\t\t\tconst anyPart = part;\n\t\t\t\tif (part != null) {\n\t\t\t\t\tpart.state = options.state;\n\t\t\t\t\tanyPart.input = anyOptions.input;\n\t\t\t\t\tanyPart.output = anyOptions.output;\n\t\t\t\t\tanyPart.errorText = anyOptions.errorText;\n\t\t\t\t\tanyPart.rawInput = anyOptions.rawInput;\n\t\t\t\t\tif (anyOptions.inputEncoding != null) anyPart.inputEncoding = anyOptions.inputEncoding;\n\t\t\t\t\telse delete anyPart.inputEncoding;\n\t\t\t\t\tanyPart.preliminary = anyOptions.preliminary;\n\t\t\t\t\tif (options.title !== void 0) anyPart.title = options.title;\n\t\t\t\t\tif (options.toolMetadata !== void 0) anyPart.toolMetadata = options.toolMetadata;\n\t\t\t\t\tanyPart.providerExecuted = (_a24 = anyOptions.providerExecuted) != null ? _a24 : part.providerExecuted;\n\t\t\t\t\tconst providerMetadata = anyOptions.providerMetadata;\n\t\t\t\t\tif (providerMetadata != null) {\n\t\t\t\t\t\tif (options.state === \"output-available\" || options.state === \"output-error\") {\n\t\t\t\t\t\t\tconst resultPart = part;\n\t\t\t\t\t\t\tresultPart.resultProviderMetadata = providerMetadata;\n\t\t\t\t\t\t} else part.callProviderMetadata = providerMetadata;\n\t\t\t\t\t}\n\t\t\t\t} else state.message.parts.push({\n\t\t\t\t\ttype: `tool-${options.toolName}`,\n\t\t\t\t\ttoolCallId: options.toolCallId,\n\t\t\t\t\tstate: options.state,\n\t\t\t\t\ttitle: options.title,\n\t\t\t\t\t...options.toolMetadata !== void 0 ? { toolMetadata: options.toolMetadata } : {},\n\t\t\t\t\tinput: anyOptions.input,\n\t\t\t\t\t...anyOptions.inputEncoding != null ? { inputEncoding: anyOptions.inputEncoding } : {},\n\t\t\t\t\toutput: anyOptions.output,\n\t\t\t\t\trawInput: anyOptions.rawInput,\n\t\t\t\t\terrorText: anyOptions.errorText,\n\t\t\t\t\tproviderExecuted: anyOptions.providerExecuted,\n\t\t\t\t\tpreliminary: anyOptions.preliminary,\n\t\t\t\t\t...anyOptions.providerMetadata != null && (options.state === \"output-available\" || options.state === \"output-error\") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},\n\t\t\t\t\t...anyOptions.providerMetadata != null && !(options.state === \"output-available\" || options.state === \"output-error\") ? { callProviderMetadata: anyOptions.providerMetadata } : {}\n\t\t\t\t});\n\t\t\t}\n\t\t\tfunction updateDynamicToolPart(options, existingPart) {\n\t\t\t\tvar _a24;\n\t\t\t\tconst part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => part2.type === \"dynamic-tool\" && part2.toolCallId === options.toolCallId);\n\t\t\t\tconst anyOptions = options;\n\t\t\t\tconst anyPart = part;\n\t\t\t\tif (part != null) {\n\t\t\t\t\tpart.state = options.state;\n\t\t\t\t\tanyPart.toolName = options.toolName;\n\t\t\t\t\tanyPart.input = anyOptions.input;\n\t\t\t\t\tanyPart.output = anyOptions.output;\n\t\t\t\t\tanyPart.errorText = anyOptions.errorText;\n\t\t\t\t\tanyPart.rawInput = anyOptions.rawInput;\n\t\t\t\t\tif (anyOptions.inputEncoding != null) anyPart.inputEncoding = anyOptions.inputEncoding;\n\t\t\t\t\telse delete anyPart.inputEncoding;\n\t\t\t\t\tanyPart.preliminary = anyOptions.preliminary;\n\t\t\t\t\tif (options.title !== void 0) anyPart.title = options.title;\n\t\t\t\t\tif (options.toolMetadata !== void 0) anyPart.toolMetadata = options.toolMetadata;\n\t\t\t\t\tanyPart.providerExecuted = (_a24 = anyOptions.providerExecuted) != null ? _a24 : part.providerExecuted;\n\t\t\t\t\tconst providerMetadata = anyOptions.providerMetadata;\n\t\t\t\t\tif (providerMetadata != null) {\n\t\t\t\t\t\tif (options.state === \"output-available\" || options.state === \"output-error\") {\n\t\t\t\t\t\t\tconst resultPart = part;\n\t\t\t\t\t\t\tresultPart.resultProviderMetadata = providerMetadata;\n\t\t\t\t\t\t} else part.callProviderMetadata = providerMetadata;\n\t\t\t\t\t}\n\t\t\t\t} else state.message.parts.push({\n\t\t\t\t\ttype: \"dynamic-tool\",\n\t\t\t\t\ttoolName: options.toolName,\n\t\t\t\t\ttoolCallId: options.toolCallId,\n\t\t\t\t\tstate: options.state,\n\t\t\t\t\tinput: anyOptions.input,\n\t\t\t\t\t...anyOptions.inputEncoding != null ? { inputEncoding: anyOptions.inputEncoding } : {},\n\t\t\t\t\toutput: anyOptions.output,\n\t\t\t\t\terrorText: anyOptions.errorText,\n\t\t\t\t\tpreliminary: anyOptions.preliminary,\n\t\t\t\t\tproviderExecuted: anyOptions.providerExecuted,\n\t\t\t\t\ttitle: options.title,\n\t\t\t\t\t...options.toolMetadata !== void 0 ? { toolMetadata: options.toolMetadata } : {},\n\t\t\t\t\t...anyOptions.providerMetadata != null && (options.state === \"output-available\" || options.state === \"output-error\") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},\n\t\t\t\t\t...anyOptions.providerMetadata != null && !(options.state === \"output-available\" || options.state === \"output-error\") ? { callProviderMetadata: anyOptions.providerMetadata } : {}\n\t\t\t\t});\n\t\t\t}\n\t\t\tasync function updateMessageMetadata(metadata) {\n\t\t\t\tif (metadata != null) {\n\t\t\t\t\tconst mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;\n\t\t\t\t\tif (messageMetadataSchema != null) await validateTypes({\n\t\t\t\t\t\tvalue: mergedMetadata,\n\t\t\t\t\t\tschema: messageMetadataSchema,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tfield: \"message.metadata\",\n\t\t\t\t\t\t\tentityId: state.message.id\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tstate.message.metadata = mergedMetadata;\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"text-start\": {\n\t\t\t\t\tconst textPart = {\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\tstate: \"streaming\"\n\t\t\t\t\t};\n\t\t\t\t\tstate.activeTextParts[chunk.id] = textPart;\n\t\t\t\t\tstate.message.parts.push(textPart);\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"text-delta\": {\n\t\t\t\t\tconst textPart = state.activeTextParts[chunk.id];\n\t\t\t\t\tif (textPart == null) throw new UIMessageStreamError({\n\t\t\t\t\t\tchunkType: \"text-delta\",\n\t\t\t\t\t\tchunkId: chunk.id,\n\t\t\t\t\t\tmessage: `Received text-delta for missing text part with ID \"${chunk.id}\". Ensure a \"text-start\" chunk is sent before any \"text-delta\" chunks.`\n\t\t\t\t\t});\n\t\t\t\t\ttextPart.text += chunk.delta;\n\t\t\t\t\ttextPart.providerMetadata = (_a23 = chunk.providerMetadata) != null ? _a23 : textPart.providerMetadata;\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"text-end\": {\n\t\t\t\t\tconst textPart = state.activeTextParts[chunk.id];\n\t\t\t\t\tif (textPart == null) throw new UIMessageStreamError({\n\t\t\t\t\t\tchunkType: \"text-end\",\n\t\t\t\t\t\tchunkId: chunk.id,\n\t\t\t\t\t\tmessage: `Received text-end for missing text part with ID \"${chunk.id}\". Ensure a \"text-start\" chunk is sent before any \"text-end\" chunks.`\n\t\t\t\t\t});\n\t\t\t\t\ttextPart.state = \"done\";\n\t\t\t\t\ttextPart.providerMetadata = (_b = chunk.providerMetadata) != null ? _b : textPart.providerMetadata;\n\t\t\t\t\tdelete state.activeTextParts[chunk.id];\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"reasoning-start\": {\n\t\t\t\t\tconst reasoningPart = {\n\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\tid: chunk.id,\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\tstate: \"streaming\"\n\t\t\t\t\t};\n\t\t\t\t\tstate.activeReasoningParts[chunk.id] = reasoningPart;\n\t\t\t\t\tstate.message.parts.push(reasoningPart);\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"reasoning-delta\": {\n\t\t\t\t\tconst reasoningPart = state.activeReasoningParts[chunk.id];\n\t\t\t\t\tif (reasoningPart == null) throw new UIMessageStreamError({\n\t\t\t\t\t\tchunkType: \"reasoning-delta\",\n\t\t\t\t\t\tchunkId: chunk.id,\n\t\t\t\t\t\tmessage: `Received reasoning-delta for missing reasoning part with ID \"${chunk.id}\". Ensure a \"reasoning-start\" chunk is sent before any \"reasoning-delta\" chunks.`\n\t\t\t\t\t});\n\t\t\t\t\treasoningPart.text += chunk.delta;\n\t\t\t\t\treasoningPart.providerMetadata = (_c = chunk.providerMetadata) != null ? _c : reasoningPart.providerMetadata;\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"reasoning-end\": {\n\t\t\t\t\tconst reasoningPart = state.activeReasoningParts[chunk.id];\n\t\t\t\t\tif (reasoningPart == null) throw new UIMessageStreamError({\n\t\t\t\t\t\tchunkType: \"reasoning-end\",\n\t\t\t\t\t\tchunkId: chunk.id,\n\t\t\t\t\t\tmessage: `Received reasoning-end for missing reasoning part with ID \"${chunk.id}\". Ensure a \"reasoning-start\" chunk is sent before any \"reasoning-end\" chunks.`\n\t\t\t\t\t});\n\t\t\t\t\treasoningPart.providerMetadata = (_d = chunk.providerMetadata) != null ? _d : reasoningPart.providerMetadata;\n\t\t\t\t\treasoningPart.state = \"done\";\n\t\t\t\t\tdelete state.activeReasoningParts[chunk.id];\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"file\":\n\t\t\t\t\tstate.message.parts.push({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: chunk.mediaType,\n\t\t\t\t\t\turl: chunk.url,\n\t\t\t\t\t\t...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"source-url\":\n\t\t\t\t\tstate.message.parts.push({\n\t\t\t\t\t\ttype: \"source-url\",\n\t\t\t\t\t\tsourceId: chunk.sourceId,\n\t\t\t\t\t\turl: chunk.url,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"source-document\":\n\t\t\t\t\tstate.message.parts.push({\n\t\t\t\t\t\ttype: \"source-document\",\n\t\t\t\t\t\tsourceId: chunk.sourceId,\n\t\t\t\t\t\tmediaType: chunk.mediaType,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\tfilename: chunk.filename,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-start\": {\n\t\t\t\t\tconst toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);\n\t\t\t\t\tstate.partialToolCalls[chunk.toolCallId] = {\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tinputEncoding: chunk.inputEncoding,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tindex: toolInvocations.length,\n\t\t\t\t\t\tdynamic: chunk.dynamic,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata\n\t\t\t\t\t};\n\t\t\t\t\tif (chunk.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinputEncoding: chunk.inputEncoding,\n\t\t\t\t\t\tinput: void 0,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinputEncoding: chunk.inputEncoding,\n\t\t\t\t\t\tinput: void 0,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-delta\": {\n\t\t\t\t\tconst partialToolCall = state.partialToolCalls[chunk.toolCallId];\n\t\t\t\t\tif (partialToolCall == null) throw new UIMessageStreamError({\n\t\t\t\t\t\tchunkType: \"tool-input-delta\",\n\t\t\t\t\t\tchunkId: chunk.toolCallId,\n\t\t\t\t\t\tmessage: `Received tool-input-delta for missing tool call with ID \"${chunk.toolCallId}\". Ensure a \"tool-input-start\" chunk is sent before any \"tool-input-delta\" chunks.`\n\t\t\t\t\t});\n\t\t\t\t\tpartialToolCall.text += chunk.inputTextDelta;\n\t\t\t\t\tconst partialArgs = partialToolCall.inputEncoding === \"text\" ? partialToolCall.text : (await parsePartialJson(partialToolCall.text)).value;\n\t\t\t\t\tif (partialToolCall.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: partialToolCall.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinputEncoding: partialToolCall.inputEncoding,\n\t\t\t\t\t\tinput: partialArgs,\n\t\t\t\t\t\trawInput: partialToolCall.text,\n\t\t\t\t\t\ttitle: partialToolCall.title,\n\t\t\t\t\t\ttoolMetadata: partialToolCall.toolMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: partialToolCall.toolName,\n\t\t\t\t\t\tstate: \"input-streaming\",\n\t\t\t\t\t\tinputEncoding: partialToolCall.inputEncoding,\n\t\t\t\t\t\tinput: partialArgs,\n\t\t\t\t\t\trawInput: partialToolCall.text,\n\t\t\t\t\t\ttitle: partialToolCall.title,\n\t\t\t\t\t\ttoolMetadata: partialToolCall.toolMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-available\":\n\t\t\t\t\tif (chunk.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-available\",\n\t\t\t\t\t\tinput: chunk.input,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"input-available\",\n\t\t\t\t\t\tinput: chunk.input,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttitle: chunk.title,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tif (onToolCall && !chunk.providerExecuted) await onToolCall({ toolCall: chunk });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-error\": {\n\t\t\t\t\tconst existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);\n\t\t\t\t\tif (existingPart != null ? existingPart.type === \"dynamic-tool\" : !!chunk.dynamic) updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\tinput: chunk.input,\n\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: chunk.toolName,\n\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\tinput: void 0,\n\t\t\t\t\t\trawInput: chunk.input,\n\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttoolMetadata: chunk.toolMetadata\n\t\t\t\t\t});\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-approval-request\": {\n\t\t\t\t\tconst toolInvocation = getToolInvocation(chunk.toolCallId);\n\t\t\t\t\ttoolInvocation.state = \"approval-requested\";\n\t\t\t\t\ttoolInvocation.approval = {\n\t\t\t\t\t\tid: chunk.approvalId,\n\t\t\t\t\t\t...chunk.approvalDescriptor != null ? { descriptor: chunk.approvalDescriptor } : {},\n\t\t\t\t\t\t...Object.prototype.hasOwnProperty.call(chunk, \"inputSchemaInput\") ? { inputSchemaInput: chunk.inputSchemaInput } : {},\n\t\t\t\t\t\t...chunk.signature != null ? { signature: chunk.signature } : {}\n\t\t\t\t\t};\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-output-denied\": {\n\t\t\t\t\tconst toolInvocation = getToolInvocation(chunk.toolCallId);\n\t\t\t\t\ttoolInvocation.state = \"output-denied\";\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-output-available\": {\n\t\t\t\t\tconst toolInvocation = getToolInvocation(chunk.toolCallId);\n\t\t\t\t\tif (toolInvocation.type === \"dynamic-tool\") updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: toolInvocation.toolName,\n\t\t\t\t\t\tstate: \"output-available\",\n\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\toutput: chunk.output,\n\t\t\t\t\t\tpreliminary: chunk.preliminary,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttitle: toolInvocation.title,\n\t\t\t\t\t\ttoolMetadata: (_e = chunk.toolMetadata) != null ? _e : toolInvocation.toolMetadata\n\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: getStaticToolName(toolInvocation),\n\t\t\t\t\t\tstate: \"output-available\",\n\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\toutput: chunk.output,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tpreliminary: chunk.preliminary,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttitle: toolInvocation.title,\n\t\t\t\t\t\ttoolMetadata: (_f = chunk.toolMetadata) != null ? _f : toolInvocation.toolMetadata\n\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-output-error\": {\n\t\t\t\t\tconst toolInvocation = getToolInvocation(chunk.toolCallId);\n\t\t\t\t\tif (toolInvocation.type === \"dynamic-tool\") updateDynamicToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: toolInvocation.toolName,\n\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttitle: toolInvocation.title,\n\t\t\t\t\t\ttoolMetadata: (_g = chunk.toolMetadata) != null ? _g : toolInvocation.toolMetadata\n\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\telse updateToolPart({\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName: getStaticToolName(toolInvocation),\n\t\t\t\t\t\tstate: \"output-error\",\n\t\t\t\t\t\tinput: toolInvocation.input,\n\t\t\t\t\t\trawInput: toolInvocation.rawInput,\n\t\t\t\t\t\terrorText: chunk.errorText,\n\t\t\t\t\t\tproviderExecuted: chunk.providerExecuted,\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata,\n\t\t\t\t\t\ttitle: toolInvocation.title,\n\t\t\t\t\t\ttoolMetadata: (_h = chunk.toolMetadata) != null ? _h : toolInvocation.toolMetadata\n\t\t\t\t\t}, toolInvocation);\n\t\t\t\t\twrite();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"start-step\":\n\t\t\t\t\tstate.message.parts.push({ type: \"step-start\" });\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish-step\":\n\t\t\t\t\tstate.activeTextParts = createIdMap();\n\t\t\t\t\tstate.activeReasoningParts = createIdMap();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"start\": {\n\t\t\t\t\tconst shouldReset = resetStateOnFirstMessageStart && isFirstMessageStart || resetStateOnMessageIdChange && chunk.messageId != null && chunk.messageId !== state.message.id;\n\t\t\t\t\tisFirstMessageStart = false;\n\t\t\t\t\tif (shouldReset) Object.assign(state, createStreamingUIMessageState({\n\t\t\t\t\t\tlastMessage: void 0,\n\t\t\t\t\t\tmessageId: (_i = chunk.messageId) != null ? _i : state.message.id\n\t\t\t\t\t}), { finishReason: void 0 });\n\t\t\t\t\tif (chunk.messageId != null) state.message.id = chunk.messageId;\n\t\t\t\t\tawait updateMessageMetadata(chunk.messageMetadata);\n\t\t\t\t\tif (shouldReset || chunk.messageId != null || chunk.messageMetadata != null) write({ updateStatus: false });\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tif (chunk.finishReason != null) state.finishReason = chunk.finishReason;\n\t\t\t\t\tawait updateMessageMetadata(chunk.messageMetadata);\n\t\t\t\t\tif (chunk.messageMetadata != null) write();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"message-metadata\":\n\t\t\t\t\tawait updateMessageMetadata(chunk.messageMetadata);\n\t\t\t\t\tif (chunk.messageMetadata != null) write();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"error\":\n\t\t\t\t\tonError?.(new Error(chunk.errorText));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: if (isDataUIMessageChunk(chunk)) {\n\t\t\t\t\tif ((dataPartSchemas == null ? void 0 : dataPartSchemas[chunk.type]) != null) {\n\t\t\t\t\t\tconst partIdx = state.message.parts.findIndex((p) => \"id\" in p && \"data\" in p && p.id === chunk.id && p.type === chunk.type);\n\t\t\t\t\t\tconst actualPartIdx = partIdx >= 0 ? partIdx : state.message.parts.length;\n\t\t\t\t\t\tawait validateTypes({\n\t\t\t\t\t\t\tvalue: chunk.data,\n\t\t\t\t\t\t\tschema: dataPartSchemas[chunk.type],\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\tfield: `message.parts[${actualPartIdx}].data`,\n\t\t\t\t\t\t\t\tentityName: chunk.type,\n\t\t\t\t\t\t\t\tentityId: chunk.id\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst dataChunk = chunk;\n\t\t\t\t\tif (dataChunk.transient) {\n\t\t\t\t\t\tonData?.(dataChunk);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst existingUIPart = dataChunk.id != null ? state.message.parts.find((chunkArg) => dataChunk.type === chunkArg.type && dataChunk.id === chunkArg.id) : void 0;\n\t\t\t\t\tif (existingUIPart != null) existingUIPart.data = dataChunk.data;\n\t\t\t\t\telse state.message.parts.push(dataChunk);\n\t\t\t\t\tonData?.(dataChunk);\n\t\t\t\t\twrite();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontroller.enqueue(chunk);\n\t\t});\n\t} }));\n}\nfunction handleUIMessageStreamFinish({ messageId, originalMessages = [], onStepFinish, onFinish, onError, stream, getOutcome }) {\n\tlet lastMessage = originalMessages == null ? void 0 : originalMessages[originalMessages.length - 1];\n\tif ((lastMessage == null ? void 0 : lastMessage.role) !== \"assistant\") lastMessage = void 0;\n\telse messageId = lastMessage.id;\n\tlet isAborted = false;\n\tlet hasProcessingFailure = false;\n\tlet processingError;\n\tconst recordProcessingFailure = (error) => {\n\t\thasProcessingFailure = true;\n\t\tprocessingError = error;\n\t};\n\tconst idInjectedStream = stream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\ttry {\n\t\t\tlet outputChunk = chunk;\n\t\t\tif (chunk.type === \"start\") {\n\t\t\t\tconst startChunk = chunk;\n\t\t\t\tif (startChunk.messageId == null && messageId != null) outputChunk = {\n\t\t\t\t\t...startChunk,\n\t\t\t\t\tmessageId\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (chunk.type === \"abort\") isAborted = true;\n\t\t\tcontroller.enqueue(outputChunk);\n\t\t} catch (error) {\n\t\t\trecordProcessingFailure(error);\n\t\t\tthrow error;\n\t\t}\n\t} }));\n\tif (onFinish == null && onStepFinish == null) return idInjectedStream;\n\tconst state = createStreamingUIMessageState({\n\t\tlastMessage: lastMessage ? structuredClone(lastMessage) : void 0,\n\t\tmessageId: messageId != null ? messageId : \"\"\n\t});\n\tconst runUpdateMessageJob = async (job) => {\n\t\ttry {\n\t\t\tawait job({\n\t\t\t\tstate,\n\t\t\t\twrite: () => {}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\trecordProcessingFailure(error);\n\t\t\tthrow error;\n\t\t}\n\t};\n\tlet finishCalled = false;\n\tconst callOnFinish = async () => {\n\t\tvar _a23;\n\t\tif (finishCalled || !onFinish) return;\n\t\tfinishCalled = true;\n\t\tconst isContinuation = state.message.id === (lastMessage == null ? void 0 : lastMessage.id);\n\t\tconst declaredOutcome = (_a23 = getOutcome == null ? void 0 : getOutcome()) != null ? _a23 : { status: \"unknown\" };\n\t\tconst outcome = hasProcessingFailure ? {\n\t\t\tstatus: \"failed\",\n\t\t\terror: processingError\n\t\t} : declaredOutcome.status === \"unknown\" && isAborted ? { status: \"aborted\" } : declaredOutcome;\n\t\tawait onFinish({\n\t\t\tisAborted: isAborted || outcome.status === \"aborted\",\n\t\t\tisContinuation,\n\t\t\toutcome,\n\t\t\tresponseMessage: state.message,\n\t\t\tmessages: [...isContinuation ? originalMessages.slice(0, -1) : originalMessages, state.message],\n\t\t\tfinishReason: state.finishReason\n\t\t});\n\t};\n\tconst callOnStepFinish = async () => {\n\t\tif (!onStepFinish) return;\n\t\tconst isContinuation = state.message.id === (lastMessage == null ? void 0 : lastMessage.id);\n\t\ttry {\n\t\t\tawait onStepFinish({\n\t\t\t\tisContinuation,\n\t\t\t\tresponseMessage: structuredClone(state.message),\n\t\t\t\tmessages: [...isContinuation ? originalMessages.slice(0, -1) : originalMessages, structuredClone(state.message)]\n\t\t\t});\n\t\t} catch (error) {\n\t\t\ttry {\n\t\t\t\tonError(error);\n\t\t\t} catch (onErrorError) {\n\t\t\t\trecordProcessingFailure(onErrorError);\n\t\t\t\tawait callOnFinish();\n\t\t\t\tthrow onErrorError;\n\t\t\t}\n\t\t}\n\t};\n\treturn processUIMessageStream({\n\t\tstream: idInjectedStream,\n\t\trunUpdateMessageJob,\n\t\tonError\n\t}).pipeThrough(new TransformStream({\n\t\tasync transform(chunk, controller) {\n\t\t\tif (chunk.type === \"finish-step\") await callOnStepFinish();\n\t\t\tcontroller.enqueue(chunk);\n\t\t},\n\t\tasync cancel() {\n\t\t\tawait callOnFinish();\n\t\t},\n\t\tasync flush() {\n\t\t\tawait callOnFinish();\n\t\t}\n\t}));\n}\nfunction pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, keepAliveMs, consumeSseStream }) {\n\tlet sseStream = createSseStreamWithKeepAlive({\n\t\tstream: stream.pipeThrough(new JsonToSseTransformStream()),\n\t\tkeepAliveMs\n\t});\n\tif (consumeSseStream) {\n\t\tconst [stream1, stream2] = sseStream.tee();\n\t\tsseStream = stream1;\n\t\tconsumeSseStream({ stream: stream2 });\n\t}\n\treturn writeToServerResponse({\n\t\tresponse,\n\t\tstatus,\n\t\tstatusText,\n\t\theaders: Object.fromEntries(prepareHeaders(headers, UI_MESSAGE_STREAM_HEADERS).entries()),\n\t\tstream: sseStream.pipeThrough(new TextEncoderStream())\n\t});\n}\nfunction createAsyncIterableStream(source) {\n\tconst stream = source.pipeThrough(new TransformStream());\n\tstream[Symbol.asyncIterator] = function() {\n\t\tconst reader = this.getReader();\n\t\tlet finished = false;\n\t\tasync function cleanup(cancelStream) {\n\t\t\tvar _a23;\n\t\t\tif (finished) return;\n\t\t\tfinished = true;\n\t\t\ttry {\n\t\t\t\tif (cancelStream) await ((_a23 = reader.cancel) == null ? void 0 : _a23.call(reader));\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\treader.releaseLock();\n\t\t\t\t} catch (e) {}\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t/**\n\t\t\t* Reads the next chunk from the stream.\n\t\t\t* @returns A promise resolving to the next IteratorResult.\n\t\t\t*/\n\t\t\tasync next() {\n\t\t\t\tif (finished) return {\n\t\t\t\t\tdone: true,\n\t\t\t\t\tvalue: void 0\n\t\t\t\t};\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tawait cleanup(true);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdone: true,\n\t\t\t\t\t\tvalue: void 0\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tdone: false,\n\t\t\t\t\tvalue\n\t\t\t\t};\n\t\t\t},\n\t\t\t/**\n\t\t\t* May be called on early exit (e.g., break from for-await) or after completion.\n\t\t\t* Ensures the stream is cancelled and resources are released.\n\t\t\t* @returns A promise resolving to a completed IteratorResult.\n\t\t\t*/\n\t\t\tasync return() {\n\t\t\t\tawait cleanup(true);\n\t\t\t\treturn {\n\t\t\t\t\tdone: true,\n\t\t\t\t\tvalue: void 0\n\t\t\t\t};\n\t\t\t},\n\t\t\t/**\n\t\t\t* Called on early exit with error.\n\t\t\t* Ensures the stream is cancelled and resources are released, then rethrows the error.\n\t\t\t* @param err The error to throw.\n\t\t\t* @returns A promise that rejects with the provided error.\n\t\t\t*/\n\t\t\tasync throw(err) {\n\t\t\t\tawait cleanup(true);\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t};\n\t};\n\treturn stream;\n}\nasync function consumeStream({ stream, onError, abortSignal }) {\n\tconst reader = stream.getReader();\n\tconst cancelOnAbort = () => {\n\t\treader.cancel().catch(() => {});\n\t};\n\tif (abortSignal == null ? void 0 : abortSignal.aborted) cancelOnAbort();\n\telse abortSignal?.addEventListener(\"abort\", cancelOnAbort, { once: true });\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done } = await reader.read();\n\t\t\tif (done) break;\n\t\t}\n\t} catch (error) {\n\t\tonError?.(error);\n\t} finally {\n\t\tabortSignal?.removeEventListener(\"abort\", cancelOnAbort);\n\t\treader.releaseLock();\n\t}\n}\nfunction createResolvablePromise() {\n\tlet resolve3;\n\tlet reject;\n\treturn {\n\t\tpromise: new Promise((res, rej) => {\n\t\t\tresolve3 = res;\n\t\t\treject = rej;\n\t\t}),\n\t\tresolve: resolve3,\n\t\treject\n\t};\n}\nfunction createStitchableStream() {\n\tlet innerStreams = [];\n\tlet controller = null;\n\tlet isClosed = false;\n\tlet isCancelled = false;\n\tlet waitForNewStream = createResolvablePromise();\n\tconst terminate = () => {\n\t\tif (isCancelled) return;\n\t\tisClosed = true;\n\t\twaitForNewStream.resolve();\n\t\tinnerStreams.forEach(({ reader, onCancel }) => {\n\t\t\tonCancel?.();\n\t\t\treader.cancel();\n\t\t});\n\t\tinnerStreams = [];\n\t\tcontroller?.close();\n\t};\n\tconst processPull = async () => {\n\t\tvar _a23;\n\t\tif (isCancelled) return;\n\t\tif (isClosed && innerStreams.length === 0) {\n\t\t\tcontroller?.close();\n\t\t\treturn;\n\t\t}\n\t\tif (innerStreams.length === 0) {\n\t\t\twaitForNewStream = createResolvablePromise();\n\t\t\tawait waitForNewStream.promise;\n\t\t\treturn processPull();\n\t\t}\n\t\tconst currentStream = innerStreams[0];\n\t\ttry {\n\t\t\tconst { value, done } = await currentStream.reader.read();\n\t\t\tif (isCancelled) return;\n\t\t\tif (done) {\n\t\t\t\tinnerStreams.shift();\n\t\t\t\tif (innerStreams.length === 0 && isClosed) controller?.close();\n\t\t\t\telse await processPull();\n\t\t\t} else controller?.enqueue(value);\n\t\t} catch (error) {\n\t\t\tif (isCancelled) return;\n\t\t\t(_a23 = currentStream.onError) == null || _a23.call(currentStream, error);\n\t\t\tcontroller?.error(error);\n\t\t\tinnerStreams.shift();\n\t\t\tterminate();\n\t\t}\n\t};\n\treturn {\n\t\tstream: new ReadableStream({\n\t\t\tstart(controllerParam) {\n\t\t\t\tcontroller = controllerParam;\n\t\t\t},\n\t\t\tpull: processPull,\n\t\t\tasync cancel() {\n\t\t\t\tisCancelled = true;\n\t\t\t\tisClosed = true;\n\t\t\t\twaitForNewStream.resolve();\n\t\t\t\tfor (const { reader, onCancel } of innerStreams) {\n\t\t\t\t\tonCancel?.();\n\t\t\t\t\tawait reader.cancel();\n\t\t\t\t}\n\t\t\t\tinnerStreams = [];\n\t\t\t}\n\t\t}),\n\t\taddStream: (innerStream, callbacks) => {\n\t\t\tvar _a23;\n\t\t\tif (isCancelled) {\n\t\t\t\t(_a23 = callbacks == null ? void 0 : callbacks.onCancel) == null || _a23.call(callbacks);\n\t\t\t\tinnerStream.cancel().catch(() => {});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isClosed) throw new Error(\"Cannot add inner stream: outer stream is closed\");\n\t\t\tinnerStreams.push({\n\t\t\t\treader: innerStream.getReader(),\n\t\t\t\t...callbacks\n\t\t\t});\n\t\t\twaitForNewStream.resolve();\n\t\t},\n\t\t/**\n\t\t* Gracefully close the outer stream. This will let the inner streams\n\t\t* finish processing and then close the outer stream.\n\t\t*/\n\t\tclose: () => {\n\t\t\tif (isCancelled) return;\n\t\t\tisClosed = true;\n\t\t\twaitForNewStream.resolve();\n\t\t\tif (innerStreams.length === 0) controller?.close();\n\t\t},\n\t\t/**\n\t\t* Immediately close the outer stream. This will cancel all inner streams\n\t\t* and close the outer stream.\n\t\t*/\n\t\tterminate\n\t};\n}\nfunction runToolsTransformation({ tools, generatorStream, tracer, telemetry, system, messages, abortSignal, repairToolCall, experimental_context, toolApprovalSecret, generateId: generateId2, stepNumber, model, onToolCallStart, onToolCallFinish }) {\n\tlet toolResultsStreamController = null;\n\tlet toolResultsStreamClosed = false;\n\tconst toolResultsStream = new ReadableStream({\n\t\tstart(controller) {\n\t\t\ttoolResultsStreamController = controller;\n\t\t},\n\t\tcancel() {\n\t\t\ttoolResultsStreamClosed = true;\n\t\t}\n\t});\n\tfunction enqueueToolResult(chunk) {\n\t\tif (toolResultsStreamClosed) return;\n\t\ttry {\n\t\t\ttoolResultsStreamController.enqueue(chunk);\n\t\t} catch (e) {\n\t\t\ttoolResultsStreamClosed = true;\n\t\t}\n\t}\n\tfunction closeToolResultsStream() {\n\t\tif (toolResultsStreamClosed) return;\n\t\ttoolResultsStreamClosed = true;\n\t\ttry {\n\t\t\ttoolResultsStreamController.close();\n\t\t} catch (e) {}\n\t}\n\tconst outstandingToolResults = /* @__PURE__ */ new Set();\n\tconst toolCallsToExecute = [];\n\tconst toolCallsByToolCallId = /* @__PURE__ */ new Map();\n\tlet canClose = false;\n\tlet finishChunk = void 0;\n\tfunction attemptClose() {\n\t\tif (canClose && outstandingToolResults.size === 0) {\n\t\t\tif (finishChunk != null) enqueueToolResult(finishChunk);\n\t\t\tcloseToolResultsStream();\n\t\t}\n\t}\n\tfunction executeToolCallAfterFinish(toolCall) {\n\t\tconst toolExecutionId = generateId2();\n\t\toutstandingToolResults.add(toolExecutionId);\n\t\texecuteToolCall({\n\t\t\ttoolCall,\n\t\t\ttools,\n\t\t\ttracer,\n\t\t\ttelemetry,\n\t\t\tmessages,\n\t\t\tabortSignal,\n\t\t\texperimental_context,\n\t\t\tstepNumber,\n\t\t\tmodel,\n\t\t\tonToolCallStart,\n\t\t\tonToolCallFinish,\n\t\t\tonPreliminaryToolResult: (result) => {\n\t\t\t\tenqueueToolResult(result);\n\t\t\t}\n\t\t}).then((result) => {\n\t\t\tenqueueToolResult(result);\n\t\t}).catch((error) => {\n\t\t\tenqueueToolResult({\n\t\t\t\ttype: \"error\",\n\t\t\t\terror\n\t\t\t});\n\t\t}).finally(() => {\n\t\t\toutstandingToolResults.delete(toolExecutionId);\n\t\t\tattemptClose();\n\t\t});\n\t}\n\tconst activeToolCallToolNames = /* @__PURE__ */ new Map();\n\tconst forwardStream = new TransformStream({\n\t\tasync transform(chunk, controller) {\n\t\t\tvar _a23, _b, _c, _d;\n\t\t\tconst chunkType = chunk.type;\n\t\t\tswitch (chunkType) {\n\t\t\t\tcase \"stream-start\":\n\t\t\t\tcase \"text-start\":\n\t\t\t\tcase \"text-delta\":\n\t\t\t\tcase \"text-end\":\n\t\t\t\tcase \"reasoning-start\":\n\t\t\t\tcase \"reasoning-delta\":\n\t\t\t\tcase \"reasoning-end\":\n\t\t\t\tcase \"source\":\n\t\t\t\tcase \"response-metadata\":\n\t\t\t\tcase \"error\":\n\t\t\t\tcase \"raw\":\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-start\":\n\t\t\t\t\tactiveToolCallToolNames.set(chunk.id, chunk.toolName);\n\t\t\t\t\tawait ((_b = (_a23 = tools == null ? void 0 : tools[chunk.toolName]) == null ? void 0 : _a23.onInputStart) == null ? void 0 : _b.call(_a23, {\n\t\t\t\t\t\ttoolCallId: chunk.id,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t}));\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-input-delta\": {\n\t\t\t\t\tconst toolName = activeToolCallToolNames.get(chunk.id);\n\t\t\t\t\tif (toolName != null) await ((_d = (_c = tools == null ? void 0 : tools[toolName]) == null ? void 0 : _c.onInputDelta) == null ? void 0 : _d.call(_c, {\n\t\t\t\t\t\tinputTextDelta: chunk.delta,\n\t\t\t\t\t\ttoolCallId: chunk.id,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t}));\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-input-end\":\n\t\t\t\t\tactiveToolCallToolNames.delete(chunk.id);\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"file\":\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tfile: new DefaultGeneratedFileWithType({\n\t\t\t\t\t\t\tdata: chunk.data,\n\t\t\t\t\t\t\tmediaType: chunk.mediaType\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"finish\":\n\t\t\t\t\tfinishChunk = {\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: chunk.finishReason.unified,\n\t\t\t\t\t\trawFinishReason: chunk.finishReason.raw,\n\t\t\t\t\t\tusage: asLanguageModelUsage(chunk.usage),\n\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\tif (isToolExecutionAllowedFinishReason(chunk.finishReason.unified)) for (const toolCall of toolCallsToExecute.splice(0)) executeToolCallAfterFinish(toolCall);\n\t\t\t\t\telse toolCallsToExecute.length = 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-approval-request\": {\n\t\t\t\t\tconst toolCall = toolCallsByToolCallId.get(chunk.toolCallId);\n\t\t\t\t\tif (toolCall == null) {\n\t\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror: new ToolCallNotFoundForApprovalError({\n\t\t\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\t\t\tapprovalId: chunk.approvalId\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\t\t\tapprovalId: chunk.approvalId,\n\t\t\t\t\t\ttoolCall\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"tool-call\":\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst toolCall = await parseToolCall({\n\t\t\t\t\t\t\ttoolCall: chunk,\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tmessages\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttoolCallsByToolCallId.set(toolCall.toolCallId, toolCall);\n\t\t\t\t\t\tcontroller.enqueue({ ...toolCall });\n\t\t\t\t\t\tif (toolCall.invalid) {\n\t\t\t\t\t\t\tif (!toolCall.providerExecuted) enqueueToolResult({\n\t\t\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\t\terror: getErrorMessage$1(toolCall.error),\n\t\t\t\t\t\t\t\tdynamic: true,\n\t\t\t\t\t\t\t\ttitle: toolCall.title,\n\t\t\t\t\t\t\t\t...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst tool2 = tools == null ? void 0 : tools[toolCall.toolName];\n\t\t\t\t\t\tif (tool2 == null) break;\n\t\t\t\t\t\tif (tool2.onInputAvailable != null) await tool2.onInputAvailable({\n\t\t\t\t\t\t\tinput: toolCall.input,\n\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (await isApprovalNeeded({\n\t\t\t\t\t\t\ttool: tool2,\n\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\tmessages,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t})) {\n\t\t\t\t\t\t\tconst approvalId = generateId2();\n\t\t\t\t\t\t\tconst signature = await maybeSignApproval({\n\t\t\t\t\t\t\t\tsecret: toolApprovalSecret,\n\t\t\t\t\t\t\t\tapprovalId,\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\t\t\t\t\tinput: toolCall.input\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\t\t\t\t\tapprovalId,\n\t\t\t\t\t\t\t\ttoolCall,\n\t\t\t\t\t\t\t\t...signature != null ? { signature } : {}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (tool2.execute != null && toolCall.providerExecuted !== true) toolCallsToExecute.push(toolCall);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tenqueueToolResult({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tool-result\": {\n\t\t\t\t\tconst toolName = chunk.toolName;\n\t\t\t\t\tconst toolCall = toolCallsByToolCallId.get(chunk.toolCallId);\n\t\t\t\t\tif (chunk.isError) enqueueToolResult({\n\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\tinput: toolCall == null ? void 0 : toolCall.input,\n\t\t\t\t\t\tproviderExecuted: true,\n\t\t\t\t\t\terror: chunk.result,\n\t\t\t\t\t\tdynamic: chunk.dynamic,\n\t\t\t\t\t\t...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},\n\t\t\t\t\t\t...(toolCall == null ? void 0 : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\telse controller.enqueue({\n\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\ttoolCallId: chunk.toolCallId,\n\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\tinput: toolCall == null ? void 0 : toolCall.input,\n\t\t\t\t\t\toutput: chunk.result,\n\t\t\t\t\t\tproviderExecuted: true,\n\t\t\t\t\t\tdynamic: chunk.dynamic,\n\t\t\t\t\t\t...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},\n\t\t\t\t\t\t...(toolCall == null ? void 0 : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: throw new Error(`Unhandled chunk type: ${chunkType}`);\n\t\t\t}\n\t\t},\n\t\tflush() {\n\t\t\tcanClose = true;\n\t\t\tattemptClose();\n\t\t}\n\t});\n\treturn new ReadableStream({ async start(controller) {\n\t\treturn Promise.all([generatorStream.pipeThrough(forwardStream).pipeTo(new WritableStream({\n\t\t\twrite(chunk) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tclose() {}\n\t\t})), toolResultsStream.pipeTo(new WritableStream({\n\t\t\twrite(chunk) {\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tclose() {\n\t\t\t\tcontroller.close();\n\t\t\t}\n\t\t}))]);\n\t} });\n}\nvar originalGenerateId2 = createIdGenerator({\n\tprefix: \"aitxt\",\n\tsize: 24\n});\nvar isOutputChunkType = {\n\tfile: true,\n\tsource: true,\n\t\"text-start\": true,\n\t\"text-end\": true,\n\t\"text-delta\": true,\n\t\"reasoning-start\": true,\n\t\"reasoning-end\": true,\n\t\"reasoning-delta\": true,\n\t\"tool-input-start\": true,\n\t\"tool-input-end\": true,\n\t\"tool-input-delta\": true,\n\t\"tool-approval-request\": true,\n\t\"tool-call\": true,\n\t\"tool-result\": true,\n\t\"tool-error\": true,\n\t\"stream-start\": false,\n\t\"response-metadata\": false,\n\tfinish: false,\n\terror: false,\n\traw: false\n};\nfunction streamText({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen = stepCountIs(1), experimental_output, output = experimental_output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools = experimental_activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download2, includeRawChunks = false, onChunk, onError = ({ error }) => {\n\tconsole.error(error);\n}, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_toolApprovalSecret, experimental_include: include, _internal: { now: now2 = now, generateId: generateId2 = originalGenerateId2 } = {}, ...settings }) {\n\tconst totalTimeoutMs = getTotalTimeoutMs(timeout);\n\tconst stepTimeoutMs = getStepTimeoutMs(timeout);\n\tconst chunkTimeoutMs = getChunkTimeoutMs(timeout);\n\tconst stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;\n\tconst chunkAbortController = chunkTimeoutMs != null ? new AbortController() : void 0;\n\treturn new DefaultStreamTextResult({\n\t\tmodel: resolveLanguageModel(model),\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings,\n\t\tmaxRetries,\n\t\tabortSignal: mergeAbortSignals(abortSignal, totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0, stepAbortController == null ? void 0 : stepAbortController.signal, chunkAbortController == null ? void 0 : chunkAbortController.signal),\n\t\tstepTimeoutMs,\n\t\tstepAbortController,\n\t\tchunkTimeoutMs,\n\t\tchunkAbortController,\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tallowSystemInMessages,\n\t\ttools,\n\t\ttoolChoice,\n\t\ttransforms: asArray(transform),\n\t\tactiveTools,\n\t\trepairToolCall,\n\t\tstopConditions: asArray(stopWhen),\n\t\toutput,\n\t\tproviderOptions,\n\t\tprepareStep,\n\t\tincludeRawChunks,\n\t\ttimeout,\n\t\tstopWhen,\n\t\toriginalAbortSignal: abortSignal,\n\t\tonChunk,\n\t\tonError,\n\t\tonFinish,\n\t\tonAbort,\n\t\tonStepFinish,\n\t\tonStart,\n\t\tonStepStart,\n\t\tonToolCallStart,\n\t\tonToolCallFinish,\n\t\tnow: now2,\n\t\tgenerateId: generateId2,\n\t\texperimental_context,\n\t\texperimental_toolApprovalSecret,\n\t\tdownload: download2,\n\t\tinclude\n\t});\n}\nfunction createOutputTransformStream(output) {\n\tlet firstTextChunkId = void 0;\n\tlet text2 = \"\";\n\tlet textChunk = \"\";\n\tlet textProviderMetadata = void 0;\n\tlet lastPublishedValue = void 0;\n\tlet hasPublishedValue = false;\n\tfunction resetOutputState() {\n\t\tfirstTextChunkId = void 0;\n\t\ttext2 = \"\";\n\t\ttextChunk = \"\";\n\t\ttextProviderMetadata = void 0;\n\t\tlastPublishedValue = \"\";\n\t}\n\tfunction publishTextChunk({ controller, partialOutput = void 0 }) {\n\t\tcontroller.enqueue({\n\t\t\tpart: {\n\t\t\t\ttype: \"text-delta\",\n\t\t\t\tid: firstTextChunkId,\n\t\t\t\ttext: textChunk,\n\t\t\t\tproviderMetadata: textProviderMetadata\n\t\t\t},\n\t\t\tpartialOutput\n\t\t});\n\t\ttextChunk = \"\";\n\t}\n\treturn new TransformStream({ async transform(chunk, controller) {\n\t\tvar _a23;\n\t\tif (chunk.type === \"start-step\") resetOutputState();\n\t\tif (chunk.type === \"finish-step\" && textChunk.length > 0) publishTextChunk({ controller });\n\t\tif (chunk.type !== \"text-delta\" && chunk.type !== \"text-start\" && chunk.type !== \"text-end\") {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (firstTextChunkId == null) firstTextChunkId = chunk.id;\n\t\telse if (chunk.id !== firstTextChunkId) {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (chunk.type === \"text-start\") {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (chunk.type === \"text-end\") {\n\t\t\tif (textChunk.length > 0) publishTextChunk({ controller });\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\ttext2 += chunk.text;\n\t\ttextChunk += chunk.text;\n\t\ttextProviderMetadata = (_a23 = chunk.providerMetadata) != null ? _a23 : textProviderMetadata;\n\t\tif (chunk.text.length === 0 && chunk.providerMetadata != null) {\n\t\t\tcontroller.enqueue({\n\t\t\t\tpart: chunk,\n\t\t\t\tpartialOutput: void 0\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst result = await output.parsePartialOutput({ text: text2 });\n\t\tif (result !== void 0) {\n\t\t\tconst currentValue = typeof result.partial === \"string\" ? result.partial : JSON.stringify(result.partial);\n\t\t\tif (!hasPublishedValue || currentValue !== lastPublishedValue) {\n\t\t\t\tpublishTextChunk({\n\t\t\t\t\tcontroller,\n\t\t\t\t\tpartialOutput: result.partial\n\t\t\t\t});\n\t\t\t\tlastPublishedValue = currentValue;\n\t\t\t\thasPublishedValue = true;\n\t\t\t}\n\t\t}\n\t} });\n}\nvar DefaultStreamTextResult = class {\n\tconstructor({ model, telemetry, headers, settings, maxRetries: maxRetriesArg, abortSignal, stepTimeoutMs, stepAbortController, chunkTimeoutMs, chunkAbortController, system, prompt, messages, allowSystemInMessages, tools, toolChoice, transforms, activeTools, repairToolCall, stopConditions, output, providerOptions, prepareStep, includeRawChunks, now: now2, generateId: generateId2, timeout, stopWhen, originalAbortSignal, onChunk, onError, onFinish, onAbort, onStepFinish, onStart, onStepStart, onToolCallStart, onToolCallFinish, experimental_context, experimental_toolApprovalSecret, download: download2, include }) {\n\t\tthis._totalUsage = new DelayedPromise();\n\t\tthis._finishReason = new DelayedPromise();\n\t\tthis._rawFinishReason = new DelayedPromise();\n\t\tthis._steps = new DelayedPromise();\n\t\tthis.outputSpecification = output;\n\t\tthis.includeRawChunks = includeRawChunks;\n\t\tthis.tools = tools;\n\t\tconst globalTelemetry = getGlobalTelemetryIntegration()(telemetry == null ? void 0 : telemetry.integrations);\n\t\tlet stepFinish;\n\t\tlet recordedContent = [];\n\t\tconst recordedResponseMessages = [];\n\t\tlet recordedFinishReason = void 0;\n\t\tlet recordedRawFinishReason = void 0;\n\t\tlet recordedTotalUsage = void 0;\n\t\tlet recordedRequest = {};\n\t\tlet recordedWarnings = [];\n\t\tconst recordedSteps = [];\n\t\tlet recordedNoOutputError;\n\t\tlet currentStepToolSet = tools;\n\t\tlet currentStepModel = model;\n\t\tconst createPartIdReserver = () => {\n\t\t\tconst usedIds = /* @__PURE__ */ new Set();\n\t\t\treturn (id) => {\n\t\t\t\tif (!usedIds.has(id)) {\n\t\t\t\t\tusedIds.add(id);\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t\tconst generatedId = generateId2();\n\t\t\t\tlet uniqueId = generatedId;\n\t\t\t\tlet suffix = 0;\n\t\t\t\twhile (usedIds.has(uniqueId)) uniqueId = `${generatedId}-${++suffix}`;\n\t\t\t\tusedIds.add(uniqueId);\n\t\t\t\treturn uniqueId;\n\t\t\t};\n\t\t};\n\t\tconst reserveTextPartId = createPartIdReserver();\n\t\tconst reserveReasoningPartId = createPartIdReserver();\n\t\tconst pendingDeferredToolCalls = /* @__PURE__ */ new Map();\n\t\tlet rootSpan;\n\t\tlet activeTextContent = createIdMap();\n\t\tlet activeReasoningContent = createIdMap();\n\t\tconst eventProcessor = new TransformStream({\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tvar _a23, _b, _c, _d;\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\tconst { part } = chunk;\n\t\t\t\tif (part.type === \"text-delta\" || part.type === \"reasoning-delta\" || part.type === \"source\" || part.type === \"tool-call\" || part.type === \"tool-result\" || part.type === \"tool-input-start\" || part.type === \"tool-input-delta\" || part.type === \"raw\") await notify({\n\t\t\t\t\tevent: { chunk: part },\n\t\t\t\t\tcallbacks: onChunk\n\t\t\t\t});\n\t\t\t\tif (part.type === \"error\") {\n\t\t\t\t\tconst error = wrapGatewayError(part.error);\n\t\t\t\t\tif (NoOutputGeneratedError.isInstance(error)) recordedNoOutputError = error;\n\t\t\t\t\tawait notify({\n\t\t\t\t\t\tevent: { error },\n\t\t\t\t\t\tcallbacks: onError\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (part.type === \"text-start\") {\n\t\t\t\t\tactiveTextContent[part.id] = {\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\trecordedContent.push(activeTextContent[part.id]);\n\t\t\t\t}\n\t\t\t\tif (part.type === \"text-delta\") {\n\t\t\t\t\tconst activeText = activeTextContent[part.id];\n\t\t\t\t\tif (activeText == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `text part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveText.text += part.text;\n\t\t\t\t\tactiveText.providerMetadata = (_a23 = part.providerMetadata) != null ? _a23 : activeText.providerMetadata;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"text-end\") {\n\t\t\t\t\tconst activeText = activeTextContent[part.id];\n\t\t\t\t\tif (activeText == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `text part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveText.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeText.providerMetadata;\n\t\t\t\t\tdelete activeTextContent[part.id];\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-start\") {\n\t\t\t\t\tactiveReasoningContent[part.id] = {\n\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t};\n\t\t\t\t\trecordedContent.push(activeReasoningContent[part.id]);\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-delta\") {\n\t\t\t\t\tconst activeReasoning = activeReasoningContent[part.id];\n\t\t\t\t\tif (activeReasoning == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `reasoning part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveReasoning.text += part.text;\n\t\t\t\t\tactiveReasoning.providerMetadata = (_c = part.providerMetadata) != null ? _c : activeReasoning.providerMetadata;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"reasoning-end\") {\n\t\t\t\t\tconst activeReasoning = activeReasoningContent[part.id];\n\t\t\t\t\tif (activeReasoning == null) {\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\tpart: {\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: `reasoning part ${part.id} not found`\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartialOutput: void 0\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactiveReasoning.providerMetadata = (_d = part.providerMetadata) != null ? _d : activeReasoning.providerMetadata;\n\t\t\t\t\tdelete activeReasoningContent[part.id];\n\t\t\t\t}\n\t\t\t\tif (part.type === \"file\") recordedContent.push({\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tfile: part.file,\n\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t});\n\t\t\t\tif (part.type === \"source\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-call\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-result\" && !part.preliminary) recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-approval-request\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"tool-error\") recordedContent.push(part);\n\t\t\t\tif (part.type === \"start-step\") {\n\t\t\t\t\trecordedContent = [];\n\t\t\t\t\tactiveReasoningContent = createIdMap();\n\t\t\t\t\tactiveTextContent = createIdMap();\n\t\t\t\t\trecordedRequest = part.request;\n\t\t\t\t\trecordedWarnings = part.warnings;\n\t\t\t\t}\n\t\t\t\tif (part.type === \"finish-step\") {\n\t\t\t\t\tconst stepMessages = await toResponseMessages({\n\t\t\t\t\t\tcontent: recordedContent,\n\t\t\t\t\t\ttools: currentStepToolSet\n\t\t\t\t\t});\n\t\t\t\t\tconst currentStepResult = new DefaultStepResult({\n\t\t\t\t\t\tstepNumber: recordedSteps.length,\n\t\t\t\t\t\tmodel: {\n\t\t\t\t\t\t\tprovider: currentStepModel.provider,\n\t\t\t\t\t\t\tmodelId: currentStepModel.modelId\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...callbackTelemetryProps,\n\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\tcontent: recordedContent,\n\t\t\t\t\t\tfinishReason: part.finishReason,\n\t\t\t\t\t\trawFinishReason: part.rawFinishReason,\n\t\t\t\t\t\tusage: part.usage,\n\t\t\t\t\t\twarnings: recordedWarnings,\n\t\t\t\t\t\trequest: recordedRequest,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t...part.response,\n\t\t\t\t\t\t\tmessages: [...recordedResponseMessages, ...stepMessages]\n\t\t\t\t\t\t},\n\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\tawait notify({\n\t\t\t\t\t\tevent: currentStepResult,\n\t\t\t\t\t\tcallbacks: [onStepFinish, globalTelemetry.onStepFinish]\n\t\t\t\t\t});\n\t\t\t\t\tlogWarnings({\n\t\t\t\t\t\twarnings: recordedWarnings,\n\t\t\t\t\t\tprovider: currentStepModel.provider,\n\t\t\t\t\t\tmodel: currentStepModel.modelId\n\t\t\t\t\t});\n\t\t\t\t\trecordedSteps.push(currentStepResult);\n\t\t\t\t\trecordedResponseMessages.push(...stepMessages);\n\t\t\t\t\tstepFinish.resolve();\n\t\t\t\t}\n\t\t\t\tif (part.type === \"finish\") {\n\t\t\t\t\trecordedTotalUsage = part.totalUsage;\n\t\t\t\t\trecordedFinishReason = part.finishReason;\n\t\t\t\t\trecordedRawFinishReason = part.rawFinishReason;\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\tvar _a23, _b, _c, _d, _e, _f, _g;\n\t\t\t\ttry {\n\t\t\t\t\tif (recordedSteps.length === 0 || recordedNoOutputError != null) {\n\t\t\t\t\t\tconst error = (abortSignal == null ? void 0 : abortSignal.aborted) ? abortSignal.reason : recordedNoOutputError != null ? recordedNoOutputError : new NoOutputGeneratedError({ message: \"No output generated. Check the stream for errors.\" });\n\t\t\t\t\t\tself._finishReason.reject(error);\n\t\t\t\t\t\tself._rawFinishReason.reject(error);\n\t\t\t\t\t\tself._totalUsage.reject(error);\n\t\t\t\t\t\tself._steps.reject(error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst finishReason = recordedFinishReason != null ? recordedFinishReason : \"other\";\n\t\t\t\t\tconst totalUsage = recordedTotalUsage != null ? recordedTotalUsage : createNullLanguageModelUsage();\n\t\t\t\t\tself._finishReason.resolve(finishReason);\n\t\t\t\t\tself._rawFinishReason.resolve(recordedRawFinishReason);\n\t\t\t\t\tself._totalUsage.resolve(totalUsage);\n\t\t\t\t\tself._steps.resolve(recordedSteps);\n\t\t\t\t\tconst finalStep = recordedSteps[recordedSteps.length - 1];\n\t\t\t\t\tconst onFinishEvent = {\n\t\t\t\t\t\tstepNumber: finalStep.stepNumber,\n\t\t\t\t\t\tmodel: finalStep.model,\n\t\t\t\t\t\tfunctionId: finalStep.functionId,\n\t\t\t\t\t\tmetadata: finalStep.metadata,\n\t\t\t\t\t\texperimental_context: finalStep.experimental_context,\n\t\t\t\t\t\tfinishReason: finalStep.finishReason,\n\t\t\t\t\t\trawFinishReason: finalStep.rawFinishReason,\n\t\t\t\t\t\ttotalUsage,\n\t\t\t\t\t\tusage: finalStep.usage,\n\t\t\t\t\t\tcontent: finalStep.content,\n\t\t\t\t\t\ttext: finalStep.text,\n\t\t\t\t\t\treasoningText: finalStep.reasoningText,\n\t\t\t\t\t\treasoning: finalStep.reasoning,\n\t\t\t\t\t\tfiles: finalStep.files,\n\t\t\t\t\t\tsources: finalStep.sources,\n\t\t\t\t\t\ttoolCalls: finalStep.toolCalls,\n\t\t\t\t\t\tstaticToolCalls: finalStep.staticToolCalls,\n\t\t\t\t\t\tdynamicToolCalls: finalStep.dynamicToolCalls,\n\t\t\t\t\t\ttoolResults: finalStep.toolResults,\n\t\t\t\t\t\tstaticToolResults: finalStep.staticToolResults,\n\t\t\t\t\t\tdynamicToolResults: finalStep.dynamicToolResults,\n\t\t\t\t\t\trequest: finalStep.request,\n\t\t\t\t\t\tresponse: finalStep.response,\n\t\t\t\t\t\twarnings: finalStep.warnings,\n\t\t\t\t\t\tproviderMetadata: finalStep.providerMetadata,\n\t\t\t\t\t\tsteps: recordedSteps\n\t\t\t\t\t};\n\t\t\t\t\tconst onFinishWithOutput = onFinish == null ? void 0 : async (event) => {\n\t\t\t\t\t\tconst parsedOutput = output == null ? void 0 : await self.getOutputPromise().catch(() => void 0);\n\t\t\t\t\t\tawait onFinish({\n\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t...output != null ? { output: parsedOutput } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t\tawait Promise.all([notify({\n\t\t\t\t\t\tevent: onFinishEvent,\n\t\t\t\t\t\tcallbacks: onFinishWithOutput\n\t\t\t\t\t}), notify({\n\t\t\t\t\t\tevent: onFinishEvent,\n\t\t\t\t\t\tcallbacks: globalTelemetry.onFinish\n\t\t\t\t\t})]);\n\t\t\t\t\trootSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\t\"ai.response.text\": { output: () => finalStep.text },\n\t\t\t\t\t\t\t\"ai.response.reasoning\": { output: () => finalStep.reasoningText },\n\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => {\n\t\t\t\t\t\t\t\tvar _a24;\n\t\t\t\t\t\t\t\treturn ((_a24 = finalStep.toolCalls) == null ? void 0 : _a24.length) ? JSON.stringify(finalStep.toolCalls) : void 0;\n\t\t\t\t\t\t\t} },\n\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(finalStep.providerMetadata),\n\t\t\t\t\t\t\t\"ai.usage.inputTokens\": totalUsage.inputTokens,\n\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.noCacheTokens\": (_a23 = totalUsage.inputTokenDetails) == null ? void 0 : _a23.noCacheTokens,\n\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheReadTokens\": (_b = totalUsage.inputTokenDetails) == null ? void 0 : _b.cacheReadTokens,\n\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheWriteTokens\": (_c = totalUsage.inputTokenDetails) == null ? void 0 : _c.cacheWriteTokens,\n\t\t\t\t\t\t\t\"ai.usage.outputTokens\": totalUsage.outputTokens,\n\t\t\t\t\t\t\t\"ai.usage.outputTokenDetails.textTokens\": (_d = totalUsage.outputTokenDetails) == null ? void 0 : _d.textTokens,\n\t\t\t\t\t\t\t\"ai.usage.outputTokenDetails.reasoningTokens\": (_e = totalUsage.outputTokenDetails) == null ? void 0 : _e.reasoningTokens,\n\t\t\t\t\t\t\t\"ai.usage.totalTokens\": totalUsage.totalTokens,\n\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": (_f = totalUsage.outputTokenDetails) == null ? void 0 : _f.reasoningTokens,\n\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": (_g = totalUsage.inputTokenDetails) == null ? void 0 : _g.cacheReadTokens\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t} finally {\n\t\t\t\t\trootSpan.end();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tconst stitchableStream = createStitchableStream();\n\t\tthis.addStream = stitchableStream.addStream;\n\t\tthis.closeStream = stitchableStream.close;\n\t\tconst reader = stitchableStream.stream.getReader();\n\t\tlet stream = new ReadableStream({\n\t\t\tasync start(controller) {\n\t\t\t\tcontroller.enqueue({ type: \"start\" });\n\t\t\t},\n\t\t\tasync pull(controller) {\n\t\t\t\tfunction abort() {\n\t\t\t\t\tonAbort?.({ steps: recordedSteps });\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"abort\",\n\t\t\t\t\t\t...(abortSignal == null ? void 0 : abortSignal.reason) !== void 0 ? { reason: getErrorMessage(abortSignal.reason) } : {}\n\t\t\t\t\t});\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\tif (done) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (abortSignal == null ? void 0 : abortSignal.aborted) {\n\t\t\t\t\t\tabort();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (isAbortError(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) abort();\n\t\t\t\t\telse controller.error(error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancel(reason) {\n\t\t\t\treturn stitchableStream.stream.cancel(reason);\n\t\t\t}\n\t\t});\n\t\tfor (const transform of transforms) stream = stream.pipeThrough(transform({\n\t\t\ttools,\n\t\t\tstopStream() {\n\t\t\t\tstitchableStream.terminate();\n\t\t\t}\n\t\t}));\n\t\tthis.baseStream = stream.pipeThrough(createOutputTransformStream(output != null ? output : text())).pipeThrough(eventProcessor);\n\t\tconst { maxRetries, retry } = prepareRetries({\n\t\t\tmaxRetries: maxRetriesArg,\n\t\t\tabortSignal\n\t\t});\n\t\tconst tracer = getTracer(telemetry);\n\t\tconst callSettings = prepareCallSettings(settings);\n\t\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\t\tmodel,\n\t\t\ttelemetry,\n\t\t\theaders,\n\t\t\tsettings: {\n\t\t\t\t...callSettings,\n\t\t\t\tmaxRetries\n\t\t\t}\n\t\t});\n\t\tconst self = this;\n\t\tconst modelInfo = {\n\t\t\tprovider: model.provider,\n\t\t\tmodelId: model.modelId\n\t\t};\n\t\tconst callbackTelemetryProps = {\n\t\t\tfunctionId: telemetry == null ? void 0 : telemetry.functionId,\n\t\t\tmetadata: telemetry == null ? void 0 : telemetry.metadata\n\t\t};\n\t\trecordSpan({\n\t\t\tname: \"ai.streamText\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.streamText\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) }\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tendWhenDone: false,\n\t\t\tfn: async (rootSpanArg) => {\n\t\t\t\trootSpan = rootSpanArg;\n\t\t\t\tconst initialPrompt = await standardizePrompt({\n\t\t\t\t\tsystem,\n\t\t\t\t\tprompt,\n\t\t\t\t\tmessages,\n\t\t\t\t\tallowSystemInMessages\n\t\t\t\t});\n\t\t\t\tawait notify({\n\t\t\t\t\tevent: {\n\t\t\t\t\t\tmodel: modelInfo,\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\ttoolChoice,\n\t\t\t\t\t\tactiveTools,\n\t\t\t\t\t\tmaxOutputTokens: callSettings.maxOutputTokens,\n\t\t\t\t\t\ttemperature: callSettings.temperature,\n\t\t\t\t\t\ttopP: callSettings.topP,\n\t\t\t\t\t\ttopK: callSettings.topK,\n\t\t\t\t\t\tpresencePenalty: callSettings.presencePenalty,\n\t\t\t\t\t\tfrequencyPenalty: callSettings.frequencyPenalty,\n\t\t\t\t\t\tstopSequences: callSettings.stopSequences,\n\t\t\t\t\t\tseed: callSettings.seed,\n\t\t\t\t\t\tmaxRetries,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\tstopWhen,\n\t\t\t\t\t\toutput,\n\t\t\t\t\t\tabortSignal: originalAbortSignal,\n\t\t\t\t\t\tinclude,\n\t\t\t\t\t\t...callbackTelemetryProps,\n\t\t\t\t\t\texperimental_context\n\t\t\t\t\t},\n\t\t\t\t\tcallbacks: [onStart, globalTelemetry.onStart]\n\t\t\t\t});\n\t\t\t\tconst initialMessages = initialPrompt.messages;\n\t\t\t\tconst initialResponseMessages = [];\n\t\t\t\tconst { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });\n\t\t\t\tif (deniedToolApprovals.length > 0 || approvedToolApprovals.length > 0) {\n\t\t\t\t\tconst { approvedToolApprovals: localApprovedToolApprovals, deniedToolApprovals: revalidationDeniedToolApprovals, invalidToolApprovals } = await validateApprovedToolApprovals({\n\t\t\t\t\t\tapprovedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),\n\t\t\t\t\t\ttools,\n\t\t\t\t\t\tmessages: initialMessages,\n\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\ttoolApprovalSecret: experimental_toolApprovalSecret\n\t\t\t\t\t});\n\t\t\t\t\tconst localDeniedToolApprovals = [...deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted), ...revalidationDeniedToolApprovals];\n\t\t\t\t\tconst deniedProviderExecutedToolApprovals = deniedToolApprovals.filter((toolApproval) => toolApproval.toolCall.providerExecuted);\n\t\t\t\t\tlet toolExecutionStepStreamController;\n\t\t\t\t\tconst toolExecutionStepStream = new ReadableStream({ start(controller) {\n\t\t\t\t\t\ttoolExecutionStepStreamController = controller;\n\t\t\t\t\t} });\n\t\t\t\t\tself.addStream(toolExecutionStepStream);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfor (const toolApproval of [...localDeniedToolApprovals, ...deniedProviderExecutedToolApprovals]) toolExecutionStepStreamController?.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-output-denied\",\n\t\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\t\ttoolName: toolApproval.toolCall.toolName\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfor (const toolApproval of invalidToolApprovals) toolExecutionStepStreamController?.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-error\",\n\t\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\t\ttoolName: toolApproval.toolCall.toolName,\n\t\t\t\t\t\t\tinput: toolApproval.toolCall.input,\n\t\t\t\t\t\t\terror: getErrorMessage(toolApproval.error),\n\t\t\t\t\t\t\ttitle: toolApproval.toolCall.title,\n\t\t\t\t\t\t\t...toolApproval.toolCall.dynamic === true ? { dynamic: true } : {},\n\t\t\t\t\t\t\t...toolApproval.toolCall.toolMetadata != null ? { toolMetadata: toolApproval.toolCall.toolMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst toolOutputs = [];\n\t\t\t\t\t\tawait Promise.all(localApprovedToolApprovals.map(async (toolApproval) => {\n\t\t\t\t\t\t\tconst result = await executeToolCall({\n\t\t\t\t\t\t\t\ttoolCall: toolApproval.toolCall,\n\t\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tmessages: initialMessages,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\t\t\tstepNumber: recordedSteps.length,\n\t\t\t\t\t\t\t\tmodel: modelInfo,\n\t\t\t\t\t\t\t\tonToolCallStart: [onToolCallStart, globalTelemetry.onToolCallStart],\n\t\t\t\t\t\t\t\tonToolCallFinish: [onToolCallFinish, globalTelemetry.onToolCallFinish],\n\t\t\t\t\t\t\t\tonPreliminaryToolResult: (result2) => {\n\t\t\t\t\t\t\t\t\ttoolExecutionStepStreamController?.enqueue(result2);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (result != null) {\n\t\t\t\t\t\t\t\ttoolExecutionStepStreamController?.enqueue(result);\n\t\t\t\t\t\t\t\ttoolOutputs.push(result);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tif (toolOutputs.length > 0 || localDeniedToolApprovals.length > 0 || invalidToolApprovals.length > 0) {\n\t\t\t\t\t\t\tconst localToolContent = [];\n\t\t\t\t\t\t\tfor (const output2 of toolOutputs) localToolContent.push({\n\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\ttoolCallId: output2.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: output2.toolName,\n\t\t\t\t\t\t\t\toutput: await createToolModelOutput({\n\t\t\t\t\t\t\t\t\ttoolCallId: output2.toolCallId,\n\t\t\t\t\t\t\t\t\tinput: output2.input,\n\t\t\t\t\t\t\t\t\ttool: tools == null ? void 0 : tools[output2.toolName],\n\t\t\t\t\t\t\t\t\toutput: output2.type === \"tool-result\" ? output2.output : output2.error,\n\t\t\t\t\t\t\t\t\terrorMode: output2.type === \"tool-error\" ? \"text\" : \"none\"\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tfor (const toolApproval of invalidToolApprovals) localToolContent.push({\n\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: toolApproval.toolCall.toolName,\n\t\t\t\t\t\t\t\toutput: await createToolModelOutput({\n\t\t\t\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\t\t\t\tinput: toolApproval.toolCall.input,\n\t\t\t\t\t\t\t\t\ttool: tools == null ? void 0 : tools[toolApproval.toolCall.toolName],\n\t\t\t\t\t\t\t\t\toutput: toolApproval.error,\n\t\t\t\t\t\t\t\t\terrorMode: \"text\"\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tfor (const toolApproval of localDeniedToolApprovals) localToolContent.push({\n\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\ttoolCallId: toolApproval.toolCall.toolCallId,\n\t\t\t\t\t\t\t\ttoolName: toolApproval.toolCall.toolName,\n\t\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\t\ttype: \"execution-denied\",\n\t\t\t\t\t\t\t\t\treason: toolApproval.approvalResponse.reason\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tinitialResponseMessages.push({\n\t\t\t\t\t\t\t\trole: \"tool\",\n\t\t\t\t\t\t\t\tcontent: localToolContent\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} finally {\n\t\t\t\t\t\ttoolExecutionStepStreamController?.close();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trecordedResponseMessages.push(...initialResponseMessages);\n\t\t\t\tasync function streamStep({ currentStep, responseMessages, usage }) {\n\t\t\t\t\tvar _a23, _b, _c, _d, _e, _f, _g, _h, _i;\n\t\t\t\t\tconst includeRawChunks2 = self.includeRawChunks;\n\t\t\t\t\tconst stepTimeoutId = setAbortTimeout({\n\t\t\t\t\t\tabortController: stepAbortController,\n\t\t\t\t\t\tlabel: \"Step\",\n\t\t\t\t\t\ttimeoutMs: stepTimeoutMs\n\t\t\t\t\t});\n\t\t\t\t\tlet chunkTimeoutId = void 0;\n\t\t\t\t\tfunction resetChunkTimeout() {\n\t\t\t\t\t\tif (chunkTimeoutId != null) clearTimeout(chunkTimeoutId);\n\t\t\t\t\t\tchunkTimeoutId = setAbortTimeout({\n\t\t\t\t\t\t\tabortController: chunkAbortController,\n\t\t\t\t\t\t\tlabel: \"Chunk\",\n\t\t\t\t\t\t\ttimeoutMs: chunkTimeoutMs\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tfunction clearChunkTimeout() {\n\t\t\t\t\t\tif (chunkTimeoutId != null) {\n\t\t\t\t\t\t\tclearTimeout(chunkTimeoutId);\n\t\t\t\t\t\t\tchunkTimeoutId = void 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfunction clearStepTimeout() {\n\t\t\t\t\t\tif (stepTimeoutId != null) clearTimeout(stepTimeoutId);\n\t\t\t\t\t}\n\t\t\t\t\tfunction clearStepTimeouts() {\n\t\t\t\t\t\tclearStepTimeout();\n\t\t\t\t\t\tclearChunkTimeout();\n\t\t\t\t\t}\n\t\t\t\t\tfunction cleanupStepTimeouts() {\n\t\t\t\t\t\tabortSignal?.removeEventListener(\"abort\", cleanupStepTimeouts);\n\t\t\t\t\t\tclearStepTimeouts();\n\t\t\t\t\t}\n\t\t\t\t\tabortSignal?.addEventListener(\"abort\", cleanupStepTimeouts, { once: true });\n\t\t\t\t\ttry {\n\t\t\t\t\t\tstepFinish = new DelayedPromise();\n\t\t\t\t\t\tconst stepInputMessages = [...initialMessages, ...responseMessages];\n\t\t\t\t\t\tconst prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tsteps: recordedSteps,\n\t\t\t\t\t\t\tstepNumber: recordedSteps.length,\n\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst stepModel = resolveLanguageModel((_a23 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a23 : model);\n\t\t\t\t\t\tcurrentStepModel = stepModel;\n\t\t\t\t\t\tconst stepModelInfo = {\n\t\t\t\t\t\t\tprovider: stepModel.provider,\n\t\t\t\t\t\t\tmodelId: stepModel.modelId\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\t\t\tprompt: {\n\t\t\t\t\t\t\t\tsystem: (_b = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b : initialPrompt.system,\n\t\t\t\t\t\t\t\tmessages: (_c = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c : stepInputMessages\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tsupportedUrls: await stepModel.supportedUrls,\n\t\t\t\t\t\t\tdownload: download2,\n\t\t\t\t\t\t\tabortSignal\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst stepActiveTools = (_d = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _d : activeTools;\n\t\t\t\t\t\tconst stepToolSet = filterActiveTools({\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcurrentStepToolSet = stepToolSet;\n\t\t\t\t\t\tconst { toolChoice: stepToolChoice, tools: stepTools } = await prepareToolsAndToolChoice({\n\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\ttoolChoice: (_e = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _e : toolChoice,\n\t\t\t\t\t\t\tactiveTools: stepActiveTools\n\t\t\t\t\t\t});\n\t\t\t\t\t\texperimental_context = (_f = prepareStepResult == null ? void 0 : prepareStepResult.experimental_context) != null ? _f : experimental_context;\n\t\t\t\t\t\tconst stepMessages = (_g = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _g : stepInputMessages;\n\t\t\t\t\t\tconst stepSystem = (_h = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _h : initialPrompt.system;\n\t\t\t\t\t\tconst stepProviderOptions = mergeObjects(providerOptions, prepareStepResult == null ? void 0 : prepareStepResult.providerOptions);\n\t\t\t\t\t\tconst stepCallSettings = prepareStepCallSettings({\n\t\t\t\t\t\t\tcallSettings,\n\t\t\t\t\t\t\tstepSettings: prepareStepResult\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait notify({\n\t\t\t\t\t\t\tevent: {\n\t\t\t\t\t\t\t\tstepNumber: recordedSteps.length,\n\t\t\t\t\t\t\t\tmodel: stepModelInfo,\n\t\t\t\t\t\t\t\tsystem: stepSystem,\n\t\t\t\t\t\t\t\tmessages: stepMessages,\n\t\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\t\t\tactiveTools: stepActiveTools,\n\t\t\t\t\t\t\t\tsteps: [...recordedSteps],\n\t\t\t\t\t\t\t\tproviderOptions: stepProviderOptions,\n\t\t\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tstopWhen,\n\t\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\t\tabortSignal: originalAbortSignal,\n\t\t\t\t\t\t\t\tinclude,\n\t\t\t\t\t\t\t\t...callbackTelemetryProps,\n\t\t\t\t\t\t\t\texperimental_context\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcallbacks: [onStepStart, globalTelemetry.onStepStart]\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst { result: { stream: stream2, response, request }, doStreamSpan, startTimestampMs } = await retry(() => recordSpan({\n\t\t\t\t\t\t\tname: \"ai.streamText.doStream\",\n\t\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\t\toperationId: \"ai.streamText.doStream\",\n\t\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\t\"ai.model.provider\": stepModel.provider,\n\t\t\t\t\t\t\t\t\t\"ai.model.id\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\t\t\"ai.prompt.tools\": { input: () => stepTools == null ? void 0 : stepTools.map((tool2) => JSON.stringify(tool2)) },\n\t\t\t\t\t\t\t\t\t\"ai.prompt.toolChoice\": { input: () => stepToolChoice != null ? JSON.stringify(stepToolChoice) : void 0 },\n\t\t\t\t\t\t\t\t\t\"gen_ai.system\": stepModel.provider,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.model\": stepModel.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": stepCallSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": stepCallSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": stepCallSettings.presencePenalty,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.stop_sequences\": stepCallSettings.stopSequences,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.temperature\": stepCallSettings.temperature,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.top_k\": stepCallSettings.topK,\n\t\t\t\t\t\t\t\t\t\"gen_ai.request.top_p\": stepCallSettings.topP\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\tendWhenDone: false,\n\t\t\t\t\t\t\tendOnError: true,\n\t\t\t\t\t\t\tfn: async (doStreamSpan2) => ({\n\t\t\t\t\t\t\t\tstartTimestampMs: now2(),\n\t\t\t\t\t\t\t\tdoStreamSpan: doStreamSpan2,\n\t\t\t\t\t\t\t\tresult: await stepModel.doStream({\n\t\t\t\t\t\t\t\t\t...stepCallSettings,\n\t\t\t\t\t\t\t\t\ttools: stepTools,\n\t\t\t\t\t\t\t\t\ttoolChoice: stepToolChoice,\n\t\t\t\t\t\t\t\t\tresponseFormat: await (output == null ? void 0 : output.responseFormat),\n\t\t\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\t\t\tproviderOptions: stepProviderOptions,\n\t\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\t\tincludeRawChunks: includeRawChunks2\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst streamWithToolResults = runToolsTransformation({\n\t\t\t\t\t\t\ttools: stepToolSet,\n\t\t\t\t\t\t\tgeneratorStream: stream2,\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tmessages: stepInputMessages,\n\t\t\t\t\t\t\trepairToolCall,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\texperimental_context,\n\t\t\t\t\t\t\ttoolApprovalSecret: experimental_toolApprovalSecret,\n\t\t\t\t\t\t\tgenerateId: generateId2,\n\t\t\t\t\t\t\tstepNumber: recordedSteps.length,\n\t\t\t\t\t\t\tmodel: stepModelInfo,\n\t\t\t\t\t\t\tonToolCallStart: [onToolCallStart, globalTelemetry.onToolCallStart],\n\t\t\t\t\t\t\tonToolCallFinish: [onToolCallFinish, globalTelemetry.onToolCallFinish]\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst stepRequest = ((_i = include == null ? void 0 : include.requestBody) != null ? _i : true) ? request != null ? request : {} : {\n\t\t\t\t\t\t\t...request,\n\t\t\t\t\t\t\tbody: void 0\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stepToolCalls = [];\n\t\t\t\t\t\tconst stepToolOutputs = [];\n\t\t\t\t\t\tlet warnings;\n\t\t\t\t\t\tlet stepFinishReason = \"other\";\n\t\t\t\t\t\tlet stepRawFinishReason = void 0;\n\t\t\t\t\t\tlet hasReceivedTerminalChunk = false;\n\t\t\t\t\t\tlet hasReceivedOutputChunk = false;\n\t\t\t\t\t\tlet stepUsage = createNullLanguageModelUsage();\n\t\t\t\t\t\tlet stepProviderMetadata;\n\t\t\t\t\t\tlet stepFirstChunk = true;\n\t\t\t\t\t\tlet stepResponse = {\n\t\t\t\t\t\t\tid: generateId2(),\n\t\t\t\t\t\t\ttimestamp: /* @__PURE__ */ new Date(),\n\t\t\t\t\t\t\tmodelId: stepModelInfo.modelId\n\t\t\t\t\t\t};\n\t\t\t\t\t\tlet activeText = \"\";\n\t\t\t\t\t\tconst textPartIds = /* @__PURE__ */ new Map();\n\t\t\t\t\t\tconst reasoningPartIds = /* @__PURE__ */ new Map();\n\t\t\t\t\t\tself.addStream(streamWithToolResults.pipeThrough(new TransformStream({\n\t\t\t\t\t\t\tasync transform(chunk, controller) {\n\t\t\t\t\t\t\t\tvar _a24, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;\n\t\t\t\t\t\t\t\tresetChunkTimeout();\n\t\t\t\t\t\t\t\tif (chunk.type === \"stream-start\") {\n\t\t\t\t\t\t\t\t\twarnings = chunk.warnings;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (stepFirstChunk) {\n\t\t\t\t\t\t\t\t\tconst msToFirstChunk = now2() - startTimestampMs;\n\t\t\t\t\t\t\t\t\tstepFirstChunk = false;\n\t\t\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.firstChunk\", { \"ai.response.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes({ \"ai.response.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"start-step\",\n\t\t\t\t\t\t\t\t\t\trequest: stepRequest,\n\t\t\t\t\t\t\t\t\t\twarnings: warnings != null ? warnings : []\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst chunkType = chunk.type;\n\t\t\t\t\t\t\t\tif (isOutputChunkType[chunkType]) hasReceivedOutputChunk = true;\n\t\t\t\t\t\t\t\tswitch (chunkType) {\n\t\t\t\t\t\t\t\t\tcase \"tool-approval-request\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"text-start\": {\n\t\t\t\t\t\t\t\t\t\tconst id = reserveTextPartId(chunk.id);\n\t\t\t\t\t\t\t\t\t\ttextPartIds.set(chunk.id, id);\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcase \"text-end\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\t\t\tid: (_a24 = textPartIds.get(chunk.id)) != null ? _a24 : chunk.id\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\ttextPartIds.delete(chunk.id);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\t\t\t\t\tif (chunk.delta.length > 0 || chunk.providerMetadata != null) controller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\t\tid: (_b2 = textPartIds.get(chunk.id)) != null ? _b2 : chunk.id,\n\t\t\t\t\t\t\t\t\t\t\ttext: chunk.delta,\n\t\t\t\t\t\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tactiveText += chunk.delta;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"reasoning-start\": {\n\t\t\t\t\t\t\t\t\t\tconst id = reserveReasoningPartId(chunk.id);\n\t\t\t\t\t\t\t\t\t\treasoningPartIds.set(chunk.id, id);\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcase \"reasoning-end\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\t\t\tid: (_c2 = reasoningPartIds.get(chunk.id)) != null ? _c2 : chunk.id\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\treasoningPartIds.delete(chunk.id);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"reasoning-delta\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\t\t\t\t\tid: (_d2 = reasoningPartIds.get(chunk.id)) != null ? _d2 : chunk.id,\n\t\t\t\t\t\t\t\t\t\t\ttext: chunk.delta,\n\t\t\t\t\t\t\t\t\t\t\tproviderMetadata: chunk.providerMetadata\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"tool-call\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tstepToolCalls.push(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"tool-result\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tif (!chunk.preliminary) stepToolOutputs.push(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"tool-error\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tstepToolOutputs.push(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\t\t\tstepResponse = {\n\t\t\t\t\t\t\t\t\t\t\tid: (_e2 = chunk.id) != null ? _e2 : stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\ttimestamp: (_f2 = chunk.timestamp) != null ? _f2 : stepResponse.timestamp,\n\t\t\t\t\t\t\t\t\t\t\tmodelId: (_g2 = chunk.modelId) != null ? _g2 : stepResponse.modelId\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"finish\": {\n\t\t\t\t\t\t\t\t\t\thasReceivedTerminalChunk = true;\n\t\t\t\t\t\t\t\t\t\tstepUsage = chunk.usage;\n\t\t\t\t\t\t\t\t\t\tstepFinishReason = chunk.finishReason;\n\t\t\t\t\t\t\t\t\t\tstepRawFinishReason = chunk.rawFinishReason;\n\t\t\t\t\t\t\t\t\t\tstepProviderMetadata = chunk.providerMetadata;\n\t\t\t\t\t\t\t\t\t\tconst msToFinish = now2() - startTimestampMs;\n\t\t\t\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.finish\");\n\t\t\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes({\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.msToFinish\": msToFinish,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.avgOutputTokensPerSecond\": 1e3 * ((_h2 = stepUsage.outputTokens) != null ? _h2 : 0) / msToFinish\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"source\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"tool-input-start\": {\n\t\t\t\t\t\t\t\t\t\tconst tool2 = stepToolSet == null ? void 0 : stepToolSet[chunk.toolName];\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\t\t\tdynamic: (_i2 = chunk.dynamic) != null ? _i2 : (tool2 == null ? void 0 : tool2.type) === \"dynamic\",\n\t\t\t\t\t\t\t\t\t\t\ttitle: tool2 == null ? void 0 : tool2.title\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcase \"tool-input-end\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"tool-input-delta\":\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\t\t\t\t\thasReceivedTerminalChunk = true;\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tstepFinishReason = \"error\";\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase \"raw\":\n\t\t\t\t\t\t\t\t\t\tif (includeRawChunks2) controller.enqueue(chunk);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tdefault: throw new Error(`Unknown chunk type: ${chunkType}`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tasync flush(controller) {\n\t\t\t\t\t\t\t\tvar _a24, _b2, _c2, _d2, _e2, _f2, _g2;\n\t\t\t\t\t\t\t\tif (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\t\t\terror: new NoOutputGeneratedError({ message: \"No output generated. The model stream ended without a finish chunk.\" })\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\t\t\tcleanupStepTimeouts();\n\t\t\t\t\t\t\t\t\tself.closeStream();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : void 0;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": stepFinishReason,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.toolCalls\": { output: () => stepToolCallsJson },\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.id\": stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.model\": stepResponse.modelId,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": stepResponse.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": stepUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.noCacheTokens\": (_a24 = stepUsage.inputTokenDetails) == null ? void 0 : _a24.noCacheTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheReadTokens\": (_b2 = stepUsage.inputTokenDetails) == null ? void 0 : _b2.cacheReadTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokenDetails.cacheWriteTokens\": (_c2 = stepUsage.inputTokenDetails) == null ? void 0 : _c2.cacheWriteTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": stepUsage.outputTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokenDetails.textTokens\": (_d2 = stepUsage.outputTokenDetails) == null ? void 0 : _d2.textTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokenDetails.reasoningTokens\": (_e2 = stepUsage.outputTokenDetails) == null ? void 0 : _e2.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": stepUsage.totalTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": (_f2 = stepUsage.outputTokenDetails) == null ? void 0 : _f2.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": (_g2 = stepUsage.inputTokenDetails) == null ? void 0 : _g2.cacheReadTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [stepFinishReason],\n\t\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": stepResponse.id,\n\t\t\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": stepResponse.modelId,\n\t\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": stepUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": stepUsage.outputTokens\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t} catch (error) {}\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"finish-step\",\n\t\t\t\t\t\t\t\t\tfinishReason: stepFinishReason,\n\t\t\t\t\t\t\t\t\trawFinishReason: stepRawFinishReason,\n\t\t\t\t\t\t\t\t\tusage: stepUsage,\n\t\t\t\t\t\t\t\t\tproviderMetadata: stepProviderMetadata,\n\t\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t\t...stepResponse,\n\t\t\t\t\t\t\t\t\t\theaders: response == null ? void 0 : response.headers\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst combinedUsage = addLanguageModelUsage(usage, stepUsage);\n\t\t\t\t\t\t\t\tawait stepFinish.promise;\n\t\t\t\t\t\t\t\tconst processedStep = recordedSteps[recordedSteps.length - 1];\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tdoStreamSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.text\": { output: () => processedStep.text },\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.reasoning\": { output: () => processedStep.reasoningText },\n\t\t\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(processedStep.providerMetadata)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t} catch (error) {} finally {\n\t\t\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst clientToolCalls = stepToolCalls.filter((toolCall) => toolCall.providerExecuted !== true);\n\t\t\t\t\t\t\t\tconst clientToolOutputs = stepToolOutputs.filter((toolOutput) => toolOutput.providerExecuted !== true);\n\t\t\t\t\t\t\t\tfor (const toolCall of stepToolCalls) {\n\t\t\t\t\t\t\t\t\tif (toolCall.providerExecuted !== true) continue;\n\t\t\t\t\t\t\t\t\tconst tool2 = stepToolSet == null ? void 0 : stepToolSet[toolCall.toolName];\n\t\t\t\t\t\t\t\t\tif ((tool2 == null ? void 0 : tool2.type) === \"provider\" && tool2.supportsDeferredResults) {\n\t\t\t\t\t\t\t\t\t\tif (!stepToolOutputs.some((output2) => (output2.type === \"tool-result\" || output2.type === \"tool-error\") && output2.toolCallId === toolCall.toolCallId)) pendingDeferredToolCalls.set(toolCall.toolCallId, { toolName: toolCall.toolName });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfor (const output2 of stepToolOutputs) if (output2.type === \"tool-result\" || output2.type === \"tool-error\") pendingDeferredToolCalls.delete(output2.toolCallId);\n\t\t\t\t\t\t\t\tcleanupStepTimeouts();\n\t\t\t\t\t\t\t\tif ((clientToolCalls.length > 0 && clientToolOutputs.length === clientToolCalls.length || pendingDeferredToolCalls.size > 0) && !await isStopConditionMet({\n\t\t\t\t\t\t\t\t\tstopConditions,\n\t\t\t\t\t\t\t\t\tsteps: recordedSteps\n\t\t\t\t\t\t\t\t})) {\n\t\t\t\t\t\t\t\t\tresponseMessages.push(...await toResponseMessages({\n\t\t\t\t\t\t\t\t\t\tcontent: recordedSteps[recordedSteps.length - 1].content,\n\t\t\t\t\t\t\t\t\t\ttools: stepToolSet\n\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tawait streamStep({\n\t\t\t\t\t\t\t\t\t\t\tcurrentStep: currentStep + 1,\n\t\t\t\t\t\t\t\t\t\t\tresponseMessages,\n\t\t\t\t\t\t\t\t\t\t\tusage: combinedUsage\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tself.closeStream();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\t\t\t\t\tfinishReason: stepFinishReason,\n\t\t\t\t\t\t\t\t\t\trawFinishReason: stepRawFinishReason,\n\t\t\t\t\t\t\t\t\t\ttotalUsage: combinedUsage\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tself.closeStream();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})), {\n\t\t\t\t\t\t\tonError: cleanupStepTimeouts,\n\t\t\t\t\t\t\tonCancel: cleanupStepTimeouts\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tcleanupStepTimeouts();\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait streamStep({\n\t\t\t\t\tcurrentStep: 0,\n\t\t\t\t\tresponseMessages: initialResponseMessages,\n\t\t\t\t\tusage: createNullLanguageModelUsage()\n\t\t\t\t});\n\t\t\t}\n\t\t}).catch((error) => {\n\t\t\tself.addStream(new ReadableStream({ start(controller) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t\tcontroller.close();\n\t\t\t} }));\n\t\t\tself.closeStream();\n\t\t});\n\t}\n\tget steps() {\n\t\tthis.consumeStream();\n\t\treturn this._steps.promise;\n\t}\n\tget finalStep() {\n\t\treturn this.steps.then((steps) => steps[steps.length - 1]);\n\t}\n\tget content() {\n\t\treturn this.finalStep.then((step) => step.content);\n\t}\n\tget warnings() {\n\t\treturn this.finalStep.then((step) => step.warnings);\n\t}\n\tget providerMetadata() {\n\t\treturn this.finalStep.then((step) => step.providerMetadata);\n\t}\n\tget text() {\n\t\treturn this.finalStep.then((step) => step.text);\n\t}\n\tget reasoningText() {\n\t\treturn this.finalStep.then((step) => step.reasoningText);\n\t}\n\tget reasoning() {\n\t\treturn this.finalStep.then((step) => step.reasoning);\n\t}\n\tget sources() {\n\t\treturn this.finalStep.then((step) => step.sources);\n\t}\n\tget files() {\n\t\treturn this.finalStep.then((step) => step.files);\n\t}\n\tget toolCalls() {\n\t\treturn this.finalStep.then((step) => step.toolCalls);\n\t}\n\tget staticToolCalls() {\n\t\treturn this.finalStep.then((step) => step.staticToolCalls);\n\t}\n\tget dynamicToolCalls() {\n\t\treturn this.finalStep.then((step) => step.dynamicToolCalls);\n\t}\n\tget toolResults() {\n\t\treturn this.finalStep.then((step) => step.toolResults);\n\t}\n\tget staticToolResults() {\n\t\treturn this.finalStep.then((step) => step.staticToolResults);\n\t}\n\tget dynamicToolResults() {\n\t\treturn this.finalStep.then((step) => step.dynamicToolResults);\n\t}\n\tget usage() {\n\t\treturn this.finalStep.then((step) => step.usage);\n\t}\n\tget request() {\n\t\treturn this.finalStep.then((step) => step.request);\n\t}\n\tget response() {\n\t\treturn this.finalStep.then((step) => step.response);\n\t}\n\tget totalUsage() {\n\t\tthis.consumeStream();\n\t\treturn this._totalUsage.promise;\n\t}\n\tget finishReason() {\n\t\tthis.consumeStream();\n\t\treturn this._finishReason.promise;\n\t}\n\tget rawFinishReason() {\n\t\tthis.consumeStream();\n\t\treturn this._rawFinishReason.promise;\n\t}\n\t/**\n\t* Split out a new stream from the original stream.\n\t* The original stream is replaced to allow for further splitting,\n\t* since we do not know how many times the stream will be split.\n\t*\n\t* Note: this leads to buffering the stream content on the server.\n\t* However, the LLM results are expected to be small enough to not cause issues.\n\t*/\n\tteeStream() {\n\t\tconst [stream1, stream2] = this.baseStream.tee();\n\t\tthis.baseStream = stream2;\n\t\treturn stream1;\n\t}\n\tget textStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ part }, controller) {\n\t\t\tif (part.type === \"text-delta\") controller.enqueue(part.text);\n\t\t} })));\n\t}\n\tget fullStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ part }, controller) {\n\t\t\tcontroller.enqueue(part);\n\t\t} })));\n\t}\n\trejectResultPromises(error) {\n\t\tif (this._finishReason.isPending()) this._finishReason.reject(error);\n\t\tif (this._rawFinishReason.isPending()) this._rawFinishReason.reject(error);\n\t\tif (this._totalUsage.isPending()) this._totalUsage.reject(error);\n\t\tif (this._steps.isPending()) this._steps.reject(error);\n\t}\n\tasync consumeStream(options) {\n\t\tvar _a23;\n\t\ttry {\n\t\t\tawait consumeStream({\n\t\t\t\tstream: this.fullStream,\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tvar _a24;\n\t\t\t\t\tthis.rejectResultPromises(error);\n\t\t\t\t\t(_a24 = options == null ? void 0 : options.onError) == null || _a24.call(options, error);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthis.rejectResultPromises(error);\n\t\t\t(_a23 = options == null ? void 0 : options.onError) == null || _a23.call(options, error);\n\t\t}\n\t}\n\tget experimental_partialOutputStream() {\n\t\treturn this.partialOutputStream;\n\t}\n\tget partialOutputStream() {\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({ transform({ partialOutput }, controller) {\n\t\t\tif (partialOutput !== void 0) controller.enqueue(partialOutput);\n\t\t} })));\n\t}\n\tget elementStream() {\n\t\tvar _a23, _b, _c;\n\t\tconst transform = (_a23 = this.outputSpecification) == null ? void 0 : _a23.createElementStreamTransform();\n\t\tif (transform == null) throw new UnsupportedFunctionalityError({ functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : \"text\"} mode` });\n\t\treturn createAsyncIterableStream(this.teeStream().pipeThrough(transform));\n\t}\n\tgetOutputPromise() {\n\t\tif (this.outputPromise == null) this.outputPromise = this.finalStep.then((step) => {\n\t\t\tvar _a23;\n\t\t\treturn ((_a23 = this.outputSpecification) != null ? _a23 : text()).parseCompleteOutput({ text: step.text }, {\n\t\t\t\tresponse: step.response,\n\t\t\t\tusage: step.usage,\n\t\t\t\tfinishReason: step.finishReason\n\t\t\t});\n\t\t});\n\t\treturn this.outputPromise;\n\t}\n\tget output() {\n\t\treturn this.getOutputPromise();\n\t}\n\ttoUIMessageStream({ originalMessages, generateMessageId, onFinish, messageMetadata, sendReasoning = true, sendSources = false, sendStart = true, sendFinish = true, onError = () => \"An error occurred.\" } = {}) {\n\t\tlet outcome = { status: \"unknown\" };\n\t\tlet hasFatalFailure = false;\n\t\tconst setSourceOutcome = (newOutcome) => {\n\t\t\tif (!hasFatalFailure && outcome.status !== \"completed\" && outcome.status !== \"aborted\" && newOutcome.status !== \"unknown\" && (outcome.status === \"unknown\" || newOutcome.status !== \"failed\")) outcome = newOutcome;\n\t\t};\n\t\tconst failOutcome = (error) => {\n\t\t\thasFatalFailure = true;\n\t\t\toutcome = {\n\t\t\t\tstatus: \"failed\",\n\t\t\t\terror\n\t\t\t};\n\t\t};\n\t\tconst responseMessageId = generateMessageId != null ? getResponseUIMessageId({\n\t\t\toriginalMessages,\n\t\t\tresponseMessageId: generateMessageId\n\t\t}) : void 0;\n\t\tconst isDynamic = (part) => {\n\t\t\tvar _a23;\n\t\t\tconst tool2 = (_a23 = this.tools) == null ? void 0 : _a23[part.toolName];\n\t\t\tif (tool2 == null) return part.dynamic;\n\t\t\treturn (tool2 == null ? void 0 : tool2.type) === \"dynamic\" ? true : void 0;\n\t\t};\n\t\tconst trackFatalFailures = (stream) => {\n\t\t\tconst reader = stream.getReader();\n\t\t\tlet readerReleased = false;\n\t\t\tlet streamCancelled = false;\n\t\t\tconst releaseReader = () => {\n\t\t\t\tif (!readerReleased) {\n\t\t\t\t\treader.releaseLock();\n\t\t\t\t\treaderReleased = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn new ReadableStream({\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\treleaseReader();\n\t\t\t\t\t\t\tif (!streamCancelled) controller.close();\n\t\t\t\t\t\t} else controller.enqueue(value);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treleaseReader();\n\t\t\t\t\t\tif (!streamCancelled) {\n\t\t\t\t\t\t\tfailOutcome(error);\n\t\t\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync cancel(reason) {\n\t\t\t\t\tstreamCancelled = true;\n\t\t\t\t\tif (readerReleased) return;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait reader.cancel(reason);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\treleaseReader();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t\treturn createAsyncIterableStream(handleUIMessageStreamFinish({\n\t\t\tstream: trackFatalFailures(trackFatalFailures(this.fullStream).pipeThrough(new TransformStream({ transform: async (part, controller) => {\n\t\t\t\tconst messageMetadataValue = messageMetadata == null ? void 0 : messageMetadata({ part });\n\t\t\t\tconst partType = part.type;\n\t\t\t\tswitch (partType) {\n\t\t\t\t\tcase \"text-start\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"text-start\",\n\t\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t\tdelta: part.text,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"text-end\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"text-end\",\n\t\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"reasoning-start\":\n\t\t\t\t\tcase \"reasoning-end\":\n\t\t\t\t\t\tif (sendReasoning) controller.enqueue({\n\t\t\t\t\t\t\ttype: partType,\n\t\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"reasoning-delta\":\n\t\t\t\t\t\tif (sendReasoning) controller.enqueue({\n\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\tid: part.id,\n\t\t\t\t\t\t\tdelta: part.text,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"file\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\t\tmediaType: part.file.mediaType,\n\t\t\t\t\t\t\turl: `data:${part.file.mediaType};base64,${part.file.base64}`,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"source\":\n\t\t\t\t\t\tif (sendSources && part.sourceType === \"url\") controller.enqueue({\n\t\t\t\t\t\t\ttype: \"source-url\",\n\t\t\t\t\t\t\tsourceId: part.id,\n\t\t\t\t\t\t\turl: part.url,\n\t\t\t\t\t\t\ttitle: part.title,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (sendSources && part.sourceType === \"document\") controller.enqueue({\n\t\t\t\t\t\t\ttype: \"source-document\",\n\t\t\t\t\t\t\tsourceId: part.id,\n\t\t\t\t\t\t\tmediaType: part.mediaType,\n\t\t\t\t\t\t\ttitle: part.title,\n\t\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tool-input-start\": {\n\t\t\t\t\t\tconst dynamic = isDynamic(part);\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-input-start\",\n\t\t\t\t\t\t\ttoolCallId: part.id,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\t...part.inputEncoding != null ? { inputEncoding: part.inputEncoding } : {},\n\t\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t\t...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},\n\t\t\t\t\t\t\t...dynamic != null ? { dynamic } : {},\n\t\t\t\t\t\t\t...part.title != null ? { title: part.title } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"tool-input-delta\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-input-delta\",\n\t\t\t\t\t\t\ttoolCallId: part.id,\n\t\t\t\t\t\t\tinputTextDelta: part.delta\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tool-call\": {\n\t\t\t\t\t\tconst dynamic = isDynamic(part);\n\t\t\t\t\t\tif (part.invalid) controller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-input-error\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t\t...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},\n\t\t\t\t\t\t\t...dynamic != null ? { dynamic } : {},\n\t\t\t\t\t\t\terrorText: onError(part.error),\n\t\t\t\t\t\t\t...part.title != null ? { title: part.title } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\telse controller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-input-available\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\ttoolName: part.toolName,\n\t\t\t\t\t\t\tinput: part.input,\n\t\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t\t...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},\n\t\t\t\t\t\t\t...dynamic != null ? { dynamic } : {},\n\t\t\t\t\t\t\t...part.title != null ? { title: part.title } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"tool-approval-request\": {\n\t\t\t\t\t\tconst inputSchemaInput = getToolCallInputSchemaInput(part.toolCall);\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\t\t\t\tapprovalId: part.approvalId,\n\t\t\t\t\t\t\ttoolCallId: part.toolCall.toolCallId,\n\t\t\t\t\t\t\t...inputSchemaInput != null && !isDeepEqualData(inputSchemaInput.value, part.toolCall.input) ? { inputSchemaInput: inputSchemaInput.value } : {},\n\t\t\t\t\t\t\t...part.signature != null ? { signature: part.signature } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"tool-result\": {\n\t\t\t\t\t\tconst dynamic = isDynamic(part);\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-output-available\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\toutput: part.output === void 0 ? null : part.output,\n\t\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t\t...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},\n\t\t\t\t\t\t\t...part.preliminary != null ? { preliminary: part.preliminary } : {},\n\t\t\t\t\t\t\t...dynamic != null ? { dynamic } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"tool-error\": {\n\t\t\t\t\t\tconst dynamic = isDynamic(part);\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-output-error\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\terrorText: part.providerExecuted ? typeof part.error === \"string\" ? part.error : JSON.stringify(part.error) : onError(part.error),\n\t\t\t\t\t\t\t...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},\n\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},\n\t\t\t\t\t\t\t...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},\n\t\t\t\t\t\t\t...dynamic != null ? { dynamic } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"tool-output-denied\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"tool-output-denied\",\n\t\t\t\t\t\t\ttoolCallId: part.toolCallId\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terrorText: onError(part.error)\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"start-step\":\n\t\t\t\t\t\tcontroller.enqueue({ type: \"start-step\" });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"finish-step\":\n\t\t\t\t\t\tcontroller.enqueue({ type: \"finish-step\" });\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"start\":\n\t\t\t\t\t\tif (sendStart) controller.enqueue({\n\t\t\t\t\t\t\ttype: \"start\",\n\t\t\t\t\t\t\t...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {},\n\t\t\t\t\t\t\t...responseMessageId != null ? { messageId: responseMessageId } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\tif (sendFinish) controller.enqueue({\n\t\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\t\tfinishReason: part.finishReason,\n\t\t\t\t\t\t\t...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"abort\":\n\t\t\t\t\t\tcontroller.enqueue(part);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"tool-input-end\": break;\n\t\t\t\t\tcase \"raw\": break;\n\t\t\t\t\tdefault: throw new Error(`Unknown chunk type: ${partType}`);\n\t\t\t\t}\n\t\t\t\tif (messageMetadataValue != null && partType !== \"start\" && partType !== \"finish\") controller.enqueue({\n\t\t\t\t\ttype: \"message-metadata\",\n\t\t\t\t\tmessageMetadata: messageMetadataValue\n\t\t\t\t});\n\t\t\t\tif (part.type === \"finish\") setSourceOutcome({ status: \"completed\" });\n\t\t\t\telse if (part.type === \"abort\") setSourceOutcome({ status: \"aborted\" });\n\t\t\t\telse if (part.type === \"error\") setSourceOutcome({\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\terror: part.error\n\t\t\t\t});\n\t\t\t} }))),\n\t\t\tmessageId: responseMessageId != null ? responseMessageId : generateMessageId == null ? void 0 : generateMessageId(),\n\t\t\toriginalMessages,\n\t\t\tonFinish,\n\t\t\tonError,\n\t\t\tgetOutcome: () => outcome\n\t\t}));\n\t}\n\tpipeUIMessageStreamToResponse(response, { originalMessages, generateMessageId, onFinish, messageMetadata, sendReasoning, sendSources, sendFinish, sendStart, onError, ...init } = {}) {\n\t\treturn pipeUIMessageStreamToResponse({\n\t\t\tresponse,\n\t\t\tstream: this.toUIMessageStream({\n\t\t\t\toriginalMessages,\n\t\t\t\tgenerateMessageId,\n\t\t\t\tonFinish,\n\t\t\t\tmessageMetadata,\n\t\t\t\tsendReasoning,\n\t\t\t\tsendSources,\n\t\t\t\tsendFinish,\n\t\t\t\tsendStart,\n\t\t\t\tonError\n\t\t\t}),\n\t\t\t...init\n\t\t});\n\t}\n\tpipeTextStreamToResponse(response, init) {\n\t\treturn pipeTextStreamToResponse({\n\t\t\tresponse,\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n\ttoUIMessageStreamResponse({ originalMessages, generateMessageId, onFinish, messageMetadata, sendReasoning, sendSources, sendFinish, sendStart, onError, ...init } = {}) {\n\t\treturn createUIMessageStreamResponse({\n\t\t\tstream: this.toUIMessageStream({\n\t\t\t\toriginalMessages,\n\t\t\t\tgenerateMessageId,\n\t\t\t\tonFinish,\n\t\t\t\tmessageMetadata,\n\t\t\t\tsendReasoning,\n\t\t\t\tsendSources,\n\t\t\t\tsendFinish,\n\t\t\t\tsendStart,\n\t\t\t\tonError\n\t\t\t}),\n\t\t\t...init\n\t\t});\n\t}\n\ttoTextStreamResponse(init) {\n\t\treturn createTextStreamResponse({\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n};\nvar ToolLoopAgent = class {\n\tconstructor(settings) {\n\t\tthis.version = \"agent-v1\";\n\t\tthis.settings = settings;\n\t}\n\t/**\n\t* The id of the agent.\n\t*/\n\tget id() {\n\t\treturn this.settings.id;\n\t}\n\t/**\n\t* The tools that the agent can use.\n\t*/\n\tget tools() {\n\t\treturn this.settings.tools;\n\t}\n\tasync prepareCall(options) {\n\t\tvar _a23, _b, _c, _d;\n\t\tif (this.settings.callOptionsSchema != null && options.options !== void 0) {\n\t\t\tconst validatedOptions = await validateTypes({\n\t\t\t\tvalue: options.options,\n\t\t\t\tschema: this.settings.callOptionsSchema,\n\t\t\t\tcontext: { field: \"options\" }\n\t\t\t});\n\t\t\toptions = {\n\t\t\t\t...options,\n\t\t\t\toptions: validatedOptions\n\t\t\t};\n\t\t}\n\t\tconst { onStepFinish: _settingsOnStepFinish, ...settingsWithoutCallback } = this.settings;\n\t\tconst baseCallArgs = {\n\t\t\t...settingsWithoutCallback,\n\t\t\tstopWhen: (_a23 = this.settings.stopWhen) != null ? _a23 : stepCountIs(20),\n\t\t\t...options\n\t\t};\n\t\tconst { instructions, allowSystemInMessages, messages, prompt, ...callArgs } = (_d = await ((_c = (_b = this.settings).prepareCall) == null ? void 0 : _c.call(_b, baseCallArgs))) != null ? _d : baseCallArgs;\n\t\treturn {\n\t\t\t...callArgs,\n\t\t\tsystem: instructions,\n\t\t\tallowSystemInMessages,\n\t\t\tmessages,\n\t\t\tprompt\n\t\t};\n\t}\n\tmergeOnStepFinishCallbacks(methodCallback) {\n\t\tconst constructorCallback = this.settings.onStepFinish;\n\t\tif (methodCallback && constructorCallback) return async (stepResult) => {\n\t\t\tawait constructorCallback(stepResult);\n\t\t\tawait methodCallback(stepResult);\n\t\t};\n\t\treturn methodCallback != null ? methodCallback : constructorCallback;\n\t}\n\t/**\n\t* Generates an output from the agent (non-streaming).\n\t*/\n\tasync generate({ abortSignal, timeout, onStepFinish, ...options }) {\n\t\tconst preparedCall = await this.prepareCall(options);\n\t\treturn generateText({\n\t\t\t...preparedCall,\n\t\t\tabortSignal,\n\t\t\ttimeout: timeout != null ? timeout : preparedCall.timeout,\n\t\t\tonStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)\n\t\t});\n\t}\n\t/**\n\t* Streams an output from the agent (streaming).\n\t*/\n\tasync stream({ abortSignal, timeout, experimental_transform, onStepFinish, ...options }) {\n\t\tconst preparedCall = await this.prepareCall(options);\n\t\treturn streamText({\n\t\t\t...preparedCall,\n\t\t\tabortSignal,\n\t\t\ttimeout: timeout != null ? timeout : preparedCall.timeout,\n\t\t\texperimental_transform,\n\t\t\tonStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)\n\t\t});\n\t}\n};\nfunction createUIMessageStream({ execute, onError = () => \"An error occurred.\", originalMessages, onStepFinish, onFinish, generateId: generateId2 = generateId }) {\n\tlet controller;\n\tconst ongoingStreamPromises = [];\n\tlet outcome = { status: \"unknown\" };\n\tconst stream = new ReadableStream({ start(controllerArg) {\n\t\tcontroller = controllerArg;\n\t} });\n\tfunction safeEnqueue(data) {\n\t\ttry {\n\t\t\tcontroller.enqueue(data);\n\t\t} catch (error) {}\n\t}\n\tfunction setOutcome(newOutcome) {\n\t\tif (outcome.status === \"unknown\" && newOutcome.status !== \"unknown\") outcome = newOutcome;\n\t}\n\tfunction failOutcome(error) {\n\t\toutcome = {\n\t\t\tstatus: \"failed\",\n\t\t\terror\n\t\t};\n\t}\n\tfunction safeError(error) {\n\t\ttry {\n\t\t\tcontroller.error(error);\n\t\t} catch (e) {}\n\t}\n\tfunction handleError(error) {\n\t\tfailOutcome(error);\n\t\tlet errorText;\n\t\ttry {\n\t\t\terrorText = onError(error);\n\t\t} catch (onErrorError) {\n\t\t\tfailOutcome(onErrorError);\n\t\t\tsafeError(onErrorError);\n\t\t\treturn;\n\t\t}\n\t\tsafeEnqueue({\n\t\t\ttype: \"error\",\n\t\t\terrorText\n\t\t});\n\t}\n\ttry {\n\t\tconst result = execute({ writer: {\n\t\t\twrite(part) {\n\t\t\t\tsafeEnqueue(part);\n\t\t\t},\n\t\t\tmerge(streamArg) {\n\t\t\t\tongoingStreamPromises.push((async () => {\n\t\t\t\t\tconst reader = streamArg.getReader();\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\tif (done) break;\n\t\t\t\t\t\tsafeEnqueue(value);\n\t\t\t\t\t}\n\t\t\t\t})().catch((error) => {\n\t\t\t\t\thandleError(error);\n\t\t\t\t}));\n\t\t\t},\n\t\t\tsetOutcome,\n\t\t\tonError\n\t\t} });\n\t\tif (result) ongoingStreamPromises.push(result.catch((error) => {\n\t\t\thandleError(error);\n\t\t}));\n\t} catch (error) {\n\t\thandleError(error);\n\t}\n\t(async () => {\n\t\twhile (ongoingStreamPromises.length > 0) await ongoingStreamPromises.shift();\n\t})().finally(() => {\n\t\ttry {\n\t\t\tcontroller.close();\n\t\t} catch (error) {}\n\t});\n\treturn handleUIMessageStreamFinish({\n\t\tstream,\n\t\tmessageId: generateId2(),\n\t\toriginalMessages,\n\t\tonStepFinish,\n\t\tonFinish,\n\t\tonError,\n\t\tgetOutcome: () => outcome\n\t});\n}\nfunction createUIMessageSnapshot(message) {\n\tconst textByPartIndex = /* @__PURE__ */ new Map();\n\tconst messageWithoutText = {\n\t\t...message,\n\t\tparts: message.parts.map((part, index) => {\n\t\t\tif (part.type === \"text\" || part.type === \"reasoning\") {\n\t\t\t\ttextByPartIndex.set(index, part.text);\n\t\t\t\treturn {\n\t\t\t\t\t...part,\n\t\t\t\t\ttext: \"\"\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn part;\n\t\t})\n\t};\n\tconst snapshot = structuredClone(messageWithoutText);\n\tfor (const [index, text2] of textByPartIndex) {\n\t\tconst part = snapshot.parts[index];\n\t\tif (part.type === \"text\" || part.type === \"reasoning\") part.text = text2;\n\t}\n\treturn snapshot;\n}\nfunction readUIMessageStream({ message, stream, onError, terminateOnError = false }) {\n\tvar _a23;\n\tlet controller;\n\tlet hasErrored = false;\n\tlet isCancelled = false;\n\tconst abortController = new AbortController();\n\tconst outputStream = new ReadableStream({\n\t\tstart(controllerParam) {\n\t\t\tcontroller = controllerParam;\n\t\t},\n\t\tcancel() {\n\t\t\tisCancelled = true;\n\t\t\tabortController.abort();\n\t\t}\n\t});\n\tconst state = createStreamingUIMessageState({\n\t\tmessageId: (_a23 = message == null ? void 0 : message.id) != null ? _a23 : \"\",\n\t\tlastMessage: message\n\t});\n\tconst handleError = (error) => {\n\t\tonError?.(error);\n\t\tif (!hasErrored && terminateOnError) {\n\t\t\thasErrored = true;\n\t\t\tcontroller?.error(error);\n\t\t}\n\t};\n\tconsumeStream({\n\t\tstream: processUIMessageStream({\n\t\t\tstream,\n\t\t\tresetStateOnMessageIdChange: true,\n\t\t\trunUpdateMessageJob(job) {\n\t\t\t\treturn job({\n\t\t\t\t\tstate,\n\t\t\t\t\twrite: () => {\n\t\t\t\t\t\tif (!isCancelled) controller?.enqueue(createUIMessageSnapshot(state.message));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tonError: handleError\n\t\t}),\n\t\tonError: handleError,\n\t\tabortSignal: abortController.signal\n\t}).finally(() => {\n\t\tif (!hasErrored && !isCancelled) controller?.close();\n\t});\n\treturn createAsyncIterableStream(outputStream);\n}\nfunction getOwn(obj, key) {\n\treturn obj != null && Object.hasOwn(obj, key) ? obj[key] : void 0;\n}\nfunction markToolPartAsUnavailable(part) {\n\tpart.dynamic = false;\n\treturn part;\n}\nfunction isToolPartFromUnavailableTool(part) {\n\treturn part.type === \"dynamic-tool\" && part.dynamic === false;\n}\nasync function convertToModelMessages(messages, options) {\n\tconst modelMessages = [];\n\tif (options == null ? void 0 : options.ignoreIncompleteToolCalls) messages = messages.map((message) => ({\n\t\t...message,\n\t\tparts: message.parts.filter((part) => !isToolUIPart(part) || part.state === \"approval-responded\" || part.state === \"output-available\" && part.preliminary !== true || part.state === \"output-error\" || part.state === \"output-denied\")\n\t}));\n\tasync function createModelOutput({ toolPart, toolName, output, errorMode }) {\n\t\tconst tool2 = getOwn(options == null ? void 0 : options.tools, toolName);\n\t\tif (errorMode === \"none\" && tool2 == null && isToolPartFromUnavailableTool(toolPart)) return {\n\t\t\ttype: \"text\",\n\t\t\tvalue: \"Tool output omitted because the tool is no longer available.\"\n\t\t};\n\t\treturn createToolModelOutput({\n\t\t\ttoolCallId: toolPart.toolCallId,\n\t\t\tinput: toolPart.input,\n\t\t\toutput,\n\t\t\ttool: tool2,\n\t\t\terrorMode\n\t\t});\n\t}\n\tfor (const message of messages) switch (message.role) {\n\t\tcase \"system\": {\n\t\t\tconst textParts = message.parts.filter((part) => part.type === \"text\");\n\t\t\tconst providerMetadata = textParts.reduce((acc, part) => {\n\t\t\t\tif (part.providerMetadata != null) return {\n\t\t\t\t\t...acc,\n\t\t\t\t\t...part.providerMetadata\n\t\t\t\t};\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\t\t\tmodelMessages.push({\n\t\t\t\trole: \"system\",\n\t\t\t\tcontent: textParts.map((part) => part.text).join(\"\"),\n\t\t\t\t...Object.keys(providerMetadata).length > 0 ? { providerOptions: providerMetadata } : {}\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tcase \"user\":\n\t\t\tmodelMessages.push({\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: message.parts.map((part) => {\n\t\t\t\t\tvar _a23;\n\t\t\t\t\tif (isTextUIPart(part)) return {\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t};\n\t\t\t\t\tif (isFileUIPart(part)) return {\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: part.mediaType,\n\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\tdata: part.url,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t};\n\t\t\t\t\tif (isDataUIPart(part)) return (_a23 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a23.call(options, part);\n\t\t\t\t}).filter(isNonNullable)\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"assistant\":\n\t\t\tif (message.parts != null) {\n\t\t\t\tlet block = [];\n\t\t\t\tasync function processBlock() {\n\t\t\t\t\tvar _a23, _b, _c, _d, _e, _f, _g;\n\t\t\t\t\tif (block.length === 0) return;\n\t\t\t\t\tconst content = [];\n\t\t\t\t\tfor (const part of block) if (isTextUIPart(part)) content.push({\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\telse if (isFileUIPart(part)) content.push({\n\t\t\t\t\t\ttype: \"file\",\n\t\t\t\t\t\tmediaType: part.mediaType,\n\t\t\t\t\t\tfilename: part.filename,\n\t\t\t\t\t\tdata: part.url,\n\t\t\t\t\t\t...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}\n\t\t\t\t\t});\n\t\t\t\t\telse if (isReasoningUIPart(part)) content.push({\n\t\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\t\ttext: part.text,\n\t\t\t\t\t\tproviderOptions: part.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\telse if (isToolUIPart(part)) {\n\t\t\t\t\t\tconst toolName = getToolName(part);\n\t\t\t\t\t\tif (part.state !== \"input-streaming\") {\n\t\t\t\t\t\t\tconst callProviderMetadata = (_a23 = part.callProviderMetadata) != null ? _a23 : part.state === \"output-error\" ? part.resultProviderMetadata : void 0;\n\t\t\t\t\t\t\tcontent.push({\n\t\t\t\t\t\t\t\ttype: \"tool-call\",\n\t\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\tinput: part.state === \"output-error\" ? (_b = part.input) != null ? _b : \"rawInput\" in part ? part.rawInput : void 0 : part.input,\n\t\t\t\t\t\t\t\tproviderExecuted: part.providerExecuted,\n\t\t\t\t\t\t\t\t...callProviderMetadata != null ? { providerOptions: callProviderMetadata } : {}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (part.approval != null) content.push({\n\t\t\t\t\t\t\t\ttype: \"tool-approval-request\",\n\t\t\t\t\t\t\t\tapprovalId: part.approval.id,\n\t\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\t\t...Object.prototype.hasOwnProperty.call(part.approval, \"inputSchemaInput\") ? { inputSchemaInput: part.approval.inputSchemaInput } : {},\n\t\t\t\t\t\t\t\t...part.approval.signature != null ? { signature: part.approval.signature } : {}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (part.providerExecuted === true && part.state !== \"approval-responded\" && (part.state === \"output-available\" || part.state === \"output-error\")) {\n\t\t\t\t\t\t\t\tconst resultProviderMetadata = (_c = part.resultProviderMetadata) != null ? _c : part.callProviderMetadata;\n\t\t\t\t\t\t\t\tcontent.push({\n\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\ttoolCallId: part.toolCallId,\n\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\toutput: await createModelOutput({\n\t\t\t\t\t\t\t\t\t\ttoolPart: part,\n\t\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\t\toutput: part.state === \"output-error\" ? part.errorText : part.output,\n\t\t\t\t\t\t\t\t\t\terrorMode: part.state === \"output-error\" ? \"json\" : \"none\"\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t...resultProviderMetadata != null ? { providerOptions: resultProviderMetadata } : {}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (isDataUIPart(part)) {\n\t\t\t\t\t\tconst dataPart = (_d = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _d.call(options, part);\n\t\t\t\t\t\tif (dataPart != null) content.push(dataPart);\n\t\t\t\t\t} else throw new Error(`Unsupported part: ${part}`);\n\t\t\t\t\tif (content.length > 0) modelMessages.push({\n\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\tcontent\n\t\t\t\t\t});\n\t\t\t\t\tconst toolParts = block.filter((part) => {\n\t\t\t\t\t\tvar _a24;\n\t\t\t\t\t\treturn isToolUIPart(part) && (part.providerExecuted !== true || ((_a24 = part.approval) == null ? void 0 : _a24.approved) != null);\n\t\t\t\t\t});\n\t\t\t\t\tif (toolParts.length > 0) {\n\t\t\t\t\t\tconst content2 = [];\n\t\t\t\t\t\tfor (const toolPart of toolParts) {\n\t\t\t\t\t\t\tif (((_e = toolPart.approval) == null ? void 0 : _e.approved) != null) content2.push({\n\t\t\t\t\t\t\t\ttype: \"tool-approval-response\",\n\t\t\t\t\t\t\t\tapprovalId: toolPart.approval.id,\n\t\t\t\t\t\t\t\tapproved: toolPart.approval.approved,\n\t\t\t\t\t\t\t\treason: toolPart.approval.reason,\n\t\t\t\t\t\t\t\tproviderExecuted: toolPart.providerExecuted\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (toolPart.providerExecuted === true) continue;\n\t\t\t\t\t\t\tswitch (toolPart.state) {\n\t\t\t\t\t\t\t\tcase \"output-denied\":\n\t\t\t\t\t\t\t\t\tcontent2.push({\n\t\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\t\ttoolCallId: toolPart.toolCallId,\n\t\t\t\t\t\t\t\t\t\ttoolName: getToolName(toolPart),\n\t\t\t\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\t\t\t\ttype: \"error-text\",\n\t\t\t\t\t\t\t\t\t\t\tvalue: (_g = (_f = toolPart.approval) == null ? void 0 : _f.reason) != null ? _g : \"Tool call execution denied.\"\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase \"output-error\":\n\t\t\t\t\t\t\t\tcase \"output-available\": {\n\t\t\t\t\t\t\t\t\tconst toolName = getToolName(toolPart);\n\t\t\t\t\t\t\t\t\tcontent2.push({\n\t\t\t\t\t\t\t\t\t\ttype: \"tool-result\",\n\t\t\t\t\t\t\t\t\t\ttoolCallId: toolPart.toolCallId,\n\t\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\t\toutput: await createModelOutput({\n\t\t\t\t\t\t\t\t\t\t\ttoolPart,\n\t\t\t\t\t\t\t\t\t\t\ttoolName,\n\t\t\t\t\t\t\t\t\t\t\toutput: toolPart.state === \"output-error\" ? toolPart.errorText : toolPart.output,\n\t\t\t\t\t\t\t\t\t\t\terrorMode: toolPart.state === \"output-error\" ? \"text\" : \"none\"\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (content2.length > 0) modelMessages.push({\n\t\t\t\t\t\t\trole: \"tool\",\n\t\t\t\t\t\t\tcontent: content2\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tblock = [];\n\t\t\t\t}\n\t\t\t\tfor (const part of message.parts) if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) || isToolUIPart(part) || isDataUIPart(part)) block.push(part);\n\t\t\t\telse if (part.type === \"step-start\") await processBlock();\n\t\t\t\tawait processBlock();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst _exhaustiveCheck = message.role;\n\t\t\tthrow new MessageConversionError({\n\t\t\t\toriginalMessage: message,\n\t\t\t\tmessage: `Unsupported role: ${_exhaustiveCheck}`\n\t\t\t});\n\t\t}\n\t}\n\treturn modelMessages;\n}\nvar toolMetadataSchema2 = z.record(z.string(), jsonValueSchema.optional());\nfunction isEmptyObject(value) {\n\treturn value != null && typeof value === \"object\" && !Array.isArray(value) && Object.keys(value).length === 0;\n}\nfunction asDynamicToolPart(toolPart) {\n\tconst { type, ...part } = toolPart;\n\treturn markToolPartAsUnavailable({\n\t\t...part,\n\t\ttype: \"dynamic-tool\",\n\t\ttoolName: type.slice(5)\n\t});\n}\nfunction getToolPartInputSchemaInput(toolPart) {\n\treturn toolPart.approval != null && Object.prototype.hasOwnProperty.call(toolPart.approval, \"inputSchemaInput\") ? { value: toolPart.approval.inputSchemaInput } : void 0;\n}\nvar uiMessagesSchema = lazySchema(() => {\n\tconst approvalRequestedSchema = z.object({\n\t\tid: z.string(),\n\t\tapproved: z.never().optional(),\n\t\tdescriptor: z.unknown().optional(),\n\t\treason: z.never().optional(),\n\t\tsignature: z.string().optional(),\n\t\tinputSchemaInput: z.unknown().optional()\n\t});\n\tconst approvalRespondedSchema = approvalRequestedSchema.extend({\n\t\tapproved: z.boolean(),\n\t\treason: z.string().optional()\n\t});\n\tconst approvalGrantedSchema = approvalRespondedSchema.extend({ approved: z.literal(true) });\n\tconst approvalDeniedSchema = approvalRespondedSchema.extend({ approved: z.literal(false) });\n\treturn zodSchema(z.array(z.object({\n\t\tid: z.string(),\n\t\trole: z.enum([\n\t\t\t\"system\",\n\t\t\t\"user\",\n\t\t\t\"assistant\"\n\t\t]),\n\t\tmetadata: z.unknown().optional(),\n\t\tparts: z.array(z.union([\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"text\"),\n\t\t\t\ttext: z.string(),\n\t\t\t\tstate: z.enum([\"streaming\", \"done\"]).optional(),\n\t\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"reasoning\"),\n\t\t\t\tid: z.string().optional(),\n\t\t\t\ttext: z.string(),\n\t\t\t\tstate: z.enum([\"streaming\", \"done\"]).optional(),\n\t\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"source-url\"),\n\t\t\t\tsourceId: z.string(),\n\t\t\t\turl: z.string(),\n\t\t\t\ttitle: z.string().optional(),\n\t\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"source-document\"),\n\t\t\t\tsourceId: z.string(),\n\t\t\t\tmediaType: z.string(),\n\t\t\t\ttitle: z.string(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"file\"),\n\t\t\t\tmediaType: z.string(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\turl: z.string(),\n\t\t\t\tproviderMetadata: providerMetadataSchema.optional()\n\t\t\t}),\n\t\t\tz.object({ type: z.literal(\"step-start\") }),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"data-\"),\n\t\t\t\tid: z.string().optional(),\n\t\t\t\tdata: z.unknown()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"input-streaming\"),\n\t\t\t\tinput: z.unknown().optional(),\n\t\t\t\trawInput: z.string().optional(),\n\t\t\t\tinputEncoding: z.enum([\"json\", \"text\"]).optional(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tapproval: z.never().optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"input-available\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: z.never().optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"approval-requested\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalRequestedSchema\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"approval-responded\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalRespondedSchema\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"output-available\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.unknown(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tresultProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tpreliminary: z.boolean().optional(),\n\t\t\t\tapproval: approvalGrantedSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"output-error\"),\n\t\t\t\tinput: z.unknown().optional(),\n\t\t\t\trawInput: z.unknown().optional(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.string(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tresultProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalGrantedSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.literal(\"dynamic-tool\"),\n\t\t\t\tdynamic: z.literal(false).optional(),\n\t\t\t\ttoolName: z.string(),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"output-denied\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalDeniedSchema\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"input-streaming\"),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tinput: z.unknown().optional(),\n\t\t\t\trawInput: z.string().optional(),\n\t\t\t\tinputEncoding: z.enum([\"json\", \"text\"]).optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tapproval: z.never().optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"input-available\"),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: z.never().optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"approval-requested\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalRequestedSchema\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"approval-responded\"),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalRespondedSchema\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"output-available\"),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\toutput: z.unknown(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tresultProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tpreliminary: z.boolean().optional(),\n\t\t\t\tapproval: approvalGrantedSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"output-error\"),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\tinput: z.unknown().optional(),\n\t\t\t\trawInput: z.unknown().optional(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.string(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tresultProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalGrantedSchema.optional()\n\t\t\t}),\n\t\t\tz.object({\n\t\t\t\ttype: z.string().startsWith(\"tool-\"),\n\t\t\t\ttoolCallId: z.string(),\n\t\t\t\ttoolMetadata: toolMetadataSchema2.optional(),\n\t\t\t\tstate: z.literal(\"output-denied\"),\n\t\t\t\tproviderExecuted: z.boolean().optional(),\n\t\t\t\tinput: z.unknown(),\n\t\t\t\toutput: z.never().optional(),\n\t\t\t\terrorText: z.never().optional(),\n\t\t\t\tcallProviderMetadata: providerMetadataSchema.optional(),\n\t\t\t\tapproval: approvalDeniedSchema\n\t\t\t})\n\t\t]))\n\t}).superRefine((message, context2) => {\n\t\tif (message.role !== \"assistant\" && message.parts.length === 0) context2.addIssue({\n\t\t\torigin: \"array\",\n\t\t\tcode: \"too_small\",\n\t\t\tminimum: 1,\n\t\t\tinclusive: true,\n\t\t\tinput: message.parts,\n\t\t\tpath: [\"parts\"],\n\t\t\tmessage: \"Message must contain at least one part\"\n\t\t});\n\t})).nonempty(\"Messages array must not be empty\"));\n});\nasync function safeValidateUIMessagesInternal({ messages, metadataSchema, dataSchemas, tools }, { convertMissingTerminalToolsToDynamic }) {\n\ttry {\n\t\tif (messages == null) return {\n\t\t\tsuccess: false,\n\t\t\terror: new InvalidArgumentError({\n\t\t\t\tparameter: \"messages\",\n\t\t\t\tvalue: messages,\n\t\t\t\tmessage: \"messages parameter must be provided\"\n\t\t\t})\n\t\t};\n\t\tconst validatedMessages = await validateTypes({\n\t\t\tvalue: messages,\n\t\t\tschema: uiMessagesSchema\n\t\t});\n\t\tif (metadataSchema) for (const [msgIdx, message] of validatedMessages.entries()) message.metadata = await validateTypes({\n\t\t\tvalue: message.metadata,\n\t\t\tschema: metadataSchema,\n\t\t\tcontext: {\n\t\t\t\tfield: `messages[${msgIdx}].metadata`,\n\t\t\t\tentityId: message.id\n\t\t\t}\n\t\t});\n\t\tconst shouldValidateToolParts = tools != null || convertMissingTerminalToolsToDynamic;\n\t\tif (dataSchemas || shouldValidateToolParts) for (const [msgIdx, message] of validatedMessages.entries()) for (const [partIdx, part] of message.parts.entries()) {\n\t\t\tif (dataSchemas && part.type.startsWith(\"data-\")) {\n\t\t\t\tconst dataPart = part;\n\t\t\t\tconst dataName = dataPart.type.slice(5);\n\t\t\t\tconst dataSchema = dataSchemas[dataName];\n\t\t\t\tif (!dataSchema) return {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\t\tvalue: dataPart.data,\n\t\t\t\t\t\tcause: `No data schema found for data part ${dataName}`,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tfield: `messages[${msgIdx}].parts[${partIdx}].data`,\n\t\t\t\t\t\t\tentityName: dataName,\n\t\t\t\t\t\t\tentityId: dataPart.id\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t\tdataPart.data = await validateTypes({\n\t\t\t\t\tvalue: dataPart.data,\n\t\t\t\t\tschema: dataSchema,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tfield: `messages[${msgIdx}].parts[${partIdx}].data`,\n\t\t\t\t\t\tentityName: dataName,\n\t\t\t\t\t\tentityId: dataPart.id\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (shouldValidateToolParts && part.type.startsWith(\"tool-\")) {\n\t\t\t\tconst toolPart = part;\n\t\t\t\tconst toolName = toolPart.type.slice(5);\n\t\t\t\tconst tool2 = getOwn(tools, toolName);\n\t\t\t\tconst isTerminal = toolPart.state === \"output-available\" || toolPart.state === \"output-error\" || toolPart.state === \"output-denied\";\n\t\t\t\tif (!tool2 && isTerminal) {\n\t\t\t\t\tif (tools != null || convertMissingTerminalToolsToDynamic) message.parts[partIdx] = asDynamicToolPart(toolPart);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!tool2) return {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\t\tvalue: toolPart.input,\n\t\t\t\t\t\tcause: `No tool schema found for tool part ${toolName}`,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tfield: `messages[${msgIdx}].parts[${partIdx}].input`,\n\t\t\t\t\t\t\tentityName: toolName,\n\t\t\t\t\t\t\tentityId: toolPart.toolCallId\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t\tconst inputValidationContext = {\n\t\t\t\t\tfield: `messages[${msgIdx}].parts[${partIdx}].input`,\n\t\t\t\t\tentityName: toolName,\n\t\t\t\t\tentityId: toolPart.toolCallId\n\t\t\t\t};\n\t\t\t\tconst inputSchemaInput = getToolPartInputSchemaInput(toolPart);\n\t\t\t\tconst inputToValidate = inputSchemaInput == null ? toolPart.input : inputSchemaInput.value;\n\t\t\t\tlet convertToDynamic = false;\n\t\t\t\tif (toolPart.state !== \"input-streaming\" && (toolPart.state !== \"output-error\" || inputSchemaInput != null || toolPart.input !== void 0)) {\n\t\t\t\t\tconst result = await safeValidateTypes({\n\t\t\t\t\t\tvalue: inputToValidate,\n\t\t\t\t\t\tschema: tool2.inputSchema,\n\t\t\t\t\t\tcontext: inputValidationContext\n\t\t\t\t\t});\n\t\t\t\t\tlet inputError;\n\t\t\t\t\tif (!result.success) inputError = result.error;\n\t\t\t\t\telse if (inputSchemaInput != null) {\n\t\t\t\t\t\tif (!isDeepEqualData(result.value, toolPart.input)) inputError = new TypeValidationError({\n\t\t\t\t\t\t\tvalue: toolPart.input,\n\t\t\t\t\t\t\tcause: \"Tool input does not match the output reconstructed from inputSchemaInput.\",\n\t\t\t\t\t\t\tcontext: inputValidationContext\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (inputError != null) {\n\t\t\t\t\t\tif (toolPart.state === \"output-error\" || toolPart.state === \"output-available\" && isEmptyObject(toolPart.input)) convertToDynamic = true;\n\t\t\t\t\t\telse throw inputError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (toolPart.state === \"output-available\" && tool2.outputSchema) await validateTypes({\n\t\t\t\t\tvalue: toolPart.output,\n\t\t\t\t\tschema: tool2.outputSchema,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tfield: `messages[${msgIdx}].parts[${partIdx}].output`,\n\t\t\t\t\t\tentityName: toolName,\n\t\t\t\t\t\tentityId: toolPart.toolCallId\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (convertToDynamic) message.parts[partIdx] = asDynamicToolPart(toolPart);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: validatedMessages\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror\n\t\t};\n\t}\n}\nasync function safeValidateUIMessages(options) {\n\treturn safeValidateUIMessagesInternal(options, { convertMissingTerminalToolsToDynamic: false });\n}\nasync function validateUIMessages(options) {\n\tconst response = await safeValidateUIMessages(options);\n\tif (!response.success) throw response.error;\n\treturn response.data;\n}\nasync function validateUIMessagesForAgent(options) {\n\tconst response = await safeValidateUIMessagesInternal(options, { convertMissingTerminalToolsToDynamic: true });\n\tif (!response.success) throw response.error;\n\treturn response.data;\n}\nasync function createAgentUIStream({ agent, uiMessages, options, abortSignal, timeout, experimental_transform, onStepFinish, ...uiMessageStreamOptions }) {\n\tvar _a23;\n\tconst validatedMessages = await validateUIMessagesForAgent({\n\t\tmessages: uiMessages != null ? uiMessages : uiMessageStreamOptions.originalMessages,\n\t\ttools: agent.tools\n\t});\n\tconst modelMessages = await convertToModelMessages(validatedMessages, { tools: agent.tools });\n\treturn (await agent.stream({\n\t\tprompt: modelMessages,\n\t\toptions,\n\t\tabortSignal,\n\t\ttimeout,\n\t\texperimental_transform,\n\t\tonStepFinish\n\t})).toUIMessageStream({\n\t\t...uiMessageStreamOptions,\n\t\toriginalMessages: (_a23 = uiMessageStreamOptions.originalMessages) != null ? _a23 : validatedMessages\n\t});\n}\nasync function createAgentUIStreamResponse({ headers, status, statusText, keepAliveMs, consumeSseStream, ...options }) {\n\treturn createUIMessageStreamResponse({\n\t\theaders,\n\t\tstatus,\n\t\tstatusText,\n\t\tkeepAliveMs,\n\t\tconsumeSseStream,\n\t\tstream: await createAgentUIStream(options)\n\t});\n}\nasync function pipeAgentUIStreamToResponse({ response, headers, status, statusText, keepAliveMs, consumeSseStream, ...options }) {\n\treturn pipeUIMessageStreamToResponse({\n\t\tresponse,\n\t\theaders,\n\t\tstatus,\n\t\tstatusText,\n\t\tkeepAliveMs,\n\t\tconsumeSseStream,\n\t\tstream: await createAgentUIStream(options)\n\t});\n}\nasync function embed({ model: modelArg, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry }) {\n\tconst model = resolveEmbeddingModel(modelArg);\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.embed\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.embed\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.value\": { input: () => JSON.stringify(value) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tconst { embedding, usage, warnings, response, providerMetadata } = await retry(() => recordSpan({\n\t\t\t\tname: \"ai.embed.doEmbed\",\n\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\toperationId: \"ai.embed.doEmbed\",\n\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\"ai.values\": { input: () => [JSON.stringify(value)] }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttracer,\n\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\tvar _a23, _b;\n\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\tvalues: [value],\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t});\n\t\t\t\t\tconst embedding2 = modelResponse.embeddings[0];\n\t\t\t\t\tconst usage2 = (_a23 = modelResponse.usage) != null ? _a23 : { tokens: NaN };\n\t\t\t\t\tdoEmbedSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => modelResponse.embeddings.map((embedding3) => JSON.stringify(embedding3)) },\n\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\tif (embedding2 == null) throw new InvalidResponseDataError({\n\t\t\t\t\t\tdata: modelResponse.embeddings,\n\t\t\t\t\t\tmessage: \"No embedding generated.\"\n\t\t\t\t\t});\n\t\t\t\t\treturn {\n\t\t\t\t\t\tembedding: embedding2,\n\t\t\t\t\t\tusage: usage2,\n\t\t\t\t\t\twarnings: (_b = modelResponse.warnings) != null ? _b : [],\n\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\tresponse: modelResponse.response\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}));\n\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.embedding\": { output: () => JSON.stringify(embedding) },\n\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\tlogWarnings({\n\t\t\t\twarnings,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.modelId\n\t\t\t});\n\t\t\treturn new DefaultEmbedResult({\n\t\t\t\tvalue,\n\t\t\t\tembedding,\n\t\t\t\tusage,\n\t\t\t\twarnings,\n\t\t\t\tproviderMetadata,\n\t\t\t\tresponse\n\t\t\t});\n\t\t}\n\t});\n}\nvar DefaultEmbedResult = class {\n\tconstructor(options) {\n\t\tthis.value = options.value;\n\t\tthis.embedding = options.embedding;\n\t\tthis.usage = options.usage;\n\t\tthis.warnings = options.warnings;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.response = options.response;\n\t}\n};\nfunction setOwn(object2, key, value) {\n\tObject.defineProperty(object2, key, {\n\t\tvalue,\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t\twritable: true\n\t});\n}\nfunction getEmbeddingModelMaxInputBytesPerCall(model) {\n\treturn model[EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL];\n}\nfunction getEmbeddingModelProviderOptionsTransformer(model) {\n\treturn model[EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER];\n}\nfunction splitArray(array2, chunkSize) {\n\tif (chunkSize <= 0) throw new Error(\"chunkSize must be greater than 0\");\n\tconst result = [];\n\tfor (let i = 0; i < array2.length; i += chunkSize) result.push(array2.slice(i, i + chunkSize));\n\treturn result;\n}\nasync function embedMany({ model: modelArg, values, maxParallelCalls = Infinity, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry }) {\n\tconst model = resolveEmbeddingModel(modelArg);\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.embedMany\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.embedMany\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.values\": { input: () => values.map((value) => JSON.stringify(value)) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async (span) => {\n\t\t\tconst [maxEmbeddingsPerCall, maxInputBytesPerCall, supportsParallelCalls] = await Promise.all([\n\t\t\t\tmodel.maxEmbeddingsPerCall,\n\t\t\t\tgetEmbeddingModelMaxInputBytesPerCall(model),\n\t\t\t\tmodel.supportsParallelCalls\n\t\t\t]);\n\t\t\tconst hasEmbeddingLimit = maxEmbeddingsPerCall != null && maxEmbeddingsPerCall !== Infinity;\n\t\t\tconst hasInputByteLimit = maxInputBytesPerCall != null && maxInputBytesPerCall !== Infinity;\n\t\t\tif (!hasEmbeddingLimit && !hasInputByteLimit) {\n\t\t\t\tconst { embeddings: embeddings2, usage, warnings: warnings2, response, providerMetadata: providerMetadata2 } = await retry(() => {\n\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\tname: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\toperationId: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\"ai.values\": { input: () => values.map((value) => JSON.stringify(value)) }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\ttracer,\n\t\t\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\t\t\tvar _a23, _b;\n\t\t\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\t\t\tvalues,\n\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\t\t\t\tproviderOptions\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst embeddings3 = modelResponse.embeddings;\n\t\t\t\t\t\t\tconst usage2 = (_a23 = modelResponse.usage) != null ? _a23 : { tokens: NaN };\n\t\t\t\t\t\t\tdoEmbedSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings3.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\t\t\t\"ai.usage.tokens\": usage2.tokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tembeddings: embeddings3,\n\t\t\t\t\t\t\t\tusage: usage2,\n\t\t\t\t\t\t\t\twarnings: (_b = modelResponse.warnings) != null ? _b : [],\n\t\t\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\t\t\tresponse: modelResponse.response\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings2.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tlogWarnings({\n\t\t\t\t\twarnings: warnings2,\n\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\tmodel: model.modelId\n\t\t\t\t});\n\t\t\t\treturn new DefaultEmbedManyResult({\n\t\t\t\t\tvalues,\n\t\t\t\t\tembeddings: embeddings2,\n\t\t\t\t\tusage,\n\t\t\t\t\twarnings: warnings2,\n\t\t\t\t\tproviderMetadata: providerMetadata2,\n\t\t\t\t\tresponses: [response]\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst valueChunks = splitByEmbeddingLimits({\n\t\t\t\tvalues,\n\t\t\t\tmaxEmbeddingsPerCall: hasEmbeddingLimit ? maxEmbeddingsPerCall : Infinity,\n\t\t\t\tmaxInputBytesPerCall: hasInputByteLimit ? maxInputBytesPerCall : Infinity\n\t\t\t});\n\t\t\tconst providerOptionsTransformer = getEmbeddingModelProviderOptionsTransformer(model);\n\t\t\tconst embeddings = [];\n\t\t\tconst warnings = [];\n\t\t\tconst responses = [];\n\t\t\tlet tokens = 0;\n\t\t\tlet providerMetadata;\n\t\t\tconst parallelChunks = splitArray(valueChunks, supportsParallelCalls ? maxParallelCalls : 1);\n\t\t\tlet nextChunkStartIndex = 0;\n\t\t\tfor (const parallelChunk of parallelChunks) {\n\t\t\t\tconst results = await Promise.all(parallelChunk.map(async (chunk) => {\n\t\t\t\t\tconst startIndex = nextChunkStartIndex;\n\t\t\t\t\tnextChunkStartIndex += chunk.length;\n\t\t\t\t\tconst chunkProviderOptions = providerOptionsTransformer ? await providerOptionsTransformer({\n\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\tvalues,\n\t\t\t\t\t\tstartIndex,\n\t\t\t\t\t\tendIndex: startIndex + chunk.length\n\t\t\t\t\t}) : providerOptions;\n\t\t\t\t\treturn retry(() => {\n\t\t\t\t\t\treturn recordSpan({\n\t\t\t\t\t\t\tname: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\t\t\toperationId: \"ai.embedMany.doEmbed\",\n\t\t\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\t\t\"ai.values\": { input: () => chunk.map((value) => JSON.stringify(value)) }\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\ttracer,\n\t\t\t\t\t\t\tfn: async (doEmbedSpan) => {\n\t\t\t\t\t\t\t\tvar _a23, _b;\n\t\t\t\t\t\t\t\tconst modelResponse = await model.doEmbed({\n\t\t\t\t\t\t\t\t\tvalues: chunk,\n\t\t\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\t\t\t\t\tproviderOptions: chunkProviderOptions\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst embeddings2 = modelResponse.embeddings;\n\t\t\t\t\t\t\t\tconst usage = (_a23 = modelResponse.usage) != null ? _a23 : { tokens: NaN };\n\t\t\t\t\t\t\t\tdoEmbedSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings2.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\t\t\t\t\t\"ai.usage.tokens\": usage.tokens\n\t\t\t\t\t\t\t\t\t}\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\t\tembeddings: embeddings2,\n\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\twarnings: (_b = modelResponse.warnings) != null ? _b : [],\n\t\t\t\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\t\t\t\tresponse: modelResponse.response\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}));\n\t\t\t\tfor (const result of results) {\n\t\t\t\t\tembeddings.push(...result.embeddings);\n\t\t\t\t\twarnings.push(...result.warnings);\n\t\t\t\t\tresponses.push(result.response);\n\t\t\t\t\ttokens += result.usage.tokens;\n\t\t\t\t\tif (result.providerMetadata) {\n\t\t\t\t\t\tif (!providerMetadata) providerMetadata = { ...result.providerMetadata };\n\t\t\t\t\t\telse for (const [providerName, metadata] of Object.entries(result.providerMetadata)) setOwn(providerMetadata, providerName, {\n\t\t\t\t\t\t\t...getOwn(providerMetadata, providerName),\n\t\t\t\t\t\t\t...metadata\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t\"ai.embeddings\": { output: () => embeddings.map((embedding) => JSON.stringify(embedding)) },\n\t\t\t\t\t\"ai.usage.tokens\": tokens\n\t\t\t\t}\n\t\t\t}));\n\t\t\tlogWarnings({\n\t\t\t\twarnings,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.modelId\n\t\t\t});\n\t\t\treturn new DefaultEmbedManyResult({\n\t\t\t\tvalues,\n\t\t\t\tembeddings,\n\t\t\t\tusage: { tokens },\n\t\t\t\twarnings,\n\t\t\t\tproviderMetadata,\n\t\t\t\tresponses\n\t\t\t});\n\t\t}\n\t});\n}\nvar textEncoder = new TextEncoder();\nfunction splitByEmbeddingLimits({ values, maxEmbeddingsPerCall, maxInputBytesPerCall }) {\n\tif (maxEmbeddingsPerCall <= 0) throw new Error(\"maxEmbeddingsPerCall must be greater than 0\");\n\tif (maxInputBytesPerCall <= 0) throw new Error(\"maxInputBytesPerCall must be greater than 0\");\n\tif (values.length === 0) return [];\n\tconst chunks = [];\n\tlet currentChunk = [];\n\tlet currentInputBytes = 0;\n\tfor (const value of values) {\n\t\tconst inputBytes = textEncoder.encode(value).length;\n\t\tif (currentChunk.length > 0 && (currentChunk.length >= maxEmbeddingsPerCall || currentInputBytes + inputBytes > maxInputBytesPerCall)) {\n\t\t\tchunks.push(currentChunk);\n\t\t\tcurrentChunk = [];\n\t\t\tcurrentInputBytes = 0;\n\t\t}\n\t\tcurrentChunk.push(value);\n\t\tcurrentInputBytes += inputBytes;\n\t}\n\tchunks.push(currentChunk);\n\treturn chunks;\n}\nvar DefaultEmbedManyResult = class {\n\tconstructor(options) {\n\t\tthis.values = options.values;\n\t\tthis.embeddings = options.embeddings;\n\t\tthis.usage = options.usage;\n\t\tthis.warnings = options.warnings;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.responses = options.responses;\n\t}\n};\nvar RetryableNoImageResultError = class extends Error {\n\tconstructor() {\n\t\tsuper(\"No image generated.\");\n\t\tthis.name = \"RetryableNoImageResultError\";\n\t}\n};\nasync function generateImage({ model: modelArg, prompt: promptArg, n = 1, maxImagesPerCall, size, aspectRatio, seed, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tvar _a23, _b;\n\tconst model = resolveImageModel(modelArg);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal,\n\t\tadditionalRetryableError: (error) => error instanceof RetryableNoImageResultError\n\t});\n\tconst maxImagesPerCallWithDefault = (_a23 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a23 : 1;\n\tconst callCount = Math.ceil(n / maxImagesPerCallWithDefault);\n\tconst callImageCounts = Array.from({ length: callCount }, (_, i) => {\n\t\tif (i < callCount - 1) return maxImagesPerCallWithDefault;\n\t\tconst remainder = n % maxImagesPerCallWithDefault;\n\t\treturn remainder === 0 ? maxImagesPerCallWithDefault : remainder;\n\t});\n\tconst results = (await Promise.all(callImageCounts.map(async (callImageCount) => {\n\t\tconst callResults = [];\n\t\ttry {\n\t\t\tawait retry(async () => {\n\t\t\t\tconst { prompt, files, mask } = normalizePrompt(promptArg);\n\t\t\t\tconst result = await model.doGenerate({\n\t\t\t\t\tprompt,\n\t\t\t\t\tfiles,\n\t\t\t\t\tmask,\n\t\t\t\t\tn: callImageCount,\n\t\t\t\t\tabortSignal,\n\t\t\t\t\theaders: headersWithUserAgent,\n\t\t\t\t\tsize,\n\t\t\t\t\taspectRatio,\n\t\t\t\t\tseed,\n\t\t\t\t\tproviderOptions: providerOptions != null ? providerOptions : {}\n\t\t\t\t});\n\t\t\t\tcallResults.push(result);\n\t\t\t\tif (result.images.length === 0 && result.isRetryable !== false) throw new RetryableNoImageResultError();\n\t\t\t\treturn result;\n\t\t\t});\n\t\t\treturn callResults;\n\t\t} catch (error) {\n\t\t\tif ((error instanceof RetryableNoImageResultError ? error : RetryError.isInstance(error) && error.lastError instanceof RetryableNoImageResultError ? error.lastError : void 0) != null) return callResults;\n\t\t\tthrow error;\n\t\t}\n\t}))).flat();\n\tconst images = [];\n\tconst warnings = [];\n\tconst responses = [];\n\tconst providerMetadata = {};\n\tlet totalUsage = {\n\t\tinputTokens: void 0,\n\t\toutputTokens: void 0,\n\t\ttotalTokens: void 0\n\t};\n\tfor (const result of results) {\n\t\timages.push(...result.images.map((image) => {\n\t\t\tvar _a24;\n\t\t\treturn new DefaultGeneratedFile({\n\t\t\t\tdata: image,\n\t\t\t\tmediaType: (_a24 = detectMediaType({\n\t\t\t\t\tdata: image,\n\t\t\t\t\tsignatures: imageMediaTypeSignatures\n\t\t\t\t})) != null ? _a24 : \"image/png\"\n\t\t\t});\n\t\t}));\n\t\twarnings.push(...result.warnings);\n\t\tif (result.usage != null) totalUsage = addImageModelUsage(totalUsage, result.usage);\n\t\tif (result.providerMetadata) for (const [providerName, metadata] of Object.entries(result.providerMetadata)) if (providerName === \"gateway\") {\n\t\t\tconst currentEntry = providerMetadata[providerName];\n\t\t\tif (currentEntry != null && typeof currentEntry === \"object\") providerMetadata[providerName] = {\n\t\t\t\t...currentEntry,\n\t\t\t\t...metadata\n\t\t\t};\n\t\t\telse providerMetadata[providerName] = metadata;\n\t\t\tconst imagesValue = providerMetadata[providerName].images;\n\t\t\tif (Array.isArray(imagesValue) && imagesValue.length === 0) delete providerMetadata[providerName].images;\n\t\t} else {\n\t\t\tconst currentEntry = (_b = getOwn(providerMetadata, providerName)) != null ? _b : { images: [] };\n\t\t\tcurrentEntry.images.push(...result.providerMetadata[providerName].images);\n\t\t\tsetOwn(providerMetadata, providerName, currentEntry);\n\t\t}\n\t\tresponses.push(result.response);\n\t}\n\tlogWarnings({\n\t\twarnings,\n\t\tprovider: model.provider,\n\t\tmodel: model.modelId\n\t});\n\tif (!images.length) throw new NoImageGeneratedError({ responses });\n\treturn new DefaultGenerateImageResult({\n\t\timages,\n\t\twarnings,\n\t\tresponses,\n\t\tproviderMetadata,\n\t\tusage: totalUsage\n\t});\n}\nvar DefaultGenerateImageResult = class {\n\tconstructor(options) {\n\t\tthis.images = options.images;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.usage = options.usage;\n\t}\n\tget image() {\n\t\treturn this.images[0];\n\t}\n};\nasync function invokeModelMaxImagesPerCall(model) {\n\tif (!(model.maxImagesPerCall instanceof Function)) return model.maxImagesPerCall;\n\treturn model.maxImagesPerCall({ modelId: model.modelId });\n}\nfunction normalizePrompt(prompt) {\n\tif (typeof prompt === \"string\") return {\n\t\tprompt,\n\t\tfiles: void 0,\n\t\tmask: void 0\n\t};\n\treturn {\n\t\tprompt: prompt.text,\n\t\tfiles: prompt.images.map(toImageModelV3File),\n\t\tmask: prompt.mask ? toImageModelV3File(prompt.mask) : void 0\n\t};\n}\nfunction toImageModelV3File(dataContent) {\n\tif (typeof dataContent === \"string\" && dataContent.startsWith(\"http\")) return {\n\t\ttype: \"url\",\n\t\turl: dataContent\n\t};\n\tif (typeof dataContent === \"string\" && dataContent.startsWith(\"data:\")) {\n\t\tconst { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(dataContent);\n\t\tif (base64Content != null) {\n\t\t\tconst uint8Data2 = convertBase64ToUint8Array(base64Content);\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tdata: uint8Data2,\n\t\t\t\tmediaType: dataUrlMediaType || detectMediaType({\n\t\t\t\t\tdata: uint8Data2,\n\t\t\t\t\tsignatures: imageMediaTypeSignatures\n\t\t\t\t}) || \"image/png\"\n\t\t\t};\n\t\t}\n\t}\n\tconst uint8Data = convertDataContentToUint8Array(dataContent);\n\treturn {\n\t\ttype: \"file\",\n\t\tdata: uint8Data,\n\t\tmediaType: detectMediaType({\n\t\t\tdata: uint8Data,\n\t\t\tsignatures: imageMediaTypeSignatures\n\t\t}) || \"image/png\"\n\t};\n}\nvar experimental_generateImage = generateImage;\nvar noSchemaOutputStrategy = {\n\ttype: \"no-schema\",\n\tjsonSchema: async () => void 0,\n\tasync validatePartialResult({ value, textDelta }) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tvalue: {\n\t\t\t\tpartial: value,\n\t\t\t\ttextDelta\n\t\t\t}\n\t\t};\n\t},\n\tasync validateFinalResult(value, context2) {\n\t\treturn value === void 0 ? {\n\t\t\tsuccess: false,\n\t\t\terror: new NoObjectGeneratedError({\n\t\t\t\tmessage: \"No object generated: response did not match schema.\",\n\t\t\t\ttext: context2.text,\n\t\t\t\tresponse: context2.response,\n\t\t\t\tusage: context2.usage,\n\t\t\t\tfinishReason: context2.finishReason\n\t\t\t})\n\t\t} : {\n\t\t\tsuccess: true,\n\t\t\tvalue\n\t\t};\n\t},\n\tcreateElementStream() {\n\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in no-schema mode\" });\n\t}\n};\nvar objectOutputStrategy = (schema) => ({\n\ttype: \"object\",\n\tjsonSchema: async () => await schema.jsonSchema,\n\tasync validatePartialResult({ value, textDelta }) {\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tvalue: {\n\t\t\t\tpartial: value,\n\t\t\t\ttextDelta\n\t\t\t}\n\t\t};\n\t},\n\tasync validateFinalResult(value) {\n\t\treturn safeValidateTypes({\n\t\t\tvalue,\n\t\t\tschema\n\t\t});\n\t},\n\tcreateElementStream() {\n\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in object mode\" });\n\t}\n});\nvar arrayOutputStrategy = (schema) => {\n\treturn {\n\t\ttype: \"array\",\n\t\tjsonSchema: async () => {\n\t\t\tconst { $schema, ...itemSchema } = await schema.jsonSchema;\n\t\t\treturn {\n\t\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { elements: {\n\t\t\t\t\ttype: \"array\",\n\t\t\t\t\titems: itemSchema\n\t\t\t\t} },\n\t\t\t\trequired: [\"elements\"],\n\t\t\t\tadditionalProperties: false\n\t\t\t};\n\t\t},\n\t\tasync validatePartialResult({ value, latestObject, isFirstDelta, isFinalDelta }) {\n\t\t\tvar _a23;\n\t\t\tif (!isJSONObject(value) || !isJSONArray(value.elements)) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains an array of elements\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst inputArray = value.elements;\n\t\t\tconst resultArray = [];\n\t\t\tfor (let i = 0; i < inputArray.length; i++) {\n\t\t\t\tconst element = inputArray[i];\n\t\t\t\tconst result = await safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema\n\t\t\t\t});\n\t\t\t\tif (i === inputArray.length - 1 && !isFinalDelta) continue;\n\t\t\t\tif (!result.success) return result;\n\t\t\t\tresultArray.push(result.value);\n\t\t\t}\n\t\t\tconst publishedElementCount = (_a23 = latestObject == null ? void 0 : latestObject.length) != null ? _a23 : 0;\n\t\t\tlet textDelta = \"\";\n\t\t\tif (isFirstDelta) textDelta += \"[\";\n\t\t\tif (publishedElementCount > 0) textDelta += \",\";\n\t\t\ttextDelta += resultArray.slice(publishedElementCount).map((element) => JSON.stringify(element)).join(\",\");\n\t\t\tif (isFinalDelta) textDelta += \"]\";\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tpartial: resultArray,\n\t\t\t\t\ttextDelta\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tasync validateFinalResult(value) {\n\t\t\tif (!isJSONObject(value) || !isJSONArray(value.elements)) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains an array of elements\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst inputArray = value.elements;\n\t\t\tconst resultArray = [];\n\t\t\tfor (const element of inputArray) {\n\t\t\t\tconst result = await safeValidateTypes({\n\t\t\t\t\tvalue: element,\n\t\t\t\t\tschema\n\t\t\t\t});\n\t\t\t\tif (!result.success) return result;\n\t\t\t\tresultArray.push(result.value);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: resultArray\n\t\t\t};\n\t\t},\n\t\tcreateElementStream(originalStream) {\n\t\t\tlet publishedElements = 0;\n\t\t\treturn createAsyncIterableStream(originalStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\tcase \"object\": {\n\t\t\t\t\t\tconst array2 = chunk.object;\n\t\t\t\t\t\tfor (; publishedElements < array2.length; publishedElements++) controller.enqueue(array2[publishedElements]);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcase \"finish\":\n\t\t\t\t\tcase \"error\": break;\n\t\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t\t}\n\t\t\t} })));\n\t\t}\n\t};\n};\nvar enumOutputStrategy = (enumValues) => {\n\treturn {\n\t\ttype: \"enum\",\n\t\tjsonSchema: async () => ({\n\t\t\t$schema: \"http://json-schema.org/draft-07/schema#\",\n\t\t\ttype: \"object\",\n\t\t\tproperties: { result: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tenum: enumValues\n\t\t\t} },\n\t\t\trequired: [\"result\"],\n\t\t\tadditionalProperties: false\n\t\t}),\n\t\tasync validateFinalResult(value) {\n\t\t\tif (!isJSONObject(value) || typeof value.result !== \"string\") return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains a string in the \\\"result\\\" property.\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst result = value.result;\n\t\t\treturn enumValues.includes(result) ? {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: result\n\t\t\t} : {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be a string in the enum\"\n\t\t\t\t})\n\t\t\t};\n\t\t},\n\t\tasync validatePartialResult({ value, textDelta }) {\n\t\t\tif (!isJSONObject(value) || typeof value.result !== \"string\") return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be an object that contains a string in the \\\"result\\\" property.\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tconst result = value.result;\n\t\t\tconst possibleEnumValues = enumValues.filter((enumValue) => enumValue.startsWith(result));\n\t\t\tif (value.result.length === 0 || possibleEnumValues.length === 0) return {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new TypeValidationError({\n\t\t\t\t\tvalue,\n\t\t\t\t\tcause: \"value must be a string in the enum\"\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tpartial: possibleEnumValues.length > 1 ? result : possibleEnumValues[0],\n\t\t\t\t\ttextDelta\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tcreateElementStream() {\n\t\t\tthrow new UnsupportedFunctionalityError({ functionality: \"element streams in enum mode\" });\n\t\t}\n\t};\n};\nfunction getOutputStrategy({ output, schema, enumValues }) {\n\tswitch (output) {\n\t\tcase \"object\": return objectOutputStrategy(asSchema(schema));\n\t\tcase \"array\": return arrayOutputStrategy(asSchema(schema));\n\t\tcase \"enum\": return enumOutputStrategy(enumValues);\n\t\tcase \"no-schema\": return noSchemaOutputStrategy;\n\t\tdefault: throw new Error(`Unsupported output: ${output}`);\n\t}\n}\nasync function parseAndValidateObjectResult(result, outputStrategy, context2) {\n\tconst parseResult = await safeParseJSON({ text: result });\n\tif (!parseResult.success) throw new NoObjectGeneratedError({\n\t\tmessage: \"No object generated: could not parse the response.\",\n\t\tcause: parseResult.error,\n\t\ttext: result,\n\t\tresponse: context2.response,\n\t\tusage: context2.usage,\n\t\tfinishReason: context2.finishReason\n\t});\n\tconst validationResult = await outputStrategy.validateFinalResult(parseResult.value, {\n\t\ttext: result,\n\t\tresponse: context2.response,\n\t\tusage: context2.usage\n\t});\n\tif (!validationResult.success) throw new NoObjectGeneratedError({\n\t\tmessage: \"No object generated: response did not match schema.\",\n\t\tcause: validationResult.error,\n\t\ttext: result,\n\t\tresponse: context2.response,\n\t\tusage: context2.usage,\n\t\tfinishReason: context2.finishReason\n\t});\n\treturn validationResult.value;\n}\nasync function parseAndValidateObjectResultWithRepair(result, outputStrategy, repairText, context2) {\n\ttry {\n\t\treturn await parseAndValidateObjectResult(result, outputStrategy, context2);\n\t} catch (error) {\n\t\tif (repairText != null && NoObjectGeneratedError.isInstance(error) && (JSONParseError.isInstance(error.cause) || TypeValidationError.isInstance(error.cause))) {\n\t\t\tconst repairedText = await repairText({\n\t\t\t\ttext: result,\n\t\t\t\terror: error.cause\n\t\t\t});\n\t\t\tif (repairedText === null) throw error;\n\t\t\treturn await parseAndValidateObjectResult(repairedText, outputStrategy, context2);\n\t\t}\n\t\tthrow error;\n\t}\n}\nfunction validateObjectGenerationInput({ output, schema, schemaName, schemaDescription, enumValues }) {\n\tif (output != null && output !== \"object\" && output !== \"array\" && output !== \"enum\" && output !== \"no-schema\") throw new InvalidArgumentError({\n\t\tparameter: \"output\",\n\t\tvalue: output,\n\t\tmessage: \"Invalid output type.\"\n\t});\n\tif (output === \"no-schema\") {\n\t\tif (schema != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is not supported for no-schema output.\"\n\t\t});\n\t\tif (schemaDescription != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaDescription\",\n\t\t\tvalue: schemaDescription,\n\t\t\tmessage: \"Schema description is not supported for no-schema output.\"\n\t\t});\n\t\tif (schemaName != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaName\",\n\t\t\tvalue: schemaName,\n\t\t\tmessage: \"Schema name is not supported for no-schema output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for no-schema output.\"\n\t\t});\n\t}\n\tif (output === \"object\") {\n\t\tif (schema == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is required for object output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for object output.\"\n\t\t});\n\t}\n\tif (output === \"array\") {\n\t\tif (schema == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Element schema is required for array output.\"\n\t\t});\n\t\tif (enumValues != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are not supported for array output.\"\n\t\t});\n\t}\n\tif (output === \"enum\") {\n\t\tif (schema != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schema\",\n\t\t\tvalue: schema,\n\t\t\tmessage: \"Schema is not supported for enum output.\"\n\t\t});\n\t\tif (schemaDescription != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaDescription\",\n\t\t\tvalue: schemaDescription,\n\t\t\tmessage: \"Schema description is not supported for enum output.\"\n\t\t});\n\t\tif (schemaName != null) throw new InvalidArgumentError({\n\t\t\tparameter: \"schemaName\",\n\t\t\tvalue: schemaName,\n\t\t\tmessage: \"Schema name is not supported for enum output.\"\n\t\t});\n\t\tif (enumValues == null) throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue: enumValues,\n\t\t\tmessage: \"Enum values are required for enum output.\"\n\t\t});\n\t\tfor (const value of enumValues) if (typeof value !== \"string\") throw new InvalidArgumentError({\n\t\t\tparameter: \"enumValues\",\n\t\t\tvalue,\n\t\t\tmessage: \"Enum values must be strings.\"\n\t\t});\n\t}\n}\nvar originalGenerateId3 = createIdGenerator({\n\tprefix: \"aiobj\",\n\tsize: 24\n});\nasync function generateObject(options) {\n\tconst { model: modelArg, output = \"object\", system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, headers, experimental_repairText: repairText, experimental_telemetry: telemetry, experimental_download: download2, providerOptions, _internal: { generateId: generateId2 = originalGenerateId3, currentDate = () => /* @__PURE__ */ new Date() } = {}, ...settings } = options;\n\tconst model = resolveLanguageModel(modelArg);\n\tconst enumValues = \"enum\" in options ? options.enum : void 0;\n\tconst { schema: inputSchema, schemaDescription, schemaName } = \"schema\" in options ? options : {};\n\tvalidateObjectGenerationInput({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tenumValues\n\t});\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst outputStrategy = getOutputStrategy({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tenumValues\n\t});\n\tconst callSettings = prepareCallSettings(settings);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders: headersWithUserAgent,\n\t\tsettings: {\n\t\t\t...callSettings,\n\t\t\tmaxRetries\n\t\t}\n\t});\n\tconst tracer = getTracer(telemetry);\n\tconst jsonSchema2 = await outputStrategy.jsonSchema();\n\ttry {\n\t\treturn await recordSpan({\n\t\t\tname: \"ai.generateObject\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.generateObject\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) },\n\t\t\t\t\t\"ai.schema\": jsonSchema2 != null ? { input: () => JSON.stringify(jsonSchema2) } : void 0,\n\t\t\t\t\t\"ai.schema.name\": schemaName,\n\t\t\t\t\t\"ai.schema.description\": schemaDescription,\n\t\t\t\t\t\"ai.settings.output\": outputStrategy.type\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tfn: async (span) => {\n\t\t\t\tvar _a23;\n\t\t\t\tlet result;\n\t\t\t\tlet finishReason;\n\t\t\t\tlet usage;\n\t\t\t\tlet warnings;\n\t\t\t\tlet response;\n\t\t\t\tlet request;\n\t\t\t\tlet resultProviderMetadata;\n\t\t\t\tlet reasoning;\n\t\t\t\tconst promptMessages = await convertToLanguageModelPrompt({\n\t\t\t\t\tprompt: await standardizePrompt({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages,\n\t\t\t\t\t\tallowSystemInMessages\n\t\t\t\t\t}),\n\t\t\t\t\tsupportedUrls: await model.supportedUrls,\n\t\t\t\t\tdownload: download2,\n\t\t\t\t\tabortSignal\n\t\t\t\t});\n\t\t\t\tconst generateResult = await retry(() => recordSpan({\n\t\t\t\t\tname: \"ai.generateObject.doGenerate\",\n\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\toperationId: \"ai.generateObject.doGenerate\",\n\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(promptMessages) },\n\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": callSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": callSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": callSettings.presencePenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.temperature\": callSettings.temperature,\n\t\t\t\t\t\t\t\"gen_ai.request.top_k\": callSettings.topK,\n\t\t\t\t\t\t\t\"gen_ai.request.top_p\": callSettings.topP\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\ttracer,\n\t\t\t\t\tfn: async (span2) => {\n\t\t\t\t\t\tvar _a24, _b, _c, _d, _e, _f, _g, _h;\n\t\t\t\t\t\tconst result2 = await model.doGenerate({\n\t\t\t\t\t\t\tresponseFormat: {\n\t\t\t\t\t\t\t\ttype: \"json\",\n\t\t\t\t\t\t\t\tschema: jsonSchema2,\n\t\t\t\t\t\t\t\tname: schemaName,\n\t\t\t\t\t\t\t\tdescription: schemaDescription\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\t\t\tprompt: promptMessages,\n\t\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\t\theaders: headersWithUserAgent\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst responseData = {\n\t\t\t\t\t\t\tid: (_b = (_a24 = result2.response) == null ? void 0 : _a24.id) != null ? _b : generateId2(),\n\t\t\t\t\t\t\ttimestamp: (_d = (_c = result2.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),\n\t\t\t\t\t\t\tmodelId: (_f = (_e = result2.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,\n\t\t\t\t\t\t\theaders: (_g = result2.response) == null ? void 0 : _g.headers,\n\t\t\t\t\t\t\tbody: (_h = result2.response) == null ? void 0 : _h.body\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst text2 = extractTextContent(result2.content);\n\t\t\t\t\t\tconst reasoning2 = extractReasoningContent(result2.content);\n\t\t\t\t\t\tif (text2 === void 0) throw new NoObjectGeneratedError({\n\t\t\t\t\t\t\tmessage: \"No object generated: the model did not return a response.\",\n\t\t\t\t\t\t\tresponse: responseData,\n\t\t\t\t\t\t\tusage: asLanguageModelUsage(result2.usage),\n\t\t\t\t\t\t\tfinishReason: result2.finishReason.unified\n\t\t\t\t\t\t});\n\t\t\t\t\t\tspan2.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\"ai.response.finishReason\": result2.finishReason.unified,\n\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => text2 },\n\t\t\t\t\t\t\t\t\"ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\"ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\"ai.response.timestamp\": responseData.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(result2.providerMetadata),\n\t\t\t\t\t\t\t\t\"ai.usage.promptTokens\": result2.usage.inputTokens.total,\n\t\t\t\t\t\t\t\t\"ai.usage.completionTokens\": result2.usage.outputTokens.total,\n\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [result2.finishReason.unified],\n\t\t\t\t\t\t\t\t\"gen_ai.response.id\": responseData.id,\n\t\t\t\t\t\t\t\t\"gen_ai.response.model\": responseData.modelId,\n\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": result2.usage.inputTokens.total,\n\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": result2.usage.outputTokens.total\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}));\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result2,\n\t\t\t\t\t\t\tobjectText: text2,\n\t\t\t\t\t\t\treasoning: reasoning2,\n\t\t\t\t\t\t\tresponseData\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tresult = generateResult.objectText;\n\t\t\t\tfinishReason = generateResult.finishReason.unified;\n\t\t\t\tusage = asLanguageModelUsage(generateResult.usage);\n\t\t\t\twarnings = generateResult.warnings;\n\t\t\t\tresultProviderMetadata = generateResult.providerMetadata;\n\t\t\t\trequest = (_a23 = generateResult.request) != null ? _a23 : {};\n\t\t\t\tresponse = generateResult.responseData;\n\t\t\t\treasoning = generateResult.reasoning;\n\t\t\t\tlogWarnings({\n\t\t\t\t\twarnings,\n\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\tmodel: model.modelId\n\t\t\t\t});\n\t\t\t\tconst object2 = await parseAndValidateObjectResultWithRepair(result, outputStrategy, repairText, {\n\t\t\t\t\tresponse,\n\t\t\t\t\tusage,\n\t\t\t\t\tfinishReason\n\t\t\t\t});\n\t\t\t\tspan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(resultProviderMetadata),\n\t\t\t\t\t\t\"ai.usage.promptTokens\": usage.inputTokens,\n\t\t\t\t\t\t\"ai.usage.completionTokens\": usage.outputTokens\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\treturn new DefaultGenerateObjectResult({\n\t\t\t\t\tobject: object2,\n\t\t\t\t\treasoning,\n\t\t\t\t\tfinishReason,\n\t\t\t\t\tusage,\n\t\t\t\t\twarnings,\n\t\t\t\t\trequest,\n\t\t\t\t\tresponse,\n\t\t\t\t\tproviderMetadata: resultProviderMetadata\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t} catch (error) {\n\t\tthrow wrapGatewayError(error);\n\t}\n}\nvar DefaultGenerateObjectResult = class {\n\tconstructor(options) {\n\t\tthis.object = options.object;\n\t\tthis.finishReason = options.finishReason;\n\t\tthis.usage = options.usage;\n\t\tthis.warnings = options.warnings;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t\tthis.response = options.response;\n\t\tthis.request = options.request;\n\t\tthis.reasoning = options.reasoning;\n\t}\n\ttoJsonResponse(init) {\n\t\tvar _a23;\n\t\treturn new Response(JSON.stringify(this.object), {\n\t\t\tstatus: (_a23 = init == null ? void 0 : init.status) != null ? _a23 : 200,\n\t\t\theaders: prepareHeaders(init == null ? void 0 : init.headers, { \"content-type\": \"application/json; charset=utf-8\" })\n\t\t});\n\t}\n};\nfunction cosineSimilarity(vector1, vector2) {\n\tif (vector1.length !== vector2.length) throw new InvalidArgumentError({\n\t\tparameter: \"vector1,vector2\",\n\t\tvalue: {\n\t\t\tvector1Length: vector1.length,\n\t\t\tvector2Length: vector2.length\n\t\t},\n\t\tmessage: `Vectors must have the same length`\n\t});\n\tconst n = vector1.length;\n\tif (n === 0) return 0;\n\tlet magnitudeSquared1 = 0;\n\tlet magnitudeSquared2 = 0;\n\tlet dotProduct = 0;\n\tfor (let i = 0; i < n; i++) {\n\t\tconst value1 = vector1[i];\n\t\tconst value2 = vector2[i];\n\t\tmagnitudeSquared1 += value1 * value1;\n\t\tmagnitudeSquared2 += value2 * value2;\n\t\tdotProduct += value1 * value2;\n\t}\n\treturn magnitudeSquared1 === 0 || magnitudeSquared2 === 0 ? 0 : dotProduct / (Math.sqrt(magnitudeSquared1) * Math.sqrt(magnitudeSquared2));\n}\nfunction createDownload(options) {\n\treturn ({ url, abortSignal }) => download({\n\t\turl,\n\t\tmaxBytes: options == null ? void 0 : options.maxBytes,\n\t\tabortSignal\n\t});\n}\nvar { atob } = globalThis;\nfunction getTextFromDataUrl(dataUrl) {\n\tconst [header, base64Content] = dataUrl.split(\",\");\n\tif (header.split(\";\")[0].split(\":\")[1] == null || base64Content == null) throw new Error(\"Invalid data URL format\");\n\ttry {\n\t\treturn atob(base64Content);\n\t} catch (error) {\n\t\tthrow new Error(`Error decoding data URL`);\n\t}\n}\nvar SerialJobExecutor = class {\n\tconstructor() {\n\t\tthis.queue = [];\n\t\tthis.isProcessing = false;\n\t\tthis.idleWaiters = [];\n\t}\n\tasync processQueue() {\n\t\tif (this.isProcessing) return;\n\t\tthis.isProcessing = true;\n\t\ttry {\n\t\t\twhile (this.queue.length > 0) {\n\t\t\t\tawait this.queue[0]();\n\t\t\t\tthis.queue.shift();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.isProcessing = false;\n\t\t\tfor (const resolve3 of this.idleWaiters.splice(0)) resolve3();\n\t\t}\n\t}\n\tasync run(job) {\n\t\treturn new Promise((resolve3, reject) => {\n\t\t\tthis.queue.push(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait job();\n\t\t\t\t\tresolve3();\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis.processQueue();\n\t\t});\n\t}\n\tasync waitForIdle() {\n\t\tif (!this.isProcessing && this.queue.length === 0) return;\n\t\tawait new Promise((resolve3) => {\n\t\t\tthis.idleWaiters.push(resolve3);\n\t\t});\n\t}\n};\nfunction simulateReadableStream({ chunks, initialDelayInMs = 0, chunkDelayInMs = 0, _internal }) {\n\tvar _a23;\n\tconst delay$1 = (_a23 = _internal == null ? void 0 : _internal.delay) != null ? _a23 : delay;\n\tlet index = 0;\n\treturn new ReadableStream({ async pull(controller) {\n\t\tif (index < chunks.length) {\n\t\t\tawait delay$1(index === 0 ? initialDelayInMs : chunkDelayInMs);\n\t\t\tcontroller.enqueue(chunks[index++]);\n\t\t} else controller.close();\n\t} });\n}\nvar originalGenerateId4 = createIdGenerator({\n\tprefix: \"aiobj\",\n\tsize: 24\n});\nasync function markPromiseAsHandled(promise) {\n\ttry {\n\t\tawait promise;\n\t} catch (e) {}\n}\nfunction streamObject(options) {\n\tconst { model, output = \"object\", system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, headers, experimental_repairText: repairText, experimental_telemetry: telemetry, experimental_download: download2, providerOptions, onError = ({ error }) => {\n\t\tconsole.error(error);\n\t}, onFinish, _internal: { generateId: generateId2 = originalGenerateId4, currentDate = () => /* @__PURE__ */ new Date(), now: now2 = now } = {}, ...settings } = options;\n\tconst enumValues = \"enum\" in options && options.enum ? options.enum : void 0;\n\tconst { schema: inputSchema, schemaDescription, schemaName } = \"schema\" in options ? options : {};\n\tvalidateObjectGenerationInput({\n\t\toutput,\n\t\tschema: inputSchema,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tenumValues\n\t});\n\treturn new DefaultStreamObjectResult({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings,\n\t\tmaxRetries,\n\t\tabortSignal,\n\t\toutputStrategy: getOutputStrategy({\n\t\t\toutput,\n\t\t\tschema: inputSchema,\n\t\t\tenumValues\n\t\t}),\n\t\tsystem,\n\t\tprompt,\n\t\tmessages,\n\t\tallowSystemInMessages,\n\t\tschemaName,\n\t\tschemaDescription,\n\t\tproviderOptions,\n\t\trepairText,\n\t\tonError,\n\t\tonFinish,\n\t\tdownload: download2,\n\t\tgenerateId: generateId2,\n\t\tcurrentDate,\n\t\tnow: now2\n\t});\n}\nvar DefaultStreamObjectResult = class {\n\tconstructor({ model: modelArg, headers, telemetry, settings, maxRetries: maxRetriesArg, abortSignal, outputStrategy, system, prompt, messages, allowSystemInMessages, schemaName, schemaDescription, providerOptions, repairText, onError, onFinish, download: download2, generateId: generateId2, currentDate, now: now2 }) {\n\t\tthis._object = new DelayedPromise();\n\t\tthis._usage = new DelayedPromise();\n\t\tthis._providerMetadata = new DelayedPromise();\n\t\tthis._warnings = new DelayedPromise();\n\t\tthis._request = new DelayedPromise();\n\t\tthis._response = new DelayedPromise();\n\t\tthis._finishReason = new DelayedPromise();\n\t\tconst model = resolveLanguageModel(modelArg);\n\t\tconst { maxRetries, retry } = prepareRetries({\n\t\t\tmaxRetries: maxRetriesArg,\n\t\t\tabortSignal\n\t\t});\n\t\tconst callSettings = prepareCallSettings(settings);\n\t\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\t\tmodel,\n\t\t\ttelemetry,\n\t\t\theaders,\n\t\t\tsettings: {\n\t\t\t\t...callSettings,\n\t\t\t\tmaxRetries\n\t\t\t}\n\t\t});\n\t\tconst tracer = getTracer(telemetry);\n\t\tconst self = this;\n\t\tconst stitchableStream = createStitchableStream();\n\t\tconst eventProcessor = new TransformStream({ transform(chunk, controller) {\n\t\t\tcontroller.enqueue(chunk);\n\t\t\tif (chunk.type === \"error\") notify({\n\t\t\t\tevent: { error: wrapGatewayError(chunk.error) },\n\t\t\t\tcallbacks: onError\n\t\t\t});\n\t\t} });\n\t\tthis.baseStream = stitchableStream.stream.pipeThrough(eventProcessor);\n\t\trecordSpan({\n\t\t\tname: \"ai.streamObject\",\n\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\ttelemetry,\n\t\t\t\tattributes: {\n\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\toperationId: \"ai.streamObject\",\n\t\t\t\t\t\ttelemetry\n\t\t\t\t\t}),\n\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\"ai.prompt\": { input: () => JSON.stringify({\n\t\t\t\t\t\tsystem,\n\t\t\t\t\t\tprompt,\n\t\t\t\t\t\tmessages\n\t\t\t\t\t}) },\n\t\t\t\t\t\"ai.schema\": { input: async () => JSON.stringify(await outputStrategy.jsonSchema()) },\n\t\t\t\t\t\"ai.schema.name\": schemaName,\n\t\t\t\t\t\"ai.schema.description\": schemaDescription,\n\t\t\t\t\t\"ai.settings.output\": outputStrategy.type\n\t\t\t\t}\n\t\t\t}),\n\t\t\ttracer,\n\t\t\tendWhenDone: false,\n\t\t\tendOnError: true,\n\t\t\tfn: async (rootSpan) => {\n\t\t\t\tconst standardizedPrompt = await standardizePrompt({\n\t\t\t\t\tsystem,\n\t\t\t\t\tprompt,\n\t\t\t\t\tmessages,\n\t\t\t\t\tallowSystemInMessages\n\t\t\t\t});\n\t\t\t\tconst callOptions = {\n\t\t\t\t\tresponseFormat: {\n\t\t\t\t\t\ttype: \"json\",\n\t\t\t\t\t\tschema: await outputStrategy.jsonSchema(),\n\t\t\t\t\t\tname: schemaName,\n\t\t\t\t\t\tdescription: schemaDescription\n\t\t\t\t\t},\n\t\t\t\t\t...prepareCallSettings(settings),\n\t\t\t\t\tprompt: await convertToLanguageModelPrompt({\n\t\t\t\t\t\tprompt: standardizedPrompt,\n\t\t\t\t\t\tsupportedUrls: await model.supportedUrls,\n\t\t\t\t\t\tdownload: download2,\n\t\t\t\t\t\tabortSignal\n\t\t\t\t\t}),\n\t\t\t\t\tproviderOptions,\n\t\t\t\t\tabortSignal,\n\t\t\t\t\theaders,\n\t\t\t\t\tincludeRawChunks: false\n\t\t\t\t};\n\t\t\t\tconst transformer = { transform: (chunk, controller) => {\n\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\tcase \"text-delta\":\n\t\t\t\t\t\t\tcontroller.enqueue(chunk.delta);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\tcase \"stream-start\": controller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t} };\n\t\t\t\tconst { result: { stream, response, request }, doStreamSpan, startTimestampMs } = await retry(() => recordSpan({\n\t\t\t\t\tname: \"ai.streamObject.doStream\",\n\t\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\t\toperationId: \"ai.streamObject.doStream\",\n\t\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\t\"ai.prompt.messages\": { input: () => stringifyForTelemetry(callOptions.prompt) },\n\t\t\t\t\t\t\t\"gen_ai.system\": model.provider,\n\t\t\t\t\t\t\t\"gen_ai.request.model\": model.modelId,\n\t\t\t\t\t\t\t\"gen_ai.request.frequency_penalty\": callSettings.frequencyPenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.max_tokens\": callSettings.maxOutputTokens,\n\t\t\t\t\t\t\t\"gen_ai.request.presence_penalty\": callSettings.presencePenalty,\n\t\t\t\t\t\t\t\"gen_ai.request.temperature\": callSettings.temperature,\n\t\t\t\t\t\t\t\"gen_ai.request.top_k\": callSettings.topK,\n\t\t\t\t\t\t\t\"gen_ai.request.top_p\": callSettings.topP\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t\ttracer,\n\t\t\t\t\tendWhenDone: false,\n\t\t\t\t\tendOnError: true,\n\t\t\t\t\tfn: async (doStreamSpan2) => ({\n\t\t\t\t\t\tstartTimestampMs: now2(),\n\t\t\t\t\t\tdoStreamSpan: doStreamSpan2,\n\t\t\t\t\t\tresult: await model.doStream(callOptions)\n\t\t\t\t\t})\n\t\t\t\t}));\n\t\t\t\tself._request.resolve(request != null ? request : {});\n\t\t\t\tlet warnings;\n\t\t\t\tlet usage = createNullLanguageModelUsage();\n\t\t\t\tlet finishReason;\n\t\t\t\tlet providerMetadata;\n\t\t\t\tlet object2;\n\t\t\t\tlet error;\n\t\t\t\tlet terminalError;\n\t\t\t\tlet accumulatedText = \"\";\n\t\t\t\tlet textDelta = \"\";\n\t\t\t\tlet fullResponse = {\n\t\t\t\t\tid: generateId2(),\n\t\t\t\t\ttimestamp: currentDate(),\n\t\t\t\t\tmodelId: model.modelId\n\t\t\t\t};\n\t\t\t\tlet latestObjectJson = void 0;\n\t\t\t\tlet latestObject = void 0;\n\t\t\t\tlet isFirstChunk = true;\n\t\t\t\tlet isFirstDelta = true;\n\t\t\t\tconst transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({\n\t\t\t\t\tasync transform(chunk, controller) {\n\t\t\t\t\t\tvar _a23, _b, _c;\n\t\t\t\t\t\tif (typeof chunk === \"object\" && chunk.type === \"stream-start\") {\n\t\t\t\t\t\t\twarnings = chunk.warnings;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isFirstChunk) {\n\t\t\t\t\t\t\tconst msToFirstChunk = now2() - startTimestampMs;\n\t\t\t\t\t\t\tisFirstChunk = false;\n\t\t\t\t\t\t\tdoStreamSpan.addEvent(\"ai.stream.firstChunk\", { \"ai.stream.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t\tdoStreamSpan.setAttributes({ \"ai.stream.msToFirstChunk\": msToFirstChunk });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof chunk === \"string\") {\n\t\t\t\t\t\t\taccumulatedText += chunk;\n\t\t\t\t\t\t\ttextDelta += chunk;\n\t\t\t\t\t\t\tconst { value: currentObjectJson, state: parseState } = await parsePartialJson(accumulatedText);\n\t\t\t\t\t\t\tif (currentObjectJson !== void 0 && !isDeepEqualData(latestObjectJson, currentObjectJson)) {\n\t\t\t\t\t\t\t\tconst validationResult = await outputStrategy.validatePartialResult({\n\t\t\t\t\t\t\t\t\tvalue: currentObjectJson,\n\t\t\t\t\t\t\t\t\ttextDelta,\n\t\t\t\t\t\t\t\t\tlatestObject,\n\t\t\t\t\t\t\t\t\tisFirstDelta,\n\t\t\t\t\t\t\t\t\tisFinalDelta: parseState === \"successful-parse\"\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (validationResult.success && !isDeepEqualData(latestObject, validationResult.value.partial)) {\n\t\t\t\t\t\t\t\t\tlatestObjectJson = currentObjectJson;\n\t\t\t\t\t\t\t\t\tlatestObject = validationResult.value.partial;\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\t\t\t\t\tobject: latestObject\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\t\ttextDelta: validationResult.value.textDelta\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\ttextDelta = \"\";\n\t\t\t\t\t\t\t\t\tisFirstDelta = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\t\t\tcase \"response-metadata\":\n\t\t\t\t\t\t\t\tfullResponse = {\n\t\t\t\t\t\t\t\t\tid: (_a23 = chunk.id) != null ? _a23 : fullResponse.id,\n\t\t\t\t\t\t\t\t\ttimestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,\n\t\t\t\t\t\t\t\t\tmodelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"error\":\n\t\t\t\t\t\t\t\tif (terminalError === void 0) {\n\t\t\t\t\t\t\t\t\tconst wrappedError = wrapGatewayError(chunk.error);\n\t\t\t\t\t\t\t\t\tterminalError = { error: wrappedError };\n\t\t\t\t\t\t\t\t\terror = wrappedError;\n\t\t\t\t\t\t\t\t\tfinishReason = \"error\";\n\t\t\t\t\t\t\t\t\tself.rejectResultPromises(wrappedError);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"finish\":\n\t\t\t\t\t\t\t\tif (textDelta !== \"\") controller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\ttextDelta\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tfinishReason = terminalError === void 0 ? chunk.finishReason.unified : \"error\";\n\t\t\t\t\t\t\t\tusage = asLanguageModelUsage(chunk.usage);\n\t\t\t\t\t\t\t\tproviderMetadata = chunk.providerMetadata;\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\t...chunk,\n\t\t\t\t\t\t\t\t\tfinishReason,\n\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\tresponse: fullResponse\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tlogWarnings({\n\t\t\t\t\t\t\t\t\twarnings: warnings != null ? warnings : [],\n\t\t\t\t\t\t\t\t\tprovider: model.provider,\n\t\t\t\t\t\t\t\t\tmodel: model.modelId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (terminalError !== void 0) break;\n\t\t\t\t\t\t\t\tself._usage.resolve(usage);\n\t\t\t\t\t\t\t\tself._providerMetadata.resolve(providerMetadata);\n\t\t\t\t\t\t\t\tself._warnings.resolve(warnings);\n\t\t\t\t\t\t\t\tself._response.resolve({\n\t\t\t\t\t\t\t\t\t...fullResponse,\n\t\t\t\t\t\t\t\t\theaders: response == null ? void 0 : response.headers\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tself._finishReason.resolve(finishReason != null ? finishReason : \"other\");\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tobject2 = await parseAndValidateObjectResultWithRepair(accumulatedText, outputStrategy, repairText, {\n\t\t\t\t\t\t\t\t\t\tresponse: fullResponse,\n\t\t\t\t\t\t\t\t\t\tusage,\n\t\t\t\t\t\t\t\t\t\tfinishReason\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tself._object.resolve(object2);\n\t\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\t\terror = e;\n\t\t\t\t\t\t\t\t\tself._object.reject(e);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault: controller.enqueue(chunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tasync flush(controller) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst finalUsage = usage != null ? usage : {\n\t\t\t\t\t\t\t\tpromptTokens: NaN,\n\t\t\t\t\t\t\t\tcompletionTokens: NaN,\n\t\t\t\t\t\t\t\ttotalTokens: NaN\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tdoStreamSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.response.finishReason\": finishReason,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\t\t\t\"ai.response.id\": fullResponse.id,\n\t\t\t\t\t\t\t\t\t\"ai.response.model\": fullResponse.modelId,\n\t\t\t\t\t\t\t\t\t\"ai.response.timestamp\": fullResponse.timestamp.toISOString(),\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(providerMetadata),\n\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": finalUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": finalUsage.outputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": finalUsage.totalTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": finalUsage.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": finalUsage.cachedInputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.finish_reasons\": [finishReason],\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.id\": fullResponse.id,\n\t\t\t\t\t\t\t\t\t\"gen_ai.response.model\": fullResponse.modelId,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.input_tokens\": finalUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\"gen_ai.usage.output_tokens\": finalUsage.outputTokens\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tdoStreamSpan.end();\n\t\t\t\t\t\t\trootSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\"ai.usage.inputTokens\": finalUsage.inputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.outputTokens\": finalUsage.outputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.totalTokens\": finalUsage.totalTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.reasoningTokens\": finalUsage.reasoningTokens,\n\t\t\t\t\t\t\t\t\t\"ai.usage.cachedInputTokens\": finalUsage.cachedInputTokens,\n\t\t\t\t\t\t\t\t\t\"ai.response.object\": { output: () => JSON.stringify(object2) },\n\t\t\t\t\t\t\t\t\t\"ai.response.providerMetadata\": JSON.stringify(providerMetadata)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tawait (onFinish == null ? void 0 : onFinish({\n\t\t\t\t\t\t\t\tusage: finalUsage,\n\t\t\t\t\t\t\t\tobject: object2,\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\t\t...fullResponse,\n\t\t\t\t\t\t\t\t\theaders: response == null ? void 0 : response.headers\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twarnings,\n\t\t\t\t\t\t\t\tproviderMetadata\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t} catch (error2) {\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: error2\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\trootSpan.end();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t\tstitchableStream.addStream(transformedStream, { onError(error2) {\n\t\t\t\t\tconst wrappedError = wrapGatewayError(error2);\n\t\t\t\t\tself.rejectResultPromises(wrappedError);\n\t\t\t\t\tnotify({\n\t\t\t\t\t\tevent: { error: wrappedError },\n\t\t\t\t\t\tcallbacks: onError\n\t\t\t\t\t});\n\t\t\t\t} });\n\t\t\t}\n\t\t}).catch((error) => {\n\t\t\tself.rejectResultPromises(error);\n\t\t\tstitchableStream.addStream(new ReadableStream({ start(controller) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror\n\t\t\t\t});\n\t\t\t\tcontroller.close();\n\t\t\t} }));\n\t\t}).finally(() => {\n\t\t\tstitchableStream.close();\n\t\t});\n\t\tthis.outputStrategy = outputStrategy;\n\t}\n\trejectResultPromises(error) {\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._object,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._usage,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._providerMetadata,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._warnings,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._request,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._response,\n\t\t\terror\n\t\t});\n\t\tthis.rejectResultPromise({\n\t\t\tdelayedPromise: this._finishReason,\n\t\t\terror\n\t\t});\n\t}\n\trejectResultPromise({ delayedPromise, error }) {\n\t\tif (delayedPromise.isPending()) {\n\t\t\tdelayedPromise.reject(error);\n\t\t\tmarkPromiseAsHandled(delayedPromise.promise);\n\t\t}\n\t}\n\tget object() {\n\t\treturn this._object.promise;\n\t}\n\tget usage() {\n\t\treturn this._usage.promise;\n\t}\n\tget providerMetadata() {\n\t\treturn this._providerMetadata.promise;\n\t}\n\tget warnings() {\n\t\treturn this._warnings.promise;\n\t}\n\tget request() {\n\t\treturn this._request.promise;\n\t}\n\tget response() {\n\t\treturn this._response.promise;\n\t}\n\tget finishReason() {\n\t\treturn this._finishReason.promise;\n\t}\n\tget partialObjectStream() {\n\t\treturn createAsyncIterableStream(this.baseStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"object\":\n\t\t\t\t\tcontroller.enqueue(chunk.object);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text-delta\":\n\t\t\t\tcase \"finish\":\n\t\t\t\tcase \"error\": break;\n\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t}\n\t\t} })));\n\t}\n\tget elementStream() {\n\t\treturn this.outputStrategy.createElementStream(this.baseStream);\n\t}\n\tget textStream() {\n\t\treturn createAsyncIterableStream(this.baseStream.pipeThrough(new TransformStream({ transform(chunk, controller) {\n\t\t\tswitch (chunk.type) {\n\t\t\t\tcase \"text-delta\":\n\t\t\t\t\tcontroller.enqueue(chunk.textDelta);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"object\":\n\t\t\t\tcase \"finish\":\n\t\t\t\tcase \"error\": break;\n\t\t\t\tdefault: throw new Error(`Unsupported chunk type: ${chunk}`);\n\t\t\t}\n\t\t} })));\n\t}\n\tget fullStream() {\n\t\treturn createAsyncIterableStream(this.baseStream);\n\t}\n\tpipeTextStreamToResponse(response, init) {\n\t\treturn pipeTextStreamToResponse({\n\t\t\tresponse,\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n\ttoTextStreamResponse(init) {\n\t\treturn createTextStreamResponse({\n\t\t\ttextStream: this.textStream,\n\t\t\t...init\n\t\t});\n\t}\n};\nvar DefaultGeneratedAudioFile = class extends DefaultGeneratedFile {\n\tconstructor({ data, mediaType }) {\n\t\tsuper({\n\t\t\tdata,\n\t\t\tmediaType\n\t\t});\n\t\tlet format = \"mp3\";\n\t\tif (mediaType) {\n\t\t\tconst mediaTypeParts = mediaType.split(\"/\");\n\t\t\tif (mediaTypeParts.length === 2) {\n\t\t\t\tif (mediaType !== \"audio/mpeg\") format = mediaTypeParts[1];\n\t\t\t}\n\t\t}\n\t\tif (!format) throw new Error(\"Audio format must be provided or determinable from media type\");\n\t\tthis.format = format;\n\t}\n};\nasync function generateSpeech({ model, text: text2, voice, outputFormat, instructions, speed, language, providerOptions = {}, maxRetries: maxRetriesArg, abortSignal, headers }) {\n\tvar _a23;\n\tconst resolvedModel = resolveSpeechModel(model);\n\tif (!resolvedModel) throw new Error(\"Model could not be resolved\");\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst result = await retry(() => resolvedModel.doGenerate({\n\t\ttext: text2,\n\t\tvoice,\n\t\toutputFormat,\n\t\tinstructions,\n\t\tspeed,\n\t\tlanguage,\n\t\tabortSignal,\n\t\theaders: headersWithUserAgent,\n\t\tproviderOptions\n\t}));\n\tif (!result.audio || result.audio.length === 0) throw new NoSpeechGeneratedError({ responses: [result.response] });\n\tlogWarnings({\n\t\twarnings: result.warnings,\n\t\tprovider: resolvedModel.provider,\n\t\tmodel: resolvedModel.modelId\n\t});\n\treturn new DefaultSpeechResult({\n\t\taudio: new DefaultGeneratedAudioFile({\n\t\t\tdata: result.audio,\n\t\t\tmediaType: (_a23 = detectMediaType({\n\t\t\t\tdata: result.audio,\n\t\t\t\tsignatures: audioMediaTypeSignatures\n\t\t\t})) != null ? _a23 : \"audio/mp3\"\n\t\t}),\n\t\twarnings: result.warnings,\n\t\tresponses: [result.response],\n\t\tproviderMetadata: result.providerMetadata\n\t});\n}\nvar DefaultSpeechResult = class {\n\tconstructor(options) {\n\t\tvar _a23;\n\t\tthis.audio = options.audio;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = (_a23 = options.providerMetadata) != null ? _a23 : {};\n\t}\n};\nfunction pruneMessages({ messages, reasoning = \"none\", toolCalls = [], emptyMessages = \"remove\" }) {\n\tif (reasoning === \"all\" || reasoning === \"before-last-message\") messages = messages.map((message, messageIndex) => {\n\t\tif (message.role !== \"assistant\" || typeof message.content === \"string\" || reasoning === \"before-last-message\" && messageIndex === messages.length - 1) return message;\n\t\treturn {\n\t\t\t...message,\n\t\t\tcontent: message.content.filter((part) => part.type !== \"reasoning\")\n\t\t};\n\t});\n\tif (toolCalls === \"none\") toolCalls = [];\n\telse if (toolCalls === \"all\") toolCalls = [{ type: \"all\" }];\n\telse if (toolCalls === \"before-last-message\") toolCalls = [{ type: \"before-last-message\" }];\n\telse if (typeof toolCalls === \"string\") toolCalls = [{ type: toolCalls }];\n\tfor (const toolCall of toolCalls) {\n\t\tconst keepLastMessagesCount = toolCall.type === \"all\" ? void 0 : toolCall.type === \"before-last-message\" ? 1 : Number(toolCall.type.slice(12).slice(0, -9));\n\t\tconst keptToolCallIds = /* @__PURE__ */ new Set();\n\t\tconst keptApprovalIds = /* @__PURE__ */ new Set();\n\t\tif (keepLastMessagesCount != null) {\n\t\t\tfor (const message of messages.slice(-keepLastMessagesCount)) if ((message.role === \"assistant\" || message.role === \"tool\") && typeof message.content !== \"string\") {\n\t\t\t\tfor (const part of message.content) if (part.type === \"tool-call\" || part.type === \"tool-result\") keptToolCallIds.add(part.toolCallId);\n\t\t\t\telse if (part.type === \"tool-approval-request\" || part.type === \"tool-approval-response\") keptApprovalIds.add(part.approvalId);\n\t\t\t}\n\t\t}\n\t\tconst toolCallIdToToolName = /* @__PURE__ */ new Map();\n\t\tfor (const message of messages) if ((message.role === \"assistant\" || message.role === \"tool\") && typeof message.content !== \"string\") {\n\t\t\tfor (const part of message.content) if (part.type === \"tool-call\" || part.type === \"tool-result\") toolCallIdToToolName.set(part.toolCallId, part.toolName);\n\t\t}\n\t\tconst approvalIdToToolCallId = /* @__PURE__ */ new Map();\n\t\tconst approvalIdToToolName = /* @__PURE__ */ new Map();\n\t\tfor (const message of messages) if ((message.role === \"assistant\" || message.role === \"tool\") && typeof message.content !== \"string\") {\n\t\t\tfor (const part of message.content) if (part.type === \"tool-approval-request\") {\n\t\t\t\tapprovalIdToToolCallId.set(part.approvalId, part.toolCallId);\n\t\t\t\tconst toolName = toolCallIdToToolName.get(part.toolCallId);\n\t\t\t\tif (toolName != null) approvalIdToToolName.set(part.approvalId, toolName);\n\t\t\t}\n\t\t}\n\t\tfor (const approvalId of keptApprovalIds) {\n\t\t\tconst toolCallId = approvalIdToToolCallId.get(approvalId);\n\t\t\tif (toolCallId != null) keptToolCallIds.add(toolCallId);\n\t\t}\n\t\tmessages = messages.map((message, messageIndex) => {\n\t\t\tif (message.role !== \"assistant\" && message.role !== \"tool\" || typeof message.content === \"string\" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) return message;\n\t\t\treturn {\n\t\t\t\t...message,\n\t\t\t\tcontent: message.content.filter((part) => {\n\t\t\t\t\tif (part.type !== \"tool-call\" && part.type !== \"tool-result\" && part.type !== \"tool-approval-request\" && part.type !== \"tool-approval-response\") return true;\n\t\t\t\t\tif ((part.type === \"tool-call\" || part.type === \"tool-result\") && keptToolCallIds.has(part.toolCallId) || (part.type === \"tool-approval-request\" || part.type === \"tool-approval-response\") && keptApprovalIds.has(part.approvalId)) return true;\n\t\t\t\t\tconst partToolName = part.type === \"tool-call\" || part.type === \"tool-result\" ? part.toolName : approvalIdToToolName.get(part.approvalId);\n\t\t\t\t\treturn toolCall.tools != null && partToolName != null && !toolCall.tools.includes(partToolName);\n\t\t\t\t})\n\t\t\t};\n\t\t});\n\t}\n\tif (emptyMessages === \"remove\") messages = messages.filter((message) => message.content.length > 0);\n\treturn messages;\n}\nvar CHUNKING_REGEXPS = {\n\tword: /\\S+\\s+/m,\n\tline: /\\n+/m\n};\nfunction isDocumentHidden() {\n\treturn typeof document !== \"undefined\" && document.visibilityState === \"hidden\";\n}\nfunction smoothStream({ delayInMs = 10, chunking = \"word\", _internal: { delay: delay$2 = delay } = {} } = {}) {\n\tlet detectChunk;\n\tif (chunking != null && typeof chunking === \"object\" && \"segment\" in chunking && typeof chunking.segment === \"function\") {\n\t\tconst segmenter = chunking;\n\t\tdetectChunk = (buffer) => {\n\t\t\tif (buffer.length === 0) return null;\n\t\t\tconst first = segmenter.segment(buffer)[Symbol.iterator]().next().value;\n\t\t\treturn (first == null ? void 0 : first.segment) || null;\n\t\t};\n\t} else if (typeof chunking === \"function\") detectChunk = (buffer) => {\n\t\tconst match = chunking(buffer);\n\t\tif (match == null) return null;\n\t\tif (!match.length) throw new Error(`Chunking function must return a non-empty string.`);\n\t\tif (!buffer.startsWith(match)) throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: \"${match}\" expected to start with \"${buffer}\"`);\n\t\treturn match;\n\t};\n\telse {\n\t\tconst chunkingRegex = typeof chunking === \"string\" ? CHUNKING_REGEXPS[chunking] : chunking instanceof RegExp ? chunking : void 0;\n\t\tif (chunkingRegex == null) throw new InvalidArgumentError$1({\n\t\t\targument: \"chunking\",\n\t\t\tmessage: `Chunking must be \"word\", \"line\", a RegExp, an Intl.Segmenter, or a ChunkDetector function. Received: ${chunking}`\n\t\t});\n\t\tdetectChunk = (buffer) => {\n\t\t\tconst match = chunkingRegex.exec(buffer);\n\t\t\tif (!match) return null;\n\t\t\treturn buffer.slice(0, match.index) + (match == null ? void 0 : match[0]);\n\t\t};\n\t}\n\treturn () => {\n\t\tlet buffer = \"\";\n\t\tlet id = \"\";\n\t\tlet type = void 0;\n\t\tlet providerMetadata = void 0;\n\t\tfunction flushBuffer(controller) {\n\t\t\tif (type !== void 0 && (buffer.length > 0 || providerMetadata != null)) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype,\n\t\t\t\t\ttext: buffer,\n\t\t\t\t\tid,\n\t\t\t\t\t...providerMetadata != null ? { providerMetadata } : {}\n\t\t\t\t});\n\t\t\t\tbuffer = \"\";\n\t\t\t\tproviderMetadata = void 0;\n\t\t\t}\n\t\t}\n\t\treturn new TransformStream({ async transform(chunk, controller) {\n\t\t\tif (chunk.type !== \"text-delta\" && chunk.type !== \"reasoning-delta\") {\n\t\t\t\tflushBuffer(controller);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (chunk.text.length === 0 && chunk.providerMetadata != null) {\n\t\t\t\tflushBuffer(controller);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (buffer.length > 0 && (chunk.type !== type || chunk.id !== id || providerMetadata != null || chunk.providerMetadata != null)) flushBuffer(controller);\n\t\t\tbuffer += chunk.text;\n\t\t\tid = chunk.id;\n\t\t\ttype = chunk.type;\n\t\t\tproviderMetadata = chunk.providerMetadata;\n\t\t\tlet match;\n\t\t\twhile ((match = detectChunk(buffer)) != null) {\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\ttype,\n\t\t\t\t\ttext: match,\n\t\t\t\t\tid,\n\t\t\t\t\t...providerMetadata != null ? { providerMetadata } : {}\n\t\t\t\t});\n\t\t\t\tbuffer = buffer.slice(match.length);\n\t\t\t\tawait delay$2(isDocumentHidden() ? null : delayInMs);\n\t\t\t}\n\t\t\tif (buffer.length === 0) providerMetadata = void 0;\n\t\t} });\n\t};\n}\nvar defaultDownload = createDownload();\nasync function experimental_generateVideo({ model: modelArg, prompt: promptArg, n = 1, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, frameImages, inputReferences, generateAudio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn = defaultDownload }) {\n\tvar _a23, _b;\n\tconst model = resolveVideoModel(modelArg);\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst { prompt, image } = normalizePrompt2(promptArg);\n\tconst normalizedFrameImages = frameImages == null ? void 0 : frameImages.flatMap((frame) => {\n\t\tconst normalizedImage = normalizeImageData(frame.image);\n\t\treturn normalizedImage != null ? [{\n\t\t\timage: normalizedImage,\n\t\t\tframeType: frame.frameType\n\t\t}] : [];\n\t});\n\tconst normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.flatMap((reference) => {\n\t\tconst normalized = normalizeReferenceData(reference);\n\t\treturn normalized != null ? [normalized] : [];\n\t});\n\tconst effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;\n\tconst warnings = [];\n\tif (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) warnings.push({\n\t\ttype: \"other\",\n\t\tmessage: \"inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined.\"\n\t});\n\tconst firstFrameImage = (_a23 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find((frame) => frame.frameType === \"first_frame\")) == null ? void 0 : _a23.image;\n\tif (image != null && firstFrameImage != null) warnings.push({\n\t\ttype: \"other\",\n\t\tmessage: \"prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image.\"\n\t});\n\tconst resolvedImage = firstFrameImage != null ? firstFrameImage : image;\n\tconst maxVideosPerCallWithDefault = (_b = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b : 1;\n\tconst callCount = Math.ceil(n / maxVideosPerCallWithDefault);\n\tconst callVideoCounts = Array.from({ length: callCount }, (_, index) => {\n\t\tconst remaining = n - index * maxVideosPerCallWithDefault;\n\t\treturn Math.min(remaining, maxVideosPerCallWithDefault);\n\t});\n\tconst results = await Promise.all(callVideoCounts.map(async (callVideoCount) => await retry(() => model.doGenerate({\n\t\tprompt,\n\t\tn: callVideoCount,\n\t\taspectRatio,\n\t\tresolution,\n\t\tduration,\n\t\tfps,\n\t\tseed,\n\t\timage: resolvedImage,\n\t\tframeImages: normalizedFrameImages,\n\t\tinputReferences: effectiveInputReferences,\n\t\tgenerateAudio,\n\t\tproviderOptions: providerOptions != null ? providerOptions : {},\n\t\theaders: headersWithUserAgent,\n\t\tabortSignal\n\t}))));\n\tconst videos = [];\n\tconst responses = [];\n\tconst providerMetadata = {};\n\tfor (const result of results) {\n\t\tfor (const videoData of result.videos) switch (videoData.type) {\n\t\t\tcase \"url\": {\n\t\t\t\tconst { data, mediaType: downloadedMediaType } = await downloadFn({\n\t\t\t\t\turl: new URL(videoData.url),\n\t\t\t\t\tabortSignal\n\t\t\t\t});\n\t\t\t\tconst isUsableMediaType = (type) => !!type && type !== \"application/octet-stream\";\n\t\t\t\tconst mediaType = isUsableMediaType(videoData.mediaType) && videoData.mediaType || isUsableMediaType(downloadedMediaType) && downloadedMediaType || detectMediaType({\n\t\t\t\t\tdata,\n\t\t\t\t\tsignatures: videoMediaTypeSignatures\n\t\t\t\t}) || \"video/mp4\";\n\t\t\t\tvideos.push(new DefaultGeneratedFile({\n\t\t\t\t\tdata,\n\t\t\t\t\tmediaType\n\t\t\t\t}));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"base64\":\n\t\t\t\tvideos.push(new DefaultGeneratedFile({\n\t\t\t\t\tdata: videoData.data,\n\t\t\t\t\tmediaType: videoData.mediaType || \"video/mp4\"\n\t\t\t\t}));\n\t\t\t\tbreak;\n\t\t\tcase \"binary\": {\n\t\t\t\tconst mediaType = videoData.mediaType || detectMediaType({\n\t\t\t\t\tdata: videoData.data,\n\t\t\t\t\tsignatures: videoMediaTypeSignatures\n\t\t\t\t}) || \"video/mp4\";\n\t\t\t\tvideos.push(new DefaultGeneratedFile({\n\t\t\t\t\tdata: videoData.data,\n\t\t\t\t\tmediaType\n\t\t\t\t}));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\twarnings.push(...result.warnings);\n\t\tresponses.push({\n\t\t\ttimestamp: result.response.timestamp,\n\t\t\tmodelId: result.response.modelId,\n\t\t\theaders: result.response.headers,\n\t\t\tproviderMetadata: result.providerMetadata\n\t\t});\n\t\tif (result.providerMetadata != null) for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {\n\t\t\tconst existingMetadata = getOwn(providerMetadata, providerName);\n\t\t\tif (existingMetadata != null && typeof existingMetadata === \"object\") {\n\t\t\t\tsetOwn(providerMetadata, providerName, {\n\t\t\t\t\t...existingMetadata,\n\t\t\t\t\t...metadata\n\t\t\t\t});\n\t\t\t\tif (\"videos\" in existingMetadata && Array.isArray(existingMetadata.videos) && \"videos\" in metadata && Array.isArray(metadata.videos)) providerMetadata[providerName].videos = [...existingMetadata.videos, ...metadata.videos];\n\t\t\t} else setOwn(providerMetadata, providerName, metadata);\n\t\t}\n\t}\n\tif (videos.length === 0) throw new NoVideoGeneratedError({ responses });\n\tif (warnings.length > 0) logWarnings({\n\t\twarnings,\n\t\tprovider: model.provider,\n\t\tmodel: model.modelId\n\t});\n\treturn {\n\t\tvideo: videos[0],\n\t\tvideos,\n\t\twarnings,\n\t\tresponses,\n\t\tproviderMetadata\n\t};\n}\nfunction normalizePrompt2(promptArg) {\n\tif (typeof promptArg === \"string\") return {\n\t\tprompt: promptArg,\n\t\timage: void 0\n\t};\n\treturn {\n\t\tprompt: promptArg.text,\n\t\timage: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0\n\t};\n}\nfunction detectFileMediaType(data, restrictToImages) {\n\tvar _a23;\n\tconst detected = restrictToImages ? detectMediaType({\n\t\tdata,\n\t\tsignatures: imageMediaTypeSignatures\n\t}) : (_a23 = detectMediaType({\n\t\tdata,\n\t\tsignatures: imageMediaTypeSignatures\n\t})) != null ? _a23 : detectMediaType({\n\t\tdata,\n\t\tsignatures: videoMediaTypeSignatures\n\t});\n\treturn detected != null ? detected : \"image/png\";\n}\nfunction normalizeImageData(dataContent, { restrictToImages = true } = {}) {\n\tif (typeof dataContent === \"string\") {\n\t\tif (dataContent.startsWith(\"http://\") || dataContent.startsWith(\"https://\")) return {\n\t\t\ttype: \"url\",\n\t\t\turl: dataContent\n\t\t};\n\t\tif (dataContent.startsWith(\"data:\")) {\n\t\t\tconst { mediaType, base64Content } = splitDataUrl(dataContent);\n\t\t\tconst data = convertBase64ToUint8Array(base64Content != null ? base64Content : \"\");\n\t\t\treturn {\n\t\t\t\ttype: \"file\",\n\t\t\t\tmediaType: mediaType != null ? mediaType : detectFileMediaType(data, restrictToImages),\n\t\t\t\tdata\n\t\t\t};\n\t\t}\n\t\tconst bytes = convertBase64ToUint8Array(dataContent);\n\t\treturn {\n\t\t\ttype: \"file\",\n\t\t\tmediaType: detectFileMediaType(bytes, restrictToImages),\n\t\t\tdata: bytes\n\t\t};\n\t}\n\tif (dataContent instanceof Uint8Array || dataContent instanceof ArrayBuffer) {\n\t\tconst bytes = dataContent instanceof Uint8Array ? dataContent : new Uint8Array(dataContent);\n\t\treturn {\n\t\t\ttype: \"file\",\n\t\t\tmediaType: detectFileMediaType(bytes, restrictToImages),\n\t\t\tdata: bytes\n\t\t};\n\t}\n}\nfunction normalizeReferenceData(reference) {\n\tif (!(typeof reference === \"object\" && reference != null && !(reference instanceof Uint8Array) && !(reference instanceof ArrayBuffer) && \"data\" in reference)) return normalizeImageData(reference, { restrictToImages: false });\n\tconst normalized = normalizeImageData(reference.data, { restrictToImages: false });\n\tif (normalized == null) return normalized;\n\treturn {\n\t\t...normalized,\n\t\t...reference.mediaType != null ? { mediaType: reference.mediaType } : {}\n\t};\n}\nasync function invokeModelMaxVideosPerCall(model) {\n\tif (typeof model.maxVideosPerCall === \"function\") return await model.maxVideosPerCall({ modelId: model.modelId });\n\treturn model.maxVideosPerCall;\n}\nfunction defaultEmbeddingSettingsMiddleware({ settings }) {\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\ttransformParams: async ({ params }) => {\n\t\t\treturn mergeObjects(settings, params);\n\t\t}\n\t};\n}\nfunction defaultSettingsMiddleware({ settings }) {\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\ttransformParams: async ({ params }) => {\n\t\t\treturn mergeObjects(settings, params);\n\t\t}\n\t};\n}\nfunction defaultTransform(text2) {\n\treturn text2.replace(/^```(?:json)?\\s*\\n?/, \"\").replace(/\\n?```\\s*$/, \"\").trim();\n}\nfunction stripMarkdownCodeFenceSuffix(text2) {\n\treturn text2.replace(/\\n?```\\s*$/, \"\").trimEnd();\n}\nfunction extractJsonMiddleware(options) {\n\tvar _a23;\n\tconst transform = (_a23 = options == null ? void 0 : options.transform) != null ? _a23 : defaultTransform;\n\tconst hasCustomTransform = (options == null ? void 0 : options.transform) !== void 0;\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\twrapGenerate: async ({ doGenerate }) => {\n\t\t\tconst { content, ...rest } = await doGenerate();\n\t\t\tconst transformedContent = [];\n\t\t\tfor (const part of content) {\n\t\t\t\tif (part.type !== \"text\") {\n\t\t\t\t\ttransformedContent.push(part);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttransformedContent.push({\n\t\t\t\t\t...part,\n\t\t\t\t\ttext: transform(part.text)\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: transformedContent,\n\t\t\t\t...rest\n\t\t\t};\n\t\t},\n\t\twrapStream: async ({ doStream }) => {\n\t\t\tconst { stream, ...rest } = await doStream();\n\t\t\tconst textBlocks = createIdMap();\n\t\t\tconst SUFFIX_BUFFER_SIZE = 12;\n\t\t\treturn {\n\t\t\t\tstream: stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {\n\t\t\t\t\tif (chunk.type === \"text-start\") {\n\t\t\t\t\t\ttextBlocks[chunk.id] = {\n\t\t\t\t\t\t\tstartEvent: chunk,\n\t\t\t\t\t\t\tphase: hasCustomTransform ? \"buffering\" : \"prefix\",\n\t\t\t\t\t\t\tbuffer: \"\",\n\t\t\t\t\t\t\tprefixStripped: false\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.type === \"text-delta\") {\n\t\t\t\t\t\tconst block = textBlocks[chunk.id];\n\t\t\t\t\t\tif (!block) {\n\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblock.buffer += chunk.delta;\n\t\t\t\t\t\tif (block.phase === \"buffering\") return;\n\t\t\t\t\t\tif (block.phase === \"prefix\") {\n\t\t\t\t\t\t\tif (block.buffer.length > 0 && !block.buffer.startsWith(\"`\")) {\n\t\t\t\t\t\t\t\tblock.phase = \"streaming\";\n\t\t\t\t\t\t\t\tcontroller.enqueue(block.startEvent);\n\t\t\t\t\t\t\t} else if (block.buffer.startsWith(\"```\")) {\n\t\t\t\t\t\t\t\tif (block.buffer.includes(\"\\n\")) {\n\t\t\t\t\t\t\t\t\tconst prefixMatch = block.buffer.match(/^```(?:json)?\\s*\\n/);\n\t\t\t\t\t\t\t\t\tif (prefixMatch) {\n\t\t\t\t\t\t\t\t\t\tblock.buffer = block.buffer.slice(prefixMatch[0].length);\n\t\t\t\t\t\t\t\t\t\tblock.prefixStripped = true;\n\t\t\t\t\t\t\t\t\t\tblock.phase = \"streaming\";\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(block.startEvent);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tblock.phase = \"streaming\";\n\t\t\t\t\t\t\t\t\t\tcontroller.enqueue(block.startEvent);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (block.buffer.length >= 3 && !block.buffer.startsWith(\"```\")) {\n\t\t\t\t\t\t\t\tblock.phase = \"streaming\";\n\t\t\t\t\t\t\t\tcontroller.enqueue(block.startEvent);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (block.phase === \"streaming\" && block.buffer.length > SUFFIX_BUFFER_SIZE) {\n\t\t\t\t\t\t\tconst toStream = block.buffer.slice(0, -12);\n\t\t\t\t\t\t\tblock.buffer = block.buffer.slice(-12);\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\tid: chunk.id,\n\t\t\t\t\t\t\t\tdelta: toStream\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.type === \"text-end\") {\n\t\t\t\t\t\tconst block = textBlocks[chunk.id];\n\t\t\t\t\t\tif (block) {\n\t\t\t\t\t\t\tif (block.phase === \"prefix\" || block.phase === \"buffering\") controller.enqueue(block.startEvent);\n\t\t\t\t\t\t\tlet remaining = block.buffer;\n\t\t\t\t\t\t\tif (block.phase === \"buffering\") remaining = transform(remaining);\n\t\t\t\t\t\t\telse if (block.prefixStripped) remaining = stripMarkdownCodeFenceSuffix(remaining);\n\t\t\t\t\t\t\telse if (block.phase === \"prefix\") remaining = transform(remaining);\n\t\t\t\t\t\t\telse remaining = stripMarkdownCodeFenceSuffix(remaining);\n\t\t\t\t\t\t\tif (remaining.length > 0) controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\tid: chunk.id,\n\t\t\t\t\t\t\t\tdelta: remaining\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\t\tdelete textBlocks[chunk.id];\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t} })),\n\t\t\t\t...rest\n\t\t\t};\n\t\t}\n\t};\n}\nfunction getPotentialStartIndex(text2, searchedText) {\n\tif (searchedText.length === 0) return null;\n\tconst directIndex = text2.indexOf(searchedText);\n\tif (directIndex !== -1) return directIndex;\n\tfor (let i = text2.length - 1; i >= 0; i--) {\n\t\tconst suffix = text2.substring(i);\n\t\tif (searchedText.startsWith(suffix)) return i;\n\t}\n\treturn null;\n}\nfunction extractReasoningMiddleware({ tagName, separator = \"\\n\", startWithReasoning = false }) {\n\tconst openingTag = `<${tagName}>`;\n\tconst closingTag = `</${tagName}>`;\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\twrapGenerate: async ({ doGenerate }) => {\n\t\t\tconst { content, ...rest } = await doGenerate();\n\t\t\tconst transformedContent = [];\n\t\t\tfor (const part of content) {\n\t\t\t\tif (part.type !== \"text\") {\n\t\t\t\t\ttransformedContent.push(part);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst text2 = startWithReasoning ? openingTag + part.text : part.text;\n\t\t\t\tconst regexp = new RegExp(`${openingTag}(.*?)${closingTag}`, \"gs\");\n\t\t\t\tconst matches = Array.from(text2.matchAll(regexp));\n\t\t\t\tif (!matches.length) {\n\t\t\t\t\ttransformedContent.push(part);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst reasoningText = matches.map((match) => match[1]).join(separator);\n\t\t\t\tlet textWithoutReasoning = text2;\n\t\t\t\tfor (let i = matches.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst match = matches[i];\n\t\t\t\t\tconst beforeMatch = textWithoutReasoning.slice(0, match.index);\n\t\t\t\t\tconst afterMatch = textWithoutReasoning.slice(match.index + match[0].length);\n\t\t\t\t\ttextWithoutReasoning = beforeMatch + (beforeMatch.length > 0 && afterMatch.length > 0 ? separator : \"\") + afterMatch;\n\t\t\t\t}\n\t\t\t\ttransformedContent.push({\n\t\t\t\t\ttype: \"reasoning\",\n\t\t\t\t\ttext: reasoningText\n\t\t\t\t});\n\t\t\t\ttransformedContent.push({\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: textWithoutReasoning\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: transformedContent,\n\t\t\t\t...rest\n\t\t\t};\n\t\t},\n\t\twrapStream: async ({ doStream }) => {\n\t\t\tconst { stream, ...rest } = await doStream();\n\t\t\tconst reasoningExtractions = createIdMap();\n\t\t\tlet delayedTextStart;\n\t\t\treturn {\n\t\t\t\tstream: stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {\n\t\t\t\t\tif (chunk.type === \"text-start\") {\n\t\t\t\t\t\tdelayedTextStart = chunk;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.type === \"text-end\" && delayedTextStart) {\n\t\t\t\t\t\tcontroller.enqueue(delayedTextStart);\n\t\t\t\t\t\tdelayedTextStart = void 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.type !== \"text-delta\") {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (reasoningExtractions[chunk.id] == null) reasoningExtractions[chunk.id] = {\n\t\t\t\t\t\tisFirstReasoning: true,\n\t\t\t\t\t\tisFirstText: true,\n\t\t\t\t\t\tafterSwitch: false,\n\t\t\t\t\t\tisReasoning: startWithReasoning,\n\t\t\t\t\t\tbuffer: \"\",\n\t\t\t\t\t\tidCounter: 0,\n\t\t\t\t\t\ttextId: chunk.id\n\t\t\t\t\t};\n\t\t\t\t\tconst activeExtraction = reasoningExtractions[chunk.id];\n\t\t\t\t\tactiveExtraction.buffer += chunk.delta;\n\t\t\t\t\tfunction publish(text2) {\n\t\t\t\t\t\tif (text2.length > 0) {\n\t\t\t\t\t\t\tconst prefix = activeExtraction.afterSwitch && (activeExtraction.isReasoning ? !activeExtraction.isFirstReasoning : !activeExtraction.isFirstText) ? separator : \"\";\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning && (activeExtraction.afterSwitch || activeExtraction.isFirstReasoning)) controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-start\",\n\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter}`\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning) controller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\t\tdelta: prefix + text2,\n\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter}`\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (delayedTextStart) {\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(delayedTextStart);\n\t\t\t\t\t\t\t\t\tdelayedTextStart = void 0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\tdelta: prefix + text2,\n\t\t\t\t\t\t\t\t\tid: activeExtraction.textId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactiveExtraction.afterSwitch = false;\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning) activeExtraction.isFirstReasoning = false;\n\t\t\t\t\t\t\telse activeExtraction.isFirstText = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdo {\n\t\t\t\t\t\tconst nextTag = activeExtraction.isReasoning ? closingTag : openingTag;\n\t\t\t\t\t\tconst startIndex = getPotentialStartIndex(activeExtraction.buffer, nextTag);\n\t\t\t\t\t\tif (startIndex == null) {\n\t\t\t\t\t\t\tpublish(activeExtraction.buffer);\n\t\t\t\t\t\t\tactiveExtraction.buffer = \"\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpublish(activeExtraction.buffer.slice(0, startIndex));\n\t\t\t\t\t\tif (startIndex + nextTag.length <= activeExtraction.buffer.length) {\n\t\t\t\t\t\t\tactiveExtraction.buffer = activeExtraction.buffer.slice(startIndex + nextTag.length);\n\t\t\t\t\t\t\tif (activeExtraction.isReasoning) {\n\t\t\t\t\t\t\t\tif (activeExtraction.isFirstReasoning) controller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"reasoning-start\",\n\t\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter}`\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"reasoning-end\",\n\t\t\t\t\t\t\t\t\tid: `reasoning-${activeExtraction.idCounter++}`\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactiveExtraction.isReasoning = !activeExtraction.isReasoning;\n\t\t\t\t\t\t\tactiveExtraction.afterSwitch = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactiveExtraction.buffer = activeExtraction.buffer.slice(startIndex);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} while (true);\n\t\t\t\t} })),\n\t\t\t\t...rest\n\t\t\t};\n\t\t}\n\t};\n}\nfunction simulateStreamingMiddleware() {\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\twrapStream: async ({ doGenerate }) => {\n\t\t\tconst result = await doGenerate();\n\t\t\tlet id = 0;\n\t\t\treturn {\n\t\t\t\tstream: new ReadableStream({ start(controller) {\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"stream-start\",\n\t\t\t\t\t\twarnings: result.warnings\n\t\t\t\t\t});\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"response-metadata\",\n\t\t\t\t\t\t...result.response\n\t\t\t\t\t});\n\t\t\t\t\tfor (const part of result.content) switch (part.type) {\n\t\t\t\t\t\tcase \"text\":\n\t\t\t\t\t\t\tif (part.text.length > 0) {\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-start\",\n\t\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\t\t...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-delta\",\n\t\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\t\tdelta: part.text\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\t\ttype: \"text-end\",\n\t\t\t\t\t\t\t\t\tid: String(id)\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tid++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"reasoning\":\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-start\",\n\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\tproviderMetadata: part.providerMetadata\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-delta\",\n\t\t\t\t\t\t\t\tid: String(id),\n\t\t\t\t\t\t\t\tdelta: part.text\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\t\t\ttype: \"reasoning-end\",\n\t\t\t\t\t\t\t\tid: String(id)\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tid++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault: controller.enqueue(part);\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t\ttype: \"finish\",\n\t\t\t\t\t\tfinishReason: result.finishReason,\n\t\t\t\t\t\tusage: result.usage,\n\t\t\t\t\t\tproviderMetadata: result.providerMetadata\n\t\t\t\t\t});\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} }),\n\t\t\t\trequest: result.request,\n\t\t\t\tresponse: result.response\n\t\t\t};\n\t\t}\n\t};\n}\nfunction defaultFormatExample(example) {\n\treturn JSON.stringify(example.input);\n}\nfunction addToolInputExamplesMiddleware({ prefix = \"Input Examples:\", format = defaultFormatExample, remove = true } = {}) {\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\ttransformParams: async ({ params }) => {\n\t\t\tvar _a23;\n\t\t\tif (!((_a23 = params.tools) == null ? void 0 : _a23.length)) return params;\n\t\t\tconst transformedTools = params.tools.map((tool2) => {\n\t\t\t\tvar _a24;\n\t\t\t\tif (tool2.type !== \"function\" || !((_a24 = tool2.inputExamples) == null ? void 0 : _a24.length)) return tool2;\n\t\t\t\tconst examplesSection = `${prefix}\n${tool2.inputExamples.map((example, index) => format(example, index)).join(\"\\n\")}`;\n\t\t\t\tconst toolDescription = tool2.description ? `${tool2.description}\n\n${examplesSection}` : examplesSection;\n\t\t\t\treturn {\n\t\t\t\t\t...tool2,\n\t\t\t\t\tdescription: toolDescription,\n\t\t\t\t\tinputExamples: remove ? void 0 : tool2.inputExamples\n\t\t\t\t};\n\t\t\t});\n\t\t\treturn {\n\t\t\t\t...params,\n\t\t\t\ttools: transformedTools\n\t\t\t};\n\t\t}\n\t};\n}\nvar wrapLanguageModel = ({ model, middleware: middlewareArg, modelId, providerId }) => {\n\treturn [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {\n\t\treturn doWrap({\n\t\t\tmodel: wrappedModel,\n\t\t\tmiddleware,\n\t\t\tmodelId,\n\t\t\tproviderId\n\t\t});\n\t}, model);\n};\nvar doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream, overrideProvider, overrideModelId, overrideSupportedUrls }, modelId, providerId }) => {\n\tvar _a23, _b, _c;\n\tasync function doTransform({ params, type }) {\n\t\treturn transformParams ? await transformParams({\n\t\t\tparams,\n\t\t\ttype,\n\t\t\tmodel\n\t\t}) : params;\n\t}\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\tprovider: (_a23 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a23 : model.provider,\n\t\tmodelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,\n\t\tsupportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,\n\t\tasync doGenerate(params) {\n\t\t\tconst transformedParams = await doTransform({\n\t\t\t\tparams,\n\t\t\t\ttype: \"generate\"\n\t\t\t});\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\tconst doStream = async () => model.doStream(transformedParams);\n\t\t\treturn wrapGenerate ? wrapGenerate({\n\t\t\t\tdoGenerate,\n\t\t\t\tdoStream,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doGenerate();\n\t\t},\n\t\tasync doStream(params) {\n\t\t\tconst transformedParams = await doTransform({\n\t\t\t\tparams,\n\t\t\t\ttype: \"stream\"\n\t\t\t});\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\tconst doStream = async () => model.doStream(transformedParams);\n\t\t\treturn wrapStream ? wrapStream({\n\t\t\t\tdoGenerate,\n\t\t\t\tdoStream,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doStream();\n\t\t}\n\t};\n};\nvar wrapEmbeddingModel = ({ model, middleware: middlewareArg, modelId, providerId }) => {\n\treturn [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {\n\t\treturn doWrap2({\n\t\t\tmodel: wrappedModel,\n\t\t\tmiddleware,\n\t\t\tmodelId,\n\t\t\tproviderId\n\t\t});\n\t}, model);\n};\nvar doWrap2 = ({ model, middleware: { transformParams, wrapEmbed, overrideProvider, overrideModelId, overrideMaxEmbeddingsPerCall, overrideSupportsParallelCalls }, modelId, providerId }) => {\n\tvar _a23, _b, _c, _d;\n\tasync function doTransform({ params }) {\n\t\treturn transformParams ? await transformParams({\n\t\t\tparams,\n\t\t\tmodel\n\t\t}) : params;\n\t}\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\tprovider: (_a23 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a23 : model.provider,\n\t\tmodelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,\n\t\tmaxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,\n\t\t[EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL]: getEmbeddingModelMaxInputBytesPerCall(model),\n\t\t[EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER]: getEmbeddingModelProviderOptionsTransformer(model),\n\t\tsupportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,\n\t\tasync doEmbed(params) {\n\t\t\tconst transformedParams = await doTransform({ params });\n\t\t\tconst doEmbed = async () => model.doEmbed(transformedParams);\n\t\t\treturn wrapEmbed ? wrapEmbed({\n\t\t\t\tdoEmbed,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doEmbed();\n\t\t}\n\t};\n};\nvar wrapImageModel = ({ model, middleware: middlewareArg, modelId, providerId }) => {\n\treturn [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {\n\t\treturn doWrap3({\n\t\t\tmodel: wrappedModel,\n\t\t\tmiddleware,\n\t\t\tmodelId,\n\t\t\tproviderId\n\t\t});\n\t}, model);\n};\nvar doWrap3 = ({ model, middleware: { transformParams, wrapGenerate, overrideProvider, overrideModelId, overrideMaxImagesPerCall }, modelId, providerId }) => {\n\tvar _a23, _b, _c;\n\tasync function doTransform({ params }) {\n\t\treturn transformParams ? await transformParams({\n\t\t\tparams,\n\t\t\tmodel\n\t\t}) : params;\n\t}\n\tconst maxImagesPerCallRaw = (_a23 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a23 : model.maxImagesPerCall;\n\tconst maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\tprovider: (_b = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _b : model.provider,\n\t\tmodelId: (_c = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _c : model.modelId,\n\t\tmaxImagesPerCall,\n\t\tasync doGenerate(params) {\n\t\t\tconst transformedParams = await doTransform({ params });\n\t\t\tconst doGenerate = async () => model.doGenerate(transformedParams);\n\t\t\treturn wrapGenerate ? wrapGenerate({\n\t\t\t\tdoGenerate,\n\t\t\t\tparams: transformedParams,\n\t\t\t\tmodel\n\t\t\t}) : doGenerate();\n\t\t}\n\t};\n};\nfunction asProviderV3(provider) {\n\tif (\"specificationVersion\" in provider && provider.specificationVersion === \"v3\") return provider;\n\tconst v2Provider = provider;\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\tlanguageModel: (modelId) => asLanguageModelV3(v2Provider.languageModel(modelId)),\n\t\tembeddingModel: (modelId) => asEmbeddingModelV3(v2Provider.textEmbeddingModel(modelId)),\n\t\timageModel: (modelId) => asImageModelV3(v2Provider.imageModel(modelId)),\n\t\ttranscriptionModel: v2Provider.transcriptionModel ? (modelId) => asTranscriptionModelV3(v2Provider.transcriptionModel(modelId)) : void 0,\n\t\tspeechModel: v2Provider.speechModel ? (modelId) => asSpeechModelV3(v2Provider.speechModel(modelId)) : void 0,\n\t\trerankingModel: void 0\n\t};\n}\nfunction wrapProvider({ provider, languageModelMiddleware, imageModelMiddleware }) {\n\tconst providerV3 = asProviderV3(provider);\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\tlanguageModel: (modelId) => wrapLanguageModel({\n\t\t\tmodel: providerV3.languageModel(modelId),\n\t\t\tmiddleware: languageModelMiddleware\n\t\t}),\n\t\tembeddingModel: providerV3.embeddingModel,\n\t\timageModel: (modelId) => {\n\t\t\tlet model = providerV3.imageModel(modelId);\n\t\t\tif (imageModelMiddleware != null) model = wrapImageModel({\n\t\t\t\tmodel,\n\t\t\t\tmiddleware: imageModelMiddleware\n\t\t\t});\n\t\t\treturn model;\n\t\t},\n\t\ttranscriptionModel: providerV3.transcriptionModel,\n\t\tspeechModel: providerV3.speechModel,\n\t\trerankingModel: providerV3.rerankingModel\n\t};\n}\nfunction customProvider({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, rerankingModels, videoModels, fallbackProvider: fallbackProviderArg }) {\n\tconst fallbackProvider = fallbackProviderArg ? asProviderV3(fallbackProviderArg) : void 0;\n\treturn {\n\t\tspecificationVersion: \"v3\",\n\t\tlanguageModel(modelId) {\n\t\t\tif (languageModels != null && modelId in languageModels) return languageModels[modelId];\n\t\t\tif (fallbackProvider) return fallbackProvider.languageModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"languageModel\"\n\t\t\t});\n\t\t},\n\t\tembeddingModel(modelId) {\n\t\t\tif (embeddingModels != null && modelId in embeddingModels) return embeddingModels[modelId];\n\t\t\tif (fallbackProvider) return fallbackProvider.embeddingModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"embeddingModel\"\n\t\t\t});\n\t\t},\n\t\timageModel(modelId) {\n\t\t\tif (imageModels != null && modelId in imageModels) return imageModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.imageModel) return fallbackProvider.imageModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"imageModel\"\n\t\t\t});\n\t\t},\n\t\ttranscriptionModel(modelId) {\n\t\t\tif (transcriptionModels != null && modelId in transcriptionModels) return transcriptionModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.transcriptionModel) return fallbackProvider.transcriptionModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"transcriptionModel\"\n\t\t\t});\n\t\t},\n\t\tspeechModel(modelId) {\n\t\t\tif (speechModels != null && modelId in speechModels) return speechModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.speechModel) return fallbackProvider.speechModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"speechModel\"\n\t\t\t});\n\t\t},\n\t\trerankingModel(modelId) {\n\t\t\tif (rerankingModels != null && modelId in rerankingModels) return rerankingModels[modelId];\n\t\t\tif (fallbackProvider == null ? void 0 : fallbackProvider.rerankingModel) return fallbackProvider.rerankingModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"rerankingModel\"\n\t\t\t});\n\t\t},\n\t\tvideoModel(modelId) {\n\t\t\tif (videoModels != null && modelId in videoModels) return videoModels[modelId];\n\t\t\tconst videoModel = fallbackProvider == null ? void 0 : fallbackProvider.videoModel;\n\t\t\tif (videoModel) return videoModel(modelId);\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId,\n\t\t\t\tmodelType: \"videoModel\"\n\t\t\t});\n\t\t}\n\t};\n}\nvar experimental_customProvider = customProvider;\nvar name22 = \"AI_NoSuchProviderError\";\nvar marker22 = `vercel.ai.error.${name22}`;\nvar symbol22 = Symbol.for(marker22);\nvar _a22;\nvar NoSuchProviderError = class extends NoSuchModelError {\n\tconstructor({ modelId, modelType, providerId, availableProviders, message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})` }) {\n\t\tsuper({\n\t\t\terrorName: name22,\n\t\t\tmodelId,\n\t\t\tmodelType,\n\t\t\tmessage\n\t\t});\n\t\tthis[_a22] = true;\n\t\tthis.providerId = providerId;\n\t\tthis.availableProviders = availableProviders;\n\t}\n\tstatic isInstance(error) {\n\t\treturn AISDKError.hasMarker(error, marker22);\n\t}\n};\n_a22 = symbol22;\nfunction createProviderRegistry(providers, { separator = \":\", languageModelMiddleware, imageModelMiddleware } = {}) {\n\tconst registry = new DefaultProviderRegistry({\n\t\tseparator,\n\t\tlanguageModelMiddleware,\n\t\timageModelMiddleware\n\t});\n\tfor (const [id, provider] of Object.entries(providers)) registry.registerProvider({\n\t\tid,\n\t\tprovider\n\t});\n\treturn registry;\n}\nvar experimental_createProviderRegistry = createProviderRegistry;\nvar DefaultProviderRegistry = class {\n\tconstructor({ separator, languageModelMiddleware, imageModelMiddleware }) {\n\t\tthis.providers = /* @__PURE__ */ Object.create(null);\n\t\tthis.separator = separator;\n\t\tthis.languageModelMiddleware = languageModelMiddleware;\n\t\tthis.imageModelMiddleware = imageModelMiddleware;\n\t}\n\tregisterProvider({ id, provider }) {\n\t\tthis.providers[id] = provider;\n\t}\n\tgetProvider(id, modelType) {\n\t\tconst provider = this.providers[id];\n\t\tif (provider == null) throw new NoSuchProviderError({\n\t\t\tmodelId: id,\n\t\t\tmodelType,\n\t\t\tproviderId: id,\n\t\t\tavailableProviders: Object.keys(this.providers)\n\t\t});\n\t\treturn provider;\n\t}\n\tsplitId(id, modelType) {\n\t\tconst index = id.indexOf(this.separator);\n\t\tif (index === -1) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType,\n\t\t\tmessage: `Invalid ${modelType} id for registry: ${id} (must be in the format \"providerId${this.separator}modelId\")`\n\t\t});\n\t\treturn [id.slice(0, index), id.slice(index + this.separator.length)];\n\t}\n\tlanguageModel(id) {\n\t\tvar _a23, _b;\n\t\tconst [providerId, modelId] = this.splitId(id, \"languageModel\");\n\t\tlet model = (_b = (_a23 = this.getProvider(providerId, \"languageModel\")).languageModel) == null ? void 0 : _b.call(_a23, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"languageModel\"\n\t\t});\n\t\tif (this.languageModelMiddleware != null) model = wrapLanguageModel({\n\t\t\tmodel,\n\t\t\tmiddleware: this.languageModelMiddleware\n\t\t});\n\t\treturn model;\n\t}\n\tembeddingModel(id) {\n\t\tvar _a23;\n\t\tconst [providerId, modelId] = this.splitId(id, \"embeddingModel\");\n\t\tconst provider = this.getProvider(providerId, \"embeddingModel\");\n\t\tconst model = (_a23 = provider.embeddingModel) == null ? void 0 : _a23.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"embeddingModel\"\n\t\t});\n\t\treturn model;\n\t}\n\timageModel(id) {\n\t\tvar _a23;\n\t\tconst [providerId, modelId] = this.splitId(id, \"imageModel\");\n\t\tconst provider = this.getProvider(providerId, \"imageModel\");\n\t\tlet model = (_a23 = provider.imageModel) == null ? void 0 : _a23.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"imageModel\"\n\t\t});\n\t\tif (this.imageModelMiddleware != null) model = wrapImageModel({\n\t\t\tmodel,\n\t\t\tmiddleware: this.imageModelMiddleware\n\t\t});\n\t\treturn model;\n\t}\n\ttranscriptionModel(id) {\n\t\tvar _a23;\n\t\tconst [providerId, modelId] = this.splitId(id, \"transcriptionModel\");\n\t\tconst provider = this.getProvider(providerId, \"transcriptionModel\");\n\t\tconst model = (_a23 = provider.transcriptionModel) == null ? void 0 : _a23.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"transcriptionModel\"\n\t\t});\n\t\treturn model;\n\t}\n\tspeechModel(id) {\n\t\tvar _a23;\n\t\tconst [providerId, modelId] = this.splitId(id, \"speechModel\");\n\t\tconst provider = this.getProvider(providerId, \"speechModel\");\n\t\tconst model = (_a23 = provider.speechModel) == null ? void 0 : _a23.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"speechModel\"\n\t\t});\n\t\treturn model;\n\t}\n\trerankingModel(id) {\n\t\tvar _a23;\n\t\tconst [providerId, modelId] = this.splitId(id, \"rerankingModel\");\n\t\tconst provider = this.getProvider(providerId, \"rerankingModel\");\n\t\tconst model = (_a23 = provider.rerankingModel) == null ? void 0 : _a23.call(provider, modelId);\n\t\tif (model == null) throw new NoSuchModelError({\n\t\t\tmodelId: id,\n\t\t\tmodelType: \"rerankingModel\"\n\t\t});\n\t\treturn model;\n\t}\n};\nasync function rerank({ model: modelArg, documents, query, topN, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry }) {\n\tconst model = resolveRerankingModel(modelArg);\n\tif (documents.length === 0) return new DefaultRerankResult({\n\t\toriginalDocuments: [],\n\t\tranking: [],\n\t\tproviderMetadata: void 0,\n\t\tresponse: {\n\t\t\ttimestamp: /* @__PURE__ */ new Date(),\n\t\t\tmodelId: model.modelId\n\t\t}\n\t});\n\tconst { maxRetries, retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst documentsToSend = typeof documents[0] === \"string\" ? {\n\t\ttype: \"text\",\n\t\tvalues: documents\n\t} : {\n\t\ttype: \"object\",\n\t\tvalues: documents\n\t};\n\tconst baseTelemetryAttributes = getBaseTelemetryAttributes({\n\t\tmodel,\n\t\ttelemetry,\n\t\theaders,\n\t\tsettings: { maxRetries }\n\t});\n\tconst tracer = getTracer(telemetry);\n\treturn recordSpan({\n\t\tname: \"ai.rerank\",\n\t\tattributes: selectTelemetryAttributes({\n\t\t\ttelemetry,\n\t\t\tattributes: {\n\t\t\t\t...assembleOperationName({\n\t\t\t\t\toperationId: \"ai.rerank\",\n\t\t\t\t\ttelemetry\n\t\t\t\t}),\n\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\"ai.documents\": { input: () => documents.map((document2) => JSON.stringify(document2)) }\n\t\t\t}\n\t\t}),\n\t\ttracer,\n\t\tfn: async () => {\n\t\t\tvar _a23, _b;\n\t\t\tconst { ranking, response, providerMetadata, warnings } = await retry(() => recordSpan({\n\t\t\t\tname: \"ai.rerank.doRerank\",\n\t\t\t\tattributes: selectTelemetryAttributes({\n\t\t\t\t\ttelemetry,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...assembleOperationName({\n\t\t\t\t\t\t\toperationId: \"ai.rerank.doRerank\",\n\t\t\t\t\t\t\ttelemetry\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t...baseTelemetryAttributes,\n\t\t\t\t\t\t\"ai.documents\": { input: () => documents.map((document2) => JSON.stringify(document2)) }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttracer,\n\t\t\t\tfn: async (doRerankSpan) => {\n\t\t\t\t\tconst modelResponse = await model.doRerank({\n\t\t\t\t\t\tdocuments: documentsToSend,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\ttopN,\n\t\t\t\t\t\tproviderOptions,\n\t\t\t\t\t\tabortSignal,\n\t\t\t\t\t\theaders\n\t\t\t\t\t});\n\t\t\t\t\tconst ranking2 = modelResponse.ranking;\n\t\t\t\t\tdoRerankSpan.setAttributes(await selectTelemetryAttributes({\n\t\t\t\t\t\ttelemetry,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\"ai.ranking.type\": documentsToSend.type,\n\t\t\t\t\t\t\t\"ai.ranking\": { output: () => ranking2.map((ranking3) => JSON.stringify(ranking3)) }\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tranking: ranking2,\n\t\t\t\t\t\tproviderMetadata: modelResponse.providerMetadata,\n\t\t\t\t\t\tresponse: modelResponse.response,\n\t\t\t\t\t\twarnings: modelResponse.warnings\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}));\n\t\t\tvalidateRankingIndices({\n\t\t\t\tranking,\n\t\t\t\tdocuments\n\t\t\t});\n\t\t\tlogWarnings({\n\t\t\t\twarnings: warnings != null ? warnings : [],\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.modelId\n\t\t\t});\n\t\t\treturn new DefaultRerankResult({\n\t\t\t\toriginalDocuments: documents,\n\t\t\t\tranking: ranking.map((ranking2) => ({\n\t\t\t\t\toriginalIndex: ranking2.index,\n\t\t\t\t\tscore: ranking2.relevanceScore,\n\t\t\t\t\tdocument: documents[ranking2.index]\n\t\t\t\t})),\n\t\t\t\tproviderMetadata,\n\t\t\t\tresponse: {\n\t\t\t\t\tid: response == null ? void 0 : response.id,\n\t\t\t\t\ttimestamp: (_a23 = response == null ? void 0 : response.timestamp) != null ? _a23 : /* @__PURE__ */ new Date(),\n\t\t\t\t\tmodelId: (_b = response == null ? void 0 : response.modelId) != null ? _b : model.modelId,\n\t\t\t\t\theaders: response == null ? void 0 : response.headers,\n\t\t\t\t\tbody: response == null ? void 0 : response.body\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n}\nfunction validateRankingIndices({ ranking, documents }) {\n\tfor (const { index } of ranking) if (!Number.isInteger(index) || index < 0 || index >= documents.length) throw new InvalidResponseDataError({\n\t\tdata: ranking,\n\t\tmessage: `Invalid ranking index ${index}. Expected an integer between 0 and ${documents.length - 1}.`\n\t});\n}\nvar DefaultRerankResult = class {\n\tconstructor(options) {\n\t\tthis.originalDocuments = options.originalDocuments;\n\t\tthis.ranking = options.ranking;\n\t\tthis.response = options.response;\n\t\tthis.providerMetadata = options.providerMetadata;\n\t}\n\tget rerankedDocuments() {\n\t\treturn this.ranking.map((ranking) => ranking.document);\n\t}\n};\nvar defaultDownload2 = createDownload();\nasync function transcribe({ model, audio, providerOptions = {}, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn = defaultDownload2 }) {\n\tconst resolvedModel = resolveTranscriptionModel(model);\n\tif (!resolvedModel) throw new Error(\"Model could not be resolved\");\n\tconst { retry } = prepareRetries({\n\t\tmaxRetries: maxRetriesArg,\n\t\tabortSignal\n\t});\n\tconst headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION}`);\n\tconst audioData = audio instanceof URL ? (await downloadFn({\n\t\turl: audio,\n\t\tabortSignal\n\t})).data : convertDataContentToUint8Array(audio);\n\tconst result = await retry(() => {\n\t\tvar _a23;\n\t\treturn resolvedModel.doGenerate({\n\t\t\taudio: audioData,\n\t\t\tabortSignal,\n\t\t\theaders: headersWithUserAgent,\n\t\t\tproviderOptions,\n\t\t\tmediaType: (_a23 = detectMediaType({\n\t\t\t\tdata: audioData,\n\t\t\t\tsignatures: audioMediaTypeSignatures\n\t\t\t})) != null ? _a23 : \"audio/wav\"\n\t\t});\n\t});\n\tlogWarnings({\n\t\twarnings: result.warnings,\n\t\tprovider: resolvedModel.provider,\n\t\tmodel: resolvedModel.modelId\n\t});\n\tif (!result.text) throw new NoTranscriptGeneratedError({ responses: [result.response] });\n\treturn new DefaultTranscriptionResult({\n\t\ttext: result.text,\n\t\tsegments: result.segments,\n\t\tlanguage: result.language,\n\t\tdurationInSeconds: result.durationInSeconds,\n\t\twarnings: result.warnings,\n\t\tresponses: [result.response],\n\t\tproviderMetadata: result.providerMetadata\n\t});\n}\nvar DefaultTranscriptionResult = class {\n\tconstructor(options) {\n\t\tvar _a23;\n\t\tthis.text = options.text;\n\t\tthis.segments = options.segments;\n\t\tthis.language = options.language;\n\t\tthis.durationInSeconds = options.durationInSeconds;\n\t\tthis.warnings = options.warnings;\n\t\tthis.responses = options.responses;\n\t\tthis.providerMetadata = (_a23 = options.providerMetadata) != null ? _a23 : {};\n\t}\n};\nasync function processTextStream({ stream, onTextPart }) {\n\tconst reader = stream.pipeThrough(new TextDecoderStream()).getReader();\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\tawait onTextPart(value);\n\t}\n}\nvar getOriginalFetch = () => fetch;\nasync function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol = \"data\", setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch: fetch2 = getOriginalFetch() }) {\n\tvar _a23;\n\ttry {\n\t\tsetLoading(true);\n\t\tsetError(void 0);\n\t\tconst abortController = new AbortController();\n\t\tsetAbortController(abortController);\n\t\tsetCompletion(\"\");\n\t\tconst response = await fetch2(api, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprompt,\n\t\t\t\t...body\n\t\t\t}),\n\t\t\tcredentials,\n\t\t\theaders: withUserAgentSuffix({\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t...headers\n\t\t\t}, `ai-sdk/${VERSION}`, getRuntimeEnvironmentUserAgent()),\n\t\t\tsignal: abortController.signal\n\t\t}).catch((err) => {\n\t\t\tthrow err;\n\t\t});\n\t\tif (!response.ok) throw new Error((_a23 = await response.text()) != null ? _a23 : \"Failed to fetch the chat response.\");\n\t\tif (!response.body) throw new Error(\"The response body is empty.\");\n\t\tlet result = \"\";\n\t\tswitch (streamProtocol) {\n\t\t\tcase \"text\":\n\t\t\t\tawait processTextStream({\n\t\t\t\t\tstream: response.body,\n\t\t\t\t\tonTextPart: (chunk) => {\n\t\t\t\t\t\tresult += chunk;\n\t\t\t\t\t\tsetCompletion(result);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase \"data\":\n\t\t\t\tawait consumeStream({\n\t\t\t\t\tstream: parseJsonEventStream({\n\t\t\t\t\t\tstream: response.body,\n\t\t\t\t\t\tschema: uiMessageChunkSchema\n\t\t\t\t\t}).pipeThrough(new TransformStream({ async transform(part) {\n\t\t\t\t\t\tif (!part.success) throw part.error;\n\t\t\t\t\t\tconst streamPart = part.value;\n\t\t\t\t\t\tif (streamPart.type === \"text-delta\") {\n\t\t\t\t\t\t\tresult += streamPart.delta;\n\t\t\t\t\t\t\tsetCompletion(result);\n\t\t\t\t\t\t} else if (streamPart.type === \"error\") throw new Error(streamPart.errorText);\n\t\t\t\t\t} })),\n\t\t\t\t\tonError: (error) => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tdefault: throw new Error(`Unknown stream protocol: ${streamProtocol}`);\n\t\t}\n\t\tif (onFinish) onFinish(prompt, result);\n\t\tsetAbortController(null);\n\t\treturn result;\n\t} catch (err) {\n\t\tif (err.name === \"AbortError\") {\n\t\t\tsetAbortController(null);\n\t\t\treturn null;\n\t\t}\n\t\tif (err instanceof Error) {\n\t\t\tif (onError) onError(err);\n\t\t}\n\t\tsetError(err);\n\t} finally {\n\t\tsetLoading(false);\n\t}\n}\nasync function convertFileListToFileUIParts(files) {\n\tif (files == null) return [];\n\tif (!globalThis.FileList || !(files instanceof globalThis.FileList)) throw new Error(\"FileList is not supported in the current environment\");\n\treturn Promise.all(Array.from(files).map(async (file) => {\n\t\tconst { name: name23, type } = file;\n\t\treturn {\n\t\t\ttype: \"file\",\n\t\t\tmediaType: type,\n\t\t\tfilename: name23,\n\t\t\turl: await new Promise((resolve3, reject) => {\n\t\t\t\tconst reader = new FileReader();\n\t\t\t\treader.onload = (readerEvent) => {\n\t\t\t\t\tvar _a23;\n\t\t\t\t\tresolve3((_a23 = readerEvent.target) == null ? void 0 : _a23.result);\n\t\t\t\t};\n\t\t\t\treader.onerror = (error) => reject(error);\n\t\t\t\treader.readAsDataURL(file);\n\t\t\t})\n\t\t};\n\t}));\n}\nfunction appendPathToUrl(url, path) {\n\tconst queryOrFragmentStart = url.search(/[?#]/);\n\tconst urlPath = queryOrFragmentStart === -1 ? url : url.slice(0, queryOrFragmentStart);\n\tconst suffix = queryOrFragmentStart === -1 ? \"\" : url.slice(queryOrFragmentStart);\n\treturn `${urlPath.endsWith(\"/\") && path.startsWith(\"/\") ? urlPath.slice(0, -1) : urlPath}${path}${suffix}`;\n}\nvar HttpChatTransport = class {\n\tconstructor({ api = \"/api/chat\", credentials, headers, body, fetch: fetch2, prepareSendMessagesRequest, prepareReconnectToStreamRequest }) {\n\t\tthis.api = api;\n\t\tthis.credentials = credentials;\n\t\tthis.headers = headers;\n\t\tthis.body = body;\n\t\tthis.fetch = fetch2;\n\t\tthis.prepareSendMessagesRequest = prepareSendMessagesRequest;\n\t\tthis.prepareReconnectToStreamRequest = prepareReconnectToStreamRequest;\n\t}\n\tasync sendMessages({ abortSignal, ...options }) {\n\t\tvar _a23, _b, _c, _d, _e;\n\t\tconst resolvedBody = await resolve(this.body);\n\t\tconst resolvedHeaders = await resolve(this.headers);\n\t\tconst resolvedCredentials = await resolve(this.credentials);\n\t\tconst baseHeaders = {\n\t\t\t...normalizeHeaders(resolvedHeaders),\n\t\t\t...normalizeHeaders(options.headers)\n\t\t};\n\t\tconst preparedRequest = await ((_a23 = this.prepareSendMessagesRequest) == null ? void 0 : _a23.call(this, {\n\t\t\tapi: this.api,\n\t\t\tid: options.chatId,\n\t\t\tmessages: options.messages,\n\t\t\tbody: {\n\t\t\t\t...resolvedBody,\n\t\t\t\t...options.body\n\t\t\t},\n\t\t\theaders: baseHeaders,\n\t\t\tcredentials: resolvedCredentials,\n\t\t\trequestMetadata: options.metadata,\n\t\t\ttrigger: options.trigger,\n\t\t\tmessageId: options.messageId\n\t\t}));\n\t\tconst api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : this.api;\n\t\tconst headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? normalizeHeaders(preparedRequest.headers) : baseHeaders;\n\t\tconst body = (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : {\n\t\t\t...resolvedBody,\n\t\t\t...options.body,\n\t\t\tid: options.chatId,\n\t\t\tmessages: options.messages,\n\t\t\ttrigger: options.trigger,\n\t\t\tmessageId: options.messageId\n\t\t};\n\t\tconst credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : resolvedCredentials;\n\t\tconst response = await ((_d = this.fetch) != null ? _d : globalThis.fetch)(api, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t...headers\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t\tcredentials,\n\t\t\tsignal: abortSignal\n\t\t});\n\t\tif (!response.ok) throw new Error((_e = await response.text()) != null ? _e : \"Failed to fetch the chat response.\");\n\t\tif (!response.body) throw new Error(\"The response body is empty.\");\n\t\treturn this.processResponseStream(response.body);\n\t}\n\tasync reconnectToStream(options) {\n\t\tvar _a23, _b, _c, _d;\n\t\tconst resolvedBody = await resolve(this.body);\n\t\tconst resolvedHeaders = await resolve(this.headers);\n\t\tconst resolvedCredentials = await resolve(this.credentials);\n\t\tconst baseHeaders = {\n\t\t\t...normalizeHeaders(resolvedHeaders),\n\t\t\t...normalizeHeaders(options.headers)\n\t\t};\n\t\tconst preparedRequest = await ((_a23 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a23.call(this, {\n\t\t\tapi: this.api,\n\t\t\tid: options.chatId,\n\t\t\tbody: {\n\t\t\t\t...resolvedBody,\n\t\t\t\t...options.body\n\t\t\t},\n\t\t\theaders: baseHeaders,\n\t\t\tcredentials: resolvedCredentials,\n\t\t\trequestMetadata: options.metadata\n\t\t}));\n\t\tlet api = preparedRequest == null ? void 0 : preparedRequest.api;\n\t\tif (api == null) {\n\t\t\tif (options.chatId === \".\" || options.chatId === \"..\") throw new InvalidArgumentError({\n\t\t\t\tparameter: \"chatId\",\n\t\t\t\tvalue: options.chatId,\n\t\t\t\tmessage: \"Chat IDs must not be \\\".\\\" or \\\"..\\\" when using the default reconnect URL.\"\n\t\t\t});\n\t\t\tapi = appendPathToUrl(this.api, `/${encodeURIComponent(options.chatId)}/stream`);\n\t\t}\n\t\tconst headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? normalizeHeaders(preparedRequest.headers) : baseHeaders;\n\t\tconst credentials = (_b = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _b : resolvedCredentials;\n\t\tconst response = await ((_c = this.fetch) != null ? _c : globalThis.fetch)(api, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders,\n\t\t\tcredentials,\n\t\t\tsignal: options.abortSignal\n\t\t});\n\t\tif (response.status === 204) return null;\n\t\tif (!response.ok) throw new Error((_d = await response.text()) != null ? _d : \"Failed to fetch the chat response.\");\n\t\tif (!response.body) throw new Error(\"The response body is empty.\");\n\t\treturn this.processResponseStream(response.body);\n\t}\n};\nvar DefaultChatTransport = class extends HttpChatTransport {\n\tconstructor({ resumeStreamIsReplay = true, ...options } = {}) {\n\t\tsuper(options);\n\t\tthis.resumeStreamIsReplay = resumeStreamIsReplay;\n\t}\n\tprocessResponseStream(stream) {\n\t\treturn parseJsonEventStream({\n\t\t\tstream,\n\t\t\tschema: uiMessageChunkSchema\n\t\t}).pipeThrough(new TransformStream({ async transform(chunk, controller) {\n\t\t\tif (!chunk.success) throw chunk.error;\n\t\t\tcontroller.enqueue(chunk.value);\n\t\t} }));\n\t}\n};\nvar AbstractChat = class {\n\tconstructor({ generateId: generateId2 = generateId, id = generateId2(), transport = new DefaultChatTransport(), messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, sendAutomaticallyWhen }) {\n\t\tthis.activeResponse = void 0;\n\t\tthis.activeResumeRequest = void 0;\n\t\tthis.resumableStreamState = void 0;\n\t\tthis.jobExecutor = new SerialJobExecutor();\n\t\tthis.activeStopCount = 0;\n\t\tthis.stopGeneration = 0;\n\t\t/**\n\t\t* Appends or replaces a user message to the chat list. This triggers the API call to fetch\n\t\t* the assistant's response.\n\t\t*\n\t\t* If a messageId is provided, the message will be replaced.\n\t\t*/\n\t\tthis.sendMessage = async (message, options) => {\n\t\t\tvar _a23, _b, _c, _d;\n\t\t\tif (message == null) {\n\t\t\t\tlet messageId = this.pendingApprovalMessageId;\n\t\t\t\tif (messageId == null) {\n\t\t\t\t\tmessageId = (_a23 = this.lastMessage) == null ? void 0 : _a23.id;\n\t\t\t\t\tfor (let i = this.state.messages.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tconst candidate = this.state.messages[i];\n\t\t\t\t\t\tif (candidate.role === \"assistant\" && candidate.parts.some((part) => isToolUIPart(part) && part.state === \"approval-responded\")) {\n\t\t\t\t\t\t\tmessageId = candidate.id;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst pendingApprovalMessageIndex = messageId != null && messageId === this.pendingApprovalMessageId ? this.state.messages.findIndex((message2) => message2.id === messageId) : -1;\n\t\t\t\tawait this.makeRequestForToolApproval({\n\t\t\t\t\tmessageId,\n\t\t\t\t\tmessageIndex: pendingApprovalMessageIndex,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet uiMessage;\n\t\t\tif (\"text\" in message || \"files\" in message) uiMessage = { parts: [...Array.isArray(message.files) ? message.files : await convertFileListToFileUIParts(message.files), ...\"text\" in message && message.text != null ? [{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: message.text\n\t\t\t}] : []] };\n\t\t\telse uiMessage = message;\n\t\t\tif (message.messageId != null) {\n\t\t\t\tconst messageIndex = this.state.messages.findIndex((m) => m.id === message.messageId);\n\t\t\t\tif (messageIndex === -1) throw new Error(`message with id ${message.messageId} not found`);\n\t\t\t\tif (this.state.messages[messageIndex].role !== \"user\") throw new Error(`message with id ${message.messageId} is not a user message`);\n\t\t\t\tthis.state.messages = this.state.messages.slice(0, messageIndex + 1);\n\t\t\t\tthis.state.replaceMessage(messageIndex, {\n\t\t\t\t\t...uiMessage,\n\t\t\t\t\tid: message.messageId,\n\t\t\t\t\trole: (_b = uiMessage.role) != null ? _b : \"user\",\n\t\t\t\t\tmetadata: message.metadata\n\t\t\t\t});\n\t\t\t} else this.state.pushMessage({\n\t\t\t\t...uiMessage,\n\t\t\t\tid: (_c = uiMessage.id) != null ? _c : this.generateId(),\n\t\t\t\trole: (_d = uiMessage.role) != null ? _d : \"user\",\n\t\t\t\tmetadata: message.metadata\n\t\t\t});\n\t\t\tawait this.makeRequest({\n\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\tmessageId: message.messageId,\n\t\t\t\t...options\n\t\t\t});\n\t\t};\n\t\t/**\n\t\t* Regenerate the assistant message with the provided message id.\n\t\t* If no message id is provided, the last assistant message will be regenerated.\n\t\t*/\n\t\tthis.regenerate = async ({ messageId, ...options } = {}) => {\n\t\t\tconst messageIndex = messageId == null ? this.state.messages.length - 1 : this.state.messages.findIndex((message) => message.id === messageId);\n\t\t\tif (messageIndex === -1) throw new Error(`message ${messageId} not found`);\n\t\t\tthis.state.messages = this.state.messages.slice(0, this.messages[messageIndex].role === \"assistant\" ? messageIndex : messageIndex + 1);\n\t\t\tawait this.makeRequest({\n\t\t\t\ttrigger: \"regenerate-message\",\n\t\t\t\tmessageId,\n\t\t\t\t...options\n\t\t\t});\n\t\t};\n\t\t/**\n\t\t* Attempt to resume an ongoing streaming response.\n\t\t*/\n\t\tthis.resumeStream = async (options = {}) => {\n\t\t\tawait this.makeRequest({\n\t\t\t\ttrigger: \"resume-stream\",\n\t\t\t\t...options\n\t\t\t});\n\t\t};\n\t\t/**\n\t\t* Resume the stream if the latest response ended with a resumable network\n\t\t* disconnect. If a response is still active, wait for it to settle first so\n\t\t* disconnects reported shortly after the caller's trigger are handled.\n\t\t*\n\t\t* @internal\n\t\t*/\n\t\tthis[\"~resumeStreamIfDisconnected\"] = async ({ shouldResume = () => true } = {}) => {\n\t\t\tconst activeResponse = this.activeResponse;\n\t\t\tif (this.resumableStreamState == null && activeResponse != null) {\n\t\t\t\tawait activeResponse.completionPromise;\n\t\t\t\tif (this.resumableStreamState !== activeResponse.state) return;\n\t\t\t}\n\t\t\tif (this.resumableStreamState != null && shouldResume()) await this.resumeStream();\n\t\t};\n\t\t/**\n\t\t* Clear the error state and set the status to ready if the chat is in an error state.\n\t\t*/\n\t\tthis.clearError = () => {\n\t\t\tif (this.status === \"error\") {\n\t\t\t\tthis.state.error = void 0;\n\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t}\n\t\t};\n\t\tthis.addToolApprovalResponse = async ({ id, approved, reason, options }) => this.jobExecutor.run(async () => {\n\t\t\tconst messages = this.state.messages;\n\t\t\tconst updatePart = (part) => isToolUIPart(part) && part.state === \"approval-requested\" && part.approval.id === id ? {\n\t\t\t\t...part,\n\t\t\t\tstate: \"approval-responded\",\n\t\t\t\tapproval: {\n\t\t\t\t\t...part.approval,\n\t\t\t\t\tid,\n\t\t\t\t\tapproved,\n\t\t\t\t\treason\n\t\t\t\t}\n\t\t\t} : part;\n\t\t\tconst messageIndex = messages.findIndex((message) => message.parts.some((part) => isToolUIPart(part) && part.state === \"approval-requested\" && part.approval.id === id));\n\t\t\tif (messageIndex !== -1) {\n\t\t\t\tconst message = messages[messageIndex];\n\t\t\t\tthis.state.replaceMessage(messageIndex, {\n\t\t\t\t\t...message,\n\t\t\t\t\tparts: message.parts.map(updatePart)\n\t\t\t\t});\n\t\t\t\tthis.pendingApprovalMessageId = message.id;\n\t\t\t}\n\t\t\tif (this.activeResponse) this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);\n\t\t\tif (this.status !== \"streaming\" && this.status !== \"submitted\" && this.sendAutomaticallyWhen) {\n\t\t\t\tconst shouldSend = await this.shouldSendAutomatically();\n\t\t\t\tif (shouldSend) this.runAutomaticRequest(() => {\n\t\t\t\t\tvar _a23;\n\t\t\t\t\tconst messageId = messageIndex === -1 ? (_a23 = this.lastMessage) == null ? void 0 : _a23.id : messages[messageIndex].id;\n\t\t\t\t\treturn this.makeRequestForToolApproval({\n\t\t\t\t\t\tmessageId,\n\t\t\t\t\t\tmessageIndex,\n\t\t\t\t\t\t...options\n\t\t\t\t\t});\n\t\t\t\t}, shouldSend);\n\t\t\t}\n\t\t});\n\t\tthis.addToolOutput = async ({ state = \"output-available\", toolCallId, output, errorText, options }) => this.jobExecutor.run(async () => {\n\t\t\tconst messages = this.state.messages;\n\t\t\tconst updatePart = (part) => isToolUIPart(part) && part.toolCallId === toolCallId ? {\n\t\t\t\t...part,\n\t\t\t\tstate,\n\t\t\t\toutput,\n\t\t\t\terrorText\n\t\t\t} : part;\n\t\t\tconst messageIndex = messages.findIndex((message) => message.parts.some((part) => isToolUIPart(part) && part.toolCallId === toolCallId));\n\t\t\tif (messageIndex !== -1) {\n\t\t\t\tconst message = messages[messageIndex];\n\t\t\t\tthis.state.replaceMessage(messageIndex, {\n\t\t\t\t\t...message,\n\t\t\t\t\tparts: message.parts.map(updatePart)\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (this.activeResponse) this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);\n\t\t\tif (messageIndex !== -1 && this.status !== \"streaming\" && this.status !== \"submitted\" && this.sendAutomaticallyWhen) {\n\t\t\t\tconst shouldSend = await this.shouldSendAutomatically();\n\t\t\t\tif (shouldSend) this.runAutomaticRequest(() => this.makeRequest({\n\t\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\t\tmessageId: messages[messageIndex].id,\n\t\t\t\t\t...options\n\t\t\t\t}), shouldSend);\n\t\t\t}\n\t\t});\n\t\t/** @deprecated Use addToolOutput */\n\t\tthis.addToolResult = this.addToolOutput;\n\t\t/**\n\t\t* Abort the current request, keep the generated tokens if any, and wait for\n\t\t* the request pipeline to finish.\n\t\t*/\n\t\tthis.stop = async () => {\n\t\t\tthis.activeStopCount++;\n\t\t\tthis.stopGeneration++;\n\t\t\ttry {\n\t\t\t\tconst activeResumeRequest = this.activeResumeRequest;\n\t\t\t\tconst activeResponse = this.activeResponse;\n\t\t\t\tactiveResumeRequest?.abortController.abort();\n\t\t\t\tactiveResponse?.abortController.abort();\n\t\t\t\tawait Promise.all([activeResumeRequest == null ? void 0 : activeResumeRequest.completionPromise, activeResponse == null ? void 0 : activeResponse.completionPromise]);\n\t\t\t\tawait this.jobExecutor.waitForIdle();\n\t\t\t} finally {\n\t\t\t\tthis.activeStopCount--;\n\t\t\t}\n\t\t};\n\t\tthis.id = id;\n\t\tthis.transport = transport;\n\t\tthis.generateId = generateId2;\n\t\tthis.messageMetadataSchema = messageMetadataSchema;\n\t\tthis.dataPartSchemas = dataPartSchemas;\n\t\tthis.state = state;\n\t\tthis.onError = onError;\n\t\tthis.onToolCall = onToolCall;\n\t\tthis.onFinish = onFinish;\n\t\tthis.onData = onData;\n\t\tthis.sendAutomaticallyWhen = sendAutomaticallyWhen;\n\t}\n\t/**\n\t* Hook status:\n\t*\n\t* - `submitted`: The message has been sent to the API and we're awaiting the start of the response stream.\n\t* - `streaming`: The response is actively streaming in from the API, receiving chunks of data.\n\t* - `ready`: The full response has been received and processed; a new user message can be submitted.\n\t* - `error`: An error occurred during the API request, preventing successful completion.\n\t*/\n\tget status() {\n\t\treturn this.state.status;\n\t}\n\tsetStatus({ status, error }) {\n\t\tif (this.status === status) {\n\t\t\tif (this.error !== error) this.state.error = error;\n\t\t\treturn;\n\t\t}\n\t\tthis.state.status = status;\n\t\tthis.state.error = error;\n\t}\n\tget error() {\n\t\treturn this.state.error;\n\t}\n\tget messages() {\n\t\treturn this.state.messages;\n\t}\n\tget lastMessage() {\n\t\treturn this.state.messages[this.state.messages.length - 1];\n\t}\n\tset messages(messages) {\n\t\tthis.state.messages = messages;\n\t}\n\tasync shouldSendAutomatically() {\n\t\tif (!this.sendAutomaticallyWhen) return false;\n\t\tconst result = this.sendAutomaticallyWhen({ messages: this.state.messages });\n\t\tif (result && typeof result === \"object\" && \"then\" in result) return await result;\n\t\treturn result;\n\t}\n\tasync runAutomaticRequest(request, shouldSend) {\n\t\tconst stopGeneration = this.stopGeneration;\n\t\tconst startedWhileStopping = this.activeStopCount > 0;\n\t\tif (!(shouldSend != null ? shouldSend : await this.shouldSendAutomatically())) return;\n\t\tif (startedWhileStopping || stopGeneration !== this.stopGeneration || this.activeStopCount > 0) return;\n\t\tawait request();\n\t}\n\tasync makeRequestForToolApproval({ messageId, messageIndex, ...options }) {\n\t\tvar _a23, _b;\n\t\tconst consumesPendingApproval = messageId != null && messageId === this.pendingApprovalMessageId;\n\t\tif (consumesPendingApproval) this.pendingApprovalMessageId = void 0;\n\t\tawait this.makeRequest({\n\t\t\ttrigger: \"submit-message\",\n\t\t\tmessageId,\n\t\t\t...options\n\t\t});\n\t\tif (consumesPendingApproval && this.status === \"error\" && this.pendingApprovalMessageId == null) this.pendingApprovalMessageId = (_b = (_a23 = this.state.messages[messageIndex]) == null ? void 0 : _a23.id) != null ? _b : messageId;\n\t}\n\tasync makeRequest(options) {\n\t\tconst completion = createResolvablePromise();\n\t\ttry {\n\t\t\tawait this.makeRequestImpl({\n\t\t\t\t...options,\n\t\t\t\tcompletionPromise: completion.promise\n\t\t\t});\n\t\t} finally {\n\t\t\tcompletion.resolve();\n\t\t}\n\t}\n\tasync makeRequestImpl({ trigger, metadata, headers, body, messageId, completionPromise }) {\n\t\tvar _a23, _b;\n\t\tif (trigger !== \"resume-stream\") this.resumableStreamState = void 0;\n\t\tconst abortController = new AbortController();\n\t\tconst activeResumeRequest = trigger === \"resume-stream\" ? {\n\t\t\tabortController,\n\t\t\tcompletionPromise\n\t\t} : void 0;\n\t\tif (activeResumeRequest) {\n\t\t\t(_a23 = this.activeResumeRequest) == null || _a23.abortController.abort();\n\t\t\tthis.activeResumeRequest = activeResumeRequest;\n\t\t}\n\t\tconst isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;\n\t\tconst clearActiveResumeRequest = () => {\n\t\t\tif (this.activeResumeRequest === activeResumeRequest) this.activeResumeRequest = void 0;\n\t\t};\n\t\tlet resumeStream;\n\t\tif (trigger === \"resume-stream\") try {\n\t\t\tconst reconnect = await this.transport.reconnectToStream({\n\t\t\t\tchatId: this.id,\n\t\t\t\tabortSignal: abortController.signal,\n\t\t\t\tmetadata,\n\t\t\t\theaders,\n\t\t\t\tbody\n\t\t\t});\n\t\t\tif (abortController.signal.aborted || !isCurrentRequest()) {\n\t\t\t\tawait (reconnect == null ? void 0 : reconnect.cancel().catch(() => {}));\n\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\tthis.resumableStreamState = void 0;\n\t\t\t\t}\n\t\t\t\tclearActiveResumeRequest();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (reconnect == null) {\n\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\tthis.resumableStreamState = void 0;\n\t\t\t\tclearActiveResumeRequest();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresumeStream = reconnect;\n\t\t} catch (err) {\n\t\t\tif (abortController.signal.aborted || err.name === \"AbortError\") {\n\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\tthis.resumableStreamState = void 0;\n\t\t\t\t}\n\t\t\t\tclearActiveResumeRequest();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!isCurrentRequest()) return;\n\t\t\tif (this.onError && err instanceof Error) this.onError(err);\n\t\t\tthis.setStatus({\n\t\t\t\tstatus: \"error\",\n\t\t\t\terror: err\n\t\t\t});\n\t\t\tclearActiveResumeRequest();\n\t\t\treturn;\n\t\t}\n\t\tthis.setStatus({\n\t\t\tstatus: \"submitted\",\n\t\t\terror: void 0\n\t\t});\n\t\tconst lastMessage = this.lastMessage;\n\t\tconst responseMessageIndex = trigger === \"submit-message\" && messageId != null ? this.state.messages.findIndex((message) => message.id === messageId) : this.state.messages.length - 1;\n\t\tconst responseMessage = responseMessageIndex === -1 ? lastMessage : this.state.messages[responseMessageIndex];\n\t\tconst originalResponseMessageId = responseMessage == null ? void 0 : responseMessage.id;\n\t\tconst resumableResponseMessage = trigger === \"resume-stream\" && (responseMessage == null ? void 0 : responseMessage.role) === \"assistant\" && responseMessage.parts.some((part) => isToolUIPart(part) && part.state === \"input-streaming\") ? this.state.snapshot(responseMessage) : void 0;\n\t\tconst usesEarlierAssistantMessage = responseMessageIndex !== -1 && responseMessageIndex < this.state.messages.length - 1 && (responseMessage == null ? void 0 : responseMessage.role) === \"assistant\";\n\t\tlet isAbort = false;\n\t\tlet isDisconnect = false;\n\t\tlet isError = false;\n\t\tlet activeResponse;\n\t\ttry {\n\t\t\tconst response = {\n\t\t\t\tstate: trigger === \"resume-stream\" && this.resumableStreamState != null ? this.resumableStreamState : createStreamingUIMessageState({\n\t\t\t\t\tlastMessage: trigger === \"resume-stream\" ? resumableResponseMessage : trigger === \"regenerate-message\" ? void 0 : this.state.snapshot(responseMessage),\n\t\t\t\t\tmessageId: this.generateId()\n\t\t\t\t}),\n\t\t\t\tabortController,\n\t\t\t\tcompletionPromise\n\t\t\t};\n\t\t\tactiveResponse = response;\n\t\t\tresponse.abortController.signal.addEventListener(\"abort\", () => {\n\t\t\t\tisAbort = true;\n\t\t\t});\n\t\t\tthis.activeResponse = response;\n\t\t\tlet stream;\n\t\t\tif (trigger === \"resume-stream\") stream = resumeStream;\n\t\t\telse stream = await this.transport.sendMessages({\n\t\t\t\tchatId: this.id,\n\t\t\t\tmessages: this.state.messages,\n\t\t\t\tabortSignal: response.abortController.signal,\n\t\t\t\tmetadata,\n\t\t\t\theaders,\n\t\t\t\tbody,\n\t\t\t\ttrigger,\n\t\t\t\tmessageId\n\t\t\t});\n\t\t\tconst runUpdateMessageJob = (job) => this.jobExecutor.run(() => {\n\t\t\t\tif (response.abortController.signal.aborted) return Promise.resolve();\n\t\t\t\treturn job({\n\t\t\t\t\tstate: response.state,\n\t\t\t\t\twrite: ({ updateStatus = true } = {}) => {\n\t\t\t\t\t\tif (response.abortController.signal.aborted) return;\n\t\t\t\t\t\tif (updateStatus) this.setStatus({ status: \"streaming\" });\n\t\t\t\t\t\tconst existingMessageIndex = this.state.messages.findLastIndex((message) => message.id === response.state.message.id);\n\t\t\t\t\t\tif (existingMessageIndex !== -1) this.state.replaceMessage(existingMessageIndex, response.state.message);\n\t\t\t\t\t\telse if (usesEarlierAssistantMessage) {\n\t\t\t\t\t\t\tconst originalMessageIndex = this.state.messages.findLastIndex((message) => message.id === originalResponseMessageId);\n\t\t\t\t\t\t\tif (originalMessageIndex !== -1) this.state.replaceMessage(originalMessageIndex, response.state.message);\n\t\t\t\t\t\t\telse this.state.pushMessage(response.state.message);\n\t\t\t\t\t\t} else this.state.pushMessage(response.state.message);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t\tawait consumeStream({\n\t\t\t\tstream: processUIMessageStream({\n\t\t\t\t\tstream,\n\t\t\t\t\tresetStateOnMessageIdChange: trigger === \"resume-stream\",\n\t\t\t\t\tresetStateOnFirstMessageStart: trigger === \"resume-stream\" && this.transport.resumeStreamIsReplay,\n\t\t\t\t\tonToolCall: this.onToolCall,\n\t\t\t\t\tonData: this.onData,\n\t\t\t\t\tmessageMetadataSchema: this.messageMetadataSchema,\n\t\t\t\t\tdataPartSchemas: this.dataPartSchemas,\n\t\t\t\t\trunUpdateMessageJob,\n\t\t\t\t\tonError: (error) => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tabortSignal: response.abortController.signal,\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (isAbort) {\n\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\tif (this.resumableStreamState === response.state) this.resumableStreamState = void 0;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (isCurrentRequest()) {\n\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\tif (this.resumableStreamState === response.state) this.resumableStreamState = void 0;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (isAbort || err.name === \"AbortError\") {\n\t\t\t\tisAbort = true;\n\t\t\t\tif (isCurrentRequest()) {\n\t\t\t\t\tthis.setStatus({ status: \"ready\" });\n\t\t\t\t\tif (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) this.resumableStreamState = void 0;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!isCurrentRequest()) return null;\n\t\t\tisError = true;\n\t\t\tif (err instanceof TypeError && (err.message.toLowerCase().includes(\"fetch\") || err.message.toLowerCase().includes(\"network\"))) isDisconnect = true;\n\t\t\tif (isDisconnect) this.resumableStreamState = activeResponse == null ? void 0 : activeResponse.state;\n\t\t\telse if (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) this.resumableStreamState = void 0;\n\t\t\tif (this.onError && err instanceof Error) this.onError(err);\n\t\t\tthis.setStatus({\n\t\t\t\tstatus: \"error\",\n\t\t\t\terror: err\n\t\t\t});\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif (activeResponse) (_b = this.onFinish) == null || _b.call(this, {\n\t\t\t\t\tmessage: activeResponse.state.message,\n\t\t\t\t\tmessages: this.state.messages,\n\t\t\t\t\tisAbort,\n\t\t\t\t\tisDisconnect,\n\t\t\t\t\tisError,\n\t\t\t\t\tfinishReason: activeResponse.state.finishReason\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tif (this.activeResponse === activeResponse) this.activeResponse = void 0;\n\t\t\t\tclearActiveResumeRequest();\n\t\t\t}\n\t\t}\n\t\tif (!isAbort && !isError) await this.runAutomaticRequest(() => {\n\t\t\tvar _a24;\n\t\t\treturn this.makeRequest({\n\t\t\t\ttrigger: \"submit-message\",\n\t\t\t\tmessageId: (_a24 = this.lastMessage) == null ? void 0 : _a24.id,\n\t\t\t\tmetadata,\n\t\t\t\theaders,\n\t\t\t\tbody\n\t\t\t});\n\t\t});\n\t}\n};\nvar DirectChatTransport = class {\n\tconstructor({ agent, options, ...uiMessageStreamOptions }) {\n\t\tthis.agent = agent;\n\t\tthis.agentOptions = options;\n\t\tthis.uiMessageStreamOptions = uiMessageStreamOptions;\n\t}\n\tasync sendMessages({ messages, abortSignal }) {\n\t\tconst modelMessages = await convertToModelMessages(await validateUIMessagesForAgent({\n\t\t\tmessages,\n\t\t\ttools: this.agent.tools\n\t\t}), { tools: this.agent.tools });\n\t\treturn (await this.agent.stream({\n\t\t\tprompt: modelMessages,\n\t\t\tabortSignal,\n\t\t\t...this.agentOptions !== void 0 ? { options: this.agentOptions } : {}\n\t\t})).toUIMessageStream(this.uiMessageStreamOptions);\n\t}\n\t/**\n\t* Direct transport does not support reconnection since there is no\n\t* persistent server-side stream to reconnect to.\n\t*\n\t* @returns Always returns `null`\n\t*/\n\tasync reconnectToStream(_options) {\n\t\treturn null;\n\t}\n};\nfunction lastAssistantMessageIsCompleteWithApprovalResponses({ messages }) {\n\tconst message = messages[messages.length - 1];\n\tif (!message) return false;\n\tif (message.role !== \"assistant\") return false;\n\tconst lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {\n\t\treturn part.type === \"step-start\" ? index : lastIndex;\n\t}, -1);\n\tconst lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart);\n\treturn lastStepToolInvocations.filter((part) => part.state === \"approval-responded\").length > 0 && lastStepToolInvocations.every((part) => part.state === \"output-available\" && part.preliminary !== true || part.state === \"output-error\" || part.state === \"output-denied\" || part.state === \"approval-responded\");\n}\nfunction lastAssistantMessageIsCompleteWithToolCalls({ messages }) {\n\tconst message = messages[messages.length - 1];\n\tif (!message) return false;\n\tif (message.role !== \"assistant\") return false;\n\tconst lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {\n\t\treturn part.type === \"step-start\" ? index : lastIndex;\n\t}, -1);\n\tconst lastStepParts = message.parts.slice(lastStepStartIndex + 1);\n\tconst lastStepToolInvocations = lastStepParts.filter(isToolUIPart).filter((part) => !part.providerExecuted);\n\tconst lastToolInvocationIndex = lastStepParts.reduce((lastIndex, part, index) => isToolUIPart(part) && !part.providerExecuted ? index : lastIndex, -1);\n\treturn lastStepToolInvocations.length > 0 && !lastStepParts.slice(lastToolInvocationIndex + 1).some((part) => part.type === \"text\" && part.state !== \"done\") && lastStepToolInvocations.every((part) => part.state === \"output-available\" && part.preliminary !== true || part.state === \"output-error\");\n}\nfunction transformTextToUiMessageStream({ stream }) {\n\treturn stream.pipeThrough(new TransformStream({\n\t\tstart(controller) {\n\t\t\tcontroller.enqueue({ type: \"start\" });\n\t\t\tcontroller.enqueue({ type: \"start-step\" });\n\t\t\tcontroller.enqueue({\n\t\t\t\ttype: \"text-start\",\n\t\t\t\tid: \"text-1\"\n\t\t\t});\n\t\t},\n\t\tasync transform(part, controller) {\n\t\t\tcontroller.enqueue({\n\t\t\t\ttype: \"text-delta\",\n\t\t\t\tid: \"text-1\",\n\t\t\t\tdelta: part\n\t\t\t});\n\t\t},\n\t\tasync flush(controller) {\n\t\t\tcontroller.enqueue({\n\t\t\t\ttype: \"text-end\",\n\t\t\t\tid: \"text-1\"\n\t\t\t});\n\t\t\tcontroller.enqueue({ type: \"finish-step\" });\n\t\t\tcontroller.enqueue({ type: \"finish\" });\n\t\t}\n\t}));\n}\nvar TextStreamChatTransport = class extends HttpChatTransport {\n\tconstructor(options = {}) {\n\t\tsuper(options);\n\t}\n\tprocessResponseStream(stream) {\n\t\treturn transformTextToUiMessageStream({ stream: stream.pipeThrough(new TextDecoderStream()) });\n\t}\n};\n//#endregion\nexport { AISDKError, APICallError, AbstractChat, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DownloadError, EmptyResponseBodyError, ToolLoopAgent as Experimental_Agent, ToolLoopAgent, HttpChatTransport, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidPromptError, InvalidResponseDataError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONParseError, JsonToSseTransformStream, LoadAPIKeyError, LoadSettingError, MessageConversionError, MissingToolResultsError, NoContentGeneratedError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, output_exports as Output, RetryError, SerialJobExecutor, TextStreamChatTransport, TooManyEmbeddingValuesForCallError, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolChoiceViolationError, TypeValidationError, UIMessageStreamError, UI_MESSAGE_STREAM_HEADERS, UnsupportedFunctionalityError, UnsupportedModelVersionError, addToolInputExamplesMiddleware, asSchema, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createGatewayProvider as createGateway, createIdGenerator, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, dynamicTool, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, gateway, generateId, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, jsonSchema, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parseJsonEventStream, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider, zodSchema };\n\n//# sourceMappingURL=index.js.map","/**\n * Forked from fastembed-js (https://github.com/Anush008/fastembed-js)\n * Original author: Anush008 <anushshetty90@gmail.com>\n * License: MIT (see LICENSE-fastembed in this package)\n *\n * The upstream project has been archived / abandoned. This fork is maintained\n * as part of the Mastra monorepo so that @mastra/fastembed no longer depends\n * on the unmaintained npm `fastembed` package.\n */\n\nimport { AddedToken, Tokenizer } from '@anush008/tokenizers';\nimport fs from 'node:fs';\nimport type { PathLike } from 'node:fs';\nimport path from 'node:path';\nimport { Readable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type { ReadableStream } from 'node:stream/web';\nimport * as ort from 'onnxruntime-node';\nimport { downloadFile } from '@huggingface/hub';\n\nexport enum ExecutionProvider {\n  CPU = 'cpu',\n  CUDA = 'cuda',\n  WebGL = 'webgl',\n  WASM = 'wasm',\n  XNNPACK = 'xnnpack',\n}\n\nexport enum EmbeddingModel {\n  AllMiniLML6V2 = 'fast-all-MiniLM-L6-v2',\n  BGEBaseEN = 'fast-bge-base-en',\n  BGEBaseENV15 = 'fast-bge-base-en-v1.5',\n  BGESmallEN = 'fast-bge-small-en',\n  BGESmallENV15 = 'fast-bge-small-en-v1.5',\n  BGESmallZH = 'fast-bge-small-zh-v1.5',\n  MLE5Large = 'fast-multilingual-e5-large',\n  CUSTOM = 'custom',\n}\n\nconst COMMON_MODEL_FILES = ['config.json', 'tokenizer.json', 'tokenizer_config.json', 'special_tokens_map.json'];\n\nconst HF_MODEL_SOURCES: Record<Exclude<EmbeddingModel, EmbeddingModel.CUSTOM>, { repo: string; files: string[] }> = {\n  [EmbeddingModel.AllMiniLML6V2]: { repo: 'Qdrant/all-MiniLM-L6-v2-onnx', files: ['model.onnx'] },\n  [EmbeddingModel.BGEBaseEN]: { repo: 'Qdrant/fast-bge-base-en', files: ['model_optimized.onnx'] },\n  [EmbeddingModel.BGEBaseENV15]: { repo: 'Qdrant/bge-base-en-v1.5-onnx-Q', files: ['model_optimized.onnx'] },\n  [EmbeddingModel.BGESmallEN]: { repo: 'Qdrant/bge-small-en', files: ['model_optimized.onnx'] },\n  [EmbeddingModel.BGESmallENV15]: { repo: 'Qdrant/bge-small-en-v1.5-onnx-Q', files: ['model_optimized.onnx'] },\n  [EmbeddingModel.BGESmallZH]: { repo: 'Qdrant/bge-small-zh-v1.5', files: ['model_optimized.onnx'] },\n  [EmbeddingModel.MLE5Large]: { repo: 'Qdrant/multilingual-e5-large-onnx', files: ['model.onnx', 'model.onnx_data'] },\n};\n\nexport enum SparseEmbeddingModel {\n  SpladePPEnV1 = 'prithivida/Splade_PP_en_v1',\n  CUSTOM = 'custom',\n}\n\nexport type SparseVector = {\n  values: number[];\n  indices: number[];\n};\n\nexport interface InitOptionsBase {\n  executionProviders?: ExecutionProvider[];\n  maxLength?: number;\n  cacheDir?: string;\n  showDownloadProgress?: boolean;\n}\n\ninterface ModelInfo {\n  model: EmbeddingModel;\n  dim: number;\n  description: string;\n}\n\ninterface SparseModelInfo {\n  model: SparseEmbeddingModel;\n  vocabSize: number;\n  description: string;\n}\n\ntype ModelInput = Record<string, ort.Tensor>;\n\nfunction normalize(v: number[]): number[] {\n  const norm = Math.sqrt(v.reduce((acc, val) => acc + val * val, 0));\n  const epsilon = 1e-12;\n  return v.map(val => val / Math.max(norm, epsilon));\n}\n\nfunction getEmbeddings(data: number[], dimensions: [number, number, number]): number[][] {\n  const [x, _y, z] = dimensions;\n  return new Array(x).fill(undefined).map((_, index) => {\n    const startIndex = index * _y * z;\n    const endIndex = startIndex + z;\n    return data.slice(startIndex, endIndex);\n  });\n}\n\nexport interface InitStandardOptions extends InitOptionsBase {\n  model: Exclude<EmbeddingModel, EmbeddingModel.CUSTOM>;\n  modelAbsoluteDirPath?: undefined;\n  modelName?: string;\n}\n\nexport interface InitCustomOptions extends InitOptionsBase {\n  model: EmbeddingModel.CUSTOM;\n  modelAbsoluteDirPath: PathLike;\n  modelName: string;\n}\n\nexport type InitOptions = InitStandardOptions | InitCustomOptions;\n\nexport interface InitSparseStandardOptions extends InitOptionsBase {\n  model: Exclude<SparseEmbeddingModel, SparseEmbeddingModel.CUSTOM>;\n  modelAbsoluteDirPath?: undefined;\n  modelName?: string;\n}\n\nexport interface InitSparseCustomOptions extends InitOptionsBase {\n  model: SparseEmbeddingModel.CUSTOM;\n  modelAbsoluteDirPath: PathLike;\n  modelName: string;\n}\n\nexport type InitSparseOptions = InitSparseStandardOptions | InitSparseCustomOptions;\n\nabstract class Embedding {\n  abstract listSupportedModels(): ModelInfo[];\n  abstract embed(texts: string[], batchSize?: number): AsyncGenerator<number[][], void, unknown>;\n  abstract passageEmbed(texts: string[], batchSize: number): AsyncGenerator<number[][], void, unknown>;\n  abstract queryEmbed(query: string): Promise<number[]>;\n}\n\nabstract class SparseEmbedding {\n  abstract listSupportedModels(): SparseModelInfo[];\n  abstract embed(texts: string[], batchSize?: number): AsyncGenerator<SparseVector[], void, unknown>;\n  abstract passageEmbed(texts: string[], batchSize: number): AsyncGenerator<SparseVector[], void, unknown>;\n  abstract queryEmbed(query: string): Promise<SparseVector>;\n}\n\ninterface AddedTokenMap {\n  content: string;\n  single_word: boolean;\n  lstrip: boolean;\n  rstrip: boolean;\n  normalized: boolean;\n}\n\nfunction isAddedTokenMap(token: unknown): token is AddedTokenMap {\n  return (\n    typeof token === 'object' &&\n    token !== null &&\n    'content' in token &&\n    'single_word' in token &&\n    'rstrip' in token &&\n    'lstrip' in token &&\n    'normalized' in token\n  );\n}\n\nfunction loadTokenizerFromDir(modelDir: PathLike, maxLength: number): Tokenizer {\n  const tokenizerPath = path.join(modelDir.toString(), 'tokenizer.json');\n  if (!fs.existsSync(tokenizerPath)) {\n    throw new Error(`Tokenizer file not found at ${tokenizerPath}`);\n  }\n\n  const configPath = path.join(modelDir.toString(), 'config.json');\n  if (!fs.existsSync(configPath)) {\n    throw new Error(`Config file not found at ${configPath}`);\n  }\n  const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));\n\n  const tokenizerFilePath = path.join(modelDir.toString(), 'tokenizer_config.json');\n  if (!fs.existsSync(tokenizerFilePath)) {\n    throw new Error(`Tokenizer config file not found at ${tokenizerFilePath}`);\n  }\n  const tokenizerConfig = JSON.parse(fs.readFileSync(tokenizerFilePath, 'utf-8'));\n  maxLength = Math.min(maxLength, tokenizerConfig['model_max_length']);\n\n  const tokensMapPath = path.join(modelDir.toString(), 'special_tokens_map.json');\n  if (!fs.existsSync(tokensMapPath)) {\n    throw new Error(`Tokens map file not found at ${tokensMapPath}`);\n  }\n  const tokensMap = JSON.parse(fs.readFileSync(tokensMapPath, 'utf-8'));\n\n  const tokenizer = Tokenizer.fromFile(tokenizerPath);\n\n  tokenizer.setTruncation(maxLength);\n  tokenizer.setPadding({\n    maxLength,\n    padId: config['pad_token_id'],\n    padToken: tokenizerConfig['pad_token'],\n  });\n\n  for (const token of Object.values(tokensMap)) {\n    if (typeof token === 'string') {\n      tokenizer.addSpecialTokens([token]);\n    } else if (isAddedTokenMap(token)) {\n      const addedToken = new AddedToken(token['content'], true, {\n        singleWord: token['single_word'],\n        leftStrip: token['lstrip'],\n        rightStrip: token['rstrip'],\n        normalized: token['normalized'],\n      });\n      tokenizer.addAddedTokens([addedToken]);\n    }\n  }\n  return tokenizer;\n}\n\nfunction assertValidBatchSize(batchSize: number): void {\n  if (!Number.isSafeInteger(batchSize) || batchSize <= 0) {\n    throw new RangeError(`batchSize must be a positive safe integer, received ${String(batchSize)}`);\n  }\n}\n\nexport class FlagEmbedding extends Embedding {\n  private constructor(\n    private tokenizer: Tokenizer,\n    private session: ort.InferenceSession,\n    private model: EmbeddingModel,\n  ) {\n    super();\n  }\n\n  static async init(options: InitStandardOptions): Promise<FlagEmbedding>;\n  static async init(options: InitCustomOptions): Promise<FlagEmbedding>;\n  static async init({\n    model = EmbeddingModel.BGESmallENV15,\n    executionProviders = [ExecutionProvider.CPU],\n    maxLength = 512,\n    cacheDir = 'local_cache',\n    showDownloadProgress = true,\n    modelAbsoluteDirPath = '',\n    modelName = '',\n  }: Partial<InitOptions> = {}) {\n    if (model === EmbeddingModel.CUSTOM) {\n      if (!modelAbsoluteDirPath) {\n        throw new Error('For custom model, modelAbsoluteDirPath is required in FlagEmbedding.init');\n      }\n      if (!modelName) {\n        throw new Error('For custom model, modelName is required in FlagEmbedding.init');\n      }\n    }\n\n    const modelDir =\n      model === EmbeddingModel.CUSTOM\n        ? modelAbsoluteDirPath\n        : await FlagEmbedding.retrieveModel(model, cacheDir, showDownloadProgress);\n\n    const tokenizer = loadTokenizerFromDir(modelDir, maxLength);\n    const defaultModelName =\n      model === EmbeddingModel.MLE5Large || model === EmbeddingModel.AllMiniLML6V2\n        ? 'model.onnx'\n        : 'model_optimized.onnx';\n    const modelPath = path.join(modelDir.toString(), modelName || defaultModelName);\n    if (!fs.existsSync(modelPath)) {\n      throw new Error(`Model file not found at ${modelPath}`);\n    }\n    const session = await ort.InferenceSession.create(modelPath, {\n      executionProviders,\n      graphOptimizationLevel: 'all',\n    });\n    return new FlagEmbedding(tokenizer, session, model);\n  }\n\n  /**\n   * Counts texts longer than the model's token window. `embed()` silently truncates these to `maxLength`.\n   */\n  async countTruncated(textStrings: string[], batchSize: number = 256): Promise<{ count: number; maxLength: number }> {\n    assertValidBatchSize(batchSize);\n    let count = 0;\n    let maxLength = 0;\n    for (let i = 0; i < textStrings.length; i += batchSize) {\n      const batch = textStrings.slice(i, i + batchSize);\n      const encodings = await Promise.all(batch.map(textString => this.tokenizer.encode(textString)));\n      for (const encoding of encodings) {\n        if (encoding.getOverflowing().length > 0) {\n          count++;\n          // Padding is set to the window size, so a truncated encoding's length is the window.\n          maxLength = encoding.getLength();\n        }\n      }\n    }\n    return { count, maxLength };\n  }\n\n  static async retrieveModel(\n    model: EmbeddingModel,\n    cacheDir: PathLike,\n    showDownloadProgress: boolean = true,\n  ): Promise<PathLike> {\n    if (model === EmbeddingModel.CUSTOM) {\n      throw new Error('Custom models must be loaded from modelAbsoluteDirPath');\n    }\n    if (!fs.existsSync(cacheDir)) {\n      fs.mkdirSync(cacheDir, { recursive: true, mode: 0o755 });\n    }\n\n    const modelDir = path.join(cacheDir.toString(), model);\n    if (fs.existsSync(modelDir)) {\n      return modelDir;\n    }\n\n    const { repo, files } = HF_MODEL_SOURCES[model];\n    const tmpDir = fs.mkdtempSync(`${modelDir}.tmp-`);\n    try {\n      if (showDownloadProgress) {\n        console.error(`Downloading ${model} from Hugging Face (${repo})...`);\n      }\n      for (const file of [...COMMON_MODEL_FILES, ...files]) {\n        const downloaded = await downloadFile({ repo, path: file });\n        if (!downloaded) throw new Error(`Model file not found in ${repo}: ${file}`);\n        await pipeline(\n          Readable.fromWeb(downloaded.stream() as ReadableStream),\n          fs.createWriteStream(path.join(tmpDir, file)),\n        );\n      }\n      try {\n        fs.renameSync(tmpDir, modelDir);\n      } catch (error) {\n        const code = (error as NodeJS.ErrnoException).code;\n        // Another concurrent download already published this model.\n        if ((code === 'EEXIST' || code === 'ENOTEMPTY') && fs.existsSync(modelDir)) {\n          fs.rmSync(tmpDir, { recursive: true, force: true });\n          return modelDir;\n        }\n        throw error;\n      }\n    } catch (error) {\n      fs.rmSync(tmpDir, { recursive: true, force: true });\n      throw error;\n    }\n    return modelDir;\n  }\n\n  async *embed(textStrings: string[], batchSize: number = 256) {\n    assertValidBatchSize(batchSize);\n    for (let i = 0; i < textStrings.length; i += batchSize) {\n      const batchTexts = textStrings.slice(i, i + batchSize);\n\n      const encodedTexts = await Promise.all(batchTexts.map(textString => this.tokenizer.encode(textString)));\n\n      const idsArray: bigint[][] = [];\n      const maskArray: bigint[][] = [];\n      const typeIdsArray: bigint[][] = [];\n\n      encodedTexts.forEach(text => {\n        const ids = text.getIds().map(BigInt);\n        const mask = text.getAttentionMask().map(BigInt);\n        const typeIds = text.getTypeIds().map(BigInt);\n\n        idsArray.push(ids);\n        maskArray.push(mask);\n        typeIdsArray.push(typeIds);\n      });\n\n      const maxLength = idsArray[0]!.length;\n\n      const batchInputIds = new ort.Tensor('int64', idsArray.flat() as unknown as number[], [\n        batchTexts.length,\n        maxLength,\n      ]);\n      const batchAttentionMask = new ort.Tensor('int64', maskArray.flat() as unknown as number[], [\n        batchTexts.length,\n        maxLength,\n      ]);\n      const batchTokenTypeId = new ort.Tensor('int64', typeIdsArray.flat() as unknown as number[], [\n        batchTexts.length,\n        maxLength,\n      ]);\n\n      const inputs: ModelInput = {\n        input_ids: batchInputIds,\n        attention_mask: batchAttentionMask,\n        token_type_ids: batchTokenTypeId,\n      };\n\n      if (this.model === EmbeddingModel.MLE5Large) {\n        delete inputs.token_type_ids;\n      }\n\n      const output = await this.session.run(inputs);\n\n      const lastHiddenState = output.last_hidden_state!;\n      const embeddings = getEmbeddings(\n        lastHiddenState.data as unknown[] as number[],\n        lastHiddenState.dims as [number, number, number],\n      );\n\n      yield embeddings.map(normalize);\n    }\n  }\n\n  passageEmbed(texts: string[], batchSize: number = 256) {\n    texts = texts.map(text => `passage: ${text}`);\n    return this.embed(texts, batchSize);\n  }\n\n  async queryEmbed(query: string): Promise<number[]> {\n    const result = await this.embed([`query: ${query}`]).next();\n    return result.value![0]!;\n  }\n\n  listSupportedModels(): ModelInfo[] {\n    return [\n      { model: EmbeddingModel.BGESmallEN, dim: 384, description: 'Fast English model' },\n      { model: EmbeddingModel.BGESmallENV15, dim: 384, description: 'v1.5 release of the fast, default English model' },\n      { model: EmbeddingModel.BGEBaseEN, dim: 768, description: 'Base English model' },\n      { model: EmbeddingModel.BGEBaseENV15, dim: 768, description: 'v1.5 release of Base English model' },\n      { model: EmbeddingModel.BGESmallZH, dim: 512, description: 'v1.5 release of the fast, Chinese model' },\n      { model: EmbeddingModel.AllMiniLML6V2, dim: 384, description: 'Sentence Transformer model, MiniLM-L6-v2' },\n      {\n        model: EmbeddingModel.MLE5Large,\n        dim: 1024,\n        description: 'Multilingual model, e5-large. Recommend using this model for non-English languages',\n      },\n    ];\n  }\n}\n\nexport class SparseTextEmbedding extends SparseEmbedding {\n  private constructor(\n    private tokenizer: Tokenizer,\n    private session: ort.InferenceSession,\n  ) {\n    super();\n  }\n\n  static async init(options: InitSparseStandardOptions): Promise<SparseTextEmbedding>;\n  static async init(options: InitSparseCustomOptions): Promise<SparseTextEmbedding>;\n  static async init({\n    model = SparseEmbeddingModel.SpladePPEnV1,\n    executionProviders = [ExecutionProvider.CPU],\n    maxLength = 512,\n    cacheDir = 'local_cache',\n    showDownloadProgress = true,\n    modelAbsoluteDirPath = '',\n    modelName = '',\n  }: Partial<InitSparseOptions> = {}) {\n    if (model === SparseEmbeddingModel.CUSTOM) {\n      if (!modelAbsoluteDirPath) {\n        throw new Error('For custom model, modelAbsoluteDirPath is required in SparseTextEmbedding.init');\n      }\n      if (!modelName) {\n        throw new Error('For custom model, modelName is required in SparseTextEmbedding.init');\n      }\n    }\n\n    const modelDir =\n      model === SparseEmbeddingModel.CUSTOM\n        ? modelAbsoluteDirPath\n        : await SparseTextEmbedding.retrieveModel(model, cacheDir, showDownloadProgress);\n\n    const { tokenizer } = this.loadTokenizer(modelDir, maxLength);\n\n    const defaultModelName = 'model.onnx';\n    const modelPath = path.join(modelDir.toString(), 'onnx', modelName || defaultModelName);\n\n    if (!fs.existsSync(modelPath)) {\n      throw new Error(`Model file not found at ${modelPath}`);\n    }\n\n    const session = await ort.InferenceSession.create(modelPath, {\n      executionProviders,\n      graphOptimizationLevel: 'all',\n    });\n\n    return new SparseTextEmbedding(tokenizer, session);\n  }\n\n  private static loadTokenizer(modelDir: PathLike, maxLength: number): { tokenizer: Tokenizer } {\n    const tokenizer = loadTokenizerFromDir(modelDir, maxLength);\n    return { tokenizer };\n  }\n\n  private static async retrieveModel(\n    model: SparseEmbeddingModel,\n    cacheDir: PathLike,\n    _showDownloadProgress: boolean = true,\n  ): Promise<PathLike> {\n    if (!fs.existsSync(cacheDir)) {\n      fs.mkdirSync(cacheDir, { mode: 0o755 });\n    }\n\n    const modelDir = path.join(cacheDir.toString(), model.replace('/', '_'));\n\n    if (fs.existsSync(modelDir)) {\n      return modelDir;\n    }\n\n    fs.mkdirSync(modelDir, { mode: 0o755 });\n\n    const filesToDownload = [\n      'onnx/model.onnx',\n      'tokenizer.json',\n      'tokenizer_config.json',\n      'config.json',\n      'special_tokens_map.json',\n    ];\n\n    for (const fileName of filesToDownload) {\n      const outputPath = path.join(modelDir, fileName);\n      const outputDir = path.dirname(outputPath);\n\n      if (!fs.existsSync(outputDir)) {\n        fs.mkdirSync(outputDir, { recursive: true, mode: 0o755 });\n      }\n\n      const downloaded = await downloadFile({\n        repo: model,\n        path: fileName,\n      });\n\n      if (!downloaded) throw new Error(`Model file not found in ${model}: ${fileName}`);\n      await pipeline(Readable.fromWeb(downloaded.stream() as ReadableStream), fs.createWriteStream(outputPath));\n    }\n\n    return modelDir;\n  }\n\n  async *embed(textStrings: string[], batchSize: number = 256) {\n    assertValidBatchSize(batchSize);\n    for (let i = 0; i < textStrings.length; i += batchSize) {\n      const batchTexts = textStrings.slice(i, i + batchSize);\n\n      const encodedTexts = await Promise.all(batchTexts.map(textString => this.tokenizer.encode(textString)));\n\n      const idsArray: bigint[][] = [];\n      const maskArray: number[][] = [];\n      const typeIdsArray: bigint[][] = [];\n\n      encodedTexts.forEach(text => {\n        const ids = text.getIds().map(BigInt);\n        const mask = text.getAttentionMask();\n        const typeIds = text.getTypeIds().map(BigInt);\n\n        idsArray.push(ids);\n        maskArray.push(mask);\n        typeIdsArray.push(typeIds);\n      });\n\n      const maxLength = idsArray[0]!.length;\n\n      const batchInputIds = new ort.Tensor('int64', idsArray.flat() as unknown as number[], [\n        batchTexts.length,\n        maxLength,\n      ]);\n      const batchAttentionMask = new ort.Tensor('int64', maskArray.flat().map(BigInt) as unknown as number[], [\n        batchTexts.length,\n        maxLength,\n      ]);\n      const batchTokenTypeId = new ort.Tensor('int64', typeIdsArray.flat() as unknown as number[], [\n        batchTexts.length,\n        maxLength,\n      ]);\n\n      const inputs: ModelInput = {\n        input_ids: batchInputIds,\n        input_mask: batchAttentionMask,\n        segment_ids: batchTokenTypeId,\n      };\n\n      const output = await this.session.run(inputs);\n\n      // SPLADE postprocessing: log(1 + ReLU(logits))\n      const outputTensor = output.output!;\n      // @ts-expect-error cpuData exists at runtime on onnxruntime Tensor\n      const logits = outputTensor.cpuData as Float32Array;\n      const dims = outputTensor.dims as [number, number, number];\n      const [currentBatchSize, seqLen, currentVocabSize] = dims;\n\n      const sparseVectors: SparseVector[] = [];\n\n      for (let batchIdx = 0; batchIdx < currentBatchSize; batchIdx++) {\n        const valuesArr = new Float32Array(currentVocabSize).fill(0);\n\n        for (let seqIdx = 0; seqIdx < seqLen; seqIdx++) {\n          const attentionValue = maskArray[batchIdx]![seqIdx]!;\n\n          if (attentionValue > 0) {\n            for (let vocabIdx = 0; vocabIdx < currentVocabSize; vocabIdx++) {\n              const logitIdx = batchIdx * seqLen * currentVocabSize + seqIdx * currentVocabSize + vocabIdx;\n              const logitValue = logits[logitIdx]!;\n              const reluValue = Math.max(0, logitValue);\n              const logValue = Math.log(1 + reluValue);\n              valuesArr[vocabIdx] = Math.max(valuesArr[vocabIdx]!, logValue);\n            }\n          }\n        }\n\n        const sparseVector: SparseVector = { values: [], indices: [] };\n        for (let tokenId = 0; tokenId < currentVocabSize; tokenId++) {\n          if (valuesArr[tokenId]! > 0) {\n            sparseVector.indices.push(tokenId);\n            sparseVector.values.push(valuesArr[tokenId]!);\n          }\n        }\n        sparseVectors.push(sparseVector);\n      }\n\n      yield sparseVectors;\n    }\n  }\n\n  passageEmbed(texts: string[], batchSize: number = 256) {\n    return this.embed(texts, batchSize);\n  }\n\n  async queryEmbed(query: string): Promise<SparseVector> {\n    const result = await this.embed([query]).next();\n    return result.value![0]!;\n  }\n\n  listSupportedModels(): SparseModelInfo[] {\n    return [\n      {\n        model: SparseEmbeddingModel.SpladePPEnV1,\n        vocabSize: 30522,\n        description: 'SPLADE++ English model for sparse retrieval',\n      },\n    ];\n  }\n}\n","import fsp from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { FlagEmbedding, EmbeddingModel } from './fastembed.js';\n\nexport type FastEmbedModelType = 'BGESmallENV15' | 'BGEBaseENV15' | 'MLE5Large';\n\n// Resolved on every load rather than once per process, so a changed HOME or a deleted\n// cache directory doesn't leave later loads pointing at a path that no longer exists.\nasync function getModelCachePath() {\n  const cachePath = path.join(os.homedir(), '.cache', 'mastra', 'fastembed-models');\n  await fsp.mkdir(cachePath, { recursive: true });\n  return cachePath;\n}\n\nconst modelCache = new Map<FastEmbedModelType, Promise<FlagEmbedding>>();\n\nexport function getCachedModel(modelType: FastEmbedModelType) {\n  let modelPromise = modelCache.get(modelType);\n  if (!modelPromise) {\n    modelPromise = (async () =>\n      FlagEmbedding.init({\n        model: EmbeddingModel[modelType],\n        cacheDir: await getModelCachePath(),\n      }))();\n    void modelPromise.catch(() => {\n      modelCache.delete(modelType);\n    });\n    modelCache.set(modelType, modelPromise);\n  }\n  return modelPromise;\n}\n\nexport async function warmupFastEmbedModels() {\n  const cacheDir = await getModelCachePath();\n  await FlagEmbedding.retrieveModel(EmbeddingModel.BGESmallENV15, cacheDir, false);\n  await FlagEmbedding.retrieveModel(EmbeddingModel.BGEBaseENV15, cacheDir, false);\n}\n","import { customProvider as customProviderV2 } from '@internal/ai-sdk-v5';\nimport { customProvider as customProviderLegacy } from '@internal/ai-sdk-v4';\nimport type { EmbeddingModelV3 } from '@internal/ai-v6';\nimport type { EmbeddingModel as EmbeddingModelV2 } from '@internal/ai-sdk-v5';\nimport type { EmbeddingModel as EmbeddingModelV1 } from '@internal/ai-sdk-v4';\nimport { customProvider as customProviderV3 } from '@internal/ai-v6';\nimport { getCachedModel, warmupFastEmbedModels, type FastEmbedModelType } from './model-cache.js';\n\nexport {\n  EmbeddingModel,\n  FlagEmbedding,\n  SparseTextEmbedding,\n  SparseEmbeddingModel,\n  ExecutionProvider,\n} from './fastembed.js';\nexport type { SparseVector, InitOptions, InitSparseOptions } from './fastembed.js';\n\nexport type { EmbeddingModel as EmbeddingModelV1 } from '@internal/ai-sdk-v4';\nexport type { EmbeddingModel as EmbeddingModelV2 } from '@internal/ai-sdk-v5';\nexport type { EmbeddingModel as EmbeddingModelV3 } from '@internal/ai-v6';\n\n/**\n * Pre-download fastembed models without creating ONNX sessions.\n * Call this before running tests in parallel to avoid concurrent download races.\n */\nexport async function warmup() {\n  await warmupFastEmbedModels();\n}\n\n// Shared function to generate embeddings using fastembed\nasync function generateEmbeddings(values: string[], modelType: FastEmbedModelType) {\n  const model = await getCachedModel(modelType);\n\n  // model.embed() returns an AsyncGenerator that processes texts in batches (default size 256)\n  const embeddings = model.embed(values);\n\n  const allResults = [];\n  for await (const result of embeddings) {\n    // result is an array of embeddings, one for each text in the batch\n    // We convert each Float32Array embedding to a regular number array\n    allResults.push(...result.map(embedding => Array.from(embedding)));\n  }\n\n  if (allResults.length === 0) throw new Error('No embeddings generated');\n  if (allResults.length !== values.length) {\n    throw new Error(`Expected ${values.length} embeddings but received ${allResults.length}`);\n  }\n\n  return {\n    embeddings: allResults,\n  };\n}\n\n// E5 models are asymmetric: queries and passages must be embedded with different prefixes.\nfunction applyPrefix(values: string[], prefix?: 'query' | 'passage') {\n  return prefix ? values.map(value => `${prefix}: ${value}`) : values;\n}\n\n// V3 models can report warnings, so surface inputs that the model's token window silently truncates.\nasync function generateEmbeddingsWithWarnings(\n  values: string[],\n  modelType: FastEmbedModelType,\n  prefix?: 'query' | 'passage',\n) {\n  const inputs = applyPrefix(values, prefix);\n  const result = await generateEmbeddings(inputs, modelType);\n  const model = await getCachedModel(modelType);\n  const { count, maxLength } = await model.countTruncated(inputs);\n  const warnings =\n    count > 0\n      ? [\n          {\n            type: 'other' as const,\n            message: `${count} of ${inputs.length} inputs exceed the model's ${maxLength}-token window and were truncated; text beyond it does not affect the embedding. Use smaller chunks to embed the full text.`,\n          },\n        ]\n      : [];\n  return { ...result, warnings };\n}\n\n// Legacy v1 provider for backwards compatibility\nconst fastEmbedLegacyProvider = customProviderLegacy({\n  textEmbeddingModels: {\n    'bge-small-en-v1.5': {\n      specificationVersion: 'v1',\n      provider: 'fastembed',\n      modelId: 'bge-small-en-v1.5',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddings(values, 'BGESmallENV15');\n      },\n    },\n    'bge-base-en-v1.5': {\n      specificationVersion: 'v1',\n      provider: 'fastembed',\n      modelId: 'bge-base-en-v1.5',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddings(values, 'BGEBaseENV15');\n      },\n    },\n  },\n});\n\n// V2 provider for AI SDK v5 compatibility\nconst fastEmbedProviderV2 = customProviderV2({\n  textEmbeddingModels: {\n    'bge-small-en-v1.5': {\n      specificationVersion: 'v2',\n      provider: 'fastembed',\n      modelId: 'bge-small-en-v1.5',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddings(values, 'BGESmallENV15');\n      },\n    },\n    'bge-base-en-v1.5': {\n      specificationVersion: 'v2',\n      provider: 'fastembed',\n      modelId: 'bge-base-en-v1.5',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddings(values, 'BGEBaseENV15');\n      },\n    },\n  },\n});\n\n// V3 provider for AI SDK v6 compatibility\nconst fastEmbedProviderV3 = customProviderV3({\n  embeddingModels: {\n    'bge-small-en-v1.5': {\n      specificationVersion: 'v3',\n      provider: 'fastembed',\n      modelId: 'bge-small-en-v1.5',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddingsWithWarnings(values, 'BGESmallENV15');\n      },\n    },\n    'bge-base-en-v1.5': {\n      specificationVersion: 'v3',\n      provider: 'fastembed',\n      modelId: 'bge-base-en-v1.5',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddingsWithWarnings(values, 'BGEBaseENV15');\n      },\n    },\n    'multilingual-e5-large-query': {\n      specificationVersion: 'v3',\n      provider: 'fastembed',\n      modelId: 'multilingual-e5-large-query',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddingsWithWarnings(values, 'MLE5Large', 'query');\n      },\n    },\n    'multilingual-e5-large-passage': {\n      specificationVersion: 'v3',\n      provider: 'fastembed',\n      modelId: 'multilingual-e5-large-passage',\n      maxEmbeddingsPerCall: 256,\n      supportsParallelCalls: true,\n      async doEmbed({ values }) {\n        return generateEmbeddingsWithWarnings(values, 'MLE5Large', 'passage');\n      },\n    },\n  },\n});\n\nexport const fastembed: EmbeddingModelV3 & {\n  small: EmbeddingModelV3;\n  base: EmbeddingModelV3;\n  multilingualE5LargeQuery: EmbeddingModelV3;\n  multilingualE5LargePassage: EmbeddingModelV3;\n  smallV2: EmbeddingModelV2<string>;\n  baseV2: EmbeddingModelV2<string>;\n  smallLegacy: EmbeddingModelV1<string>;\n  baseLegacy: EmbeddingModelV1<string>;\n} = Object.assign(fastEmbedProviderV3.embeddingModel(`bge-small-en-v1.5`), {\n  small: fastEmbedProviderV3.embeddingModel(`bge-small-en-v1.5`),\n  base: fastEmbedProviderV3.embeddingModel(`bge-base-en-v1.5`),\n  multilingualE5LargeQuery: fastEmbedProviderV3.embeddingModel(`multilingual-e5-large-query`),\n  multilingualE5LargePassage: fastEmbedProviderV3.embeddingModel(`multilingual-e5-large-passage`),\n  smallV2: fastEmbedProviderV2.textEmbeddingModel(`bge-small-en-v1.5`),\n  baseV2: fastEmbedProviderV2.textEmbeddingModel(`bge-base-en-v1.5`),\n  smallLegacy: fastEmbedLegacyProvider.textEmbeddingModel(`bge-small-en-v1.5`),\n  baseLegacy: fastEmbedLegacyProvider.textEmbeddingModel(`bge-base-en-v1.5`),\n});\n"],"ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAgB,cAAc,SAAS;CACnC,MAAM,gBAAgB,OAAO,OAAO,OAAO,CAAC,CAAC,QAAQ,MAAM,OAAO,MAAM,QAAQ;CAIhF,OAHe,OAAO,QAAQ,OAAO,CAAC,CACjC,QAAQ,CAAC,GAAG,OAAO,cAAc,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CACpD,KAAK,CAAC,GAAG,OAAO,CACT;AAChB;AACA,SAAgB,WAAW,OAAO,YAAY,KAAK;CAC/C,OAAO,MAAM,KAAK,QAAQ,mBAAmB,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS;AACrE;AACA,SAAgB,sBAAsB,GAAG,OAAO;CAC5C,IAAI,OAAO,UAAU,UACjB,OAAO,MAAM,SAAS;CAC1B,OAAO;AACX;AAEA,IAAM,SAAN,MAAa;CACT,YAAY,QAAQ;EAChB,KAAK,UAAU;EACf,KAAK,SAAS,KAAA;CAClB;CACA,IAAI,QAAQ;EACR,MAAM,SAAS,K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