{"version":3,"sources":["jsdelivr-header.js","/npm/ky@2.1.0/source/errors/KyError.ts","/npm/ky@2.1.0/source/errors/HTTPError.ts","/npm/ky@2.1.0/source/errors/NetworkError.ts","/npm/ky@2.1.0/source/errors/NonError.ts","/npm/ky@2.1.0/source/errors/ForceRetryError.ts","/npm/ky@2.1.0/source/errors/SchemaValidationError.ts","/npm/ky@2.1.0/source/errors/TimeoutError.ts","/npm/ky@2.1.0/source/core/constants.ts","/npm/ky@2.1.0/source/utils/body.ts","/npm/ky@2.1.0/source/utils/is.ts","/npm/ky@2.1.0/source/utils/merge.ts","/npm/ky@2.1.0/source/utils/normalize.ts","/npm/ky@2.1.0/source/utils/timeout.ts","/npm/ky@2.1.0/source/utils/delay.ts","/npm/ky@2.1.0/source/utils/options.ts","/npm/ky@2.1.0/source/utils/is-network-error.ts","/npm/ky@2.1.0/source/utils/type-guards.ts","/npm/ky@2.1.0/source/core/retry-timing.ts","/npm/ky@2.1.0/source/core/Ky.ts","/npm/ky@2.1.0/source/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACCM,MAAO,UAAgB,KAAK,CACxB,KAAO,UAEhB,IAAI,WAAS,CACZ,MAAO,EACR,CACA,CCCK,MAAO,UAA+B,CAAO,CACzC,KAAO,YAChB,SACA,QACA,QACA,KAEA,YAAY,EAAoB,EAAkB,EAAoC,CACrF,MAAM,EAAQ,EAAS,QAAU,EAAS,SAAW,EAAK,EAAS,OAAS,GACtE,EAAQ,EAAS,YAAc,GAC/B,EAAS,GAAG,CAAI,IAAI,CAAK,GAAG,KAAI,EAChC,EAAS,EAAS,eAAe,CAAM,GAAK,mBAElD,MAAM,uBAAuB,CAAM,KAAK,EAAQ,MAAM,IAAI,EAAQ,GAAG,EAAE,EAEvE,KAAK,SAAW,EAChB,KAAK,QAAU,EACf,KAAK,QAAU,CAChB,CACA,CCvBK,MAAO,UAAqB,CAAO,CAC/B,KAAO,eAChB,QAEA,YAAY,EAAkB,EAAyB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AO,OAAO,CAAiB,CAChE,CAEA,OAAO,KAAK,EACb,CAEA,GAAe,EAAgB,CAC9B,KAAK,GAA2B,OAChC,KAAK,QAAU,CAChB,CAEA,GAAoB,EAAkB,CACrC,OAAO,KAAK,GAAkB,IAAI,CAAQ,GAAK,KAAK,OACrD,CAEA,GAAoB,EAAoB,EAAgB,CACvD,YAAK,GAAkB,IAAI,EAAU,CAAO,EACrC,CACR,CAEA,GAA+B,EAAkB,EAAuB,CACvE,MAAI,CAAC,KAAK,GAAS,kBAAoB,CAAC,EAAQ,MAAQ,CAAC,EACjD,EAGD,GAAc,EAAS,KAAK,GAAS,iBAAkB,GAAgB,KAAK,GAAS,MAAQ,MAAS,CAC9G,CACA,CChrCD,MAAM,EAAkB,GAA2C,CAElE,MAAM,EAAmC,CAAC,EAAc,IAAsB,EAAG,OAAO,EAAO,EAAiB,EAAU,CAAO,CAAC,EAElI,UAAW,KAAU,EAEpB,EAAG,CAAM,EAAI,CAAC,EAAc,IAAsB,EAAG,OAAO,EAAO,EAAiB,EAAU,EAAS,CAAC,OAAA,CAAM,CAAC,CAAC,EAGjH,OAAA,EAAG,OAAU,GAAmC,EAAe,EAAiB,CAAW,CAAC,EAC5F,EAAG,OAAU,IACR,OAAO,GAAgB,aAC1B,EAAc,EAAY,GAAY,CAAA,CAAE,GAGlC,EAAe,EAAiB,EAAU,CAAW,CAAC,GAG9D,EAAG,KAAO,EACV,EAAG,MAAQ,GAEJ,CACR,EAEM,GAAK,EAAc","file":"/npm/ky@2.1.0/distribution/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.\n * Original file: /npm/ky@2.1.0/distribution/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\nBase class for all Ky-specific errors. `HTTPError`, `NetworkError`, `TimeoutError`, and `ForceRetryError` extend this class.\n\nYou can use `instanceof KyError` to check if an error originated from Ky, or use the `isKyError()` type guard for cross-realm compatibility and TypeScript type narrowing.\n\nNote: `SchemaValidationError` is intentionally not considered a Ky error. `KyError` covers failures in Ky's HTTP lifecycle (bad status, timeout, retry), while schema validation errors originate from the user-provided schema, not from Ky itself.\n*/\nexport class KyError extends Error {\n\toverride name = 'KyError';\n\n\tget isKyError(): true {\n\t\treturn true;\n\t}\n}\n","import type {NormalizedOptions} from '../types/options.js';\nimport type {KyRequest} from '../types/request.js';\nimport type {KyResponse} from '../types/response.js';\nimport {KyError} from './KyError.js';\n\n/**\nError thrown when the response has a non-2xx status code and `throwHttpErrors` is enabled.\n\nThe error has a `response` property with the `Response` object, a `request` property with the `Request` object, an `options` property with the normalized options (either passed to `ky` when creating an instance with `ky.create()` or directly when performing the request), and a `data` property with the pre-parsed response body. For JSON responses (based on `Content-Type`), the body is parsed using the `parseJson` option if set, or `JSON.parse` by default. For other content types, it is set as plain text. If the body is empty, unreadable, too large, parsing fails, or the error-data read/parse timeout is reached, `data` will be `undefined`. To avoid hanging or excessive buffering, `error.data` body reads and async JSON parsing are bounded by the request timeout (or 10 seconds when `timeout` is disabled), any remaining `totalTimeout` budget, and a 10 MiB response body size limit. If `totalTimeout` expires while populating `error.data`, Ky throws `TimeoutError` instead of `HTTPError`. The `data` property is populated before `beforeError` hooks run, so hooks can access it.\n\nThe response body is automatically consumed when populating `error.data`, so `error.response.json()` and other body methods will not work. Use `error.data` instead. The `error.response` object is still available for headers, status, etc.\n\nBe aware that some types of errors, such as network errors, inherently mean that a response was not received. In that case, the error will be an instance of `NetworkError` instead of `HTTPError` and will not contain a `response` property.\n*/\nexport class HTTPError<T = unknown> extends KyError {\n\toverride name = 'HTTPError' as const;\n\tresponse: KyResponse<T>;\n\trequest: KyRequest;\n\toptions: Readonly<NormalizedOptions>;\n\tdata: T | string | undefined;\n\n\tconstructor(response: Response, request: Request, options: Readonly<NormalizedOptions>) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText ?? '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}: ${request.method} ${request.url}`);\n\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","import type {KyRequest} from '../types/request.js';\nimport {KyError} from './KyError.js';\n\n/**\nError thrown when a network error occurs during the request (e.g., DNS failure, connection refused, offline). It has a `request` property with the `Request` object. The original error is available via the standard `cause` property.\n\nNetwork errors are automatically retried (for retriable methods).\n\nNote: Network errors are detected using runtime-specific heuristics. Unrecognized runtimes may produce errors that are not wrapped in `NetworkError`. Use the `shouldRetry` option to handle such cases.\n*/\nexport class NetworkError extends KyError {\n\toverride name = 'NetworkError' as const;\n\trequest: KyRequest;\n\n\tconstructor(request: Request, options?: {cause?: Error}) {\n\t\tsuper(`Request failed due to a network error: ${request.method} ${request.url}`, options);\n\t\tthis.request = request;\n\t}\n}\n","/**\nWrapper for non-Error values that were thrown.\n\nIn JavaScript, any value can be thrown (not just Error instances). This class wraps such values to ensure consistent error handling.\n*/\nexport class NonError extends Error {\n\toverride name = 'NonError';\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tlet message = 'Non-error value was thrown';\n\n\t\t// Intentionally minimal as this error is just an edge-case.\n\t\ttry {\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tmessage = value;\n\t\t\t} else if (value && typeof value === 'object' && 'message' in value && typeof value.message === 'string') {\n\t\t\t\tmessage = value.message;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Use default message if accessing properties throws\n\t\t}\n\n\t\tsuper(message);\n\n\t\tthis.value = value;\n\t}\n}\n","import type {ForceRetryOptions} from '../core/constants.js';\nimport {KyError} from './KyError.js';\nimport {NonError} from './NonError.js';\n\n/**\nError used to signal a forced retry from `afterResponse` hooks.\n\nThis is thrown when `ky.retry()` is returned from an `afterResponse` hook. It is observable in `beforeRetry` and `beforeError` hooks via the `isForceRetryError()` type guard.\n*/\nexport class ForceRetryError extends KyError {\n\toverride name = 'ForceRetryError' as const;\n\tcustomDelay: number | undefined;\n\tcode: string | undefined;\n\tcustomRequest: Request | undefined;\n\n\tconstructor(options?: ForceRetryOptions) {\n\t\t// Runtime protection: wrap non-Error causes in NonError\n\t\t// TypeScript type is Error for guidance, but JS users can pass anything\n\t\tconst cause = options?.cause\n\t\t\t? (options.cause instanceof Error ? options.cause : new NonError(options.cause))\n\t\t\t: undefined;\n\n\t\tsuper(\n\t\t\toptions?.code ? `Forced retry: ${options.code}` : 'Forced retry',\n\t\t\tcause ? {cause} : undefined,\n\t\t);\n\n\t\tthis.customDelay = options?.delay;\n\t\tthis.code = options?.code;\n\t\tthis.customRequest = options?.request;\n\t}\n}\n","import type {StandardSchemaV1Issue} from '../types/standard-schema.js';\n\n/**\nThe error thrown when [Standard Schema](https://github.com/standard-schema/standard-schema) validation fails in `.json(schema)`. It has an `issues` property with the validation issues from the schema.\n\nThis error intentionally does not extend `KyError` because it does not represent a failure in Ky's HTTP lifecycle. The request succeeded; the user's schema rejected the data. As such, it is not matched by `isKyError()`.\n\n@example\n```\nimport ky, {SchemaValidationError} from 'ky';\nimport {z} from 'zod';\n\nconst userSchema = z.object({name: z.string()});\n\ntry {\n\tconst user = await ky('/api/user').json(userSchema);\n\tconsole.log(user.name);\n} catch (error) {\n\tif (error instanceof SchemaValidationError) {\n\t\tconsole.error(error.issues);\n\t}\n}\n```\n*/\nexport class SchemaValidationError extends Error {\n\toverride name = 'SchemaValidationError' as const;\n\treadonly issues: readonly StandardSchemaV1Issue[];\n\n\tconstructor(issues: readonly StandardSchemaV1Issue[]) {\n\t\tsuper('Response schema validation failed');\n\t\tthis.issues = issues;\n\t}\n}\n","import type {KyRequest} from '../types/request.js';\nimport {KyError} from './KyError.js';\n\n/**\nError thrown when the request times out. It has a `request` property with the `Request` object.\n*/\nexport class TimeoutError extends KyError {\n\toverride name = 'TimeoutError' as const;\n\trequest: KyRequest;\n\n\tconstructor(request: Request) {\n\t\tsuper(`Request timed out: ${request.method} ${request.url}`);\n\t\tthis.request = request;\n\t}\n}\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type KyOptionsRegistry, type RequestHttpMethod} from '../types/options.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\ttry {\n\t\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\t\tmethod: 'POST',\n\t\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\t\tget duplex() {\n\t\t\t\t\tduplexAccessed = true;\n\t\t\t\t\treturn 'half';\n\t\t\t\t},\n\t\t\t}).headers.has('Content-Type');\n\t\t} catch (error) {\n\t\t\t// QQBrowser on iOS throws \"unsupported BodyInit type\" error (see issue #581)\n\t\t\tif (error instanceof Error && error.message === 'unsupported BodyInit type') {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsAbortSignal = typeof globalThis.AbortSignal === 'function' && typeof globalThis.AbortSignal.any === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete', 'query'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], RequestHttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n\t// Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).\n\t// We still feature-check at runtime before exposing the shortcut.\n\tbytes: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\n// Size in bytes of a typical form boundary (e.g., '------WebKitFormBoundaryaxpyiPgbbPti10Rw'), used to help estimate upload size\nexport const usualFormBoundarySize = 40;\n\n/**\nSymbol that can be returned by a `beforeRetry` hook to stop retrying without throwing an error.\n*/\nexport const stop = Symbol('stop');\n\n/**\nOptions for forcing a retry via `ky.retry()`.\n*/\nexport type ForceRetryOptions = {\n\t/**\n\tCustom delay in milliseconds before retrying.\n\n\tIf not provided, uses the default retry delay calculation based on `retry.delay` configuration.\n\n\t**Note:** Custom delays bypass jitter and `backoffLimit`. This is intentional, as custom delays often come from server responses (e.g., `Retry-After` headers) and should be respected exactly as specified.\n\t*/\n\tdelay?: number;\n\n\t/**\n\tError code for the retry.\n\n\tThis machine-readable identifier will be included in the error message passed to `beforeRetry` hooks, allowing you to distinguish between different types of forced retries.\n\n\t@example\n\t```\n\treturn ky.retry({code: 'RATE_LIMIT'});\n\t// Resulting error message: 'Forced retry: RATE_LIMIT'\n\t```\n\t*/\n\tcode?: string;\n\n\t/**\n\tOriginal error that caused the retry.\n\n\tThis allows you to preserve the error chain when forcing a retry based on caught exceptions. The error will be set as the `cause` of the `ForceRetryError`, enabling proper error chain traversal.\n\n\t@example\n\t```\n\ttry {\n\t\tconst data = await response.json();\n\t\tvalidateBusinessLogic(data);\n\t} catch (error) {\n\t\treturn ky.retry({\n\t\t\tcode: 'VALIDATION_FAILED',\n\t\t\tcause: error // Preserves original error in chain\n\t\t});\n\t}\n\t```\n\t*/\n\tcause?: Error;\n\n\t/**\n\tCustom request to use for the retry.\n\n\tThis allows you to modify or completely replace the request during a forced retry. The custom request becomes the starting point for the retry - `beforeRetry` hooks can still further modify it if needed.\n\n\t**Note:** The custom request's `signal` will be replaced with Ky's managed signal to handle timeouts and user-provided abort signals correctly. If the original request body has been consumed, you must provide a new body or clone the request before consuming.\n\n\t**Warning:** Custom retry requests are not sanitized. If you reuse headers across origins, remove any credentials you do not want forwarded.\n\n\t@example\n\t```\n\t// Fallback to a different endpoint\n\treturn ky.retry({\n\t\trequest: new Request('https://backup-api.com/endpoint', {\n\t\t\tmethod: request.method,\n\t\t\theaders: request.headers,\n\t\t}),\n\t\tcode: 'BACKUP_ENDPOINT'\n\t});\n\n\t// Retry with refreshed authentication token\n\tconst data = await response.json();\n\treturn ky.retry({\n\t\trequest: new Request(request, {\n\t\t\theaders: {\n\t\t\t\t...Object.fromEntries(request.headers),\n\t\t\t\t'Authorization': `Bearer ${data.newToken}`\n\t\t\t}\n\t\t}),\n\t\tcode: 'TOKEN_REFRESHED'\n\t});\n\t```\n\t*/\n\trequest?: Request;\n};\n\n/**\nMarker returned by `ky.retry()` to signal a forced retry from `afterResponse` hooks.\n*/\nexport class RetryMarker {\n\toptions: ForceRetryOptions | undefined;\n\n\tconstructor(options?: ForceRetryOptions) {\n\t\tthis.options = options;\n\t}\n}\n\n/**\nForce a retry from an `afterResponse` hook.\n\nThis allows you to retry a request based on the response content, even if the response has a successful status code. The retry will respect the `retry.limit` option and skip the `shouldRetry` check. The forced retry is observable in `beforeRetry` hooks, where the error will be a `ForceRetryError`.\n\n@param options - Optional configuration for the retry.\n\n@example\n```\nimport ky, {isForceRetryError} from 'ky';\n\nconst api = ky.extend({\n\thooks: {\n\t\tafterResponse: [\n\t\t\tasync ({request, response}) => {\n\t\t\t\t// Retry based on response body content\n\t\t\t\tif (response.status === 200) {\n\t\t\t\t\tconst data = await response.json();\n\n\t\t\t\t\t// Simple retry with default delay\n\t\t\t\t\tif (data.error?.code === 'TEMPORARY_ERROR') {\n\t\t\t\t\t\treturn ky.retry();\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with custom delay from API response\n\t\t\t\t\tif (data.error?.code === 'RATE_LIMIT') {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\tdelay: data.error.retryAfter * 1000,\n\t\t\t\t\t\t\tcode: 'RATE_LIMIT'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with a modified request (e.g., fallback endpoint)\n\t\t\t\t\tif (data.error?.code === 'FALLBACK_TO_BACKUP') {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\trequest: new Request('https://backup-api.com/endpoint', {\n\t\t\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\t\t\theaders: request.headers,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcode: 'BACKUP_ENDPOINT'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with refreshed authentication\n\t\t\t\t\tif (data.error?.code === 'TOKEN_REFRESH' && data.newToken) {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\trequest: new Request(request, {\n\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\t...Object.fromEntries(request.headers),\n\t\t\t\t\t\t\t\t\t'Authorization': `Bearer ${data.newToken}`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcode: 'TOKEN_REFRESHED'\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Retry with cause to preserve error chain\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvalidateResponse(data);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn ky.retry({\n\t\t\t\t\t\t\tcode: 'VALIDATION_FAILED',\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\tbeforeRetry: [\n\t\t\t({error, retryCount}) => {\n\t\t\t\t// Observable in beforeRetry hooks\n\t\t\t\tif (isForceRetryError(error)) {\n\t\t\t\t\tconsole.log(`Forced retry #${retryCount}: ${error.message}`);\n\t\t\t\t\t// Example output: \"Forced retry #1: Forced retry: RATE_LIMIT\"\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n\nconst response = await api.get('https://example.com/api');\n```\n*/\nexport const retry = (options?: ForceRetryOptions) => new RetryMarker(options);\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tstringifyJson: true,\n\tsearchParams: true,\n\tbaseUrl: true,\n\tprefix: true,\n\tretry: true,\n\ttimeout: true,\n\ttotalTimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tonUploadProgress: true,\n\tfetch: true,\n\tcontext: true,\n};\n\n// Standard RequestInit options that should NOT be passed separately to fetch()\n// because they're already applied to the Request object.\n// Note: `dispatcher` and `priority` are NOT included here - they're fetch-only\n// options that the Request constructor doesn't accept, so they need to be passed\n// separately to fetch().\nexport const requestOptionsRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tduplex: true,\n} as const;\n","import type {Options} from '../types/options.js';\nimport {usualFormBoundarySize} from '../core/constants.js';\n\nconst encoder = new TextEncoder();\n\n// eslint-disable-next-line @typescript-eslint/no-restricted-types\nexport const getBodySize = (body?: BodyInit | null): number => {\n\tif (!body) {\n\t\treturn 0;\n\t}\n\n\tif (body instanceof FormData) {\n\t\t// This is an approximation, as FormData size calculation is not straightforward\n\t\tlet size = 0;\n\n\t\tfor (const [key, value] of body) {\n\t\t\tsize += usualFormBoundarySize;\n\t\t\tsize += encoder.encode(`Content-Disposition: form-data; name=\"${key}\"`).byteLength;\n\t\t\tsize += typeof value === 'string'\n\t\t\t\t? encoder.encode(value).byteLength\n\t\t\t\t: value.size;\n\t\t}\n\n\t\treturn size;\n\t}\n\n\tif (body instanceof Blob) {\n\t\treturn body.size;\n\t}\n\n\tif (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {\n\t\treturn body.byteLength;\n\t}\n\n\tif (typeof body === 'string') {\n\t\treturn encoder.encode(body).byteLength;\n\t}\n\n\tif (body instanceof URLSearchParams) {\n\t\treturn encoder.encode(body.toString()).byteLength;\n\t}\n\n\treturn 0;\n};\n\nconst withProgress = (stream: ReadableStream<Uint8Array>, totalBytes: number, onProgress: Options['onDownloadProgress'] | Options['onUploadProgress']): ReadableStream<Uint8Array> => {\n\tlet previousChunk: Uint8Array | undefined;\n\tlet transferredBytes = 0;\n\n\treturn stream.pipeThrough(new TransformStream<Uint8Array, Uint8Array>({\n\t\ttransform(currentChunk, controller) {\n\t\t\tcontroller.enqueue(currentChunk);\n\n\t\t\tif (previousChunk) {\n\t\t\t\ttransferredBytes += previousChunk.byteLength;\n\n\t\t\t\tlet percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t// Avoid reporting 100% progress before the stream is actually finished (in case totalBytes is inaccurate)\n\t\t\t\tif (percent >= 1) {\n\t\t\t\t\t// Epsilon is used here to get as close as possible to 100% without reaching it.\n\t\t\t\t\t// If we were to use 0.99 here, percent could potentially go backwards.\n\t\t\t\t\tpercent = 1 - Number.EPSILON;\n\t\t\t\t}\n\n\t\t\t\tonProgress?.({percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes}, previousChunk);\n\t\t\t}\n\n\t\t\tpreviousChunk = currentChunk;\n\t\t},\n\t\tflush() {\n\t\t\tconst finalChunk = previousChunk ?? new Uint8Array();\n\t\t\ttransferredBytes += finalChunk.byteLength;\n\t\t\tonProgress?.({percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes}, finalChunk);\n\t\t},\n\t}));\n};\n\nexport const streamResponse = (response: Response, onDownloadProgress: Options['onDownloadProgress']) => {\n\tif (!response.body) {\n\t\treturn response;\n\t}\n\n\tconst responseInit = {\n\t\tstatus: response.status,\n\t\tstatusText: response.statusText,\n\t\theaders: response.headers,\n\t};\n\n\tif (response.status === 204) {\n\t\treturn new Response(null, responseInit);\n\t}\n\n\tconst totalBytes = Math.max(0, Number(response.headers.get('content-length')) || 0);\n\treturn new Response(withProgress(response.body, totalBytes, onDownloadProgress), responseInit);\n};\n\n// eslint-disable-next-line @typescript-eslint/no-restricted-types\nexport const streamRequest = (request: Request, onUploadProgress: Options['onUploadProgress'], originalBody?: BodyInit | null) => {\n\tif (!request.body) {\n\t\treturn request;\n\t}\n\n\t// Use original body for size calculation since request.body is already a stream\n\tconst totalBytes = getBodySize(originalBody ?? request.body);\n\n\treturn new Request(request, {\n\t\t// @ts-expect-error - Types are outdated.\n\t\tduplex: 'half',\n\t\tbody: withProgress(request.body, totalBytes, onUploadProgress),\n\t});\n};\n","// eslint-disable-next-line @typescript-eslint/no-restricted-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport type {Hooks} from '../types/hooks.js';\nimport {supportsAbortSignal} from '../core/constants.js';\nimport {isObject} from './is.js';\n\nconst replaceSymbol: unique symbol = Symbol('replaceOption');\n\ntype ReplaceMarked<T> = {\n\t[replaceSymbol]: true;\n\tvalue: T;\n};\n\ntype ReplaceState<T> = {\n\tisReplace: boolean;\n\tvalue: T;\n};\n\nconst getReplaceState = <T>(value: T): ReplaceState<T> =>\n\tisObject(value) && (value as any)[replaceSymbol] === true\n\t\t? {\n\t\t\tisReplace: true,\n\t\t\tvalue: (value as unknown as ReplaceMarked<T>).value,\n\t\t}\n\t\t: {\n\t\t\tisReplace: false,\n\t\t\tvalue,\n\t\t};\n\n/**\nWraps a value so that `ky.extend()` will replace the parent value instead of merging with it. Works with hooks, headers, search parameters, context, and any other deep-merged option.\n\nBy default, `.extend()` deep-merges options with the parent instance: hooks get appended, headers get merged, and search parameters get accumulated. Use `replaceOption` when you want to fully replace a merged property instead.\n\n@example\n```\nimport ky, {replaceOption} from 'ky';\n\nconst base = ky.create({\n\thooks: {beforeRequest: [addAuth, addTracking]},\n});\n\n// Replaces instead of appending\nconst extended = base.extend({\n\thooks: replaceOption({beforeRequest: [onlyThis]}),\n});\n// hooks.beforeRequest is now [onlyThis], not [addAuth, addTracking, onlyThis]\n```\n*/\nexport const replaceOption = <T>(value: T): T => {\n\tconst markedValue: ReplaceMarked<T> = {[replaceSymbol]: true, value};\n\treturn markedValue as unknown as T;\n};\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as RequestInit['headers']);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as RequestInit['headers']);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n\tif (!isObject(value) || Array.isArray(value)) {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n};\n\nexport const cloneShallow = <T>(value: T): T => {\n\tif (value instanceof URLSearchParams) {\n\t\tconst copy = new URLSearchParams(value) as URLSearchParams & {[deletedParametersSymbol]?: Set<string>};\n\t\tconst deleted = (value as URLSearchParams & {[deletedParametersSymbol]?: Set<string>})[deletedParametersSymbol];\n\t\tif (deleted) {\n\t\t\t// Preserve internal deletion markers so init-hook cloning does not resurrect params removed during option merging.\n\t\t\tcopy[deletedParametersSymbol] = new Set(deleted);\n\t\t}\n\n\t\treturn copy as T;\n\t}\n\n\tif (value instanceof globalThis.Headers) {\n\t\treturn new globalThis.Headers(value) as T;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn [...value] as T;\n\t}\n\n\tif (isPlainObject(value)) {\n\t\tconst copy = {...value};\n\t\treturn copy as T;\n\t}\n\n\treturn value;\n};\n\nconst normalizeHeaderObject = (headers: Record<string, string | undefined>): Record<string, string> =>\n\tObject.fromEntries(\n\t\tObject.entries(headers).filter((entry): entry is [string, string] => entry[1] !== undefined),\n\t);\n\nconst mergeHeaderContainers = (source1: KyHeadersInit, source2: KyHeadersInit): KyHeadersInit => {\n\tif (isPlainObject(source1) && isPlainObject(source2)) {\n\t\treturn normalizeHeaderObject({...source1, ...source2});\n\t}\n\n\treturn mergeHeaders(source1, source2);\n};\n\nfunction newHookValue<K extends keyof Hooks>(original: Hooks, incoming: Hooks, property: K): Required<Hooks>[K] {\n\treturn (Object.hasOwn(incoming, property) && incoming[property] === undefined)\n\t\t? []\n\t\t: deepMerge<Required<Hooks>[K]>(original[property] ?? [], incoming[property] ?? []);\n}\n\nexport const mergeHooks = (original: Hooks = {}, incoming: Hooks = {}): Required<Hooks> => (\n\t{\n\t\tinit: newHookValue(original, incoming, 'init'),\n\t\tbeforeRequest: newHookValue(original, incoming, 'beforeRequest'),\n\t\tbeforeRetry: newHookValue(original, incoming, 'beforeRetry'),\n\t\tbeforeError: newHookValue(original, incoming, 'beforeError'),\n\t\tafterResponse: newHookValue(original, incoming, 'afterResponse'),\n\t}\n);\n\nexport const deletedParametersSymbol = Symbol('deletedParameters');\n\nconst appendSearchParameters = (target: any, source: any): URLSearchParams => {\n\tconst result = new URLSearchParams() as URLSearchParams & {[deletedParametersSymbol]?: Set<string>};\n\tconst deleted = new Set<string>();\n\n\tfor (const input of [target, source]) {\n\t\tif (input === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (input instanceof URLSearchParams) {\n\t\t\tfor (const [key, value] of input.entries()) {\n\t\t\t\tresult.append(key, value);\n\t\t\t\tdeleted.delete(key);\n\t\t\t}\n\n\t\t\tconst inputDeleted = (input as any)[deletedParametersSymbol] as Set<string> | undefined;\n\t\t\tif (inputDeleted) {\n\t\t\t\tfor (const key of inputDeleted) {\n\t\t\t\t\tresult.delete(key);\n\t\t\t\t\tdeleted.add(key);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Array.isArray(input)) {\n\t\t\tfor (const pair of input) {\n\t\t\t\tif (!Array.isArray(pair) || pair.length !== 2) {\n\t\t\t\t\tthrow new TypeError('Array search parameters must be provided in [[key, value], ...] format');\n\t\t\t\t}\n\n\t\t\t\tresult.append(String(pair[0]), String(pair[1]));\n\t\t\t\tdeleted.delete(String(pair[0]));\n\t\t\t}\n\t\t} else if (isObject(input)) {\n\t\t\tfor (const [key, value] of Object.entries(input)) {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tresult.delete(key);\n\t\t\t\t\tdeleted.add(key);\n\t\t\t\t} else {\n\t\t\t\t\tresult.append(key, String(value));\n\t\t\t\t\tdeleted.delete(key);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// String\n\t\t\tconst parameters = new URLSearchParams(input);\n\t\t\tfor (const [key, value] of parameters.entries()) {\n\t\t\t\tresult.append(key, value);\n\t\t\t\tdeleted.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (deleted.size > 0) {\n\t\tresult[deletedParametersSymbol] = deleted;\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nconst deepMergeInternal = <T>(isRoot: boolean, ...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers: KyHeadersInit = {};\n\tlet hooks = {};\n\tlet searchParameters: any;\n\tconst signals: AbortSignal[] = [];\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tconst replaceState = getReplaceState(value);\n\t\t\t\tconst {isReplace} = replaceState;\n\t\t\t\tvalue = replaceState.value;\n\n\t\t\t\tconst isRootSignal = isRoot && key === 'signal';\n\t\t\t\tif (isRootSignal && (isReplace || value === undefined)) {\n\t\t\t\t\tsignals.length = 0;\n\t\t\t\t}\n\n\t\t\t\t// Special handling for AbortSignal instances at the root options level\n\t\t\t\tif (isRootSignal && value instanceof globalThis.AbortSignal) {\n\t\t\t\t\tsignals.push(value);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Special handling for context - shallow merge only\n\t\t\t\tif (key === 'context') {\n\t\t\t\t\tif (value !== undefined && value !== null && (!isObject(value) || Array.isArray(value))) {\n\t\t\t\t\t\tthrow new TypeError('The `context` option must be an object');\n\t\t\t\t\t}\n\n\t\t\t\t\t// Shallow merge: always create a new object to prevent mutation bugs\n\t\t\t\t\treturnValue = {\n\t\t\t\t\t\t...returnValue,\n\t\t\t\t\t\tcontext: (value === undefined || value === null)\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: (isReplace\n\t\t\t\t\t\t\t\t? {...value}\n\t\t\t\t\t\t\t\t: {...returnValue.context, ...value}),\n\t\t\t\t\t};\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Special handling for searchParams\n\t\t\t\tif (key === 'searchParams') {\n\t\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\t\t// Explicit undefined or null removes searchParams\n\t\t\t\t\t\tsearchParameters = undefined;\n\t\t\t\t\t} else if (isReplace) {\n\t\t\t\t\t\tsearchParameters = value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// First source: keep as-is to preserve type (string/object/URLSearchParams)\n\t\t\t\t\t\t// Subsequent sources: merge and convert to URLSearchParams\n\t\t\t\t\t\tsearchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// `retry` accepts a number as shorthand for `{limit: number}`. Expand it before\n\t\t\t\t// merging so extending a numeric `retry` with an object keeps the limit instead\n\t\t\t\t// of dropping it (e.g. `ky.create({retry: 3}).extend({retry: {methods: ['get']}})`).\n\t\t\t\t// Scoped to the root options level so it never rewrites nested user data that\n\t\t\t\t// happens to contain a `retry` key (e.g. a `json` request body).\n\t\t\t\tif (isRoot && key === 'retry' && isObject(value) && !isReplace && typeof returnValue[key] === 'number') {\n\t\t\t\t\treturnValue = {...returnValue, [key]: {limit: returnValue[key]}};\n\t\t\t\t}\n\n\t\t\t\tif (isObject(value) && !isReplace && key in returnValue) {\n\t\t\t\t\tvalue = deepMergeInternal(false, returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).hooks)) {\n\t\t\t\tconst {value: hookValue, isReplace} = getReplaceState((source as any).hooks);\n\t\t\t\thooks = isReplace\n\t\t\t\t\t? mergeHooks({}, hookValue)\n\t\t\t\t\t: mergeHooks(hooks, hookValue);\n\n\t\t\t\treturnValue.hooks = hooks;\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\tconst {value: headerValue, isReplace} = getReplaceState((source as any).headers);\n\t\t\t\theaders = isReplace\n\t\t\t\t\t? cloneShallow(headerValue as KyHeadersInit)\n\t\t\t\t\t: mergeHeaderContainers(headers, headerValue as KyHeadersInit);\n\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (searchParameters !== undefined) {\n\t\treturnValue.searchParams = searchParameters;\n\t}\n\n\tif (signals.length > 0) {\n\t\tif (signals.length === 1) {\n\t\t\treturnValue.signal = signals[0];\n\t\t} else if (supportsAbortSignal) {\n\t\t\treturnValue.signal = AbortSignal.any(signals);\n\t\t} else {\n\t\t\t// When AbortSignal.any is not available, use the last signal\n\t\t\t// This maintains the previous behavior before signal merging was added\n\t\t\t// This can be removed when the `supportsAbortSignal` check is removed.\n\t\t\treturnValue.signal = signals.at(-1);\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T =>\n\tdeepMergeInternal<T>(true, ...sources);\n","import {requestMethods} from '../core/constants.js';\nimport type {RetryOptions} from '../types/retry.js';\nimport type {HttpMethod, InternalOptions, RequestHttpMethod} from '../types/options.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as RequestHttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods: HttpMethod[] = ['get', 'put', 'head', 'delete', 'options', 'trace', 'query'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\nconst invalidRetryLimitErrorMessage = '`retry.limit` must be a finite, non-negative integer';\n\ntype InternalRetryOptions = InternalOptions['retry'];\n\nconst defaultRetryOptions: InternalRetryOptions = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n\tjitter: undefined,\n\tretryOnTimeout: false,\n};\n\nconst getDefaultRetryOptions = (): InternalRetryOptions => ({\n\t...defaultRetryOptions,\n\tmethods: [...defaultRetryOptions.methods],\n\tstatusCodes: [...defaultRetryOptions.statusCodes],\n\tafterStatusCodes: [...defaultRetryOptions.afterStatusCodes],\n});\n\n/**\nNormalizes an omitted retry limit or validates a supplied one.\n*/\nconst normalizeRetryLimit = (retryLimit: unknown): number => {\n\tif (retryLimit === undefined) {\n\t\treturn defaultRetryOptions.limit;\n\t}\n\n\tif (typeof retryLimit !== 'number' || !Number.isInteger(retryLimit) || retryLimit < 0) {\n\t\tthrow new TypeError(invalidRetryLimitErrorMessage);\n\t}\n\n\treturn retryLimit;\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): InternalRetryOptions => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...getDefaultRetryOptions(),\n\t\t\tlimit: normalizeRetryLimit(retry),\n\t\t};\n\t}\n\n\tif (retry === null || typeof retry !== 'object' || Array.isArray(retry)) {\n\t\tthrow new TypeError('`retry` must be a number or an object');\n\t}\n\n\tconst normalizedRetry = Object.fromEntries(Object.entries(retry).filter(([, value]) => value !== undefined)) as RetryOptions;\n\tconst retryLimit = normalizeRetryLimit(normalizedRetry.limit);\n\n\tif (normalizedRetry.methods !== undefined && !Array.isArray(normalizedRetry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (normalizedRetry.statusCodes !== undefined && !Array.isArray(normalizedRetry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\tif (normalizedRetry.afterStatusCodes !== undefined && !Array.isArray(normalizedRetry.afterStatusCodes)) {\n\t\tthrow new Error('retry.afterStatusCodes must be an array');\n\t}\n\n\tif (normalizedRetry.methods !== undefined) {\n\t\tnormalizedRetry.methods = normalizedRetry.methods.map(method => method.toLowerCase());\n\t}\n\n\tif (normalizedRetry.statusCodes !== undefined) {\n\t\tnormalizedRetry.statusCodes = [...normalizedRetry.statusCodes];\n\t}\n\n\tif (normalizedRetry.afterStatusCodes !== undefined) {\n\t\tnormalizedRetry.afterStatusCodes = [...normalizedRetry.afterStatusCodes];\n\t}\n\n\treturn {\n\t\t...getDefaultRetryOptions(),\n\t\t...normalizedRetry,\n\t\tlimit: retryLimit,\n\t};\n};\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason as Error);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';\nimport type {SearchParamsOption} from '../types/options.js';\nimport {deletedParametersSymbol} from './merge.js';\n\nexport const findUnknownOptions = (\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\t// Skip inherited properties\n\t\tif (!Object.hasOwn(options, key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Forward every non-standard, non-Ky option to fetch().\n\t\t// We intentionally do not check whether the key also exists on `Request`, because some runtimes\n\t\t// patch `Request.prototype` with fetch-only extensions. For example, Next.js adds `next`, and the\n\t\t// old `key in request` heuristic dropped it unless Ky kept a special-case allowlist.\n\t\t// Passing all non-standard keys makes that allowlist unnecessary and preserves future fetch extensions too.\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n\nexport const hasSearchParameters = (search: SearchParamsOption): boolean => {\n\tif (search === undefined) {\n\t\treturn false;\n\t}\n\n\t// The `typeof array` still gives \"object\", so we need different checking for array.\n\tif (Array.isArray(search)) {\n\t\treturn search.length > 0;\n\t}\n\n\tif (search instanceof URLSearchParams) {\n\t\treturn search.size > 0 || Boolean((search as any)[deletedParametersSymbol]?.size);\n\t}\n\n\t// Record\n\tif (typeof search === 'object') {\n\t\treturn Object.keys(search).length > 0;\n\t}\n\n\tif (typeof search === 'string') {\n\t\treturn search.trim().length > 0;\n\t}\n\n\treturn Boolean(search);\n};\n","// Inlined from https://github.com/sindresorhus/is-network-error v1.3.2\n\nconst objectToString = Object.prototype.toString;\n\nconst isError = (value: unknown): value is Error => objectToString.call(value) === '[object Error]';\n\nconst errorMessages = new Set([\n\t'network error', // Chrome\n\t'NetworkError when attempting to fetch resource.', // Firefox\n\t'The Internet connection appears to be offline.', // Safari 16\n\t'Network request failed', // `cross-fetch`\n\t'fetch failed', // Undici (Node.js)\n\t'terminated', // Undici (Node.js)\n\t' A network error occurred.', // Bun (WebKit) - leading space is intentional\n\t'Network connection lost', // Cloudflare Workers (fetch)\n]);\n\nexport default function isRawNetworkError(error: unknown): error is TypeError {\n\tconst isValid = error\n\t\t&& isError(error)\n\t\t&& error.name === 'TypeError'\n\t\t&& typeof error.message === 'string';\n\n\tif (!isValid) {\n\t\treturn false;\n\t}\n\n\tconst {message, stack} = error;\n\n\t// Safari 17+ has generic message but no stack for network errors\n\tif (message === 'Load failed' || (message.startsWith('Load failed (') && message.endsWith(')'))) {\n\t\treturn stack === undefined\n\t\t\t// Sentry adds its own stack trace to the fetch error, so also check for that\n\t\t\t|| '__sentry_captured__' in error;\n\t}\n\n\t// Deno network errors start with specific text\n\tif (message.startsWith('error sending request for url')) {\n\t\treturn true;\n\t}\n\n\t// Chrome: exact \"Failed to fetch\" or with hostname: \"Failed to fetch (example.com)\"\n\tif (message === 'Failed to fetch' || (message.startsWith('Failed to fetch (') && message.endsWith(')'))) {\n\t\treturn true;\n\t}\n\n\t// Standard network error messages\n\treturn errorMessages.has(message);\n}\n","import type {KyError} from '../errors/KyError.js';\nimport {HTTPError} from '../errors/HTTPError.js';\nimport {NetworkError} from '../errors/NetworkError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport {ForceRetryError} from '../errors/ForceRetryError.js';\n\n// Handles cross-realm cases (e.g., iframes, different JS contexts) where `instanceof` fails.\nconst isErrorType = (error: unknown, cls: {name: string}): boolean =>\n\terror instanceof (cls as any) || (error as any)?.name === cls.name;\n\n/**\nType guard to check if an error is a `KyError`.\n\nNote: `SchemaValidationError` is intentionally not considered a Ky error. `KyError` covers failures in Ky's HTTP lifecycle (bad status, timeout, retry), while schema validation errors originate from the user-provided schema, not from Ky itself.\n\n@param error - The error to check\n@returns `true` if the error is a Ky error, `false` otherwise\n\n@example\n```\nimport ky, {isKyError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data');\n} catch (error) {\n\tif (isKyError(error)) {\n\t\t// Handle Ky-specific errors\n\t\tconsole.log('Ky error occurred:', error.message);\n\t} else {\n\t\t// Handle other errors\n\t\tconsole.log('Unknown error:', error);\n\t}\n}\n```\n*/\nexport function isKyError(error: unknown): error is KyError {\n\treturn (error as any)?.isKyError === true || isHTTPError(error) || isNetworkError(error) || isTimeoutError(error) || isForceRetryError(error);\n}\n\n/**\nType guard to check if an error is an `HTTPError`.\n\n@param error - The error to check\n@returns `true` if the error is an `HTTPError`, `false` otherwise\n\n@example\n```\nimport ky, {isHTTPError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data');\n} catch (error) {\n\tif (isHTTPError(error)) {\n\t\tconsole.log('HTTP error status:', error.response.status);\n\t}\n}\n```\n*/\nexport function isHTTPError<T = unknown>(error: unknown): error is HTTPError<T> {\n\treturn isErrorType(error, HTTPError);\n}\n\n/**\nType guard to check if an error is a `NetworkError`.\n\n@param error - The error to check\n@returns `true` if the error is a `NetworkError`, `false` otherwise\n\n@example\n```\nimport ky, {isNetworkError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data');\n} catch (error) {\n\tif (isNetworkError(error)) {\n\t\tconsole.log('Network error:', error.request.url);\n\t}\n}\n```\n*/\nexport function isNetworkError(error: unknown): error is NetworkError {\n\treturn isErrorType(error, NetworkError);\n}\n\n/**\nType guard to check if an error is a `TimeoutError`.\n\n@param error - The error to check\n@returns `true` if the error is a `TimeoutError`, `false` otherwise\n\n@example\n```\nimport ky, {isTimeoutError} from 'ky';\ntry {\n\tconst response = await ky.get('/api/data', { timeout: 1000 });\n} catch (error) {\n\tif (isTimeoutError(error)) {\n\t\tconsole.log('Request timed out:', error.request.url);\n\t}\n}\n```\n*/\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n\treturn isErrorType(error, TimeoutError);\n}\n\n/**\nType guard to check if an error is a `ForceRetryError`.\n\n@param error - The error to check\n@returns `true` if the error is a `ForceRetryError`, `false` otherwise\n\n@example\n```\nimport ky, {isForceRetryError} from 'ky';\n\nconst api = ky.extend({\n\thooks: {\n\t\tbeforeRetry: [\n\t\t\t({error, retryCount}) => {\n\t\t\t\tif (isForceRetryError(error)) {\n\t\t\t\t\tconsole.log(`Forced retry #${retryCount}: ${error.code}`);\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n});\n```\n*/\nexport function isForceRetryError(error: unknown): error is ForceRetryError {\n\treturn isErrorType(error, ForceRetryError);\n}\n","// Older epoch-second values are indistinguishable from ordinary delay seconds, so timestamp compatibility only applies to current-era reset headers.\nconst timestampThreshold = Date.parse('2024-01-01');\nconst delayPattern = /^\\d+$/;\nconst months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\n// HTTP-date parsing is limited to IMF-fixdate and the two obsolete HTTP-date formats. Other date-like strings intentionally fall back to the normal retry delay.\nconst imfDatePattern = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\\d{4}) (\\d{2}):(\\d{2}):(\\d{2}) GMT$/;\nconst rfc850DatePattern = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2}) GMT$/;\nconst asctimeDatePattern = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\\d{2}| \\d) (\\d{2}:\\d{2}:\\d{2}) (\\d{4})$/;\n\ntype RetryTimingHeader = {\n\tvalue: string;\n\tallowTimestamp: boolean;\n};\n\ntype RetryTimingDateParts = {\n\tyear: number;\n\tmonth: string;\n\tday: string;\n\thours: string;\n\tminutes: string;\n\tseconds: string;\n};\n\nexport const getRetryTimingHeader = (headers: Headers): RetryTimingHeader | undefined => {\n\tconst retryAfter = headers.get('Retry-After');\n\tif (retryAfter !== null) {\n\t\treturn {value: retryAfter, allowTimestamp: false};\n\t}\n\n\t// Retry-After is authoritative when present. Only missing Retry-After falls through to rate-limit headers.\n\tconst rateLimitReset = headers.get('RateLimit-Reset');\n\tif (rateLimitReset !== null) {\n\t\treturn {value: rateLimitReset, allowTimestamp: true};\n\t}\n\n\tconst rateLimitRetryAfter = headers.get('X-RateLimit-Retry-After'); // Symfony-based services\n\tif (rateLimitRetryAfter !== null) {\n\t\treturn {value: rateLimitRetryAfter, allowTimestamp: false};\n\t}\n\n\tconst rateLimitResetAlias = headers.get('X-RateLimit-Reset') // GitHub\n\t\t?? headers.get('X-Rate-Limit-Reset'); // Twitter\n\tif (rateLimitResetAlias !== null) {\n\t\treturn {value: rateLimitResetAlias, allowTimestamp: true};\n\t}\n\n\treturn undefined;\n};\n\nconst createTimestamp = ({year, month, day, hours, minutes, seconds}: RetryTimingDateParts): number | undefined => {\n\tconst monthIndex = months.indexOf(month);\n\tconst dayNumber = Number(day);\n\tconst hoursNumber = Number(hours);\n\tconst minutesNumber = Number(minutes);\n\tconst secondsNumber = Number(seconds);\n\tif (\n\t\tmonthIndex === -1\n\t\t|| hoursNumber > 23\n\t\t|| minutesNumber > 59\n\t\t|| secondsNumber > 60\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst normalizedSeconds = Math.min(secondsNumber, 59);\n\tconst date = new Date(Date.UTC(year, monthIndex, dayNumber, hoursNumber, minutesNumber, normalizedSeconds));\n\tdate.setUTCFullYear(year);\n\tconst timestamp = date.getTime();\n\n\t// Date.UTC normalizes overflow, so round-trip the parts to reject invalid dates. A leap second is represented by parsing 60 as 59 and adding one second.\n\tif (\n\t\tdate.getUTCFullYear() !== year\n\t\t|| date.getUTCMonth() !== monthIndex\n\t\t|| date.getUTCDate() !== dayNumber\n\t\t|| date.getUTCHours() !== hoursNumber\n\t\t|| date.getUTCMinutes() !== minutesNumber\n\t\t|| date.getUTCSeconds() !== normalizedSeconds\n\t) {\n\t\treturn undefined;\n\t}\n\n\treturn secondsNumber === 60 ? timestamp + 1000 : timestamp;\n};\n\nconst getCapture = (match: RegExpExecArray, index: number): string => match[index]!;\n\nconst parseDate = (value: string): number | undefined => {\n\tconst imfDate = imfDatePattern.exec(value);\n\tif (imfDate) {\n\t\treturn createTimestamp({\n\t\t\tyear: Number(getCapture(imfDate, 3)),\n\t\t\tmonth: getCapture(imfDate, 2),\n\t\t\tday: getCapture(imfDate, 1),\n\t\t\thours: getCapture(imfDate, 4),\n\t\t\tminutes: getCapture(imfDate, 5),\n\t\t\tseconds: getCapture(imfDate, 6),\n\t\t});\n\t}\n\n\tconst rfc850Date = rfc850DatePattern.exec(value);\n\tif (rfc850Date) {\n\t\tconst now = new Date();\n\t\tconst twoDigitYear = Number(getCapture(rfc850Date, 3));\n\t\tconst currentCenturyYear = (Math.floor(now.getUTCFullYear() / 100) * 100) + twoDigitYear;\n\t\tconst fiftyYearsFromNow = Date.UTC(now.getUTCFullYear() + 50, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());\n\t\tlet timestamp: number | undefined;\n\n\t\t// RFC 9110 maps two-digit years to the latest matching century that is not more than 50 years in the future.\n\t\tfor (const year of [\n\t\t\tcurrentCenturyYear - 100,\n\t\t\tcurrentCenturyYear,\n\t\t\tcurrentCenturyYear + 100,\n\t\t]) {\n\t\t\tconst candidateTimestamp = createTimestamp({\n\t\t\t\tyear,\n\t\t\t\tmonth: getCapture(rfc850Date, 2),\n\t\t\t\tday: getCapture(rfc850Date, 1),\n\t\t\t\thours: getCapture(rfc850Date, 4),\n\t\t\t\tminutes: getCapture(rfc850Date, 5),\n\t\t\t\tseconds: getCapture(rfc850Date, 6),\n\t\t\t});\n\t\t\tif (\n\t\t\t\tcandidateTimestamp !== undefined\n\t\t\t\t&& candidateTimestamp <= fiftyYearsFromNow\n\t\t\t) {\n\t\t\t\ttimestamp = candidateTimestamp;\n\t\t\t}\n\t\t}\n\n\t\treturn timestamp;\n\t}\n\n\tconst asctimeDate = asctimeDatePattern.exec(value);\n\tif (asctimeDate) {\n\t\tconst time = getCapture(asctimeDate, 4);\n\t\tconst [hours, minutes, seconds] = time.split(':') as [string, string, string];\n\t\treturn createTimestamp({\n\t\t\tyear: Number(getCapture(asctimeDate, 5)),\n\t\t\tmonth: getCapture(asctimeDate, 2),\n\t\t\tday: getCapture(asctimeDate, 3).trim(),\n\t\t\thours,\n\t\t\tminutes,\n\t\t\tseconds,\n\t\t});\n\t}\n\n\treturn undefined;\n};\n\nexport const calculateRetryTimingDelay = ({value, allowTimestamp}: RetryTimingHeader): number | undefined => {\n\tif (delayPattern.test(value)) {\n\t\tlet delay = Number(value) * 1000;\n\n\t\t// Standard Retry-After numbers are delay seconds. Timestamp compatibility only applies to reset headers.\n\t\tif (\n\t\t\tallowTimestamp\n\t\t\t&& delay >= timestampThreshold\n\t\t) {\n\t\t\tdelay -= Date.now();\n\t\t}\n\n\t\treturn Math.max(0, delay);\n\t}\n\n\tconst timestamp = parseDate(value);\n\tif (timestamp === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst delay = timestamp - Date.now();\n\treturn Number.isFinite(delay) ? Math.max(0, delay) : undefined;\n};\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {NetworkError} from '../errors/NetworkError.js';\nimport {NonError} from '../errors/NonError.js';\nimport {ForceRetryError} from '../errors/ForceRetryError.js';\nimport {SchemaValidationError} from '../errors/SchemaValidationError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {\n\tInput,\n\tInternalOptions,\n\tNormalizedOptions,\n\tOptions,\n\tSearchParamsInit,\n\tSearchParamsOption,\n} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport type {StandardSchemaV1} from '../types/standard-schema.js';\nimport {streamRequest, streamResponse} from '../utils/body.js';\nimport {\n\tcloneShallow,\n\tmergeHeaders,\n\tmergeHooks,\n\tdeletedParametersSymbol,\n} from '../utils/merge.js';\nimport type {RetryOptions} from '../types/retry.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions, hasSearchParameters} from '../utils/options.js';\nimport isRawNetworkError from '../utils/is-network-error.js';\nimport {isHTTPError, isNetworkError, isTimeoutError} from '../utils/type-guards.js';\nimport {\n\tcalculateRetryTimingDelay,\n\tgetRetryTimingHeader,\n} from './retry-timing.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tRetryMarker,\n\tsupportsAbortController,\n\tsupportsAbortSignal,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nconst maxErrorResponseBodySize = 10 * 1024 * 1024;\nconst prefixUrlRenamedErrorMessage = 'The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl';\nconst timedOutResponseData = Symbol('timedOutResponseData');\nconst timedOutOperation = Symbol('timedOutOperation');\n\ntype ErrorDataTimeout = {\n\tmilliseconds: number;\n\tfromTotalTimeout: boolean;\n};\n\nconst createTextDecoder = (contentType: string): TextDecoder => {\n\tconst match = /;\\s*charset\\s*=\\s*(?:\"([^\"]+)\"|([^;,\\s]+))/i.exec(contentType);\n\tconst charset = match?.[1] ?? match?.[2];\n\tif (charset) {\n\t\ttry {\n\t\t\treturn new TextDecoder(charset);\n\t\t} catch {}\n\t}\n\n\treturn new TextDecoder();\n};\n\nconst invalidSchemaMessage = 'The `schema` argument must follow the Standard Schema specification';\n\nconst cloneRetryOptions = (retry: RetryOptions | number): RetryOptions | number => {\n\tif (retry === null || typeof retry !== 'object' || Array.isArray(retry)) {\n\t\treturn retry as RetryOptions | number;\n\t}\n\n\tconst clonedRetry = {...retry};\n\n\t// Clone nested arrays too so init hooks can mutate retry config without leaking state across requests.\n\tif (Array.isArray(clonedRetry.methods)) {\n\t\tclonedRetry.methods = [...clonedRetry.methods];\n\t}\n\n\tif (Array.isArray(clonedRetry.statusCodes)) {\n\t\tclonedRetry.statusCodes = [...clonedRetry.statusCodes];\n\t}\n\n\tif (Array.isArray(clonedRetry.afterStatusCodes)) {\n\t\tclonedRetry.afterStatusCodes = [...clonedRetry.afterStatusCodes];\n\t}\n\n\treturn clonedRetry;\n};\n\nconst objectToString = Object.prototype.toString;\nconst leadingC0ControlOrSpacePattern = /^[\\0-\\u0020]+/g;\nconst asciiTabOrNewLinePattern = /[\\t\\n\\r]/g;\nconst schemePattern = /^[a-z][\\d+.a-z-]*:/i;\nconst malformedHttpProtocolPattern = /^https?:(?!\\/\\/)/i;\n\nconst isRequestInstance = (value: unknown): value is Request =>\n\tvalue instanceof globalThis.Request || objectToString.call(value) === '[object Request]';\n\n// Accepted custom responses are treated as full Responses throughout Ky.\n// If a custom fetch returns one, it must behave like a Response for cloning,\n// body consumption, `json()` decoration, and any enabled stream features.\nconst isResponseInstance = (value: unknown): value is Response =>\n\tvalue instanceof globalThis.Response || objectToString.call(value) === '[object Response]';\n\nconst isAbsoluteInput = (input: string): boolean =>\n\tschemePattern.test(input);\n\nconst normalizeInputForProtocolCheck = (input: string): string =>\n\tinput.replaceAll(leadingC0ControlOrSpacePattern, '').replaceAll(asciiTabOrNewLinePattern, '');\n\nconst cloneSearchParametersForInitHook = (searchParameters: SearchParamsOption | undefined): SearchParamsOption | undefined => {\n\tif (Array.isArray(searchParameters)) {\n\t\treturn searchParameters.map(parameter => [...parameter]) as SearchParamsOption;\n\t}\n\n\treturn cloneShallow(searchParameters) as SearchParamsOption | undefined;\n};\n\n// Shallow-clone mutable option properties so init hook mutations don't leak across requests.\nfunction cloneInitHookOptions(options: Options): Options {\n\tconst clonedOptions: Options = {\n\t\t...options,\n\t\tjson: cloneShallow(options.json),\n\t\tcontext: cloneShallow(options.context)!,\n\t\theaders: cloneShallow(options.headers)!,\n\t\tsearchParams: cloneSearchParametersForInitHook(options.searchParams),\n\t};\n\n\tif (options.retry !== undefined) {\n\t\tclonedOptions.retry = cloneRetryOptions(options.retry);\n\t}\n\n\treturn clonedOptions;\n}\n\nconst validateJsonWithSchema = async (jsonValue: unknown, schema: StandardSchemaV1): Promise<unknown> => {\n\tif (\n\t\t(\n\t\t\ttypeof schema !== 'object'\n\t\t\t&& typeof schema !== 'function'\n\t\t)\n\t\t|| schema === null\n\t) {\n\t\tthrow new TypeError(invalidSchemaMessage);\n\t}\n\n\tconst standardSchema = schema['~standard'];\n\n\tif (\n\t\ttypeof standardSchema !== 'object'\n\t\t|| standardSchema === null\n\t\t|| typeof standardSchema.validate !== 'function'\n\t) {\n\t\tthrow new TypeError(invalidSchemaMessage);\n\t}\n\n\tconst validationResult = await standardSchema.validate(jsonValue);\n\n\tif (validationResult.issues) {\n\t\tthrow new SchemaValidationError(validationResult.issues);\n\t}\n\n\treturn validationResult.value;\n};\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst initHooks = options.hooks?.init ?? [];\n\t\tconst initHookOptions = initHooks.length > 0 ? cloneInitHookOptions(options) : options;\n\n\t\tfor (const hook of initHooks) {\n\t\t\thook(initHookOptions);\n\t\t}\n\n\t\tconst ky = new Ky(input, initHookOptions);\n\n\t\tconst function_ = async (): Promise<Response | void> => {\n\t\t\tif (typeof ky.#options.timeout === 'number' && ky.#options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\tif (typeof ky.#options.totalTimeout === 'number' && ky.#options.totalTimeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`totalTimeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tconst beforeRequestResponse = await ky.#runBeforeRequestHooks();\n\t\t\tif (beforeRequestResponse !== undefined) {\n\t\t\t\tky.#retryLimit = normalizeRetryOptions(ky.#options.retry).limit;\n\t\t\t}\n\n\t\t\tlet response = beforeRequestResponse ?? await ky.#retry(async () => ky.#fetch());\n\t\t\tlet responseFromHook = beforeRequestResponse !== undefined\n\t\t\t\t|| ky.#consumeReturnedResponseFromBeforeRetryHook();\n\n\t\t\tfor (;;) {\n\t\t\t\t// `undefined` means a hook stopped the flow without providing a response.\n\t\t\t\t// Non-native Responses still continue through Ky if they pass `isResponseInstance()`.\n\t\t\t\tif (response === undefined) {\n\t\t\t\t\treturn response;\n\t\t\t\t}\n\n\t\t\t\tif (isResponseInstance(response)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\t\tresponse = await ky.#runAfterResponseHooks(response);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!(error instanceof ForceRetryError)) {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\t\tconst retriedResponse: Response | void = await ky.#retryFromError(error, async () => ky.#fetch());\n\t\t\t\t\t\tif (retriedResponse === undefined) {\n\t\t\t\t\t\t\treturn retriedResponse;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresponse = retriedResponse;\n\t\t\t\t\t\tresponseFromHook = ky.#consumeReturnedResponseFromBeforeRetryHook();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst currentResponse: Response = response;\n\n\t\t\t\t// Opaque responses (`response.type === 'opaque'`) from `no-cors` requests always have `status: 0` and `ok: false`, but this is not a failure - the actual status is hidden by the browser.\n\t\t\t\tif (!currentResponse.ok && currentResponse.type !== 'opaque' && (\n\t\t\t\t\ttypeof ky.#options.throwHttpErrors === 'function'\n\t\t\t\t\t\t? ky.#options.throwHttpErrors(currentResponse.status)\n\t\t\t\t\t\t: ky.#options.throwHttpErrors\n\t\t\t\t)) {\n\t\t\t\t\t// `request` must reflect the request that actually failed, but `options` stays as Ky's\n\t\t\t\t\t// normalized options snapshot. Replacement `Request` instances do not preserve the\n\t\t\t\t\t// original `BodyInit`, so trying to make `options` mirror arbitrary requests would be lossy.\n\t\t\t\t\tconst httpError: HTTPError = new HTTPError(currentResponse, ky.#getResponseRequest(currentResponse), ky.#getNormalizedOptions());\n\t\t\t\t\tconst errorToThrow: Error = httpError;\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\thttpError.data = await ky.#getResponseData(currentResponse);\n\n\t\t\t\t\tif (responseFromHook) {\n\t\t\t\t\t\tthrow errorToThrow;\n\t\t\t\t\t}\n\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst retriedResponse: Response | void = await ky.#retryFromError(httpError, async () => ky.#fetch());\n\t\t\t\t\tif (retriedResponse === undefined) {\n\t\t\t\t\t\treturn retriedResponse;\n\t\t\t\t\t}\n\n\t\t\t\t\tresponse = retriedResponse;\n\t\t\t\t\tresponseFromHook = ky.#consumeReturnedResponseFromBeforeRetryHook();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (!isResponseInstance(response)) {\n\t\t\t\treturn response;\n\t\t\t}\n\n\t\t\tky.#decorateResponse(response);\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\tif (ky.#options.onDownloadProgress) {\n\t\t\t\tif (typeof ky.#options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\tconst progressResponse = response.clone();\n\t\t\t\tky.#cancelResponseBody(response);\n\t\t\t\treturn streamResponse(progressResponse, ky.#options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst result = (async () => {\n\t\t\ttry {\n\t\t\t\treturn await function_();\n\t\t\t} catch (error: unknown) {\n\t\t\t\tawait ky.#throwProcessedError(error);\n\t\t\t} finally {\n\t\t\t\tconst originalRequest = ky.#originalRequest;\n\n\t\t\t\t// Ignore cancellation errors from already-locked or already-consumed streams.\n\t\t\t\tky.#cancelBody(originalRequest?.body ?? undefined);\n\t\t\t\t// Only cancel the current request body if it's distinct from the original (i.e. it was cloned for retries).\n\t\t\t\tif (ky.request !== originalRequest) {\n\t\t\t\t\tky.#cancelBody(ky.request.body ?? undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t})() as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\t// Only expose `.bytes()` when the environment implements it.\n\t\t\tif (\n\t\t\t\ttype === 'bytes'\n\t\t\t\t&& typeof (globalThis.Response?.prototype as unknown as {bytes?: unknown})?.bytes !== 'function'\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tresult[type] = async (schema?: StandardSchemaV1) => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst response = await result;\n\n\t\t\t\tif (type !== 'json') {\n\t\t\t\t\treturn ky.#raceBodyRead(async () => response[type](), response);\n\t\t\t\t}\n\n\t\t\t\tconst text = await ky.#raceBodyRead(async () => response.text(), response) as string;\n\t\t\t\tconst request = ky.#getResponseRequest(response);\n\t\t\t\tconst parsedResult = await ky.#raceWithTotalTimeout(async () => {\n\t\t\t\t\tconst jsonValue = initHookOptions.parseJson\n\t\t\t\t\t\t? await initHookOptions.parseJson(text, {request, response})\n\t\t\t\t\t\t: (text === '' && schema !== undefined\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: JSON.parse(text));\n\n\t\t\t\t\treturn schema === undefined ? jsonValue : validateJsonWithSchema(jsonValue, schema);\n\t\t\t\t});\n\n\t\t\t\tif (parsedResult === timedOutOperation) {\n\t\t\t\t\tawait ky.#throwProcessedError(new TimeoutError(request));\n\t\t\t\t}\n\n\t\t\t\treturn parsedResult;\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\tstatic #normalizeSearchParams(searchParams: SearchParamsOption): SearchParamsOption {\n\t\t// Filter out undefined values from plain objects\n\t\tif (searchParams && typeof searchParams === 'object' && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {\n\t\t\treturn Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined));\n\t\t}\n\n\t\treturn searchParams;\n\t}\n\n\tpublic request: Request;\n\t#abortController?: AbortController;\n\t#retryCount = 0;\n\t#retryLimit: number;\n\treadonly #input: Input;\n\treadonly #options: InternalOptions;\n\t#originalRequest?: Request;\n\treadonly #userProvidedAbortSignal?: AbortSignal;\n\treadonly #beforeRetryHookErrors = new WeakSet<Error>();\n\t#cachedNormalizedOptions: NormalizedOptions | undefined;\n\treadonly #startTime: number | undefined;\n\t#returnedResponseFromBeforeRetryHook = false;\n\treadonly #responseRequests = new WeakMap<Response, Request>();\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis.#input = input;\n\t\tif (Object.hasOwn(options, 'prefixUrl')) {\n\t\t\tthrow new Error(prefixUrlRenamedErrorMessage);\n\t\t}\n\n\t\tthis.#options = {\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this.#input as Request).headers, options.headers),\n\t\t\thooks: mergeHooks({}, options.hooks),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this.#input as Request).method ?? 'GET'),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefix: String(options.prefix || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors ?? true,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\ttotalTimeout: options.totalTimeout ?? false,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t\tcontext: options.context ?? {},\n\t\t};\n\t\tthis.#retryLimit = this.#options.retry.limit;\n\n\t\tif (typeof this.#input !== 'string' && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (typeof this.#input === 'string') {\n\t\t\tif (this.#options.prefix) {\n\t\t\t\tconst normalizedPrefix = this.#options.prefix.replace(/\\/+$/, '');\n\t\t\t\tconst normalizedInput = this.#input.replace(/^\\/+/, '');\n\t\t\t\tthis.#input = `${normalizedPrefix}/${normalizedInput}`;\n\t\t\t}\n\n\t\t\tif (this.#options.baseUrl) {\n\t\t\t\tconst normalizedInput = normalizeInputForProtocolCheck(this.#input);\n\n\t\t\t\tif (malformedHttpProtocolPattern.test(normalizedInput)) {\n\t\t\t\t\tthrow new TypeError('`input` url protocol must be followed by `//` when using `baseUrl`');\n\t\t\t\t}\n\n\t\t\t\tif (!isAbsoluteInput(normalizedInput)) {\n\t\t\t\t\tthis.#input = new URL(this.#input, (new Request(this.#options.baseUrl)).url);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (supportsAbortController && supportsAbortSignal) {\n\t\t\tthis.#userProvidedAbortSignal = this.#options.signal ?? (this.#input as Request).signal;\n\t\t\tthis.#abortController = new globalThis.AbortController();\n\t\t\tthis.#options.signal = this.#createManagedSignal();\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis.#options.duplex = 'half';\n\t\t}\n\n\t\tif (this.#options.json !== undefined) {\n\t\t\tthis.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);\n\t\t\tthis.#options.headers.set('content-type', this.#options.headers.get('content-type') ?? 'application/json');\n\t\t}\n\n\t\t// To provide correct form boundary, Content-Type header should be deleted when creating Request from another Request with FormData/URLSearchParams body\n\t\t// Only delete if user didn't explicitly provide a custom content-type\n\t\tconst userProvidedContentType = options.headers && new globalThis.Headers(options.headers as HeadersInit).has('content-type');\n\t\tif (\n\t\t\tthis.#input instanceof globalThis.Request\n\t\t\t&& ((supportsFormData && this.#options.body instanceof globalThis.FormData) || this.#options.body instanceof URLSearchParams)\n\t\t\t&& !userProvidedContentType\n\t\t) {\n\t\t\tthis.#options.headers.delete('content-type');\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this.#input, this.#options);\n\n\t\tif (hasSearchParameters(this.#options.searchParams)) {\n\t\t\tconst url = new URL(this.request.url);\n\t\t\tconst deleted = (this.#options.searchParams as any)?.[deletedParametersSymbol] as Set<string> | undefined;\n\n\t\t\tif (deleted) {\n\t\t\t\t// Remove keys from the input URL first so later searchParams entries can intentionally re-add them.\n\t\t\t\tfor (const key of deleted) {\n\t\t\t\t\turl.searchParams.delete(key);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof this.#options.searchParams === 'string') {\n\t\t\t\tconst stringSearchParameters = this.#options.searchParams.replace(/^\\?/, '');\n\t\t\t\tif (stringSearchParameters !== '') {\n\t\t\t\t\turl.search = url.search ? `${url.search}&${stringSearchParameters}` : `?${stringSearchParameters}`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst optionsSearchParameters = new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams) as unknown as SearchParamsInit);\n\n\t\t\t\tfor (const [key, value] of optionsSearchParameters.entries()) {\n\t\t\t\t\turl.searchParams.append(key, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tthis.#options.searchParams\n\t\t\t\t&& typeof this.#options.searchParams === 'object'\n\t\t\t\t&& !Array.isArray(this.#options.searchParams)\n\t\t\t\t&& !(this.#options.searchParams instanceof URLSearchParams)\n\t\t\t) {\n\t\t\t\tfor (const [key, value] of Object.entries(this.#options.searchParams)) {\n\t\t\t\t\tif (value === undefined) {\n\t\t\t\t\t\turl.searchParams.delete(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Recreate request with the updated URL. We already have all options in this.#options, including duplex.\n\t\t\tthis.request = new globalThis.Request(url, this.#options as RequestInit);\n\t\t}\n\n\t\tif (this.#options.onUploadProgress && typeof this.#options.onUploadProgress !== 'function') {\n\t\t\tthrow new TypeError('The `onUploadProgress` option must be a function');\n\t\t}\n\n\t\t// `totalTimeout` starts when the request pipeline is created, so it also includes\n\t\t// Ky's internal scheduling and user hook time before the first fetch attempt.\n\t\tthis.#startTime = typeof this.#options.totalTimeout === 'number' ? this.#getCurrentTime() : undefined;\n\t}\n\n\t#calculateDelay(retry: InternalOptions['retry']): number {\n\t\tconst retryDelay = retry.delay(this.#retryCount + 1);\n\n\t\tlet jitteredDelay = retryDelay;\n\t\tif (retry.jitter === true) {\n\t\t\tjitteredDelay = Math.random() * retryDelay;\n\t\t} else if (typeof retry.jitter === 'function') {\n\t\t\tjitteredDelay = retry.jitter(retryDelay);\n\n\t\t\tif (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {\n\t\t\t\tjitteredDelay = retryDelay;\n\t\t\t}\n\t\t}\n\n\t\treturn Math.min(retry.backoffLimit, jitteredDelay);\n\t}\n\n\tasync #calculateRetryDelay(error: unknown) {\n\t\tconst retry = normalizeRetryOptions(this.#options.retry);\n\t\tif (this.#retryCount >= Math.min(retry.limit, this.#retryLimit)) {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Wrap non-Error throws to ensure consistent error handling\n\t\tconst errorObject = error instanceof Error ? error : new NonError(error);\n\n\t\t// Handle forced retry from afterResponse hook - skip method check and shouldRetry\n\t\tif (errorObject instanceof ForceRetryError) {\n\t\t\treturn errorObject.customDelay ?? this.#calculateDelay(retry);\n\t\t}\n\n\t\t// Check if method is retriable for non-forced retries\n\t\tif (!retry.methods.includes(this.request.method.toLowerCase())) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tconst {shouldRetry} = retry;\n\t\tif (shouldRetry !== undefined) {\n\t\t\tconst result = await this.#raceWithTotalTimeout(async () => shouldRetry({error: errorObject, retryCount: this.#retryCount + 1}));\n\t\t\tif (result === timedOutOperation) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\t// Only exact booleans override the default retry checks.\n\t\t\tif (result === false) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (result === true) {\n\t\t\t\treturn this.#calculateDelay(retry);\n\t\t\t}\n\t\t}\n\n\t\t// Default timeout behavior\n\t\tif (isTimeoutError(error)) {\n\t\t\tif (!retry.retryOnTimeout) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn this.#calculateDelay(retry);\n\t\t}\n\n\t\tif (isHTTPError(error)) {\n\t\t\tif (!retry.statusCodes.includes(error.response.status)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tconst retryTimingHeader = getRetryTimingHeader(error.response.headers);\n\t\t\tif (retryTimingHeader && retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\tconst after = calculateRetryTimingDelay(retryTimingHeader);\n\t\t\t\tif (after === undefined) {\n\t\t\t\t\t// Malformed retry timing headers should not disable retries; they only lose their server-provided timing.\n\t\t\t\t\treturn this.#calculateDelay(retry);\n\t\t\t\t}\n\n\t\t\t\t// Don't apply jitter when server provides explicit retry timing\n\t\t\t\treturn Math.min(retry.maxRetryAfter, after);\n\t\t\t}\n\n\t\t\tif (error.response.status === 413) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn this.#calculateDelay(retry);\n\t\t}\n\n\t\t// Only retry known retriable error types. Unknown errors (e.g., programming bugs) are not retried.\n\t\tif (!isNetworkError(error)) {\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn this.#calculateDelay(retry);\n\t}\n\n\t#decorateResponse(response: Response): Response {\n\t\tconst request = this.#getResponseRequest(response);\n\n\t\tif (this.#options.parseJson) {\n\t\t\tresponse.json = async () => {\n\t\t\t\tconst text = await response.text();\n\t\t\t\treturn this.#options.parseJson!(text, {request, response});\n\t\t\t};\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tasync #throwProcessedError(error: unknown): Promise<never> {\n\t\t// Non-Error throws (e.g., thrown strings) pass through unchanged\n\t\tif (!(error instanceof Error)) {\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Errors thrown by beforeRetry hooks must propagate unchanged.\n\t\tif (this.#beforeRetryHookErrors.has(error)) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tlet processedError: Error = error;\n\t\tfor (const hook of this.#options.hooks.beforeError) {\n\t\t\t// `request` is the current failing request. `options` intentionally remains the\n\t\t\t// stable normalized Ky options snapshot for the same reason as `HTTPError` above.\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst hookResult: unknown = await hook({\n\t\t\t\trequest: this.request,\n\t\t\t\toptions: this.#getNormalizedOptions(),\n\t\t\t\terror: processedError,\n\t\t\t\tretryCount: this.#retryCount,\n\t\t\t});\n\n\t\t\t// Only overwrite if the hook returns a valid Error instance.\n\t\t\tif (hookResult instanceof Error) {\n\t\t\t\tprocessedError = hookResult;\n\t\t\t}\n\t\t}\n\n\t\tthrow processedError;\n\t}\n\n\tasync #getResponseData(response: Response): Promise<unknown> {\n\t\t// Even with request timeouts disabled, bound error-body reads so retries and error propagation\n\t\t// cannot be stalled indefinitely by never-ending response streams.\n\t\tconst readTimeout = this.#getErrorDataTimeout();\n\t\tconst text = await this.#readResponseText(response, readTimeout.milliseconds);\n\t\tif (text === timedOutResponseData) {\n\t\t\tif (readTimeout.fromTotalTimeout) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\tthis.#throwIfTotalTimeoutExhausted();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (!text) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (!this.#isJsonContentType(response.headers.get('content-type') ?? '')) {\n\t\t\treturn text;\n\t\t}\n\n\t\tconst parseTimeout = this.#getErrorDataTimeout();\n\t\tconst data = await this.#parseJson(text, response, parseTimeout.milliseconds, this.#getResponseRequest(response));\n\t\tif (data === timedOutResponseData) {\n\t\t\tif (parseTimeout.fromTotalTimeout) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\tthis.#throwIfTotalTimeoutExhausted();\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t#getErrorDataTimeout(): ErrorDataTimeout {\n\t\tconst errorDataTimeout = this.#options.timeout === false ? 10_000 : this.#options.timeout;\n\t\tconst remainingTotal = this.#getRemainingTotalTimeout();\n\t\tif (remainingTotal === undefined) {\n\t\t\treturn {\n\t\t\t\tmilliseconds: errorDataTimeout,\n\t\t\t\tfromTotalTimeout: false,\n\t\t\t};\n\t\t}\n\n\t\tif (remainingTotal <= 0) {\n\t\t\tthrow new TimeoutError(this.request);\n\t\t}\n\n\t\treturn {\n\t\t\tmilliseconds: Math.min(errorDataTimeout, remainingTotal),\n\t\t\tfromTotalTimeout: remainingTotal <= errorDataTimeout,\n\t\t};\n\t}\n\n\t#getBodyReadTimeout(): number | undefined {\n\t\tconst remainingTotal = this.#getRemainingTotalTimeout();\n\t\tif (remainingTotal !== undefined) {\n\t\t\tif (remainingTotal <= 0) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\treturn this.#options.timeout === false\n\t\t\t\t? remainingTotal\n\t\t\t\t: Math.min(this.#options.timeout, remainingTotal);\n\t\t}\n\n\t\treturn this.#options.timeout === false ? undefined : this.#options.timeout;\n\t}\n\n\t// Unlike error bodies (`#getResponseData`), a successful body read has no fallback value to return -\n\t// the caller's `.json()`/`.text()`/etc. promise must settle, so a timeout here always rejects.\n\tasync #raceBodyRead(createBodyPromise: () => Promise<unknown>, response: Response): Promise<unknown> {\n\t\tlet timeoutMs: number | undefined;\n\t\ttry {\n\t\t\ttimeoutMs = this.#getBodyReadTimeout();\n\t\t} catch (error: unknown) {\n\t\t\tawait this.#throwProcessedError(error);\n\t\t}\n\n\t\tconst bodyPromise = createBodyPromise();\n\t\tif (timeoutMs === undefined) {\n\t\t\treturn bodyPromise;\n\t\t}\n\n\t\tconst result = await Promise.race([\n\t\t\tbodyPromise,\n\t\t\tnew Promise<typeof timedOutResponseData>(resolve => {\n\t\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\t\tresolve(timedOutResponseData);\n\t\t\t\t}, timeoutMs);\n\t\t\t\tvoid bodyPromise.finally(() => {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t}).catch(() => undefined);\n\t\t\t}),\n\t\t]);\n\n\t\tif (result === timedOutResponseData) {\n\t\t\t// The stream is locked by the native body method's own reader by this point, so\n\t\t\t// `response.body.cancel()` would reject as \"already locked\". Aborting the request's\n\t\t\t// signal is what actually interrupts the underlying network read.\n\t\t\tthis.#abortController?.abort();\n\t\t\tawait this.#throwProcessedError(new TimeoutError(this.#getResponseRequest(response)));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tasync #raceWithTotalTimeout<T>(operation: () => Promise<T>): Promise<T | typeof timedOutOperation> {\n\t\tconst remainingTotal = this.#getRemainingTotalTimeout();\n\t\tif (remainingTotal === undefined) {\n\t\t\treturn operation();\n\t\t}\n\n\t\tif (remainingTotal <= 0) {\n\t\t\tthis.#abortController?.abort();\n\t\t\treturn timedOutOperation;\n\t\t}\n\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\tconst timeoutPromise = new Promise<typeof timedOutOperation>(resolve => {\n\t\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\t\tresolve(timedOutOperation);\n\t\t\t\t}, remainingTotal);\n\t\t\t});\n\t\t\tconst operationResult = Promise.resolve()\n\t\t\t\t.then(operation)\n\t\t\t\t.then(value => ({status: 'fulfilled', value} as const))\n\t\t\t\t.catch((error: unknown) => ({status: 'rejected', error} as const));\n\t\t\tconst result = await Promise.race([operationResult, timeoutPromise]);\n\t\t\tconst remainingAfterOperation = this.#getRemainingTotalTimeout();\n\t\t\tconst didTimeOut = result === timedOutOperation || (remainingAfterOperation !== undefined && remainingAfterOperation <= 0);\n\t\t\tif (didTimeOut) {\n\t\t\t\tthis.#abortController?.abort();\n\n\t\t\t\tif (result === timedOutOperation) {\n\t\t\t\t\tvoid operationResult.then(result => {\n\t\t\t\t\t\tif (result.status === 'fulfilled') {\n\t\t\t\t\t\t\tthis.#cancelReturnedBody(result.value);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else if (result.status === 'fulfilled') {\n\t\t\t\t\tthis.#cancelReturnedBody(result.value);\n\t\t\t\t}\n\n\t\t\t\treturn timedOutOperation;\n\t\t\t}\n\n\t\t\tif (result.status === 'rejected') {\n\t\t\t\tthrow result.error;\n\t\t\t}\n\n\t\t\treturn result.value;\n\t\t} finally {\n\t\t\tclearTimeout(timeoutId);\n\t\t}\n\t}\n\n\t#isJsonContentType(contentType: string): boolean {\n\t\t// Match JSON subtypes like `json`, `problem+json`, and `vnd.api+json`.\n\t\tconst mimeType = (contentType.split(';', 1)[0] ?? '').trim().toLowerCase();\n\t\treturn /\\/(?:.*[.+-])?json$/.test(mimeType);\n\t}\n\n\tasync #readResponseText(response: Response, timeoutMs: number): Promise<string | typeof timedOutResponseData | undefined> {\n\t\tconst {body} = response;\n\t\tif (!body) {\n\t\t\ttry {\n\t\t\t\treturn await response.text();\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tlet reader: ReadableStreamDefaultReader<Uint8Array>;\n\t\ttry {\n\t\t\treader = body.getReader();\n\t\t} catch {\n\t\t\t// Another consumer already locked the stream.\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst decoder = createTextDecoder(response.headers.get('content-type') ?? '');\n\t\tconst chunks: string[] = [];\n\t\tlet totalBytes = 0;\n\n\t\tconst readAll = (async (): Promise<string | undefined> => {\n\t\t\ttry {\n\t\t\t\tfor (;;) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\tif (done) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\ttotalBytes += value.byteLength;\n\t\t\t\t\tif (totalBytes > maxErrorResponseBodySize) {\n\t\t\t\t\t\tvoid reader.cancel().catch(() => undefined);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tchunks.push(decoder.decode(value, {stream: true}));\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tchunks.push(decoder.decode());\n\t\t\treturn chunks.join('');\n\t\t})();\n\n\t\tconst timeoutPromise = new Promise<typeof timedOutResponseData>(resolve => {\n\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\tresolve(timedOutResponseData);\n\t\t\t}, timeoutMs);\n\t\t\tvoid readAll.finally(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t\t});\n\n\t\tconst result = await Promise.race([readAll, timeoutPromise]);\n\t\tif (result === timedOutResponseData) {\n\t\t\tvoid reader.cancel().catch(() => undefined);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tasync #parseJson(text: string, response: Response, timeoutMs: number, request: Request): Promise<unknown> {\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\treturn await Promise.race([\n\t\t\t\tPromise.resolve().then(() => this.#options.parseJson\n\t\t\t\t\t? this.#options.parseJson(text, {request, response})\n\t\t\t\t\t: JSON.parse(text),\n\t\t\t\t),\n\t\t\t\tnew Promise<typeof timedOutResponseData>(resolve => {\n\t\t\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\t\t\tresolve(timedOutResponseData);\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}),\n\t\t\t]);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t} finally {\n\t\t\tclearTimeout(timeoutId);\n\t\t}\n\t}\n\n\t#cancelBody(body: ReadableStream | undefined): void {\n\t\tif (!body) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore cancellation failures from already-locked or already-consumed streams.\n\t\tvoid body.cancel().catch(() => undefined);\n\t}\n\n\t#cancelResponseBody(response: Response): void {\n\t\t// Ignore cancellation failures from already-locked or already-consumed streams.\n\t\tthis.#cancelBody(response.body ?? undefined);\n\t}\n\n\t#cancelReturnedBody(value: unknown): void {\n\t\tif (isResponseInstance(value)) {\n\t\t\tthis.#cancelResponseBody(value);\n\t\t} else if (isRequestInstance(value)) {\n\t\t\tthis.#cancelBody(value.body ?? undefined);\n\t\t}\n\t}\n\n\t#createManagedSignal(): AbortSignal {\n\t\treturn this.#userProvidedAbortSignal\n\t\t\t? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController!.signal])\n\t\t\t: this.#abortController!.signal;\n\t}\n\n\t#throwIfTotalTimeoutExhausted(): void {\n\t\tconst remaining = this.#getRemainingTotalTimeout();\n\t\tif (remaining !== undefined && remaining <= 0) {\n\t\t\tthrow new TimeoutError(this.request);\n\t\t}\n\t}\n\n\tasync #runBeforeRequestHooks(): Promise<Response | undefined> {\n\t\tfor (const hook of this.#options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await this.#raceWithTotalTimeout(async () => hook({\n\t\t\t\trequest: this.request,\n\t\t\t\toptions: this.#getNormalizedOptions(),\n\t\t\t\tretryCount: 0,\n\t\t\t}));\n\n\t\t\tif (result === timedOutOperation) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\tif (isRequestInstance(result)) {\n\t\t\t\tthis.#assignRequest(result);\n\t\t\t} else if (isResponseInstance(result)) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tasync #runAfterResponseHooks(response: Response): Promise<Response> {\n\t\tconst responseRequest = this.#getResponseRequest(response);\n\n\t\tfor (const hook of this.#options.hooks.afterResponse) {\n\t\t\tconst hookResponse = this.#setResponseRequest(response.clone(), responseRequest);\n\t\t\tthis.#decorateResponse(hookResponse);\n\n\t\t\tlet modifiedResponse;\n\t\t\ttry {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tmodifiedResponse = await this.#raceWithTotalTimeout(async () => hook({\n\t\t\t\t\trequest: this.request,\n\t\t\t\t\toptions: this.#getNormalizedOptions(),\n\t\t\t\t\tresponse: hookResponse,\n\t\t\t\t\tretryCount: this.#retryCount,\n\t\t\t\t}));\n\n\t\t\t\tif (modifiedResponse === timedOutOperation) {\n\t\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Cancel both responses to prevent memory leaks when hook throws\n\t\t\t\tif (hookResponse !== response) {\n\t\t\t\t\tthis.#cancelResponseBody(hookResponse);\n\t\t\t\t}\n\n\t\t\t\tthis.#cancelResponseBody(response);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (modifiedResponse instanceof RetryMarker) {\n\t\t\t\t// Cancel both the cloned response passed to the hook and the current response to prevent resource leaks (especially important in Deno/Bun).\n\t\t\t\t// Do not await cancellation since hooks can clone the response, leaving extra tee branches that keep cancel promises pending per the Streams spec.\n\t\t\t\tif (hookResponse !== response) {\n\t\t\t\t\tthis.#cancelResponseBody(hookResponse);\n\t\t\t\t}\n\n\t\t\t\tthis.#cancelResponseBody(response);\n\t\t\t\tthrow new ForceRetryError(modifiedResponse.options);\n\t\t\t}\n\n\t\t\tconst nextResponse = isResponseInstance(modifiedResponse)\n\t\t\t\t? this.#setResponseRequest(modifiedResponse, responseRequest)\n\t\t\t\t: response;\n\n\t\t\t// Cancel any response bodies we won't use to prevent memory leaks.\n\t\t\t// Uses fire-and-forget since hooks may have cloned the response, creating tee branches that block cancellation.\n\t\t\t// If the hook wrapped an existing body into a new Response, both Response objects can still point at the same stream.\n\t\t\tif (hookResponse !== response && hookResponse !== nextResponse && hookResponse.body !== nextResponse.body) {\n\t\t\t\tthis.#cancelResponseBody(hookResponse);\n\t\t\t}\n\n\t\t\tif (response !== nextResponse && response.body !== nextResponse.body) {\n\t\t\t\tthis.#cancelResponseBody(response);\n\t\t\t}\n\n\t\t\tresponse = nextResponse;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tasync #retry<T extends (...arguments_: any) => Promise<any>>(function_: T): Promise<ReturnType<T> | Response | void> {\n\t\ttry {\n\t\t\treturn await function_();\n\t\t} catch (error) {\n\t\t\treturn this.#retryFromError(error, function_);\n\t\t}\n\t}\n\n\tasync #retryFromError<T extends (...arguments_: any) => Promise<any>>(error: unknown, function_: T): Promise<ReturnType<T> | Response | void> {\n\t\tthis.#returnedResponseFromBeforeRetryHook = false;\n\n\t\tconst retryDelay = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);\n\t\tconst delayOptions = {signal: this.#userProvidedAbortSignal};\n\n\t\tconst remainingTimeout = this.#getRemainingTotalTimeout();\n\t\tif (remainingTimeout !== undefined) {\n\t\t\tif (remainingTimeout <= 0) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\t// If waiting would consume all remaining budget, time out without starting another request.\n\t\t\tif (retryDelay >= remainingTimeout) {\n\t\t\t\tawait delay(remainingTimeout, delayOptions);\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\t\t}\n\n\t\t// Only use user-provided signal for delay, not our internal abortController\n\t\tawait delay(retryDelay, delayOptions);\n\n\t\tthis.#throwIfTotalTimeoutExhausted();\n\n\t\t// Apply custom request from forced retry before beforeRetry hooks\n\t\t// Ensure the custom request has the correct managed signal for timeouts and user aborts\n\t\tif (error instanceof ForceRetryError && error.customRequest) {\n\t\t\tconst customRequest = new globalThis.Request(error.customRequest, this.#options.signal ? {signal: this.#options.signal} : undefined);\n\t\t\t// Replacement Requests are authoritative by design. Do not rewrite headers here,\n\t\t\t// even for cross-origin retries. Callers using `ky.retry({request})` explicitly\n\t\t\t// opted into the exact Request they constructed.\n\t\t\tthis.#assignRequest(customRequest);\n\t\t}\n\n\t\tfor (const hook of this.#options.hooks.beforeRetry) {\n\t\t\tlet hookResult: Awaited<ReturnType<typeof hook>> | typeof timedOutOperation;\n\t\t\ttry {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\thookResult = await this.#raceWithTotalTimeout(async () => hook({\n\t\t\t\t\trequest: this.request,\n\t\t\t\t\toptions: this.#getNormalizedOptions(),\n\t\t\t\t\terror: error as Error,\n\t\t\t\t\tretryCount: this.#retryCount + 1,\n\t\t\t\t}));\n\t\t\t} catch (hookError) {\n\t\t\t\t// Preserve the original request error path (`throw error`) so beforeError hooks can still run.\n\t\t\t\tif (hookError instanceof Error && hookError !== error) {\n\t\t\t\t\tthis.#beforeRetryHookErrors.add(hookError);\n\t\t\t\t}\n\n\t\t\t\tthrow hookError;\n\t\t\t}\n\n\t\t\tif (hookResult === timedOutOperation) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\tif (isRequestInstance(hookResult)) {\n\t\t\t\t// Same contract as `ky.retry({request})`: a Request returned from `beforeRetry`\n\t\t\t\t// is used as-is rather than being sanitized or otherwise rewritten by Ky.\n\t\t\t\tthis.#assignRequest(hookResult);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (isResponseInstance(hookResult)) {\n\t\t\t\tthis.#returnedResponseFromBeforeRetryHook = true;\n\t\t\t\tthis.#retryCount++;\n\t\t\t\treturn hookResult;\n\t\t\t}\n\n\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\tif (hookResult === stop) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthis.#throwIfTotalTimeoutExhausted();\n\n\t\tthis.#retryCount++;\n\t\treturn this.#retry(function_);\n\t}\n\n\t#consumeReturnedResponseFromBeforeRetryHook(): boolean {\n\t\tconst value = this.#returnedResponseFromBeforeRetryHook;\n\t\tthis.#returnedResponseFromBeforeRetryHook = false;\n\t\treturn value;\n\t}\n\n\tasync #fetch(): Promise<Response> {\n\t\t// Reset abortController if it was aborted (happens on timeout retry)\n\t\tif (this.#abortController?.signal.aborted) {\n\t\t\tthis.#abortController = new globalThis.AbortController();\n\t\t\tthis.#options.signal = this.#createManagedSignal();\n\t\t\t// Recreate request with new signal\n\t\t\tthis.request = new globalThis.Request(this.request, {signal: this.#options.signal});\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.#options);\n\t\tthis.#retryLimit = normalizeRetryOptions(this.#options.retry).limit;\n\t\tconst retryRequest = this.#retryLimit > 0 ? this.request.clone() : undefined;\n\t\tconst request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);\n\n\t\t// Cloning is done here to prepare in advance for retries.\n\t\t// Skip cloning when retries are disabled - cloning a streaming body calls ReadableStream#tee()\n\t\t// which buffers the entire stream in memory, causing excessive memory usage for large uploads.\n\t\tthis.#originalRequest = request;\n\t\tif (retryRequest) {\n\t\t\tthis.request = retryRequest;\n\t\t}\n\n\t\ttry {\n\t\t\tconst remainingTotal = this.#getRemainingTotalTimeout();\n\t\t\tif (remainingTotal !== undefined && remainingTotal <= 0) {\n\t\t\t\tthrow new TimeoutError(this.request);\n\t\t\t}\n\n\t\t\tconst effectiveTimeout: number | undefined = this.#options.timeout === false\n\t\t\t\t? remainingTotal\n\t\t\t\t: (remainingTotal === undefined\n\t\t\t\t\t? this.#options.timeout\n\t\t\t\t\t: Math.min(this.#options.timeout, remainingTotal));\n\n\t\t\tconst response = effectiveTimeout === undefined\n\t\t\t\t? await this.#options.fetch(request, nonRequestOptions)\n\t\t\t\t: await timeout(request, nonRequestOptions, this.#abortController, {\n\t\t\t\t\ttimeout: effectiveTimeout,\n\t\t\t\t\tfetch: this.#options.fetch,\n\t\t\t\t});\n\n\t\t\treturn this.#setResponseRequest(response, request);\n\t\t} catch (error) {\n\t\t\tif (isRawNetworkError(error)) {\n\t\t\t\tthrow new NetworkError(this.request, {cause: error as Error});\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t#getRemainingTotalTimeout(): number | undefined {\n\t\tif (this.#startTime === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst elapsed = this.#getCurrentTime() - this.#startTime;\n\t\treturn Math.max(0, (this.#options.totalTimeout as number) - elapsed);\n\t}\n\n\t#getCurrentTime(): number {\n\t\treturn globalThis.performance?.now() ?? Date.now();\n\t}\n\n\t#getNormalizedOptions(): NormalizedOptions {\n\t\tif (!this.#cachedNormalizedOptions) {\n\t\t\t// Exclude Ky-specific options that are not part of `RequestInit`.\n\t\t\tconst {\n\t\t\t\thooks,\n\t\t\t\tjson,\n\t\t\t\tparseJson,\n\t\t\t\tstringifyJson,\n\t\t\t\tsearchParams,\n\t\t\t\ttimeout,\n\t\t\t\ttotalTimeout,\n\t\t\t\tthrowHttpErrors,\n\t\t\t\tfetch,\n\t\t\t\t...normalizedOptions\n\t\t\t} = this.#options;\n\n\t\t\tthis.#cachedNormalizedOptions = Object.freeze(normalizedOptions) as NormalizedOptions;\n\t\t}\n\n\t\treturn this.#cachedNormalizedOptions;\n\t}\n\n\t#assignRequest(request: Request): void {\n\t\tthis.#cachedNormalizedOptions = undefined;\n\t\tthis.request = request;\n\t}\n\n\t#getResponseRequest(response: Response): Request {\n\t\treturn this.#responseRequests.get(response) ?? this.request;\n\t}\n\n\t#setResponseRequest(response: Response, request: Request): Response {\n\t\tthis.#responseRequests.set(response, request);\n\t\treturn response;\n\t}\n\n\t#wrapRequestWithUploadProgress(request: Request, originalBody?: BodyInit): Request {\n\t\tif (!this.#options.onUploadProgress || !request.body || !supportsRequestStreams) {\n\t\t\treturn request;\n\t\t}\n\n\t\treturn streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);\n\t}\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop, retry} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options> | ((parentDefaults: Partial<Options>) => Partial<Options>)) => {\n\t\tif (typeof newDefaults === 'function') {\n\t\t\tnewDefaults = newDefaults(defaults ?? {});\n\t\t}\n\n\t\treturn createInstance(validateAndMerge(defaults, newDefaults));\n\t};\n\n\tky.stop = stop;\n\tky.retry = retry;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tInput,\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tShouldRetryState,\n\tSearchParamsOption,\n\tProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tInitHook,\n\tBeforeRequestHook,\n\tBeforeRequestState,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tBeforeErrorState,\n\tAfterResponseHook,\n\tAfterResponseState,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {\n\tStandardSchemaV1,\n\tStandardSchemaV1InferOutput,\n\tStandardSchemaV1Issue,\n} from './types/standard-schema.js';\nexport type {KyRequest} from './types/request.js';\nexport type {KyResponse} from './types/response.js';\nexport {KyError} from './errors/KyError.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {SchemaValidationError} from './errors/SchemaValidationError.js';\nexport {NetworkError} from './errors/NetworkError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\nexport {ForceRetryError} from './errors/ForceRetryError.js';\nexport {\n\tisKyError,\n\tisHTTPError,\n\tisNetworkError,\n\tisTimeoutError,\n\tisForceRetryError,\n} from './utils/type-guards.js';\nexport {replaceOption} from './utils/merge.js';\n\n// Intentionally not exporting this for now as it's just an implementation detail and we don't want to commit to a certain API yet at least.\n// export {NonError} from './errors/NonError.js';\n"]}