@d1g1tal/transportr 3.3.5 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,7 @@ import { MediaType } from "@d1g1tal/media-type";
7
7
  * @author D1g1talEntr0py <jason.dimeo@gmail.com>
8
8
  */
9
9
  declare class ResponseStatus {
10
- private readonly _code;
11
- private readonly _text;
10
+ #private;
12
11
  /**
13
12
  *
14
13
  * @param code The status code from the {@link Response}
@@ -122,11 +121,7 @@ type HttpErrorOptions = {
122
121
  * @author D1g1talEntr0py <jason.dimeo@gmail.com>
123
122
  */
124
123
  declare class HttpError extends Error {
125
- private readonly _entity;
126
- private readonly responseStatus;
127
- private readonly _url;
128
- private readonly _method;
129
- private readonly _timing;
124
+ #private;
130
125
  /**
131
126
  * Creates an instance of HttpError.
132
127
  * @param status The status code and status text of the {@link Response}.
@@ -655,7 +650,7 @@ type RequestOptions = Prettify<{
655
650
  unwrap?: boolean;
656
651
  /** When true, script tags in HTML fragment responses are preserved by DOMPurify instead of stripped. Defaults to false. Only applies to getHtmlFragment(). */
657
652
  allowScripts?: boolean;
658
- } & Omit<RequestInit, 'headers'> & MethodBody>;
653
+ } & Omit<RequestInit, 'headers' | 'body' | 'method'> & MethodBody>;
659
654
  /** Configuration for retry behavior on failed requests. */
660
655
  type RetryOptions = {
661
656
  /** Maximum number of retry attempts. Defaults to 0 (no retries). */
@@ -718,11 +713,19 @@ declare const endsWithSlashRegEx: RegExp;
718
713
  declare const XSRF_COOKIE_NAME = "XSRF-TOKEN";
719
714
  /** Default XSRF header name */
720
715
  declare const XSRF_HEADER_NAME = "X-XSRF-TOKEN";
721
- type MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN' | 'EVENT_STREAM' | 'NDJSON';
722
716
  declare const mediaTypes: {
723
- [key in MediaTypeKey]: MediaType;
717
+ readonly PNG: "image/png";
718
+ readonly TEXT: "text/plain";
719
+ readonly JSON: "application/json";
720
+ readonly HTML: "text/html";
721
+ readonly JAVA_SCRIPT: "text/javascript";
722
+ readonly CSS: "text/css";
723
+ readonly XML: "application/xml";
724
+ readonly BIN: "application/octet-stream";
725
+ readonly EVENT_STREAM: "text/event-stream";
726
+ readonly NDJSON: "application/x-ndjson";
724
727
  };
725
- declare const defaultMediaType: string;
728
+ declare const defaultMediaType: MediaType;
726
729
  declare const defaultOrigin: string;
727
730
  /** Constant object for caching policies */
728
731
  declare const RequestCachingPolicy: {
@@ -789,37 +792,7 @@ type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];
789
792
  * @author D1g1talEntr0py <jason.dimeo@gmail.com>
790
793
  */
791
794
  declare class Transportr {
792
- private readonly _baseUrl;
793
- private readonly _origin;
794
- /** Pre-normalized base pathname with any trailing slash stripped — reused per request to avoid repeated regex/replace work. */
795
- private readonly _basePath;
796
- private readonly _options;
797
- /** Pre-built Headers template for methods that strip Content-Type (GET/HEAD/OPTIONS/etc.). Cloned per request. Rebuilt by `configure()` when defaults change. */
798
- private _noBodyHeadersTemplate;
799
- private readonly subscribr;
800
- private readonly hooks;
801
- /** Aggregate count of hooks registered on this instance — zero phases are skipped without array allocation. */
802
- private readonly hookCount;
803
- /** Per-event subscription counts on this instance — used to skip publish() entirely when no listeners exist. */
804
- private readonly subCounts;
805
- private static globalSubscribr;
806
- private static globalHooks;
807
- /** Aggregate count of registered global hooks — zero means we skip the entire global-hook loop. */
808
- private static globalHookCount;
809
- /** Per-event subscription counts on the global subscribr — mirrors `subCounts` per instance. */
810
- private static globalSubCounts;
811
- private static signalControllers;
812
- /** Map of in-flight deduplicated requests keyed by URL + method */
813
- private static inflightRequests;
814
- /** Cached config for the common "no retry" case (retry === undefined) */
815
- private static readonly noRetryConfig;
816
- /** Memoized normalized retry options keyed by the user-provided RetryOptions object (reference identity). */
817
- private static readonly retryConfigCache;
818
- /** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */
819
- private static mediaTypeCache;
820
- /** Cache mapping raw response Content-Type header strings to their resolved ResponseHandler (or null when no handler matches). */
821
- private static readonly handlerResolutionCache;
822
- private static contentTypeHandlers;
795
+ #private;
823
796
  /**
824
797
  * Create a new Transportr instance with the provided location or origin and context path.
825
798
  *
@@ -865,8 +838,6 @@ declare class Transportr {
865
838
  };
866
839
  /** Request Event */
867
840
  static readonly RequestEvent: typeof RequestEvent;
868
- /** Default Request Options */
869
- private static readonly defaultRequestOptions;
870
841
  /**
871
842
  * Returns a {@link EventRegistration} used for subscribing to global events with typed data.
872
843
  *
@@ -1002,6 +973,8 @@ declare class Transportr {
1002
973
  get<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
1003
974
  unwrap: false;
1004
975
  }): Promise<Result<T | undefined>>;
976
+ /** Throws on failure and resolves to the response body (default behavior). */
977
+ get<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1005
978
  /** Returns a Result tuple instead of throwing. */
1006
979
  post<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & {
1007
980
  unwrap: false;
@@ -1010,6 +983,10 @@ declare class Transportr {
1010
983
  post<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & {
1011
984
  unwrap: false;
1012
985
  }): Promise<Result<T | undefined>>;
986
+ /** Throws on failure and resolves to the response body (default behavior). */
987
+ post<T extends ResponseBody = ResponseBody>(path: string | undefined, body?: RequestBody, options?: RequestOptions): Promise<T | undefined>;
988
+ /** Throws on failure and resolves to the response body (default behavior). */
989
+ post<T extends ResponseBody = ResponseBody>(body: RequestBody, options?: RequestOptions): Promise<T | undefined>;
1013
990
  /** Returns a Result tuple instead of throwing. */
1014
991
  put<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & {
1015
992
  unwrap: false;
@@ -1018,6 +995,10 @@ declare class Transportr {
1018
995
  put<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & {
1019
996
  unwrap: false;
1020
997
  }): Promise<Result<T | undefined>>;
998
+ /** Throws on failure and resolves to the response body (default behavior). */
999
+ put<T extends ResponseBody = ResponseBody>(path: string | undefined, body?: RequestBody, options?: RequestOptions): Promise<T | undefined>;
1000
+ /** Throws on failure and resolves to the response body (default behavior). */
1001
+ put<T extends ResponseBody = ResponseBody>(body: RequestBody, options?: RequestOptions): Promise<T | undefined>;
1021
1002
  /** Returns a Result tuple instead of throwing. */
1022
1003
  patch<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & {
1023
1004
  unwrap: false;
@@ -1026,6 +1007,10 @@ declare class Transportr {
1026
1007
  patch<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & {
1027
1008
  unwrap: false;
1028
1009
  }): Promise<Result<T | undefined>>;
1010
+ /** Throws on failure and resolves to the response body (default behavior). */
1011
+ patch<T extends ResponseBody = ResponseBody>(path: string | undefined, body?: RequestBody, options?: RequestOptions): Promise<T | undefined>;
1012
+ /** Throws on failure and resolves to the response body (default behavior). */
1013
+ patch<T extends ResponseBody = ResponseBody>(body: RequestBody, options?: RequestOptions): Promise<T | undefined>;
1029
1014
  /** Returns a Result tuple instead of throwing. */
1030
1015
  delete<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & {
1031
1016
  unwrap: false;
@@ -1034,6 +1019,8 @@ declare class Transportr {
1034
1019
  delete<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & {
1035
1020
  unwrap: false;
1036
1021
  }): Promise<Result<T | undefined>>;
1022
+ /** Throws on failure and resolves to the response body (default behavior). */
1023
+ delete<T extends ResponseBody = ResponseBody>(path?: string | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1037
1024
  /** Returns a Result tuple instead of throwing. */
1038
1025
  head<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & {
1039
1026
  unwrap: false;
@@ -1042,6 +1029,8 @@ declare class Transportr {
1042
1029
  head<T extends ResponseBody = ResponseBody>(path: RequestOptions & {
1043
1030
  unwrap: false;
1044
1031
  }): Promise<Result<T | undefined>>;
1032
+ /** Throws on failure and resolves to the response body (default behavior). */
1033
+ head<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined>;
1045
1034
  /** Returns a Result tuple instead of throwing. */
1046
1035
  options(path: string | undefined, options: RequestOptions & {
1047
1036
  unwrap: false;
@@ -1050,6 +1039,8 @@ declare class Transportr {
1050
1039
  options(path: RequestOptions & {
1051
1040
  unwrap: false;
1052
1041
  }): Promise<Result<string[] | undefined>>;
1042
+ /** Throws on failure and resolves to allowed methods (default behavior). */
1043
+ options(path?: string | RequestOptions, options?: RequestOptions): Promise<string[] | undefined>;
1053
1044
  /** Returns a Result tuple instead of throwing. */
1054
1045
  request<T = unknown>(path: string | undefined, options: RequestOptions & {
1055
1046
  unwrap: false;
@@ -1058,6 +1049,8 @@ declare class Transportr {
1058
1049
  request<T = unknown>(path: RequestOptions & {
1059
1050
  unwrap: false;
1060
1051
  }): Promise<Result<TypedResponse<T>>>;
1052
+ /** Throws on failure and resolves to the typed response (default behavior). */
1053
+ request<T = unknown>(path?: string | RequestOptions, options?: RequestOptions): Promise<TypedResponse<T>>;
1061
1054
  /** Returns a Result tuple instead of throwing. */
1062
1055
  getJson(path: string | undefined, options: RequestOptions & {
1063
1056
  unwrap: false;
@@ -1066,6 +1059,8 @@ declare class Transportr {
1066
1059
  getJson(path: RequestOptions & {
1067
1060
  unwrap: false;
1068
1061
  }): Promise<Result<Json | undefined>>;
1062
+ /** Throws on failure and resolves to JSON content (default behavior). */
1063
+ getJson(path?: string | RequestOptions, options?: RequestOptions): Promise<Json | undefined>;
1069
1064
  /** Returns a Result tuple instead of throwing. */
1070
1065
  getXml(path: string | undefined, options: RequestOptions & {
1071
1066
  unwrap: false;
@@ -1074,6 +1069,8 @@ declare class Transportr {
1074
1069
  getXml(path: RequestOptions & {
1075
1070
  unwrap: false;
1076
1071
  }): Promise<Result<Document | undefined>>;
1072
+ /** Throws on failure and resolves to XML content (default behavior). */
1073
+ getXml(path?: string | RequestOptions, options?: RequestOptions): Promise<Document | undefined>;
1077
1074
  /** Returns a Result tuple instead of throwing. */
1078
1075
  getHtml(path: string | undefined, options: RequestOptions & {
1079
1076
  unwrap: false;
@@ -1082,6 +1079,8 @@ declare class Transportr {
1082
1079
  getHtml(path: RequestOptions & {
1083
1080
  unwrap: false;
1084
1081
  }): Promise<Result<Document | Element | null | undefined>>;
1082
+ /** Throws on failure and resolves to parsed HTML (default behavior). */
1083
+ getHtml(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<Document | Element | null | undefined>;
1085
1084
  /** Returns a Result tuple instead of throwing. */
1086
1085
  getHtmlFragment(path: string | undefined, options: RequestOptions & {
1087
1086
  unwrap: false;
@@ -1090,6 +1089,8 @@ declare class Transportr {
1090
1089
  getHtmlFragment(path: RequestOptions & {
1091
1090
  unwrap: false;
1092
1091
  }): Promise<Result<DocumentFragment | Element | null | undefined>>;
1092
+ /** Throws on failure and resolves to parsed HTML fragment (default behavior). */
1093
+ getHtmlFragment(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<DocumentFragment | Element | null | undefined>;
1093
1094
  /** Returns a Result tuple instead of throwing. */
1094
1095
  getScript(path: string | undefined, options: RequestOptions & {
1095
1096
  unwrap: false;
@@ -1098,6 +1099,8 @@ declare class Transportr {
1098
1099
  getScript(path: RequestOptions & {
1099
1100
  unwrap: false;
1100
1101
  }): Promise<Result<void>>;
1102
+ /** Throws on failure and resolves when the script is loaded (default behavior). */
1103
+ getScript(path?: string | RequestOptions, options?: RequestOptions): Promise<void>;
1101
1104
  /** Returns a Result tuple instead of throwing. */
1102
1105
  getStylesheet(path: string | undefined, options: RequestOptions & {
1103
1106
  unwrap: false;
@@ -1106,6 +1109,8 @@ declare class Transportr {
1106
1109
  getStylesheet(path: RequestOptions & {
1107
1110
  unwrap: false;
1108
1111
  }): Promise<Result<void>>;
1112
+ /** Throws on failure and resolves when the stylesheet is loaded (default behavior). */
1113
+ getStylesheet(path?: string | RequestOptions, options?: RequestOptions): Promise<void>;
1109
1114
  /** Returns a Result tuple instead of throwing. */
1110
1115
  getBlob(path: string | undefined, options: RequestOptions & {
1111
1116
  unwrap: false;
@@ -1114,10 +1119,14 @@ declare class Transportr {
1114
1119
  getBlob(path: RequestOptions & {
1115
1120
  unwrap: false;
1116
1121
  }): Promise<Result<Blob | undefined>>;
1122
+ /** Throws on failure and resolves to Blob data (default behavior). */
1123
+ getBlob(path?: string | RequestOptions, options?: RequestOptions): Promise<Blob | undefined>;
1117
1124
  /** Returns a Result tuple instead of throwing. */
1118
1125
  getImage(path: string | undefined, options: RequestOptions & {
1119
1126
  unwrap: false;
1120
1127
  }): Promise<Result<HTMLImageElement | undefined>>;
1128
+ /** Throws on failure and resolves to an image element (default behavior). */
1129
+ getImage(path?: string | RequestOptions, options?: RequestOptions): Promise<HTMLImageElement | undefined>;
1121
1130
  /** Returns a Result tuple instead of throwing. */
1122
1131
  getBuffer(path: string | undefined, options: RequestOptions & {
1123
1132
  unwrap: false;
@@ -1126,6 +1135,8 @@ declare class Transportr {
1126
1135
  getBuffer(path: RequestOptions & {
1127
1136
  unwrap: false;
1128
1137
  }): Promise<Result<ArrayBuffer | undefined>>;
1138
+ /** Throws on failure and resolves to ArrayBuffer data (default behavior). */
1139
+ getBuffer(path?: string | RequestOptions, options?: RequestOptions): Promise<ArrayBuffer | undefined>;
1129
1140
  /** Returns a Result tuple instead of throwing. */
1130
1141
  getStream(path: string | undefined, options: RequestOptions & {
1131
1142
  unwrap: false;
@@ -1134,6 +1145,8 @@ declare class Transportr {
1134
1145
  getStream(path: RequestOptions & {
1135
1146
  unwrap: false;
1136
1147
  }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;
1148
+ /** Throws on failure and resolves to a readable stream (default behavior). */
1149
+ getStream(path?: string | RequestOptions, options?: RequestOptions): Promise<ReadableStream<Uint8Array> | null | undefined>;
1137
1150
  /** Returns a Result tuple instead of throwing. */
1138
1151
  getEventStream(path: string | undefined, options: RequestOptions & {
1139
1152
  unwrap: false;
@@ -1142,6 +1155,8 @@ declare class Transportr {
1142
1155
  getEventStream(path: RequestOptions & {
1143
1156
  unwrap: false;
1144
1157
  }): Promise<Result<AsyncIterable<ServerSentEvent>>>;
1158
+ /** Throws on failure and resolves to an SSE async iterable (default behavior). */
1159
+ getEventStream(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<ServerSentEvent>>;
1145
1160
  /** Returns a Result tuple instead of throwing. */
1146
1161
  getJsonStream<T = Json>(path: string | undefined, options: RequestOptions & {
1147
1162
  unwrap: false;
@@ -1150,209 +1165,8 @@ declare class Transportr {
1150
1165
  getJsonStream<T = Json>(path: RequestOptions & {
1151
1166
  unwrap: false;
1152
1167
  }): Promise<Result<AsyncIterable<T>>>;
1153
- /**
1154
- * Handles a GET request.
1155
- * @async
1156
- * @param path The path to the resource.
1157
- * @param userOptions The user options for the request.
1158
- * @param options The options for the request.
1159
- * @param responseHandler The response handler for the request.
1160
- * @returns A promise that resolves to the response body or void.
1161
- */
1162
- private _get;
1163
- /**
1164
- * It processes the request options and returns a new object with the processed options.
1165
- * Hot path: when no retry, no dedupe, and no upload/download progress tracking, this is essentially
1166
- * `fetch(url, options)` with two `Set` operations and one event publish bracket — all inner closures have been hoisted
1167
- * to private static helpers to avoid per-request allocations.
1168
- * @param path The path to the resource.
1169
- * @param config The processed request configuration produced by `processRequestOptions`.
1170
- * @returns A promise resolving to the typed response.
1171
- */
1172
- private _request;
1173
- /**
1174
- * Performs the underlying fetch with retry logic. Hoisted out of `_request` so the function body
1175
- * does not allocate a closure per request.
1176
- * @param url The fully-resolved request URL.
1177
- * @param requestOptions The processed request options.
1178
- * @param path The original request path (used in error/retry events).
1179
- * @param method The HTTP method.
1180
- * @param canRetry Whether the request is eligible for retry.
1181
- * @param retryConfig Normalized retry configuration.
1182
- * @param originalBody The original (pre-upload-wrap) body, needed to rebuild the upload stream on retry.
1183
- * @param onUploadProgress Optional upload progress callback.
1184
- * @param startTime The performance.now() timestamp captured at request start (for timing reporting).
1185
- * @param global Whether this request publishes to global event subscribers.
1186
- * @returns The typed response.
1187
- */
1188
- private _doFetch;
1189
- /**
1190
- * Wraps the request body with a progress-tracking TransformStream.
1191
- * Re-creates the stream from the original body on each call so retries get a fresh stream.
1192
- * @param requestOptions Mutable request options whose `body` will be replaced with the wrapped stream.
1193
- * @param originalBody The original body before any wrapping.
1194
- * @param onUploadProgress The progress callback (already validated as defined by the caller).
1195
- */
1196
- private static _wrapUploadBody;
1197
- /**
1198
- * Wraps the response body with a progress-tracking TransformStream when onDownloadProgress is set.
1199
- * @param response The response to potentially wrap.
1200
- * @param requestOptions The request options carrying the optional onDownloadProgress callback.
1201
- * @returns The original response or a new response with progress tracking.
1202
- */
1203
- private static _wrapDownloadProgress;
1204
- /**
1205
- * Captures a RequestTiming snapshot from a start timestamp to now.
1206
- * @param startTime The start timestamp from `performance.now()`.
1207
- * @returns Timing information for the request.
1208
- */
1209
- private static _snapshotTiming;
1210
- /**
1211
- * Normalizes a retry option into a full RetryOptions object.
1212
- * @param retry The retry option from request options.
1213
- * @returns Normalized retry configuration.
1214
- */
1215
- private static normalizeRetryOptions;
1216
- /**
1217
- * Waits for the appropriate delay before a retry attempt.
1218
- * @param config The retry configuration.
1219
- * @param attempt The current attempt number (1-based).
1220
- * @returns A promise that resolves after the delay.
1221
- */
1222
- private static retryDelay;
1223
- /**
1224
- * Shared implementation for body-accepting HTTP methods (POST, PUT, PATCH, DELETE).
1225
- * @param method The HTTP method to use.
1226
- * @param path The request path, or the request body when called without a path.
1227
- * @param body The request body, or options when called without a path.
1228
- * @param options Additional request options.
1229
- * @param responseHandler Optional response handler override.
1230
- * @returns A promise that resolves to the response body.
1231
- */
1232
- private executeBodyMethod;
1233
- /**
1234
- * Runs the beforeRequest hook chain (global → instance → per-request).
1235
- * Returns immediately if no hooks of any kind are registered, allocating nothing.
1236
- * @param requestOptions Mutable request options (hooks may patch via Object.assign).
1237
- * @param url The current request URL.
1238
- * @param path The original path argument (used to rebuild the URL when hooks update searchParams).
1239
- * @param perRequest Per-request beforeRequest hooks, if any.
1240
- * @returns The (possibly rebuilt) request URL.
1241
- */
1242
- private runBeforeRequestHooks;
1243
- /**
1244
- * Runs the afterResponse hook chain (global → instance → per-request).
1245
- * Returns the input response untouched when no hooks are registered.
1246
- * @param response The current response.
1247
- * @param requestOptions The original request options passed to each hook.
1248
- * @param perRequest Per-request afterResponse hooks, if any.
1249
- * @returns The (possibly replaced) response.
1250
- */
1251
- private runAfterResponseHooks;
1252
- /**
1253
- * Runs the beforeError hook chain (global → instance → per-request).
1254
- * Returns the input error untouched when no hooks are registered.
1255
- * @param error The current HttpError.
1256
- * @param perRequest Per-request beforeError hooks, if any.
1257
- * @returns The (possibly transformed) error.
1258
- */
1259
- private runBeforeErrorHooks;
1260
- /**
1261
- * It returns a response handler based on the content type of the response.
1262
- * @param path The path to the resource.
1263
- * @param userOptions The user options for the request.
1264
- * @param options The options for the request.
1265
- * @param responseHandler The response handler for the request.
1266
- * @returns A response handler function.
1267
- */
1268
- private execute;
1269
- /**
1270
- * Creates a new set of options for a request.
1271
- * @param options The user options for the request.
1272
- * @param userOptions The default options for the request.
1273
- * @returns A new set of options for the request.
1274
- */
1275
- private static createOptions;
1276
- /**
1277
- * Merges user and request headers into the target Headers object.
1278
- * @param target The target Headers object.
1279
- * @param headerSources Variable number of header sources to merge.
1280
- * @returns The merged Headers object.
1281
- */
1282
- private static mergeHeaders;
1283
- /**
1284
- * Merges user and request search parameters into the target URLSearchParams object.
1285
- * @param target The target URLSearchParams object.
1286
- * @param sources The search parameters to merge.
1287
- * @returns The merged URLSearchParams object.
1288
- */
1289
- private static mergeSearchParams;
1290
- /**
1291
- * Processes request options by merging user, instance, and method-specific options.
1292
- *
1293
- * Hot path optimizations:
1294
- * - No parameter destructuring (avoids two transient rest objects per call).
1295
- * - Skips Headers/URLSearchParams construction entirely when neither user nor method overrides supply them.
1296
- * - Reuses the pre-stripped `_noBodyHeadersTemplate` for non-body methods so we never have to delete `content-type` per request.
1297
- * - Builds `requestOptions` via `Object.assign` with a stable property order to keep V8 hidden classes monomorphic.
1298
- * @param userOptions The user-provided options for the request.
1299
- * @param options Additional method-specific options.
1300
- * @returns Processed request options with signal controller and global flag.
1301
- */
1302
- private processRequestOptions;
1303
- /**
1304
- * Gets the base URL from a URL or string.
1305
- * @param url The URL or string to parse.
1306
- * @returns The base URL.
1307
- */
1308
- private static getBaseUrl;
1309
- /**
1310
- * Parses a content-type string into a MediaType instance with caching.
1311
- * This method caches parsed MediaType instances to avoid re-parsing the same content-type strings,
1312
- * which significantly improves performance for repeated requests with the same content types.
1313
- * @param contentType The content-type string to parse.
1314
- * @returns The parsed MediaType instance, or undefined if parsing fails.
1315
- */
1316
- private static getOrParseMediaType;
1317
- /**
1318
- * Creates a new URL with the given path and search parameters.
1319
- * Uses the pre-normalized base pathname/origin to avoid per-request regex work.
1320
- * Polymorphic on the first arg to preserve the legacy direct-URL test API.
1321
- * @param source A Transportr instance (preferred) or a base URL.
1322
- * @param path The path to append to the base URL.
1323
- * @param searchParams The search parameters to append to the URL.
1324
- * @returns A new URL with the given path and search parameters.
1325
- */
1326
- private static createUrl;
1327
- /**
1328
- * It generates a ResponseStatus object from an error name and a Response object.
1329
- * @param errorName The name of the error.
1330
- * @param response The Response object.
1331
- * @returns A ResponseStatus object.
1332
- */
1333
- private static generateResponseStatusFromError;
1334
- /**
1335
- * Handles an error that occurs during a request.
1336
- * @param path The path of the request.
1337
- * @param response The Response object.
1338
- * @param options Additional error context including cause, entity, url, method, and timing.
1339
- * @param requestOptions The original request options that led to the error, used for hooks context.
1340
- * @returns An HttpError object.
1341
- */
1342
- private handleError;
1343
- /**
1344
- * Publishes an event to the global and instance event handlers.
1345
- * Skips entirely when no subscribers are registered for the event — the common case in production —
1346
- * which avoids both the CustomEvent allocation and the validateEventName/forEach overhead inside Subscribr.
1347
- * @param eventObject The event object to publish.
1348
- */
1349
- private publish;
1350
- /**
1351
- * It returns a response handler based on the content type of the response.
1352
- * @param contentType The content type of the response.
1353
- * @returns A response handler function.
1354
- */
1355
- private getResponseHandler;
1168
+ /** Throws on failure and resolves to an NDJSON async iterable (default behavior). */
1169
+ getJsonStream<T = Json>(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<T>>;
1356
1170
  /**
1357
1171
  * A string representation of the Transportr instance.
1358
1172
  * @returns The string 'Transportr'.
@@ -1,9 +1,8 @@
1
- var k=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,Be=/(["\\])/ug,ke=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,re=class oe extends Map{constructor(e=[]){super(e)}static isValid(e,t){return k.test(e)&&ke.test(t)}get(e){return super.get(e.toLowerCase())}has(e){return super.has(e.toLowerCase())}set(e,t){if(!oe.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(e.toLowerCase(),t),this}delete(e){return super.delete(e.toLowerCase())}toString(){return Array.from(this).map(([e,t])=>`;${e}=${!t||!k.test(t)?`"${t.replace(Be,"\\$1")}"`:t}`).join("")}get[Symbol.toStringTag](){return"MediaTypeParameters"}},xe=new Set([" "," ",`
2
- `,"\r"]),Le=/[ \t\n\r]+$/u,Ue=/^[ \t\n\r]+|[ \t\n\r]+$/ug,Me=class E{static parse(e){e=e.replace(Ue,"");let t=0,[r,s]=E.collect(e,t,["/"]);if(t=s,!r.length||t>=e.length||!k.test(r))throw new TypeError(E.generateErrorMessage("type",r));++t;let[o,i]=E.collect(e,t,[";"],!0,!0);if(t=i,!o.length||!k.test(o))throw new TypeError(E.generateErrorMessage("subtype",o));let a=new re;for(;t<e.length;){for(++t;xe.has(e[t]);)++t;let u;if([u,t]=E.collect(e,t,[";","="],!1),t>=e.length||e[t]===";")continue;++t;let l;if(e[t]==='"')for([l,t]=E.collectHttpQuotedString(e,t);t<e.length&&e[t]!==";";)++t;else if([l,t]=E.collect(e,t,[";"],!1,!0),!l)continue;u&&re.isValid(u,l)&&!a.has(u)&&a.set(u,l)}return{type:r,subtype:o,parameters:a}}get[Symbol.toStringTag](){return"MediaTypeParser"}static collect(e,t,r,s=!0,o=!1){let i="";for(let{length:a}=e;t<a&&!r.includes(e[t]);t++)i+=e[t];return s&&(i=i.toLowerCase()),o&&(i=i.replace(Le,"")),[i,t]}static collectHttpQuotedString(e,t){let r="";for(let s=e.length,o;++t<s&&(o=e[t])!=='"';)r+=o=="\\"&&++t<s?e[t]:o;return[r,t]}static generateErrorMessage(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},y=class ie{_type;_subtype;_parameters;constructor(e,t={}){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");({type:this._type,subtype:this._subtype,parameters:this._parameters}=Me.parse(e));for(let[r,s]of Object.entries(t))this._parameters.set(r,s)}static parse(e){try{return new ie(e)}catch{}return null}get type(){return this._type}get subtype(){return this._subtype}get essence(){return`${this._type}/${this._subtype}`}get parameters(){return this._parameters}matches(e){return typeof e=="string"?this.essence.includes(e):this._type===e._type&&this._subtype===e._subtype}toString(){return`${this.essence}${this._parameters.toString()}`}get[Symbol.toStringTag](){return"MediaType"}};var Ie=class extends Map{set(n,e){return super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),this}getOrInsert(n,e){return this.has(n)?super.get(n):(super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),e)}getOrInsertComputed(n,e){if(this.has(n))return super.get(n);let t=e(n);return super.set(n,t instanceof Set?t:(super.get(n)??new Set).add(t)),t}find(n,e){let t=this.get(n);if(t!==void 0)return Array.from(t).find(e)}hasValue(n,e){let t=super.get(n);return t?t.has(e):!1}deleteValue(n,e){if(e===void 0)return this.delete(n);let t=super.get(n);if(t){let r=t.delete(e);return t.size===0&&super.delete(n),r}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},Ne=class{context;eventHandler;constructor(n,e){this.context=n,this.eventHandler=e}handle(n,e){this.eventHandler.call(this.context,n,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},De=class{_eventName;_contextEventHandler;constructor(n,e){this._eventName=n,this._contextEventHandler=e}get eventName(){return this._eventName}get contextEventHandler(){return this._contextEventHandler}get[Symbol.toStringTag](){return"Subscription"}},x=class{subscribers=new Ie;errorHandler;setErrorHandler(n){this.errorHandler=n}subscribe(n,e,t=e,r){if(this.validateEventName(n),r?.once){let i=e;e=(a,u)=>{i.call(t,a,u),this.unsubscribe(o)}}let s=new Ne(t,e);this.subscribers.set(n,s);let o=new De(n,s);return o}unsubscribe({eventName:n,contextEventHandler:e}){let t=this.subscribers.get(n)??new Set,r=t.delete(e);return r&&t.size===0&&this.subscribers.delete(n),r}publish(n,e=new CustomEvent(n),t){this.validateEventName(n),this.subscribers.get(n)?.forEach(r=>{try{r.handle(e,t)}catch(s){this.errorHandler?this.errorHandler(s,n,e,t):console.error(`Error in event handler for '${n}':`,s)}})}isSubscribed({eventName:n,contextEventHandler:e}){return this.subscribers.get(n)?.has(e)??!1}validateEventName(n){if(!n||typeof n!="string")throw new TypeError("Event name must be a non-empty string");if(n.trim()!==n)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.subscribers.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var S=class extends Error{_entity;responseStatus;_url;_method;_timing;constructor(e,{message:t,cause:r,entity:s,url:o,method:i,timing:a}={}){super(t,{cause:r}),this._entity=s,this.responseStatus=e,this._url=o,this._method=i,this._timing=a}get entity(){return this._entity}get statusCode(){return this.responseStatus.code}get statusText(){return this.responseStatus?.text}get url(){return this._url}get method(){return this._method}get timing(){return this._timing}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var w=class{_code;_text;constructor(e,t){this._code=e,this._text=t}get code(){return this._code}get text(){return this._text}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this._code} ${this._text}`}};var O={charset:"utf-8"};var ae="XSRF-TOKEN",ue="X-XSRF-TOKEN",R={PNG:new y("image/png"),TEXT:new y("text/plain",O),JSON:new y("application/json",O),HTML:new y("text/html",O),JAVA_SCRIPT:new y("text/javascript",O),CSS:new y("text/css",O),XML:new y("application/xml",O),BIN:new y("application/octet-stream"),EVENT_STREAM:new y("text/event-stream",O),NDJSON:new y("application/x-ndjson",O)},$=R.JSON.toString(),J=globalThis.location?.origin??"http://localhost",le={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},m={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},v={ABORT:"abort",TIMEOUT:"timeout"},q={ABORT:"AbortError",TIMEOUT:"TimeoutError"},C={once:!0,passive:!0},L=()=>new CustomEvent(v.ABORT,{detail:{cause:q.ABORT}}),de=()=>new CustomEvent(v.TIMEOUT,{detail:{cause:q.TIMEOUT}}),ce=["POST","PUT","PATCH","DELETE"],pe=new w(500,"Internal Server Error"),fe=new w(499,"Aborted"),he=new w(504,"Request Timeout"),G=[408,413,429,500,502,503,504],z=["GET","PUT","HEAD","DELETE","OPTIONS"],U=300,M=2;var I=class{abortSignal;abortController=new AbortController;events;hasComposite;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let r=e!=null,s=t!==1/0;if(!r&&!s){this.abortSignal=this.abortController.signal,this.hasComposite=!1;return}let o=[this.abortController.signal];r&&o.push(e),s&&o.push(AbortSignal.timeout(t)),this.abortSignal=AbortSignal.any(o),this.hasComposite=!0,s&&this.abortSignal.addEventListener(v.ABORT,this,C)}handleEvent({target:{reason:e}}){this.abortController.signal.aborted||e instanceof DOMException&&e.name===q.TIMEOUT&&this.abortSignal.dispatchEvent(de())}get signal(){return this.abortSignal}onAbort(e){return this.addEventListener(v.ABORT,e)}onTimeout(e){return this.addEventListener(v.TIMEOUT,e)}abort(e=L()){this.abortController.abort(e.detail?.cause)}destroy(){this.hasComposite&&this.abortSignal.removeEventListener(v.ABORT,this,C);let e=this.events;if(e!==void 0){for(let[t,r]of e)this.abortSignal.removeEventListener(r,t,C);e.clear()}return this}addEventListener(e,t){return this.abortSignal.addEventListener(e,t,C),(this.events??=new Map).set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var N,X,D=()=>N||(N=(typeof document>"u"||typeof DOMParser>"u"||typeof DocumentFragment>"u"?import("jsdom").then(({JSDOM:e})=>{let{window:t}=new e("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=t,Object.assign(globalThis,{document:t.document,DOMParser:t.DOMParser,DocumentFragment:t.DocumentFragment})}).catch(()=>{throw N=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}):Promise.resolve()).then(()=>import("./BDFNHL2U.js")).then(({default:e})=>{X=e})),Re=async(n,e)=>(await D(),new DOMParser().parseFromString(X.sanitize(await n.text()),e)),V=async(n,e)=>{await D();let t=URL.createObjectURL(await n.blob());try{return new Promise((r,s)=>e(t,r,s))}finally{URL.revokeObjectURL(t)}},ge=n=>n.text(),W=n=>V(n,(e,t,r)=>{let s=document.createElement("script");Object.assign(s,{src:e,type:"text/javascript",async:!0}),s.onload=()=>{document.head.removeChild(s),t()},s.onerror=()=>{document.head.removeChild(s),r(new Error("Script failed to load"))},document.head.appendChild(s)}),K=n=>V(n,(e,t,r)=>{let s=document.createElement("link");Object.assign(s,{href:e,type:"text/css",rel:"stylesheet"}),s.onload=()=>t(),s.onerror=()=>{document.head.removeChild(s),r(new Error("Stylesheet load failed"))},document.head.appendChild(s)}),Y=n=>n.json(),me=n=>n.blob(),Q=n=>V(n,(e,t,r)=>{let s=new Image;s.onload=()=>t(s),s.onerror=()=>r(new Error("Image failed to load")),s.src=e}),ye=n=>n.arrayBuffer(),Z=n=>Promise.resolve(n.body),ee=async n=>Re(n,"application/xml"),te=async n=>Re(n,"text/html"),be=async n=>(await D(),document.createRange().createContextualFragment(X.sanitize(await n.text()))),Te=async n=>(await D(),document.createRange().createContextualFragment(await n.text()));async function*Ee(n,e,t){let r=n.getReader(),s=new TextDecoder,o=e.length,i="",a=0;try{for(;;){let u;for(;(u=i.indexOf(e,a))!==-1;)yield i.slice(a,u),a=u+o;a>0&&a>=i.length-a&&(i=a<i.length?i.slice(a):"",a=0);let{done:l,value:d}=await r.read();if(l)break;i+=s.decode(d,{stream:!0})}if(t){let l=((a<i.length?i.slice(a):"")+s.decode()).trim();l&&(yield l)}}finally{await r.cancel()}}var _e=n=>{let e="message",t="",r,s,o,i=n.split(`
3
- `);for(let u=0,l=i.length;u<l;u++){let d=i[u];if(d.charCodeAt(0)===58)continue;let c=d.indexOf(":"),p,f;switch(c===-1?(p=d,f=""):(p=d.slice(0,c),f=d.charCodeAt(c+1)===32?d.slice(c+2):d.slice(c+1)),p){case"event":e=f;break;case"data":s===void 0?s=f:(o??=[]).push(f);break;case"id":t=f;break;case"retry":{let h=parseInt(f,10);isNaN(h)||(r=h);break}}}if(s===void 0&&e==="message")return;let a=o===void 0?s??"":`${s}
1
+ var I=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,xe=/(["\\])/ug,ke=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,L=n=>{for(let e=0,t=n.length;e<t;e++){let s=n.charCodeAt(e);if(s>=65&&s<=90)return n.toLowerCase()}return n},oe=class ie extends Map{constructor(e=[]){super(e)}static isValid(e,t){return I.test(e)&&ke.test(t)}get(e){return super.get(L(e))}has(e){return super.has(L(e))}set(e,t){if(!ie.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(L(e),t),this}delete(e){return super.delete(L(e))}toString(){let e="";for(let[t,s]of this)e+=";",e+=t,e+="=",s.length===0||!I.test(s)?(e+='"',e+=s.replace(xe,"\\$1"),e+='"'):e+=s;return e}get[Symbol.toStringTag](){return"MediaTypeParameters"}},v=n=>n===32||n===9||n===10||n===13,Le=Map.prototype.set,Ie=Map.prototype.has,Me=class b{constructor(){}static parse(e){let t=0,s=e.length;for(;t<s&&v(e.charCodeAt(t));)t++;for(;s>t&&v(e.charCodeAt(s-1));)s--;(t!==0||s!==e.length)&&(e=e.slice(t,s));let r=e.length,o=0;for(;o<r&&e.charCodeAt(o)!==47;)o++;if(o===0||o>=r)throw new TypeError(b.#s("type",e.slice(0,o)));let i=e.slice(0,o);if(!I.test(i))throw new TypeError(b.#s("type",i));i=i.toLowerCase(),o++;let a=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let d=o;for(;d>a&&v(e.charCodeAt(d-1));)d--;if(d===a)throw new TypeError(b.#s("subtype",""));let u=e.slice(a,d);if(!I.test(u))throw new TypeError(b.#s("subtype",u));u=u.toLowerCase();let l=new oe;for(;o<r;){for(o++;o<r&&v(e.charCodeAt(o));)o++;let c=o;for(;o<r;){let p=e.charCodeAt(o);if(p===59||p===61)break;o++}let f=c===o?"":e.slice(c,o);if(o>=r||e.charCodeAt(o)===59)continue;o++;let R;if(o<r&&e.charCodeAt(o)===34){o=b.#t(e,o,r),R=b.#e;let p=e.indexOf(";",o);o=p===-1?r:p}else{let p=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let y=o;for(;y>p&&v(e.charCodeAt(y-1));)y--;if(y===p)continue;R=e.slice(p,y)}if(f.length!==0&&oe.isValid(f,R)){let p=f.toLowerCase();Ie.call(l,p)||Le.call(l,p,R)}}return{type:i,subtype:u,parameters:l}}static#e="";static#t(e,t,s){t++;let r=t;for(;t<s;){let i=e.charCodeAt(t);if(i===34||i===92)break;t++}if(t>=s)return b.#e=e.slice(r,t),t;if(e.charCodeAt(t)===34)return b.#e=e.slice(r,t),t+1;let o=e.slice(r,t);for(;t<s;){let i=e.charCodeAt(t);if(i===34){t++;break}i===92&&t+1<s&&t++,o+=e[t],t++}return b.#e=o,t}static#s(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},M=class ae{#e;#t;#s;#n;constructor(e,t){if({type:this.#e,subtype:this.#t,parameters:this.#n}=Me.parse(e),this.#s=this.#e+"/"+this.#t,t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.#n.set(s,t[s])}}static parse(e){try{return new ae(e)}catch{}return null}get type(){return this.#e}get subtype(){return this.#t}get essence(){return this.#s}get parameters(){return this.#n}matches(e){return typeof e=="string"?this.#s===e:this.#e===e.#e&&this.#t===e.#t}toString(){return this.#s+this.#n.toString()}get[Symbol.toStringTag](){return"MediaType"}};var Ue=class extends Map{set(n,e){return super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),this}getOrInsert(n,e){return this.has(n)?super.get(n):(super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),e)}getOrInsertComputed(n,e){if(this.has(n))return super.get(n);let t=e(n);return super.set(n,t instanceof Set?t:(super.get(n)??new Set).add(t)),t}find(n,e){let t=this.get(n);if(t!==void 0)return Array.from(t).find(e)}hasValue(n,e){let t=super.get(n);return t?t.has(e):!1}deleteValue(n,e){if(e===void 0)return this.delete(n);let t=super.get(n);if(t){let s=t.delete(e);return t.size===0&&super.delete(n),s}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},Ne=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}handle(n,e){this.#t.call(this.#e,n,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},De=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}get eventName(){return this.#e}get contextEventHandler(){return this.#t}get[Symbol.toStringTag](){return"Subscription"}},U=class{#e=new Ue;#t;setErrorHandler(n){this.#t=n}subscribe(n,e,t=e,s){if(this.#s(n),s?.once){let i=e;e=(a,d)=>{i.call(t,a,d),this.unsubscribe(o)}}let r=new Ne(t,e);this.#e.set(n,r);let o=new De(n,r);return o}unsubscribe({eventName:n,contextEventHandler:e}){let t=this.#e.get(n);if(!t)return!1;let s=t.delete(e);return s&&t.size===0&&this.#e.delete(n),s}publish(n,e=new CustomEvent(n),t){this.#s(n),this.#e.get(n)?.forEach(s=>{try{s.handle(e,t)}catch(r){this.#t?this.#t(r,n,e,t):console.error(`Error in event handler for '${n}':`,r)}})}isSubscribed({eventName:n,contextEventHandler:e}){return this.#e.get(n)?.has(e)??!1}#s(n){if(!n||typeof n!="string")throw new TypeError("Event name must be a non-empty string");if(n.trim()!==n)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.#e.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var O=class extends Error{#e;#t;#s;#n;#o;constructor(e,{message:t,cause:s,entity:r,url:o,method:i,timing:a}={}){super(t,{cause:s}),this.#e=r,this.#t=e,this.#s=o,this.#n=i,this.#o=a}get entity(){return this.#e}get statusCode(){return this.#t.code}get statusText(){return this.#t?.text}get url(){return this.#s}get method(){return this.#n}get timing(){return this.#o}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var E=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get code(){return this.#e}get text(){return this.#t}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this.#e} ${this.#t}`}};var ue="XSRF-TOKEN",de="X-XSRF-TOKEN",h={PNG:"image/png",TEXT:"text/plain",JSON:"application/json",HTML:"text/html",JAVA_SCRIPT:"text/javascript",CSS:"text/css",XML:"application/xml",BIN:"application/octet-stream",EVENT_STREAM:"text/event-stream",NDJSON:"application/x-ndjson"},Fe={charset:"utf-8"},A=new M(h.JSON,Fe),W=globalThis.location?.origin??"http://localhost",le={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},m={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},q={ABORT:"abort",TIMEOUT:"timeout"},w={ABORT:"AbortError",TIMEOUT:"TimeoutError"},B={once:!0,passive:!0},N=()=>new CustomEvent(q.ABORT,{detail:{cause:w.ABORT}}),ce=()=>new CustomEvent(q.TIMEOUT,{detail:{cause:w.TIMEOUT}}),pe=["POST","PUT","PATCH","DELETE"],fe=new E(500,"Internal Server Error"),Re=new E(499,"Aborted"),he=new E(504,"Request Timeout"),K=[408,413,429,500,502,503,504],Y=["GET","PUT","HEAD","DELETE","OPTIONS"],D=300,F=2;var j=class{#e;#t=new AbortController;#s;#n;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let s=e!=null,r=t!==1/0;if(!s&&!r){this.#e=this.#t.signal,this.#n=!1;return}let o=[this.#t.signal];s&&o.push(e),r&&o.push(AbortSignal.timeout(t)),this.#e=AbortSignal.any(o),this.#n=!0,r&&this.#e.addEventListener(q.ABORT,this,B)}handleEvent({target:{reason:e}}){this.#t.signal.aborted||e instanceof DOMException&&e.name===w.TIMEOUT&&this.#e.dispatchEvent(ce())}get signal(){return this.#e}onAbort(e){return this.#o(q.ABORT,e)}onTimeout(e){return this.#o(q.TIMEOUT,e)}abort(e=N()){this.#t.abort(e.detail?.cause)}destroy(){this.#n&&this.#e.removeEventListener(q.ABORT,this,B);let e=this.#s;if(e!==void 0){for(let[t,s]of e)this.#e.removeEventListener(s,t,B);e.clear()}return this}#o(e,t){return this.#e.addEventListener(e,t,B),(this.#s??=new Map).set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var J,$,G=()=>J||(J=(typeof document>"u"||typeof DOMParser>"u"||typeof DocumentFragment>"u"?import("jsdom").then(({JSDOM:e})=>{let{window:t}=new e("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=t,Object.assign(globalThis,{document:t.document,DOMParser:t.DOMParser,DocumentFragment:t.DocumentFragment})}).catch(()=>{throw J=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}):Promise.resolve()).then(()=>import("./FPFIT6Y7.js")).then(({default:e})=>{$=e})),ge=async(n,e)=>(await G(),new DOMParser().parseFromString($.sanitize(await n.text()),e)),Z=async(n,e)=>{await G();let t=URL.createObjectURL(await n.blob());try{return new Promise((s,r)=>e(t,s,r))}finally{URL.revokeObjectURL(t)}},me=n=>n.text(),Q=n=>Z(n,(e,t,s)=>{let r=Object.assign(document.createElement("script"),{src:e,type:"text/javascript",async:!0});r.onload=()=>{document.head.removeChild(r),t()},r.onerror=()=>{document.head.removeChild(r),s(new Error("Script failed to load"))},document.head.appendChild(r)}),_=n=>Z(n,(e,t,s)=>{let r=Object.assign(document.createElement("link"),{href:e,type:"text/css",rel:"stylesheet"});r.onload=()=>t(),r.onerror=()=>{document.head.removeChild(r),s(new Error("Stylesheet load failed"))},document.head.appendChild(r)}),H=n=>n.json(),ye=n=>n.blob(),ee=n=>Z(n,(e,t,s)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>s(new Error("Image failed to load")),r.src=e}),be=n=>n.arrayBuffer(),te=n=>Promise.resolve(n.body),C=async n=>ge(n,"application/xml"),ne=async n=>ge(n,"text/html"),Te=async n=>(await G(),document.createRange().createContextualFragment($.sanitize(await n.text()))),Oe=async n=>(await G(),document.createRange().createContextualFragment($.sanitize(await n.text(),{ADD_TAGS:["script"]})));async function*Ee(n,e,t){let s=n.getReader(),r=new TextDecoder,o=e.length,i="",a=0;try{for(;;){let d;for(;(d=i.indexOf(e,a))!==-1;)yield i.slice(a,d),a=d+o;a>0&&a>=i.length-a&&(i=a<i.length?i.slice(a):"",a=0);let{done:u,value:l}=await s.read();if(u)break;i+=r.decode(l,{stream:!0})}if(t){let u=((a<i.length?i.slice(a):"")+r.decode()).trim();u&&(yield u)}}finally{await s.cancel()}}var je=n=>{let e="message",t="",s,r,o,i=n.split(`
2
+ `);for(let d=0,u,l=i.length;d<l;d++){if(u=i[d],u.charCodeAt(0)===58)continue;let c=u.indexOf(":"),f,R;switch(c===-1?(f=u,R=""):(f=u.slice(0,c),R=u.charCodeAt(c+1)===32?u.slice(c+2):u.slice(c+1)),f){case"event":{e=R;break}case"data":{r===void 0?r=R:(o??=[]).push(R);break}case"id":{t=R;break}case"retry":{let p=parseInt(R,10);isNaN(p)||(s=p);break}}}if(r===void 0&&e==="message")return;let a=o===void 0?r??"":`${r}
4
3
  ${o.join(`
5
- `)}`;return{event:e,data:a,id:t,retry:r}},Se=n=>({async*[Symbol.asyncIterator](){for await(let e of Ee(n.body,`
4
+ `)}`;return{event:e,data:a,id:t,retry:s}},qe=n=>({async*[Symbol.asyncIterator](){for await(let e of Ee(n.body,`
6
5
 
7
- `,!1)){if(!e)continue;let t=_e(e);t&&(yield t)}}}),we=n=>({async*[Symbol.asyncIterator](){for await(let e of Ee(n.body,`
8
- `,!0)){let t=e.trim();t&&(yield JSON.parse(t))}}});var Oe=n=>n!==void 0&&ce.includes(n),ve=n=>n instanceof FormData||n instanceof Blob||n instanceof ArrayBuffer||n instanceof ReadableStream||n instanceof URLSearchParams||ArrayBuffer.isView(n),qe=n=>{if(typeof document>"u")return;let e=document.cookie;if(!e)return;let t=`${n}=`,r=t.length,s=e.length,o=0;for(;o<s;){for(;o<s&&e.charCodeAt(o)===32;)o++;let i=e.indexOf(";",o);if(i===-1&&(i=s),i-o>=r&&e.startsWith(t,o))return decodeURIComponent(e.slice(o+r,i));o=i+1}},Pe=n=>JSON.stringify(n),_=n=>n!==null&&typeof n=="string",He=n=>n instanceof ArrayBuffer||Object.prototype.toString.call(n)==="[object ArrayBuffer]",g=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype,F=(...n)=>{let e=n.length;if(e===0)return;if(e===1){let[r]=n;return g(r)?ne(r):r}let t={};for(let r=0,s=n.length;r<s;r++){let o=n[r];if(!g(o))return;let i=Object.keys(o);for(let a=0,u=i.length;a<u;a++){let l=i[a],d=o[l],c=t[l];if(Array.isArray(d))if(Array.isArray(c)){let p=d.slice();for(let f=0,h=c.length;f<h;f++){let T=c[f];d.includes(T)||p.push(T)}t[l]=p}else t[l]=d.slice();else g(d)?t[l]=g(c)?F(c,d):ne(d):t[l]=d}}return t};function ne(n){if(g(n)){let e={},t=Object.keys(n);for(let r=0,s=t.length,o;r<s;r++)o=t[r],e[o]=ne(n[o]);return e}return n}var Ce=class n{_baseUrl;_origin;_basePath;_options;_noBodyHeadersTemplate;subscribr;hooks={beforeRequest:[],afterResponse:[],beforeError:[]};hookCount={beforeRequest:0,afterResponse:0,beforeError:0};subCounts=Object.create(null);static globalSubscribr=new x;static globalHooks={beforeRequest:[],afterResponse:[],beforeError:[]};static globalHookCount={beforeRequest:0,afterResponse:0,beforeError:0};static globalSubCounts=Object.create(null);static signalControllers=new Set;static inflightRequests=new Map;static noRetryConfig={limit:0,statusCodes:[],methods:[],delay:U,backoffFactor:M};static retryConfigCache=new WeakMap;static mediaTypeCache=new Map(Object.values(R).map(e=>[e.toString(),e]));static handlerResolutionCache=new Map;static contentTypeHandlers=[[R.TEXT.type,ge],[R.JSON.subtype,Y],[R.BIN.subtype,Z],[R.HTML.subtype,te],[R.XML.subtype,ee],[R.PNG.type,Q],[R.JAVA_SCRIPT.subtype,W],[R.CSS.subtype,K]];constructor(e=J,t={}){g(e)&&([e,t]=[J,e]),this._baseUrl=n.getBaseUrl(e),this._origin=this._baseUrl.origin;let r=this._baseUrl.pathname;this._basePath=r.length>0&&r.charCodeAt(r.length-1)===47?r.slice(0,-1):r,this._options=n.createOptions(t,n.defaultRequestOptions),this._noBodyHeadersTemplate=new Headers(this._options.headers),this._noBodyHeadersTemplate.delete("content-type"),this.subscribr=new x}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=m;static defaultRequestOptions={body:void 0,cache:le.NO_STORE,credentials:n.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":$,accept:$}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:n.RequestMode.CORS,priority:n.RequestPriority.AUTO,redirect:n.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:n.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,r){let s=n.globalSubscribr.subscribe(e,t,r);return n.globalSubCounts[e]=(n.globalSubCounts[e]??0)+1,s}static unregister(e){let t=n.globalSubscribr.unsubscribe(e);if(t){let r=e.eventName,s=(n.globalSubCounts[r]??1)-1;s<=0?delete n.globalSubCounts[r]:n.globalSubCounts[r]=s}return t}static abortAll(){for(let e of this.signalControllers)e.abort(L());this.signalControllers.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],r=new Array(e.length);for(let s=0;s<e.length;s++){let o=new AbortController;t.push(o),r[s]=e[s](o.signal)}try{return await Promise.race(r)}finally{for(let s of t)s.abort()}}static registerContentTypeHandler(e,t){n.contentTypeHandlers.unshift([e,t]),n.handlerResolutionCache.clear()}static unregisterContentTypeHandler(e){let t=n.contentTypeHandlers.findIndex(([r])=>r===e);return t===-1?!1:(n.contentTypeHandlers.splice(t,1),n.handlerResolutionCache.clear(),!0)}static addHooks(e){let{beforeRequest:t,afterResponse:r,beforeError:s}=e;t&&(n.globalHooks.beforeRequest.push(...t),n.globalHookCount.beforeRequest+=t.length),r&&(n.globalHooks.afterResponse.push(...r),n.globalHookCount.afterResponse+=r.length),s&&(n.globalHooks.beforeError.push(...s),n.globalHookCount.beforeError+=s.length)}static clearHooks(){n.globalHooks={beforeRequest:[],afterResponse:[],beforeError:[]},n.globalHookCount.beforeRequest=0,n.globalHookCount.afterResponse=0,n.globalHookCount.beforeError=0}static unregisterAll(){n.abortAll(),n.globalSubscribr=new x,n.globalSubCounts=Object.create(null),n.clearHooks(),n.inflightRequests.clear()}get baseUrl(){return this._baseUrl}register(e,t,r){let s=this.subscribr.subscribe(e,t,r);return this.subCounts[e]=(this.subCounts[e]??0)+1,s}unregister(e){let t=this.subscribr.unsubscribe(e);if(t){let r=e.eventName,s=(this.subCounts[r]??1)-1;s<=0?delete this.subCounts[r]:this.subCounts[r]=s}return t}addHooks(e){let{beforeRequest:t,afterResponse:r,beforeError:s}=e;return t&&(this.hooks.beforeRequest.push(...t),this.hookCount.beforeRequest+=t.length),r&&(this.hooks.afterResponse.push(...r),this.hookCount.afterResponse+=r.length),s&&(this.hooks.beforeError.push(...s),this.hookCount.beforeError+=s.length),this}clearHooks(){return this.hooks.beforeRequest.length=0,this.hooks.afterResponse.length=0,this.hooks.beforeError.length=0,this.hookCount.beforeRequest=0,this.hookCount.afterResponse=0,this.hookCount.beforeError=0,this}configure({headers:e,searchParams:t,hooks:r,...s}){return e&&(n.mergeHeaders(this._options.headers,e),this._noBodyHeadersTemplate=new Headers(this._options.headers),this._noBodyHeadersTemplate.delete("content-type")),t&&n.mergeSearchParams(this._options.searchParams,t),Object.assign(this._options,s),r&&this.addHooks(r),this}destroy(){this.clearHooks(),this.subscribr.destroy();for(let e in this.subCounts)delete this.subCounts[e]}async get(e,t){return this._get(e,t)}async post(e,t,r){return this.executeBodyMethod("POST",e,t,r)}async put(e,t,r){return this.executeBodyMethod("PUT",e,t,r)}async patch(e,t,r){return this.executeBodyMethod("PATCH",e,t,r)}async delete(e,t,r){return this.executeBodyMethod("DELETE",e,t,r)}async head(e,t){return this.execute(e,t,{method:"HEAD"})}async options(e,t={}){g(e)&&([e,t]=[void 0,e]);let r=this.processRequestOptions(t,{method:"OPTIONS"}),{requestOptions:s}=r,o=s.unwrap!==!1,i=s.hooks;try{let a=n.createUrl(this,e,s.searchParams);await this.runBeforeRequestHooks(s,a,e,i?.beforeRequest);let u=await this._request(e,r);u=await this.runAfterResponseHooks(u,s,i?.afterResponse);let l=u.headers.get("allow"),d;if(l){let c=l.split(",");d=new Array(c.length);for(let p=0,f=c.length;p<f;p++)d[p]=c[p].trim()}return this.publish({name:m.SUCCESS,data:d,global:t.global}),o?d:[!0,d]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){g(e)&&([e,t]=[void 0,e]);let r=this.processRequestOptions(t,{}),s=r.requestOptions.unwrap!==!1;try{let o=await this._request(e,r);return this.publish({name:m.SUCCESS,data:o,global:t.global}),s?o:[!0,o]}catch(o){if(!s)return[!1,o];throw o}}async getJson(e,t){return this._get(e,t,{headers:{accept:`${R.JSON}`}},Y)}async getXml(e,t){return this._get(e,t,{headers:{accept:`${R.XML}`}},ee)}async getHtml(e,t,r){let s=await this._get(e,t,{headers:{accept:`${R.HTML}`}},te);return Array.isArray(s)?s:r&&s?s.querySelector(r):s}async getHtmlFragment(e,t,r){let s=(g(e)?e:t)?.allowScripts===!0,o=await this._get(e,t,{headers:{accept:`${R.HTML}`}},s?Te:be);return Array.isArray(o)?o:r&&o?o.querySelector(r):o}async getScript(e,t){return this._get(e,t,{headers:{accept:`${R.JAVA_SCRIPT}`}},W)}async getStylesheet(e,t){return this._get(e,t,{headers:{accept:`${R.CSS}`}},K)}async getBlob(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},me)}async getImage(e,t){return this._get(e,t,{headers:{accept:"image/*"}},Q)}async getBuffer(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},ye)}async getStream(e,t){return this._get(e,t,{headers:{accept:"application/octet-stream"}},Z)}async getEventStream(e,t){g(e)&&([e,t]=[void 0,e]);let r=this.processRequestOptions(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${R.EVENT_STREAM}`}}),{requestOptions:s}=r,o=s.unwrap!==!1,i=s.hooks;try{let a=n.createUrl(this,e,s.searchParams);await this.runBeforeRequestHooks(s,a,e,i?.beforeRequest);let u=await this._request(e,r),l=await this.runAfterResponseHooks(u,s,i?.afterResponse);this.publish({name:m.SUCCESS,data:l,global:r.global});let d=Se(l);return o?d:[!0,d]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){g(e)&&([e,t]=[void 0,e]);let r=this.processRequestOptions(t??{},{method:"GET",headers:{accept:`${R.NDJSON}`}}),{requestOptions:s}=r,o=s.unwrap!==!1,i=s.hooks;try{let a=n.createUrl(this,e,s.searchParams);await this.runBeforeRequestHooks(s,a,e,i?.beforeRequest);let u=await this._request(e,r),l=await this.runAfterResponseHooks(u,s,i?.afterResponse);this.publish({name:m.SUCCESS,data:l,global:r.global});let d=we(l);return o?d:[!0,d]}catch(a){if(!o)return[!1,a];throw a}}async _get(e,t,r={},s){return r.method="GET",r.body=void 0,this.execute(e,t,r,s)}async _request(e,t){let{signalController:r,requestOptions:s,global:o}=t;n.signalControllers.add(r);let i=n.normalizeRetryOptions(s.retry),a=s.method??"GET",u=i.limit>0&&i.methods.includes(a),l=s.dedupe===!0&&(a==="GET"||a==="HEAD"),d=performance.now();try{let c=n.createUrl(this,e,s.searchParams),p;if(l){p=`${a}:${c.href}`;let A=n.inflightRequests.get(p);if(A)return(await A).clone()}let f=s.onUploadProgress,h=s.body;f&&h!=null&&(s.duplex="half");let T=this._doFetch(c,s,e,a,u,i,h,f,d,o);if(l){n.inflightRequests.set(p,T);try{return n._wrapDownloadProgress(await T,s)}finally{n.inflightRequests.delete(p)}}return n._wrapDownloadProgress(await T,s)}finally{if(n.signalControllers.delete(r.destroy()),!s.signal?.aborted){let c=performance.now();this.publish({name:m.COMPLETE,data:{timing:{start:d,end:c,duration:c-d}},global:o}),n.signalControllers.size===0&&this.publish({name:m.ALL_COMPLETE,global:o})}}}async _doFetch(e,t,r,s,o,i,a,u,l,d){let c=0;for(;;)try{u&&await n._wrapUploadBody(t,a,u);let p=await fetch(e,t);if(!p.ok){if(o&&c<i.limit&&i.statusCodes.includes(p.status)){c++,this.publish({name:m.RETRY,data:{attempt:c,status:p.status,method:s,path:r,timing:n._snapshotTiming(l)},global:d}),await n.retryDelay(i,c);continue}let f;if(t.captureErrorBody!==!1)try{f=await p.text()}catch{}throw await this.handleError(r,p,{entity:f,url:e,method:s,timing:n._snapshotTiming(l)},t)}return p}catch(p){if(p instanceof S)throw p;if(o&&c<i.limit){c++,this.publish({name:m.RETRY,data:{attempt:c,error:p.message,method:s,path:r,timing:n._snapshotTiming(l)},global:d}),await n.retryDelay(i,c);continue}throw await this.handleError(r,void 0,{cause:p,url:e,method:s,timing:n._snapshotTiming(l)},t)}}static async _wrapUploadBody(e,t,r){if(t==null)return;let s=null;if(typeof t=="string")s=new TextEncoder().encode(t);else if(t instanceof Blob)s=new Uint8Array(await t.arrayBuffer());else if(He(t))s=new Uint8Array(t);else if(ArrayBuffer.isView(t))s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(!(t instanceof ReadableStream))return;let o=s?s.byteLength:null,i=s?new ReadableStream({start(l){l.enqueue(s),l.close()}}):t,a=0,u=new TransformStream({transform(l,d){a+=l.byteLength,r({loaded:a,total:o,percentage:o!==null&&o>0?Math.round(a/o*100):null}),d.enqueue(l)}});e.body=i.pipeThrough(u)}static _wrapDownloadProgress(e,t){let r=t.onDownloadProgress;if(!r||!e.body)return e;let s=e.headers.get("content-length"),o=s?parseInt(s,10):null,i=0,a=new TransformStream({transform(u,l){i+=u.byteLength,r({loaded:i,total:o,percentage:o!==null&&o>0?Math.round(i/o*100):null}),l.enqueue(u)}});return new Response(e.body.pipeThrough(a),{status:e.status,statusText:e.statusText,headers:e.headers})}static _snapshotTiming(e){let t=performance.now();return{start:e,end:t,duration:t-e}}static normalizeRetryOptions(e){if(e===void 0)return n.noRetryConfig;if(typeof e=="number")return{limit:e,statusCodes:G,methods:z,delay:U,backoffFactor:M};let t=n.retryConfigCache.get(e);if(t!==void 0)return t;let r={limit:e.limit??0,statusCodes:e.statusCodes??G,methods:e.methods??z,delay:e.delay??U,backoffFactor:e.backoffFactor??M};return n.retryConfigCache.set(e,r),r}static retryDelay(e,t){let r=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(s=>setTimeout(s,r))}executeBodyMethod(e,t,r,s,o){let[i,a,u]=_(t)?[t,r,s]:[void 0,t,r],l=u!==void 0?Object.assign({},u,{body:a,method:e}):{body:a,method:e};return this.execute(i,l,{},o)}async runBeforeRequestHooks(e,t,r,s){let o=n.globalHooks.beforeRequest,i=this.hooks.beforeRequest,a=s===void 0?0:s.length;if(o.length===0&&i.length===0&&a===0)return t;for(let u=0,l=o.length;u<l;u++){let d=await o[u](e,t);d&&(Object.assign(e,d),d.searchParams!==void 0&&(t=n.createUrl(this,r,e.searchParams)))}for(let u=0,l=i.length;u<l;u++){let d=await i[u](e,t);d&&(Object.assign(e,d),d.searchParams!==void 0&&(t=n.createUrl(this,r,e.searchParams)))}for(let u=0;u<a;u++){let l=await s[u](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.createUrl(this,r,e.searchParams)))}return t}async runAfterResponseHooks(e,t,r){let s=n.globalHooks.afterResponse,o=this.hooks.afterResponse,i=r===void 0?0:r.length;if(s.length===0&&o.length===0&&i===0)return e;for(let a=0,u=s.length;a<u;a++){let l=await s[a](e,t);l&&(e=l)}for(let a=0,u=o.length;a<u;a++){let l=await o[a](e,t);l&&(e=l)}for(let a=0;a<i;a++){let u=await r[a](e,t);u&&(e=u)}return e}async runBeforeErrorHooks(e,t){let r=n.globalHooks.beforeError,s=this.hooks.beforeError,o=t===void 0?0:t.length;if(r.length===0&&s.length===0&&o===0)return e;for(let i=0,a=r.length;i<a;i++){let u=await r[i](e);u instanceof S&&(e=u)}for(let i=0,a=s.length;i<a;i++){let u=await s[i](e);u instanceof S&&(e=u)}for(let i=0;i<o;i++){let a=await t[i](e);a instanceof S&&(e=a)}return e}async execute(e,t={},r={},s){g(e)&&([e,t]=[void 0,e]);let o=this.processRequestOptions(t,r),{requestOptions:i}=o,a=i.unwrap!==!1,u=i.hooks;try{let l=n.createUrl(this,e,i.searchParams);await this.runBeforeRequestHooks(i,l,e,u?.beforeRequest);let d=await this._request(e,o);d=await this.runAfterResponseHooks(d,i,u?.afterResponse);try{!s&&d.status!==204&&(s=this.getResponseHandler(d.headers.get("content-type")));let c=await s?.(d);return this.publish({name:m.SUCCESS,data:c,global:o.global}),a?c:[!0,c]}catch(c){throw await this.handleError(e,d,{cause:c},i)}}catch(l){if(!a)return[!1,l];throw l}}static createOptions({headers:e,searchParams:t,...r},{headers:s,searchParams:o,...i}){return s=n.mergeHeaders(new Headers,e,s),o=n.mergeSearchParams(new URLSearchParams,t,o),{...F(i,r),headers:s,searchParams:o}}static mergeHeaders(e,...t){for(let r of t)if(r!==void 0)if(r instanceof Headers)r.forEach((s,o)=>e.set(o,s));else if(Array.isArray(r))for(let[s,o]of r)e.set(s,o);else{let s=Object.keys(r);for(let o=0,i=s.length;o<i;o++){let a=s[o],u=r[a];u!==void 0&&e.set(a,u)}}return e}static mergeSearchParams(e,...t){for(let r of t)if(r!==void 0)if(r instanceof URLSearchParams)r.forEach((s,o)=>e.set(o,s));else if(_(r)||Array.isArray(r))for(let[s,o]of new URLSearchParams(r))e.set(s,o);else{let s=Object.keys(r);for(let o=0;o<s.length;o++){let i=s[o],a=r[i];a!==void 0&&e.set(i,typeof a=="string"?a:String(a))}}return e}processRequestOptions(e,t){let r=e.headers,s=e.searchParams,o=e.body,i=t.headers,a=t.searchParams,u=t.method??e.method??this._options.method??"GET",l=Oe(u),d;!l&&r===void 0&&i===void 0?d=new Headers(this._noBodyHeadersTemplate):(d=new Headers(this._options.headers),(r!==void 0||i!==void 0)&&n.mergeHeaders(d,r,i));let c=this._options.searchParams,p=c!==void 0&&c.size>0,f;!p&&s===void 0&&a===void 0?f=new URLSearchParams:(f=new URLSearchParams(c),(s!==void 0||a!==void 0)&&n.mergeSearchParams(f,s,a));let h=Object.assign({},this._options,e,t);if(h.headers=d,h.searchParams=f,l)if(ve(o))h.body=o,d.delete("content-type");else{let b=this._options.body,P=g(b)&&g(o)?F(b,o):o!==void 0?o:b,H=d.get("content-type"),Ae=H!==null&&H.includes("json");h.body=Ae&&g(P)?Pe(P):P}else h.body instanceof URLSearchParams&&n.mergeSearchParams(f,h.body),h.body=void 0,(r!==void 0||i!==void 0)&&d.delete("content-type");let T=h.signal,A=h.timeout,B=h.global??!1,j=h.xsrf;if(j){let{cookieName:b,headerName:P}=typeof j=="object"?j:{},H=qe(b??ae);H&&d.set(P??ue,H)}let se=new I({signal:T,timeout:A}).onAbort(b=>this.publish({name:m.ABORTED,event:b,global:B})).onTimeout(b=>this.publish({name:m.TIMEOUT,event:b,global:B}));return h.signal=se.signal,this.publish({name:m.CONFIGURED,data:h,global:B}),{signalController:se,requestOptions:h,global:B}}static getBaseUrl(e){if(e instanceof URL)return e;if(!_(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static getOrParseMediaType(e){if(e===null)return;let t=n.mediaTypeCache.get(e);return t!==void 0||(t=y.parse(e)??void 0,t!==void 0&&(n.mediaTypeCache.size>=100&&n.mediaTypeCache.delete(n.mediaTypeCache.keys().next().value),n.mediaTypeCache.set(e,t))),t}static createUrl(e,t,r){let s;if(e instanceof URL){let o=e.pathname,i=o.charCodeAt(o.length-1)===47?o.slice(0,-1):o;s=t?new URL(`${i}${t}`,e.origin):new URL(e)}else s=t?new URL(`${e._basePath}${t}`,e._origin):new URL(e._baseUrl);return r&&n.mergeSearchParams(s.searchParams,r),s}static generateResponseStatusFromError(e,{status:t,statusText:r}=new Response){switch(e){case q.ABORT:return fe;case q.TIMEOUT:return he;default:return t>=400?new w(t,r):pe}}async handleError(e,t,{cause:r,entity:s,url:o,method:i,timing:a}={},u){let l=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,d=new S(n.generateResponseStatusFromError(r?.name,t),{message:l,cause:r,entity:s,url:o,method:i,timing:a});return d=await this.runBeforeErrorHooks(d,u?.hooks?.beforeError),this.publish({name:m.ERROR,data:d}),d}publish({name:e,event:t,data:r,global:s=!0}){let o=s&&(n.globalSubCounts[e]??0)>0,i=(this.subCounts[e]??0)>0;if(!o&&!i)return;let a=t??new CustomEvent(e);o&&n.globalSubscribr.publish(e,a,r),i&&this.subscribr.publish(e,a,r)}getResponseHandler(e){if(!e)return;let t=n.handlerResolutionCache.get(e);if(t!==void 0)return t===null?void 0:t;let r=n.getOrParseMediaType(e);if(!r){n.handlerResolutionCache.set(e,null);return}let s=n.contentTypeHandlers;for(let o=0,i=s.length;o<i;o++){let a=s[o];if(r.matches(a[0])){let u=a[1];return n.handlerResolutionCache.set(e,u),u}}n.handlerResolutionCache.set(e,null)}get[Symbol.toStringTag](){return"Transportr"}};export{Ce as Transportr};
6
+ `,!1)){if(!e)continue;let t=je(e);t&&(yield t)}}}),we=n=>({async*[Symbol.asyncIterator](){for await(let e of Ee(n.body,`
7
+ `,!0)){let t=e.trim();t&&(yield JSON.parse(t))}}});var Se=n=>n!==void 0&&pe.includes(n),Pe=n=>n instanceof FormData||n instanceof Blob||n instanceof ArrayBuffer||n instanceof ReadableStream||n instanceof URLSearchParams||ArrayBuffer.isView(n),ve=n=>{if(typeof document>"u")return;let e=document.cookie;if(!e)return;let t=`${n}=`,s=t.length,r=e.length,o=0;for(;o<r;){for(;o<r&&e.charCodeAt(o)===32;)o++;let i=e.indexOf(";",o);if(i===-1&&(i=r),i-o>=s&&e.startsWith(t,o))return decodeURIComponent(e.slice(o+s,i));o=i+1}},Ae=n=>JSON.stringify(n),z=n=>n!==null&&typeof n=="string",Be=n=>n instanceof ArrayBuffer||Object.prototype.toString.call(n)==="[object ArrayBuffer]",g=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype,X=(...n)=>{let e=n.length;if(e===0)return;if(e===1){let[s]=n;return g(s)?se(s):s}let t={};for(let s=0,r=n.length;s<r;s++){let o=n[s];if(!g(o))return;let i=Object.keys(o);for(let a=0,d=i.length;a<d;a++){let u=i[a],l=o[u],c=t[u];if(Array.isArray(l))if(Array.isArray(c)){let f=l.slice();for(let R=0,p=c.length;R<p;R++){let y=c[R];l.includes(y)||f.push(y)}t[u]=f}else t[u]=l.slice();else g(l)?t[u]=g(c)?X(c,l):se(l):t[u]=l}}return t};function se(n){if(g(n)){let e={},t=Object.keys(n);for(let s=0,r=t.length,o;s<r;s++)o=t[s],e[o]=se(n[o]);return e}return n}var He=class n{#e;#t;#s;#n;#o;#h;#a={beforeRequest:[],afterResponse:[],beforeError:[]};#f={beforeRequest:0,afterResponse:0,beforeError:0};#u=Object.create(null);static#O=new U;static#c={beforeRequest:[],afterResponse:[],beforeError:[]};static#R={beforeRequest:0,afterResponse:0,beforeError:0};static#p=Object.create(null);static#g=new Set;static#E=new Map;static#L={limit:0,statusCodes:[],methods:[],delay:D,backoffFactor:F};static#C=new WeakMap;static#m=new Map([[A.toString(),A]]);static#d=new Map;static#q=[[h.TEXT,me],[h.JSON,H],[h.BIN,te],[h.HTML,ne],[h.XML,C],[h.PNG,ee],[h.JAVA_SCRIPT,Q],[h.CSS,_]];constructor(e=W,t={}){g(e)&&([e,t]=[W,e]),this.#e=n.#j(e),this.#t=this.#e.origin;let s=this.#e.pathname;this.#s=s.length>0&&s.charCodeAt(s.length-1)===47?s.slice(0,-1):s,this.#n=n.#F(t,n.#I),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type"),this.#h=new U}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=m;static#I={body:void 0,cache:le.NO_STORE,credentials:n.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":A.toString(),accept:A.toString()}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:n.RequestMode.CORS,priority:n.RequestPriority.AUTO,redirect:n.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:n.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,s){let r=n.#O.subscribe(e,t,s);return n.#p[e]=(n.#p[e]??0)+1,r}static unregister(e){let t=n.#O.unsubscribe(e);if(t){let s=e.eventName,r=(n.#p[s]??1)-1;r<=0?delete n.#p[s]:n.#p[s]=r}return t}static abortAll(){for(let e of this.#g)e.abort(N());this.#g.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],s=new Array(e.length);for(let r=0;r<e.length;r++){let o=new AbortController;t.push(o),s[r]=e[r](o.signal)}try{return await Promise.race(s)}finally{for(let r of t)r.abort()}}static registerContentTypeHandler(e,t){n.#q.unshift([e,t]),n.#d.clear()}static unregisterContentTypeHandler(e){let t=n.#q.findIndex(([s])=>s===e);return t===-1?!1:(n.#q.splice(t,1),n.#d.clear(),!0)}static addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;t&&(n.#c.beforeRequest.push(...t),n.#R.beforeRequest+=t.length),s&&(n.#c.afterResponse.push(...s),n.#R.afterResponse+=s.length),r&&(n.#c.beforeError.push(...r),n.#R.beforeError+=r.length)}static clearHooks(){n.#c={beforeRequest:[],afterResponse:[],beforeError:[]},n.#R.beforeRequest=0,n.#R.afterResponse=0,n.#R.beforeError=0}static unregisterAll(){n.abortAll(),n.#O=new U,n.#p=Object.create(null),n.clearHooks(),n.#E.clear()}get baseUrl(){return this.#e}register(e,t,s){let r=this.#h.subscribe(e,t,s);return this.#u[e]=(this.#u[e]??0)+1,r}unregister(e){let t=this.#h.unsubscribe(e);if(t){let s=e.eventName,r=(this.#u[s]??1)-1;r<=0?delete this.#u[s]:this.#u[s]=r}return t}addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;return t&&(this.#a.beforeRequest.push(...t),this.#f.beforeRequest+=t.length),s&&(this.#a.afterResponse.push(...s),this.#f.afterResponse+=s.length),r&&(this.#a.beforeError.push(...r),this.#f.beforeError+=r.length),this}clearHooks(){return this.#a.beforeRequest.length=0,this.#a.afterResponse.length=0,this.#a.beforeError.length=0,this.#f.beforeRequest=0,this.#f.afterResponse=0,this.#f.beforeError=0,this}configure({headers:e,searchParams:t,hooks:s,...r}){return e&&(n.#B(this.#n.headers,e),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type")),t&&n.#b(this.#n.searchParams,t),Object.assign(this.#n,r),s&&this.addHooks(s),this}destroy(){this.clearHooks(),this.#h.destroy();for(let e in this.#u)delete this.#u[e]}async get(e,t){return this.#i(e,t)}async post(e,t,s){return this.#S("POST",e,t,s)}async put(e,t,s){return this.#S("PUT",e,t,s)}async patch(e,t,s){return this.#S("PATCH",e,t,s)}async delete(e,t,s){return this.#S("DELETE",e,t,s)}async head(e,t){return this.#A(e,t,{method:"HEAD"})}async options(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{method:"OPTIONS"}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s);d=await this.#v(d,r,i?.afterResponse);let u=d.headers.get("allow"),l;if(u){let c=u.split(",");l=new Array(c.length);for(let f=0,R=c.length;f<R;f++)l[f]=c[f].trim()}return this.#r({name:m.SUCCESS,data:l,global:t.global}),o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{}),r=s.requestOptions.unwrap!==!1;try{let o=await this.#y(e,s);return this.#r({name:m.SUCCESS,data:o,global:t.global}),r?o:[!0,o]}catch(o){if(!r)return[!1,o];throw o}}async getJson(e,t){return this.#i(e,t,{headers:{accept:`${h.JSON}`}},H)}async getXml(e,t){return this.#i(e,t,{headers:{accept:`${h.XML}`}},C)}async getHtml(e,t,s){let r=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},ne);return Array.isArray(r)?r:s&&r?r.querySelector(s):r}async getHtmlFragment(e,t,s){let r=(g(e)?e:t)?.allowScripts===!0,o=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},r?Oe:Te);return Array.isArray(o)?o:s&&o?o.querySelector(s):o}async getScript(e,t){return this.#i(e,t,{headers:{accept:`${h.JAVA_SCRIPT}`}},Q)}async getStylesheet(e,t){return this.#i(e,t,{headers:{accept:`${h.CSS}`}},_)}async getBlob(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},ye)}async getImage(e,t){return this.#i(e,t,{headers:{accept:"image/*"}},ee)}async getBuffer(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},be)}async getStream(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},te)}async getEventStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${h.EVENT_STREAM}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:m.SUCCESS,data:u,global:s.global});let l=qe(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:"GET",headers:{accept:`${h.NDJSON}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:m.SUCCESS,data:u,global:s.global});let l=we(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async#i(e,t,s={},r){return s.method="GET",s.body=void 0,this.#A(e,t,s,r)}async#y(e,t){let{signalController:s,requestOptions:r,global:o}=t;n.#g.add(s);let i=n.#N(r.retry),a=r.method??"GET",d=i.limit>0&&i.methods.includes(a),u=r.dedupe===!0&&(a==="GET"||a==="HEAD"),l=performance.now();try{let c=n.#l(this,e,r.searchParams),f;if(u){f=`${a}:${c.href}`;let x=n.#E.get(f);if(x)return(await x).clone()}let R=r.onUploadProgress,p=r.body;R&&p!=null&&(r.duplex="half");let y=this.#M(c,r,e,a,d,i,p,R,l,o);if(u){n.#E.set(f,y);try{return n.#x(await y,r)}finally{n.#E.delete(f)}}return n.#x(await y,r)}finally{if(n.#g.delete(s.destroy()),!r.signal?.aborted){let c=performance.now();this.#r({name:m.COMPLETE,data:{timing:{start:l,end:c,duration:c-l}},global:o}),n.#g.size===0&&this.#r({name:m.ALL_COMPLETE,global:o})}}}async#M(e,t,s,r,o,i,a,d,u,l){let c=0;for(;;)try{d&&await n.#U(t,a,d);let f=await fetch(e,t);if(!f.ok){if(o&&c<i.limit&&i.statusCodes.includes(f.status)){c++,this.#r({name:m.RETRY,data:{attempt:c,status:f.status,method:r,path:s,timing:n.#w(u)},global:l}),await n.#k(i,c);continue}let R;if(t.captureErrorBody!==!1)try{R=await f.text()}catch{}throw await this.#H(s,f,{entity:R,url:e,method:r,timing:n.#w(u)},t)}return f}catch(f){if(f instanceof O)throw f;if(o&&c<i.limit){c++,this.#r({name:m.RETRY,data:{attempt:c,error:f.message,method:r,path:s,timing:n.#w(u)},global:l}),await n.#k(i,c);continue}throw await this.#H(s,void 0,{cause:f,url:e,method:r,timing:n.#w(u)},t)}}static async#U(e,t,s){if(t==null)return;let r=null;if(typeof t=="string")r=new TextEncoder().encode(t);else if(t instanceof Blob)r=new Uint8Array(await t.arrayBuffer());else if(Be(t))r=new Uint8Array(t);else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(!(t instanceof ReadableStream))return;let o=r?r.byteLength:null,i=r?new ReadableStream({start(u){u.enqueue(r),u.close()}}):t,a=0,d=new TransformStream({transform(u,l){a+=u.byteLength,s({loaded:a,total:o,percentage:o!==null&&o>0?Math.round(a/o*100):null}),l.enqueue(u)}});e.body=i.pipeThrough(d)}static#x(e,t){let s=t.onDownloadProgress;if(!s||!e.body)return e;let r=e.headers.get("content-length"),o=r?parseInt(r,10):null,i=0,a=new TransformStream({transform(d,u){i+=d.byteLength,s({loaded:i,total:o,percentage:o!==null&&o>0?Math.round(i/o*100):null}),u.enqueue(d)}});return new Response(e.body.pipeThrough(a),{status:e.status,statusText:e.statusText,headers:e.headers})}static#w(e){let t=performance.now();return{start:e,end:t,duration:t-e}}static#N(e){if(e===void 0)return n.#L;if(typeof e=="number")return{limit:e,statusCodes:K,methods:Y,delay:D,backoffFactor:F};let t=n.#C.get(e);if(t!==void 0)return t;let s={limit:e.limit??0,statusCodes:e.statusCodes??K,methods:e.methods??Y,delay:e.delay??D,backoffFactor:e.backoffFactor??F};return n.#C.set(e,s),s}static#k(e,t){let s=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(r=>setTimeout(r,s))}#S(e,t,s,r,o){let[i,a,d]=z(t)?[t,s,r]:[void 0,t,s],u=d!==void 0?Object.assign({},d,{body:a,method:e}):{body:a,method:e};return this.#A(i,u,{},o)}async#P(e,t,s,r){let o=n.#c.beforeRequest,i=this.#a.beforeRequest,a=r===void 0?0:r.length;if(o.length===0&&i.length===0&&a===0)return t;for(let d=0,u=o.length;d<u;d++){let l=await o[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0,u=i.length;d<u;d++){let l=await i[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0;d<a;d++){let u=await r[d](e,t);u&&(Object.assign(e,u),u.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}return t}async#v(e,t,s){let r=n.#c.afterResponse,o=this.#a.afterResponse,i=s===void 0?0:s.length;if(r.length===0&&o.length===0&&i===0)return e;for(let a=0,d=r.length;a<d;a++){let u=await r[a](e,t);u&&(e=u)}for(let a=0,d=o.length;a<d;a++){let u=await o[a](e,t);u&&(e=u)}for(let a=0;a<i;a++){let d=await s[a](e,t);d&&(e=d)}return e}async#D(e,t){let s=n.#c.beforeError,r=this.#a.beforeError,o=t===void 0?0:t.length;if(s.length===0&&r.length===0&&o===0)return e;for(let i=0,a=s.length;i<a;i++){let d=await s[i](e);d instanceof O&&(e=d)}for(let i=0,a=r.length;i<a;i++){let d=await r[i](e);d instanceof O&&(e=d)}for(let i=0;i<o;i++){let a=await t[i](e);a instanceof O&&(e=a)}return e}async#A(e,t={},s={},r){g(e)&&([e,t]=[void 0,e]);let o=this.#T(t,s),{requestOptions:i}=o,a=i.unwrap!==!1,d=i.hooks;try{let u=n.#l(this,e,i.searchParams);await this.#P(i,u,e,d?.beforeRequest);let l=await this.#y(e,o);l=await this.#v(l,i,d?.afterResponse);try{!r&&l.status!==204&&(r=this.#G(l.headers.get("content-type")));let c=await r?.(l);return this.#r({name:m.SUCCESS,data:c,global:o.global}),a?c:[!0,c]}catch(c){throw await this.#H(e,l,{cause:c},i)}}catch(u){if(!a)return[!1,u];throw u}}static#F({headers:e,searchParams:t,...s},{headers:r,searchParams:o,...i}){return r=n.#B(new Headers,e,r),o=n.#b(new URLSearchParams,t,o),{...X(i,s),headers:r,searchParams:o}}static#B(e,...t){for(let s of t)if(s!==void 0)if(s instanceof Headers)s.forEach((r,o)=>e.set(o,r));else if(Array.isArray(s))for(let[r,o]of s)e.set(r,o);else{let r=Object.keys(s);for(let o=0,i=r.length;o<i;o++){let a=r[o],d=s[a];d!==void 0&&e.set(a,d)}}return e}static#b(e,...t){for(let s of t)if(s!==void 0)if(s instanceof URLSearchParams)s.forEach((r,o)=>e.set(o,r));else if(z(s)||Array.isArray(s))for(let[r,o]of new URLSearchParams(s))e.set(r,o);else{let r=Object.keys(s);for(let o=0;o<r.length;o++){let i=r[o],a=s[i];a!==void 0&&e.set(i,typeof a=="string"?a:String(a))}}return e}#T(e,t){let s=e.headers,r=e.searchParams,o=e.body,i=t.headers,a=t.searchParams,d=t.method??e.method??this.#n.method??"GET",u=Se(d),l;!u&&s===void 0&&i===void 0?l=new Headers(this.#o):(l=new Headers(this.#n.headers),(s!==void 0||i!==void 0)&&n.#B(l,s,i));let c=this.#n.searchParams,f=c!==void 0&&c.size>0,R;!f&&r===void 0&&a===void 0?R=new URLSearchParams:(R=new URLSearchParams(c),(r!==void 0||a!==void 0)&&n.#b(R,r,a));let p=Object.assign({},this.#n,e,t);if(p.headers=l,p.searchParams=R,u)if(Pe(o))p.body=o,l.delete("content-type");else{let T=this.#n.body,S=g(T)&&g(o)?X(T,o):o!==void 0?o:T,P=l.get("content-type"),Ce=P!==null&&P.includes("json");p.body=Ce&&g(S)?Ae(S):S}else p.body instanceof URLSearchParams&&n.#b(R,p.body),p.body=void 0,(s!==void 0||i!==void 0)&&l.delete("content-type");let y=p.signal,x=p.timeout,k=p.global??!1,V=p.xsrf;if(V){let{cookieName:T,headerName:S}=typeof V=="object"?V:{},P=ve(T??ue);P&&l.set(S??de,P)}let re=new j({signal:y,timeout:x}).onAbort(T=>this.#r({name:m.ABORTED,event:T,global:k})).onTimeout(T=>this.#r({name:m.TIMEOUT,event:T,global:k}));return p.signal=re.signal,this.#r({name:m.CONFIGURED,data:p,global:k}),{signalController:re,requestOptions:p,global:k}}static#j(e){if(e instanceof URL)return e;if(!z(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static#J(e){if(e===null)return;let t=n.#m.get(e);return t!==void 0||(t=M.parse(e)??void 0,t!==void 0&&(n.#m.size>=100&&n.#m.delete(n.#m.keys().next().value),n.#m.set(e,t))),t}static#l(e,t,s){let r;if(e instanceof URL){let o=e.pathname,i=o.charCodeAt(o.length-1)===47?o.slice(0,-1):o;r=t?new URL(`${i}${t}`,e.origin):new URL(e)}else r=t?new URL(`${e.#s}${t}`,e.#t):new URL(e.#e);return s&&n.#b(r.searchParams,s),r}static#$(e,{status:t,statusText:s}=new Response){switch(e){case w.ABORT:return Re;case w.TIMEOUT:return he;default:return t>=400?new E(t,s):fe}}async#H(e,t,{cause:s,entity:r,url:o,method:i,timing:a}={},d){let u=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,l=new O(n.#$(s?.name,t),{message:u,cause:s,entity:r,url:o,method:i,timing:a});return l=await this.#D(l,d?.hooks?.beforeError),this.#r({name:m.ERROR,data:l}),l}#r({name:e,event:t,data:s,global:r=!0}){let o=r&&(n.#p[e]??0)>0,i=(this.#u[e]??0)>0;if(!o&&!i)return;let a=t??new CustomEvent(e);o&&n.#O.publish(e,a,s),i&&this.#h.publish(e,a,s)}#G(e){if(!e)return;let t=n.#d.get(e);if(t!==void 0)return t===null?void 0:t;let s=n.#J(e);if(!s){n.#d.set(e,null);return}let r=n.#q;for(let i=0,a=r.length;i<a;i++){let d=r[i];if(s.matches(d[0])){let u=d[1];return n.#d.set(e,u),u}}let o=s.subtype;if(o.endsWith("+json"))return n.#d.set(e,H),H;if(o.endsWith("+xml"))return n.#d.set(e,C),C;n.#d.set(e,null)}get[Symbol.toStringTag](){return"Transportr"}};export{He as Transportr};
9
8
  //# sourceMappingURL=transportr.js.map