@d1g1tal/transportr 3.1.5 → 3.2.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.
@@ -1,4 +1,4 @@
1
- var __mod = (() => {
1
+ (() => {
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,13 +6,13 @@ var __mod = (() => {
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b2) => (typeof require !== "undefined" ? require : a)[b2]
9
+ get: (a, b3) => (typeof require !== "undefined" ? require : a)[b3]
10
10
  }) : x)(function(x) {
11
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
12
12
  throw Error('Dynamic require of "' + x + '" is not supported');
13
13
  });
14
- var __esm = (fn, res) => function __init() {
15
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
14
+ var __esm = (fn2, res) => function __init() {
15
+ return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res;
16
16
  };
17
17
  var __export = (target, all) => {
18
18
  for (var name in all)
@@ -34,1136 +34,462 @@ var __mod = (() => {
34
34
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
35
  mod
36
36
  ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
37
 
39
- // node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/dist/purify.es.mjs
40
- var purify_es_exports = {};
41
- __export(purify_es_exports, {
42
- default: () => purify
38
+ // iife:/home/runner/work/transportr/transportr/dist/OP3JQ447.js
39
+ var OP3JQ447_exports = {};
40
+ __export(OP3JQ447_exports, {
41
+ default: () => mn
43
42
  });
44
- function unapply(func) {
45
- return function(thisArg) {
46
- if (thisArg instanceof RegExp) {
47
- thisArg.lastIndex = 0;
48
- }
49
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
50
- args[_key3 - 1] = arguments[_key3];
51
- }
52
- return apply(func, thisArg, args);
43
+ function R(s2) {
44
+ return function(o) {
45
+ o instanceof RegExp && (o.lastIndex = 0);
46
+ for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++) a[c - 1] = arguments[c];
47
+ return ve(s2, o, a);
53
48
  };
54
49
  }
55
- function unconstruct(Func) {
50
+ function Zt(s2) {
56
51
  return function() {
57
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
58
- args[_key4] = arguments[_key4];
59
- }
60
- return construct(Func, args);
52
+ for (var o = arguments.length, l = new Array(o), a = 0; a < o; a++) l[a] = arguments[a];
53
+ return Ue(s2, l);
61
54
  };
62
55
  }
63
- function addToSet(set, array) {
64
- let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
65
- if (setPrototypeOf) {
66
- setPrototypeOf(set, null);
67
- }
68
- let l2 = array.length;
69
- while (l2--) {
70
- let element = array[l2];
71
- if (typeof element === "string") {
72
- const lcElement = transformCaseFunc(element);
73
- if (lcElement !== element) {
74
- if (!isFrozen(array)) {
75
- array[l2] = lcElement;
76
- }
77
- element = lcElement;
78
- }
79
- }
80
- set[element] = true;
81
- }
82
- return set;
56
+ function r(s2, o) {
57
+ let l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : pe;
58
+ ct && ct(s2, null);
59
+ let a = o.length;
60
+ for (; a--; ) {
61
+ let c = o[a];
62
+ if (typeof c == "string") {
63
+ let D2 = l(c);
64
+ D2 !== c && (Yt(o) || (o[a] = D2), c = D2);
65
+ }
66
+ s2[c] = true;
67
+ }
68
+ return s2;
83
69
  }
84
- function cleanArray(array) {
85
- for (let index = 0; index < array.length; index++) {
86
- const isPropertyExist = objectHasOwnProperty(array, index);
87
- if (!isPropertyExist) {
88
- array[index] = null;
89
- }
90
- }
91
- return array;
70
+ function Jt(s2) {
71
+ for (let o = 0; o < s2.length; o++) y(s2, o) || (s2[o] = null);
72
+ return s2;
92
73
  }
93
- function clone(object) {
94
- const newObject = create(null);
95
- for (const [property, value] of entries(object)) {
96
- const isPropertyExist = objectHasOwnProperty(object, property);
97
- if (isPropertyExist) {
98
- if (Array.isArray(value)) {
99
- newObject[property] = cleanArray(value);
100
- } else if (value && typeof value === "object" && value.constructor === Object) {
101
- newObject[property] = clone(value);
102
- } else {
103
- newObject[property] = value;
104
- }
105
- }
106
- }
107
- return newObject;
74
+ function C(s2) {
75
+ let o = me(null);
76
+ for (let [l, a] of _t(s2)) y(s2, l) && (Array.isArray(a) ? o[l] = Jt(a) : a && typeof a == "object" && a.constructor === Object ? o[l] = C(a) : o[l] = a);
77
+ return o;
108
78
  }
109
- function lookupGetter(object, prop) {
110
- while (object !== null) {
111
- const desc = getOwnPropertyDescriptor(object, prop);
112
- if (desc) {
113
- if (desc.get) {
114
- return unapply(desc.get);
115
- }
116
- if (typeof desc.value === "function") {
117
- return unapply(desc.value);
118
- }
79
+ function J(s2, o) {
80
+ for (; s2 !== null; ) {
81
+ let a = jt(s2, o);
82
+ if (a) {
83
+ if (a.get) return R(a.get);
84
+ if (typeof a.value == "function") return R(a.value);
119
85
  }
120
- object = getPrototypeOf(object);
86
+ s2 = Xt(s2);
121
87
  }
122
- function fallbackValue() {
88
+ function l() {
123
89
  return null;
124
90
  }
125
- return fallbackValue;
91
+ return l;
126
92
  }
127
- function createDOMPurify() {
128
- let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
129
- const DOMPurify = (root) => createDOMPurify(root);
130
- DOMPurify.version = "3.3.3";
131
- DOMPurify.removed = [];
132
- if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
133
- DOMPurify.isSupported = false;
134
- return DOMPurify;
135
- }
136
- let {
137
- document: document2
138
- } = window2;
139
- const originalDocument = document2;
140
- const currentScript = originalDocument.currentScript;
141
- const {
142
- DocumentFragment: DocumentFragment2,
143
- HTMLTemplateElement,
144
- Node,
145
- Element,
146
- NodeFilter,
147
- NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
148
- HTMLFormElement,
149
- DOMParser: DOMParser2,
150
- trustedTypes
151
- } = window2;
152
- const ElementPrototype = Element.prototype;
153
- const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
154
- const remove = lookupGetter(ElementPrototype, "remove");
155
- const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
156
- const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
157
- const getParentNode = lookupGetter(ElementPrototype, "parentNode");
158
- if (typeof HTMLTemplateElement === "function") {
159
- const template = document2.createElement("template");
160
- if (template.content && template.content.ownerDocument) {
161
- document2 = template.content.ownerDocument;
162
- }
163
- }
164
- let trustedTypesPolicy;
165
- let emptyHTML = "";
166
- const {
167
- implementation,
168
- createNodeIterator,
169
- createDocumentFragment,
170
- getElementsByTagName
171
- } = document2;
172
- const {
173
- importNode
174
- } = originalDocument;
175
- let hooks = _createHooksMap();
176
- DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
177
- const {
178
- MUSTACHE_EXPR: MUSTACHE_EXPR2,
179
- ERB_EXPR: ERB_EXPR2,
180
- TMPLIT_EXPR: TMPLIT_EXPR2,
181
- DATA_ATTR: DATA_ATTR2,
182
- ARIA_ATTR: ARIA_ATTR2,
183
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
184
- ATTR_WHITESPACE: ATTR_WHITESPACE2,
185
- CUSTOM_ELEMENT: CUSTOM_ELEMENT2
186
- } = EXPRESSIONS;
187
- let {
188
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
189
- } = EXPRESSIONS;
190
- let ALLOWED_TAGS = null;
191
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
192
- let ALLOWED_ATTR = null;
193
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
194
- let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
195
- tagNameCheck: {
196
- writable: true,
197
- configurable: false,
198
- enumerable: true,
199
- value: null
200
- },
201
- attributeNameCheck: {
202
- writable: true,
203
- configurable: false,
204
- enumerable: true,
205
- value: null
206
- },
207
- allowCustomizedBuiltInElements: {
208
- writable: true,
209
- configurable: false,
210
- enumerable: true,
211
- value: false
212
- }
213
- }));
214
- let FORBID_TAGS = null;
215
- let FORBID_ATTR = null;
216
- const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
217
- tagCheck: {
218
- writable: true,
219
- configurable: false,
220
- enumerable: true,
221
- value: null
222
- },
223
- attributeCheck: {
224
- writable: true,
225
- configurable: false,
226
- enumerable: true,
227
- value: null
228
- }
229
- }));
230
- let ALLOW_ARIA_ATTR = true;
231
- let ALLOW_DATA_ATTR = true;
232
- let ALLOW_UNKNOWN_PROTOCOLS = false;
233
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
234
- let SAFE_FOR_TEMPLATES = false;
235
- let SAFE_FOR_XML = true;
236
- let WHOLE_DOCUMENT = false;
237
- let SET_CONFIG = false;
238
- let FORCE_BODY = false;
239
- let RETURN_DOM = false;
240
- let RETURN_DOM_FRAGMENT = false;
241
- let RETURN_TRUSTED_TYPE = false;
242
- let SANITIZE_DOM = true;
243
- let SANITIZE_NAMED_PROPS = false;
244
- const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
245
- let KEEP_CONTENT = true;
246
- let IN_PLACE = false;
247
- let USE_PROFILES = {};
248
- let FORBID_CONTENTS = null;
249
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
250
- let DATA_URI_TAGS = null;
251
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
252
- let URI_SAFE_ATTRIBUTES = null;
253
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
254
- const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
255
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
256
- const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
257
- let NAMESPACE = HTML_NAMESPACE;
258
- let IS_EMPTY_INPUT = false;
259
- let ALLOWED_NAMESPACES = null;
260
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
261
- let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
262
- let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
263
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
264
- let PARSER_MEDIA_TYPE = null;
265
- const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
266
- const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
267
- let transformCaseFunc = null;
268
- let CONFIG = null;
269
- const formElement = document2.createElement("form");
270
- const isRegexOrFunction = function isRegexOrFunction2(testValue) {
271
- return testValue instanceof RegExp || testValue instanceof Function;
272
- };
273
- const _parseConfig = function _parseConfig2() {
274
- let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
275
- if (CONFIG && CONFIG === cfg) {
276
- return;
277
- }
278
- if (!cfg || typeof cfg !== "object") {
279
- cfg = {};
280
- }
281
- cfg = clone(cfg);
282
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
283
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
284
- transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
285
- ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
286
- ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
287
- ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
288
- URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
289
- DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
290
- FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
291
- FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
292
- FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
293
- USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
294
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
295
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
296
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
297
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
298
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
299
- SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
300
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
301
- RETURN_DOM = cfg.RETURN_DOM || false;
302
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
303
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
304
- FORCE_BODY = cfg.FORCE_BODY || false;
305
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
306
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
307
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
308
- IN_PLACE = cfg.IN_PLACE || false;
309
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
310
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
311
- MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
312
- HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
313
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
314
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
315
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
316
- }
317
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
318
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
319
- }
320
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
321
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
322
- }
323
- if (SAFE_FOR_TEMPLATES) {
324
- ALLOW_DATA_ATTR = false;
325
- }
326
- if (RETURN_DOM_FRAGMENT) {
327
- RETURN_DOM = true;
328
- }
329
- if (USE_PROFILES) {
330
- ALLOWED_TAGS = addToSet({}, text);
331
- ALLOWED_ATTR = create(null);
332
- if (USE_PROFILES.html === true) {
333
- addToSet(ALLOWED_TAGS, html$1);
334
- addToSet(ALLOWED_ATTR, html);
335
- }
336
- if (USE_PROFILES.svg === true) {
337
- addToSet(ALLOWED_TAGS, svg$1);
338
- addToSet(ALLOWED_ATTR, svg);
339
- addToSet(ALLOWED_ATTR, xml);
340
- }
341
- if (USE_PROFILES.svgFilters === true) {
342
- addToSet(ALLOWED_TAGS, svgFilters);
343
- addToSet(ALLOWED_ATTR, svg);
344
- addToSet(ALLOWED_ATTR, xml);
345
- }
346
- if (USE_PROFILES.mathMl === true) {
347
- addToSet(ALLOWED_TAGS, mathMl$1);
348
- addToSet(ALLOWED_ATTR, mathMl);
349
- addToSet(ALLOWED_ATTR, xml);
350
- }
351
- }
352
- if (!objectHasOwnProperty(cfg, "ADD_TAGS")) {
353
- EXTRA_ELEMENT_HANDLING.tagCheck = null;
354
- }
355
- if (!objectHasOwnProperty(cfg, "ADD_ATTR")) {
356
- EXTRA_ELEMENT_HANDLING.attributeCheck = null;
357
- }
358
- if (cfg.ADD_TAGS) {
359
- if (typeof cfg.ADD_TAGS === "function") {
360
- EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
361
- } else {
362
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
363
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
364
- }
365
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
366
- }
367
- }
368
- if (cfg.ADD_ATTR) {
369
- if (typeof cfg.ADD_ATTR === "function") {
370
- EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
371
- } else {
372
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
373
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
374
- }
375
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
376
- }
377
- }
378
- if (cfg.ADD_URI_SAFE_ATTR) {
379
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
380
- }
381
- if (cfg.FORBID_CONTENTS) {
382
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
383
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
384
- }
385
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
386
- }
387
- if (cfg.ADD_FORBID_CONTENTS) {
388
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
389
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
390
- }
391
- addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
392
- }
393
- if (KEEP_CONTENT) {
394
- ALLOWED_TAGS["#text"] = true;
395
- }
396
- if (WHOLE_DOCUMENT) {
397
- addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
398
- }
399
- if (ALLOWED_TAGS.table) {
400
- addToSet(ALLOWED_TAGS, ["tbody"]);
401
- delete FORBID_TAGS.tbody;
402
- }
403
- if (cfg.TRUSTED_TYPES_POLICY) {
404
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
405
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
406
- }
407
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
408
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
409
- }
410
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
411
- emptyHTML = trustedTypesPolicy.createHTML("");
412
- } else {
413
- if (trustedTypesPolicy === void 0) {
414
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
415
- }
416
- if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
417
- emptyHTML = trustedTypesPolicy.createHTML("");
418
- }
419
- }
420
- if (freeze) {
421
- freeze(cfg);
422
- }
423
- CONFIG = cfg;
424
- };
425
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
426
- const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
427
- const _checkValidNamespace = function _checkValidNamespace2(element) {
428
- let parent = getParentNode(element);
429
- if (!parent || !parent.tagName) {
430
- parent = {
431
- namespaceURI: NAMESPACE,
432
- tagName: "template"
433
- };
434
- }
435
- const tagName = stringToLowerCase(element.tagName);
436
- const parentTagName = stringToLowerCase(parent.tagName);
437
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
438
- return false;
439
- }
440
- if (element.namespaceURI === SVG_NAMESPACE) {
441
- if (parent.namespaceURI === HTML_NAMESPACE) {
442
- return tagName === "svg";
443
- }
444
- if (parent.namespaceURI === MATHML_NAMESPACE) {
445
- return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
446
- }
447
- return Boolean(ALL_SVG_TAGS[tagName]);
448
- }
449
- if (element.namespaceURI === MATHML_NAMESPACE) {
450
- if (parent.namespaceURI === HTML_NAMESPACE) {
451
- return tagName === "math";
452
- }
453
- if (parent.namespaceURI === SVG_NAMESPACE) {
454
- return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
455
- }
456
- return Boolean(ALL_MATHML_TAGS[tagName]);
457
- }
458
- if (element.namespaceURI === HTML_NAMESPACE) {
459
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
460
- return false;
461
- }
462
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
463
- return false;
464
- }
465
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
466
- }
467
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
468
- return true;
469
- }
470
- return false;
471
- };
472
- const _forceRemove = function _forceRemove2(node) {
473
- arrayPush(DOMPurify.removed, {
474
- element: node
475
- });
93
+ function ht() {
94
+ let s2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : fn(), o = (i) => ht(i);
95
+ if (o.version = "3.3.3", o.removed = [], !s2 || !s2.document || s2.document.nodeType !== Q.document || !s2.Element) return o.isSupported = false, o;
96
+ let { document: l } = s2, a = l, c = a.currentScript, { DocumentFragment: D2, HTMLTemplateElement: v2, Node: Te2, Element: Fe, NodeFilter: B2, NamedNodeMap: St = s2.NamedNodeMap || s2.MozNamedAttrMap, HTMLFormElement: Rt, DOMParser: Dt, trustedTypes: ee2 } = s2, Y2 = Fe.prototype, Ot = J(Y2, "cloneNode"), yt = J(Y2, "remove"), bt = J(Y2, "nextSibling"), Lt = J(Y2, "childNodes"), te2 = J(Y2, "parentNode");
97
+ if (typeof v2 == "function") {
98
+ let i = l.createElement("template");
99
+ i.content && i.content.ownerDocument && (l = i.content.ownerDocument);
100
+ }
101
+ let g, X2 = "", { implementation: de2, createNodeIterator: Nt, createDocumentFragment: Ct, getElementsByTagName: It } = l, { importNode: Mt } = a, A2 = Et();
102
+ o.isSupported = typeof _t == "function" && typeof te2 == "function" && de2 && de2.createHTMLDocument !== void 0;
103
+ let { MUSTACHE_EXPR: Ee2, ERB_EXPR: _e2, TMPLIT_EXPR: ge2, DATA_ATTR: wt, ARIA_ATTR: xt, IS_SCRIPT_OR_DATA: Pt, ATTR_WHITESPACE: He2, CUSTOM_ELEMENT: kt } = dt, { IS_ALLOWED_URI: ze } = dt, T2 = null, Ge = r({}, [...ut, ...we, ...xe, ...Pe, ...mt]), d = null, We = r({}, [...pt, ...ke, ...Tt, ...ue]), u = Object.seal(me(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false } })), j2 = null, ne = null, x = Object.seal(me(null, { tagCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeCheck: { writable: true, configurable: false, enumerable: true, value: null } })), Be = true, Ae2 = true, Ye = false, Xe = true, U2 = false, oe = true, P = false, he2 = false, Se2 = false, F2 = false, ie2 = false, ae2 = false, je2 = true, Ve = false, vt = "user-content-", Re2 = true, V2 = false, H2 = {}, L2 = null, De2 = r({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]), $e = null, qe2 = r({}, ["audio", "video", "img", "source", "image", "track"]), Oe2 = null, Ke = r({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), re = "http://www.w3.org/1998/Math/MathML", se2 = "http://www.w3.org/2000/svg", I2 = "http://www.w3.org/1999/xhtml", z2 = I2, ye2 = false, be2 = null, Ut = r({}, [re, se2, I2], Ie), le2 = r({}, ["mi", "mo", "mn", "ms", "mtext"]), ce2 = r({}, ["annotation-xml"]), Ft = r({}, ["title", "style", "font", "a", "script"]), $2 = null, Ht = ["application/xhtml+xml", "text/html"], zt = "text/html", p = null, G2 = null, Gt = l.createElement("form"), Ze = function(e) {
104
+ return e instanceof RegExp || e instanceof Function;
105
+ }, Le2 = function() {
106
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
107
+ if (!(G2 && G2 === e)) {
108
+ if ((!e || typeof e != "object") && (e = {}), e = C(e), $2 = Ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? zt : e.PARSER_MEDIA_TYPE, p = $2 === "application/xhtml+xml" ? Ie : pe, T2 = y(e, "ALLOWED_TAGS") ? r({}, e.ALLOWED_TAGS, p) : Ge, d = y(e, "ALLOWED_ATTR") ? r({}, e.ALLOWED_ATTR, p) : We, be2 = y(e, "ALLOWED_NAMESPACES") ? r({}, e.ALLOWED_NAMESPACES, Ie) : Ut, Oe2 = y(e, "ADD_URI_SAFE_ATTR") ? r(C(Ke), e.ADD_URI_SAFE_ATTR, p) : Ke, $e = y(e, "ADD_DATA_URI_TAGS") ? r(C(qe2), e.ADD_DATA_URI_TAGS, p) : qe2, L2 = y(e, "FORBID_CONTENTS") ? r({}, e.FORBID_CONTENTS, p) : De2, j2 = y(e, "FORBID_TAGS") ? r({}, e.FORBID_TAGS, p) : C({}), ne = y(e, "FORBID_ATTR") ? r({}, e.FORBID_ATTR, p) : C({}), H2 = y(e, "USE_PROFILES") ? e.USE_PROFILES : false, Be = e.ALLOW_ARIA_ATTR !== false, Ae2 = e.ALLOW_DATA_ATTR !== false, Ye = e.ALLOW_UNKNOWN_PROTOCOLS || false, Xe = e.ALLOW_SELF_CLOSE_IN_ATTR !== false, U2 = e.SAFE_FOR_TEMPLATES || false, oe = e.SAFE_FOR_XML !== false, P = e.WHOLE_DOCUMENT || false, F2 = e.RETURN_DOM || false, ie2 = e.RETURN_DOM_FRAGMENT || false, ae2 = e.RETURN_TRUSTED_TYPE || false, Se2 = e.FORCE_BODY || false, je2 = e.SANITIZE_DOM !== false, Ve = e.SANITIZE_NAMED_PROPS || false, Re2 = e.KEEP_CONTENT !== false, V2 = e.IN_PLACE || false, ze = e.ALLOWED_URI_REGEXP || gt, z2 = e.NAMESPACE || I2, le2 = e.MATHML_TEXT_INTEGRATION_POINTS || le2, ce2 = e.HTML_INTEGRATION_POINTS || ce2, u = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && Ze(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (u.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && Ze(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (u.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (u.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), U2 && (Ae2 = false), ie2 && (F2 = true), H2 && (T2 = r({}, mt), d = me(null), H2.html === true && (r(T2, ut), r(d, pt)), H2.svg === true && (r(T2, we), r(d, ke), r(d, ue)), H2.svgFilters === true && (r(T2, xe), r(d, ke), r(d, ue)), H2.mathMl === true && (r(T2, Pe), r(d, Tt), r(d, ue))), y(e, "ADD_TAGS") || (x.tagCheck = null), y(e, "ADD_ATTR") || (x.attributeCheck = null), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? x.tagCheck = e.ADD_TAGS : (T2 === Ge && (T2 = C(T2)), r(T2, e.ADD_TAGS, p))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? x.attributeCheck = e.ADD_ATTR : (d === We && (d = C(d)), r(d, e.ADD_ATTR, p))), e.ADD_URI_SAFE_ATTR && r(Oe2, e.ADD_URI_SAFE_ATTR, p), e.FORBID_CONTENTS && (L2 === De2 && (L2 = C(L2)), r(L2, e.FORBID_CONTENTS, p)), e.ADD_FORBID_CONTENTS && (L2 === De2 && (L2 = C(L2)), r(L2, e.ADD_FORBID_CONTENTS, p)), Re2 && (T2["#text"] = true), P && r(T2, ["html", "head", "body"]), T2.table && (r(T2, ["tbody"]), delete j2.tbody), e.TRUSTED_TYPES_POLICY) {
109
+ if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
110
+ if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
111
+ g = e.TRUSTED_TYPES_POLICY, X2 = g.createHTML("");
112
+ } else g === void 0 && (g = un(ee2, c)), g !== null && typeof X2 == "string" && (X2 = g.createHTML(""));
113
+ S && S(e), G2 = e;
114
+ }
115
+ }, Je = r({}, [...we, ...xe, ...Qt]), Qe = r({}, [...Pe, ...en]), Wt = function(e) {
116
+ let t = te2(e);
117
+ (!t || !t.tagName) && (t = { namespaceURI: z2, tagName: "template" });
118
+ let n = pe(e.tagName), f = pe(t.tagName);
119
+ return be2[e.namespaceURI] ? e.namespaceURI === se2 ? t.namespaceURI === I2 ? n === "svg" : t.namespaceURI === re ? n === "svg" && (f === "annotation-xml" || le2[f]) : !!Je[n] : e.namespaceURI === re ? t.namespaceURI === I2 ? n === "math" : t.namespaceURI === se2 ? n === "math" && ce2[f] : !!Qe[n] : e.namespaceURI === I2 ? t.namespaceURI === se2 && !ce2[f] || t.namespaceURI === re && !le2[f] ? false : !Qe[n] && (Ft[n] || !Je[n]) : !!($2 === "application/xhtml+xml" && be2[e.namespaceURI]) : false;
120
+ }, N2 = function(e) {
121
+ q(o.removed, { element: e });
476
122
  try {
477
- getParentNode(node).removeChild(node);
478
- } catch (_) {
479
- remove(node);
123
+ te2(e).removeChild(e);
124
+ } catch {
125
+ yt(e);
480
126
  }
481
- };
482
- const _removeAttribute = function _removeAttribute2(name, element) {
127
+ }, k2 = function(e, t) {
483
128
  try {
484
- arrayPush(DOMPurify.removed, {
485
- attribute: element.getAttributeNode(name),
486
- from: element
487
- });
488
- } catch (_) {
489
- arrayPush(DOMPurify.removed, {
490
- attribute: null,
491
- from: element
492
- });
493
- }
494
- element.removeAttribute(name);
495
- if (name === "is") {
496
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
497
- try {
498
- _forceRemove(element);
499
- } catch (_) {
500
- }
501
- } else {
502
- try {
503
- element.setAttribute(name, "");
504
- } catch (_) {
505
- }
506
- }
129
+ q(o.removed, { attribute: t.getAttributeNode(e), from: t });
130
+ } catch {
131
+ q(o.removed, { attribute: null, from: t });
507
132
  }
508
- };
509
- const _initDocument = function _initDocument2(dirty) {
510
- let doc = null;
511
- let leadingWhitespace = null;
512
- if (FORCE_BODY) {
513
- dirty = "<remove></remove>" + dirty;
514
- } else {
515
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
516
- leadingWhitespace = matches && matches[0];
133
+ if (t.removeAttribute(e), e === "is") if (F2 || ie2) try {
134
+ N2(t);
135
+ } catch {
517
136
  }
518
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
519
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
137
+ else try {
138
+ t.setAttribute(e, "");
139
+ } catch {
520
140
  }
521
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
522
- if (NAMESPACE === HTML_NAMESPACE) {
523
- try {
524
- doc = new DOMParser2().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
525
- } catch (_) {
526
- }
141
+ }, et = function(e) {
142
+ let t = null, n = null;
143
+ if (Se2) e = "<remove></remove>" + e;
144
+ else {
145
+ let m2 = Me(e, /^[\r\n\t ]+/);
146
+ n = m2 && m2[0];
147
+ }
148
+ $2 === "application/xhtml+xml" && z2 === I2 && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
149
+ let f = g ? g.createHTML(e) : e;
150
+ if (z2 === I2) try {
151
+ t = new Dt().parseFromString(f, $2);
152
+ } catch {
527
153
  }
528
- if (!doc || !doc.documentElement) {
529
- doc = implementation.createDocument(NAMESPACE, "template", null);
154
+ if (!t || !t.documentElement) {
155
+ t = de2.createDocument(z2, "template", null);
530
156
  try {
531
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
532
- } catch (_) {
533
- }
534
- }
535
- const body = doc.body || doc.documentElement;
536
- if (dirty && leadingWhitespace) {
537
- body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
538
- }
539
- if (NAMESPACE === HTML_NAMESPACE) {
540
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
541
- }
542
- return WHOLE_DOCUMENT ? doc.documentElement : body;
543
- };
544
- const _createNodeIterator = function _createNodeIterator2(root) {
545
- return createNodeIterator.call(
546
- root.ownerDocument || root,
547
- root,
548
- // eslint-disable-next-line no-bitwise
549
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
550
- null
551
- );
157
+ t.documentElement.innerHTML = ye2 ? X2 : f;
158
+ } catch {
159
+ }
160
+ }
161
+ let _2 = t.body || t.documentElement;
162
+ return e && n && _2.insertBefore(l.createTextNode(n), _2.childNodes[0] || null), z2 === I2 ? It.call(t, P ? "html" : "body")[0] : P ? t.documentElement : _2;
163
+ }, tt = function(e) {
164
+ return Nt.call(e.ownerDocument || e, e, B2.SHOW_ELEMENT | B2.SHOW_COMMENT | B2.SHOW_TEXT | B2.SHOW_PROCESSING_INSTRUCTION | B2.SHOW_CDATA_SECTION, null);
165
+ }, Ne2 = function(e) {
166
+ return e instanceof Rt && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof St) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
167
+ }, nt = function(e) {
168
+ return typeof Te2 == "function" && e instanceof Te2;
552
169
  };
553
- const _isClobbered = function _isClobbered2(element) {
554
- return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
555
- };
556
- const _isNode = function _isNode2(value) {
557
- return typeof Node === "function" && value instanceof Node;
558
- };
559
- function _executeHooks(hooks2, currentNode, data) {
560
- arrayForEach(hooks2, (hook) => {
561
- hook.call(DOMPurify, currentNode, data, CONFIG);
170
+ function M2(i, e, t) {
171
+ fe(i, (n) => {
172
+ n.call(o, e, t, G2);
562
173
  });
563
174
  }
564
- const _sanitizeElements = function _sanitizeElements2(currentNode) {
565
- let content = null;
566
- _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
567
- if (_isClobbered(currentNode)) {
568
- _forceRemove(currentNode);
569
- return true;
570
- }
571
- const tagName = transformCaseFunc(currentNode.nodeName);
572
- _executeHooks(hooks.uponSanitizeElement, currentNode, {
573
- tagName,
574
- allowedTags: ALLOWED_TAGS
575
- });
576
- if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
577
- _forceRemove(currentNode);
578
- return true;
579
- }
580
- if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
581
- _forceRemove(currentNode);
582
- return true;
583
- }
584
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
585
- _forceRemove(currentNode);
586
- return true;
587
- }
588
- if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {
589
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
590
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
591
- return false;
592
- }
593
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
594
- return false;
175
+ let ot = function(e) {
176
+ let t = null;
177
+ if (M2(A2.beforeSanitizeElements, e, null), Ne2(e)) return N2(e), true;
178
+ let n = p(e.nodeName);
179
+ if (M2(A2.uponSanitizeElement, e, { tagName: n, allowedTags: T2 }), oe && e.hasChildNodes() && !nt(e.firstElementChild) && h(/<[/\w!]/g, e.innerHTML) && h(/<[/\w!]/g, e.textContent) || e.nodeType === Q.progressingInstruction || oe && e.nodeType === Q.comment && h(/<[/\w]/g, e.data)) return N2(e), true;
180
+ if (!(x.tagCheck instanceof Function && x.tagCheck(n)) && (!T2[n] || j2[n])) {
181
+ if (!j2[n] && at(n) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n))) return false;
182
+ if (Re2 && !L2[n]) {
183
+ let f = te2(e) || e.parentNode, _2 = Lt(e) || e.childNodes;
184
+ if (_2 && f) {
185
+ let m2 = _2.length;
186
+ for (let O = m2 - 1; O >= 0; --O) {
187
+ let w2 = Ot(_2[O], true);
188
+ w2.__removalCount = (e.__removalCount || 0) + 1, f.insertBefore(w2, bt(e));
189
+ }
595
190
  }
596
191
  }
597
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
598
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
599
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
600
- if (childNodes && parentNode) {
601
- const childCount = childNodes.length;
602
- for (let i = childCount - 1; i >= 0; --i) {
603
- const childClone = cloneNode(childNodes[i], true);
604
- childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
605
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
192
+ return N2(e), true;
193
+ }
194
+ return e instanceof Fe && !Wt(e) || (n === "noscript" || n === "noembed" || n === "noframes") && h(/<\/no(script|embed|frames)/i, e.innerHTML) ? (N2(e), true) : (U2 && e.nodeType === Q.text && (t = e.textContent, fe([Ee2, _e2, ge2], (f) => {
195
+ t = K(t, f, " ");
196
+ }), e.textContent !== t && (q(o.removed, { element: e.cloneNode() }), e.textContent = t)), M2(A2.afterSanitizeElements, e, null), false);
197
+ }, it = function(e, t, n) {
198
+ if (ne[t] || je2 && (t === "id" || t === "name") && (n in l || n in Gt)) return false;
199
+ if (!(Ae2 && !ne[t] && h(wt, t))) {
200
+ if (!(Be && h(xt, t))) {
201
+ if (!(x.attributeCheck instanceof Function && x.attributeCheck(t, e))) {
202
+ if (!d[t] || ne[t]) {
203
+ if (!(at(e) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, e) || u.tagNameCheck instanceof Function && u.tagNameCheck(e)) && (u.attributeNameCheck instanceof RegExp && h(u.attributeNameCheck, t) || u.attributeNameCheck instanceof Function && u.attributeNameCheck(t, e)) || t === "is" && u.allowCustomizedBuiltInElements && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n)))) return false;
204
+ } else if (!Oe2[t]) {
205
+ if (!h(ze, K(n, He2, ""))) {
206
+ if (!((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && qt(n, "data:") === 0 && $e[e])) {
207
+ if (!(Ye && !h(Pt, K(n, He2, "")))) {
208
+ if (n) return false;
209
+ }
210
+ }
211
+ }
606
212
  }
607
213
  }
608
214
  }
609
- _forceRemove(currentNode);
610
- return true;
611
- }
612
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
613
- _forceRemove(currentNode);
614
- return true;
615
- }
616
- if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
617
- _forceRemove(currentNode);
618
- return true;
619
- }
620
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
621
- content = currentNode.textContent;
622
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
623
- content = stringReplace(content, expr, " ");
624
- });
625
- if (currentNode.textContent !== content) {
626
- arrayPush(DOMPurify.removed, {
627
- element: currentNode.cloneNode()
628
- });
629
- currentNode.textContent = content;
630
- }
631
- }
632
- _executeHooks(hooks.afterSanitizeElements, currentNode, null);
633
- return false;
634
- };
635
- const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
636
- if (FORBID_ATTR[lcName]) {
637
- return false;
638
215
  }
639
- if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
640
- return false;
641
- }
642
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ;
643
- else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ;
644
- else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ;
645
- else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
646
- if (
647
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
648
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
649
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
650
- _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
651
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
652
- lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
653
- ) ;
654
- else {
655
- return false;
656
- }
657
- } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
658
- else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
659
- else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
660
- else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
661
- else if (value) {
662
- return false;
663
- } else ;
664
216
  return true;
665
- };
666
- const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
667
- return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
668
- };
669
- const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
670
- _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
671
- const {
672
- attributes
673
- } = currentNode;
674
- if (!attributes || _isClobbered(currentNode)) {
675
- return;
676
- }
677
- const hookEvent = {
678
- attrName: "",
679
- attrValue: "",
680
- keepAttr: true,
681
- allowedAttributes: ALLOWED_ATTR,
682
- forceKeepAttr: void 0
683
- };
684
- let l2 = attributes.length;
685
- while (l2--) {
686
- const attr = attributes[l2];
687
- const {
688
- name,
689
- namespaceURI,
690
- value: attrValue
691
- } = attr;
692
- const lcName = transformCaseFunc(name);
693
- const initValue = attrValue;
694
- let value = name === "value" ? initValue : stringTrim(initValue);
695
- hookEvent.attrName = lcName;
696
- hookEvent.attrValue = value;
697
- hookEvent.keepAttr = true;
698
- hookEvent.forceKeepAttr = void 0;
699
- _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
700
- value = hookEvent.attrValue;
701
- if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
702
- _removeAttribute(name, currentNode);
703
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
704
- }
705
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
706
- _removeAttribute(name, currentNode);
217
+ }, at = function(e) {
218
+ return e !== "annotation-xml" && Me(e, kt);
219
+ }, rt = function(e) {
220
+ M2(A2.beforeSanitizeAttributes, e, null);
221
+ let { attributes: t } = e;
222
+ if (!t || Ne2(e)) return;
223
+ let n = { attrName: "", attrValue: "", keepAttr: true, allowedAttributes: d, forceKeepAttr: void 0 }, f = t.length;
224
+ for (; f--; ) {
225
+ let _2 = t[f], { name: m2, namespaceURI: O, value: w2 } = _2, W2 = p(m2), Ce2 = w2, E = m2 === "value" ? Ce2 : Kt(Ce2);
226
+ if (n.attrName = W2, n.attrValue = E, n.keepAttr = true, n.forceKeepAttr = void 0, M2(A2.uponSanitizeAttribute, e, n), E = n.attrValue, Ve && (W2 === "id" || W2 === "name") && (k2(m2, e), E = vt + E), oe && h(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, E)) {
227
+ k2(m2, e);
707
228
  continue;
708
229
  }
709
- if (lcName === "attributename" && stringMatch(value, "href")) {
710
- _removeAttribute(name, currentNode);
230
+ if (W2 === "attributename" && Me(E, "href")) {
231
+ k2(m2, e);
711
232
  continue;
712
233
  }
713
- if (hookEvent.forceKeepAttr) {
234
+ if (n.forceKeepAttr) continue;
235
+ if (!n.keepAttr) {
236
+ k2(m2, e);
714
237
  continue;
715
238
  }
716
- if (!hookEvent.keepAttr) {
717
- _removeAttribute(name, currentNode);
239
+ if (!Xe && h(/\/>/i, E)) {
240
+ k2(m2, e);
718
241
  continue;
719
242
  }
720
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
721
- _removeAttribute(name, currentNode);
722
- continue;
723
- }
724
- if (SAFE_FOR_TEMPLATES) {
725
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
726
- value = stringReplace(value, expr, " ");
727
- });
728
- }
729
- const lcTag = transformCaseFunc(currentNode.nodeName);
730
- if (!_isValidAttribute(lcTag, lcName, value)) {
731
- _removeAttribute(name, currentNode);
243
+ U2 && fe([Ee2, _e2, ge2], (lt) => {
244
+ E = K(E, lt, " ");
245
+ });
246
+ let st = p(e.nodeName);
247
+ if (!it(st, W2, E)) {
248
+ k2(m2, e);
732
249
  continue;
733
250
  }
734
- if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
735
- if (namespaceURI) ;
736
- else {
737
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
738
- case "TrustedHTML": {
739
- value = trustedTypesPolicy.createHTML(value);
740
- break;
741
- }
742
- case "TrustedScriptURL": {
743
- value = trustedTypesPolicy.createScriptURL(value);
744
- break;
745
- }
746
- }
251
+ if (g && typeof ee2 == "object" && typeof ee2.getAttributeType == "function" && !O) switch (ee2.getAttributeType(st, W2)) {
252
+ case "TrustedHTML": {
253
+ E = g.createHTML(E);
254
+ break;
747
255
  }
748
- }
749
- if (value !== initValue) {
750
- try {
751
- if (namespaceURI) {
752
- currentNode.setAttributeNS(namespaceURI, name, value);
753
- } else {
754
- currentNode.setAttribute(name, value);
755
- }
756
- if (_isClobbered(currentNode)) {
757
- _forceRemove(currentNode);
758
- } else {
759
- arrayPop(DOMPurify.removed);
760
- }
761
- } catch (_) {
762
- _removeAttribute(name, currentNode);
256
+ case "TrustedScriptURL": {
257
+ E = g.createScriptURL(E);
258
+ break;
763
259
  }
764
260
  }
765
- }
766
- _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
767
- };
768
- const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
769
- let shadowNode = null;
770
- const shadowIterator = _createNodeIterator(fragment);
771
- _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
772
- while (shadowNode = shadowIterator.nextNode()) {
773
- _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
774
- _sanitizeElements(shadowNode);
775
- _sanitizeAttributes(shadowNode);
776
- if (shadowNode.content instanceof DocumentFragment2) {
777
- _sanitizeShadowDOM2(shadowNode.content);
261
+ if (E !== Ce2) try {
262
+ O ? e.setAttributeNS(O, m2, E) : e.setAttribute(m2, E), Ne2(e) ? N2(e) : ft(o.removed);
263
+ } catch {
264
+ k2(m2, e);
778
265
  }
779
266
  }
780
- _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
267
+ M2(A2.afterSanitizeAttributes, e, null);
268
+ }, Bt = function i(e) {
269
+ let t = null, n = tt(e);
270
+ for (M2(A2.beforeSanitizeShadowDOM, e, null); t = n.nextNode(); ) M2(A2.uponSanitizeShadowNode, t, null), ot(t), rt(t), t.content instanceof D2 && i(t.content);
271
+ M2(A2.afterSanitizeShadowDOM, e, null);
781
272
  };
782
- DOMPurify.sanitize = function(dirty) {
783
- let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
784
- let body = null;
785
- let importedNode = null;
786
- let currentNode = null;
787
- let returnNode = null;
788
- IS_EMPTY_INPUT = !dirty;
789
- if (IS_EMPTY_INPUT) {
790
- dirty = "<!-->";
791
- }
792
- if (typeof dirty !== "string" && !_isNode(dirty)) {
793
- if (typeof dirty.toString === "function") {
794
- dirty = dirty.toString();
795
- if (typeof dirty !== "string") {
796
- throw typeErrorCreate("dirty is not a string, aborting");
797
- }
798
- } else {
799
- throw typeErrorCreate("toString is not a function");
800
- }
801
- }
802
- if (!DOMPurify.isSupported) {
803
- return dirty;
804
- }
805
- if (!SET_CONFIG) {
806
- _parseConfig(cfg);
807
- }
808
- DOMPurify.removed = [];
809
- if (typeof dirty === "string") {
810
- IN_PLACE = false;
811
- }
812
- if (IN_PLACE) {
813
- if (dirty.nodeName) {
814
- const tagName = transformCaseFunc(dirty.nodeName);
815
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
816
- throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
817
- }
818
- }
819
- } else if (dirty instanceof Node) {
820
- body = _initDocument("<!---->");
821
- importedNode = body.ownerDocument.importNode(dirty, true);
822
- if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
823
- body = importedNode;
824
- } else if (importedNode.nodeName === "HTML") {
825
- body = importedNode;
826
- } else {
827
- body.appendChild(importedNode);
828
- }
829
- } else {
830
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
831
- dirty.indexOf("<") === -1) {
832
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
833
- }
834
- body = _initDocument(dirty);
835
- if (!body) {
836
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
837
- }
838
- }
839
- if (body && FORCE_BODY) {
840
- _forceRemove(body.firstChild);
841
- }
842
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
843
- while (currentNode = nodeIterator.nextNode()) {
844
- _sanitizeElements(currentNode);
845
- _sanitizeAttributes(currentNode);
846
- if (currentNode.content instanceof DocumentFragment2) {
847
- _sanitizeShadowDOM(currentNode.content);
848
- }
849
- }
850
- if (IN_PLACE) {
851
- return dirty;
852
- }
853
- if (RETURN_DOM) {
854
- if (RETURN_DOM_FRAGMENT) {
855
- returnNode = createDocumentFragment.call(body.ownerDocument);
856
- while (body.firstChild) {
857
- returnNode.appendChild(body.firstChild);
858
- }
859
- } else {
860
- returnNode = body;
861
- }
862
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
863
- returnNode = importNode.call(originalDocument, returnNode, true);
864
- }
865
- return returnNode;
866
- }
867
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
868
- if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
869
- serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
870
- }
871
- if (SAFE_FOR_TEMPLATES) {
872
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
873
- serializedHTML = stringReplace(serializedHTML, expr, " ");
874
- });
875
- }
876
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
877
- };
878
- DOMPurify.setConfig = function() {
879
- let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
880
- _parseConfig(cfg);
881
- SET_CONFIG = true;
882
- };
883
- DOMPurify.clearConfig = function() {
884
- CONFIG = null;
885
- SET_CONFIG = false;
886
- };
887
- DOMPurify.isValidAttribute = function(tag, attr, value) {
888
- if (!CONFIG) {
889
- _parseConfig({});
890
- }
891
- const lcTag = transformCaseFunc(tag);
892
- const lcName = transformCaseFunc(attr);
893
- return _isValidAttribute(lcTag, lcName, value);
894
- };
895
- DOMPurify.addHook = function(entryPoint, hookFunction) {
896
- if (typeof hookFunction !== "function") {
897
- return;
898
- }
899
- arrayPush(hooks[entryPoint], hookFunction);
900
- };
901
- DOMPurify.removeHook = function(entryPoint, hookFunction) {
902
- if (hookFunction !== void 0) {
903
- const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
904
- return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
905
- }
906
- return arrayPop(hooks[entryPoint]);
907
- };
908
- DOMPurify.removeHooks = function(entryPoint) {
909
- hooks[entryPoint] = [];
910
- };
911
- DOMPurify.removeAllHooks = function() {
912
- hooks = _createHooksMap();
913
- };
914
- return DOMPurify;
273
+ return o.sanitize = function(i) {
274
+ let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = null, n = null, f = null, _2 = null;
275
+ if (ye2 = !i, ye2 && (i = "<!-->"), typeof i != "string" && !nt(i)) if (typeof i.toString == "function") {
276
+ if (i = i.toString(), typeof i != "string") throw Z("dirty is not a string, aborting");
277
+ } else throw Z("toString is not a function");
278
+ if (!o.isSupported) return i;
279
+ if (he2 || Le2(e), o.removed = [], typeof i == "string" && (V2 = false), V2) {
280
+ if (i.nodeName) {
281
+ let w2 = p(i.nodeName);
282
+ if (!T2[w2] || j2[w2]) throw Z("root node is forbidden and cannot be sanitized in-place");
283
+ }
284
+ } else if (i instanceof Te2) t = et("<!---->"), n = t.ownerDocument.importNode(i, true), n.nodeType === Q.element && n.nodeName === "BODY" || n.nodeName === "HTML" ? t = n : t.appendChild(n);
285
+ else {
286
+ if (!F2 && !U2 && !P && i.indexOf("<") === -1) return g && ae2 ? g.createHTML(i) : i;
287
+ if (t = et(i), !t) return F2 ? null : ae2 ? X2 : "";
288
+ }
289
+ t && Se2 && N2(t.firstChild);
290
+ let m2 = tt(V2 ? i : t);
291
+ for (; f = m2.nextNode(); ) ot(f), rt(f), f.content instanceof D2 && Bt(f.content);
292
+ if (V2) return i;
293
+ if (F2) {
294
+ if (ie2) for (_2 = Ct.call(t.ownerDocument); t.firstChild; ) _2.appendChild(t.firstChild);
295
+ else _2 = t;
296
+ return (d.shadowroot || d.shadowrootmode) && (_2 = Mt.call(a, _2, true)), _2;
297
+ }
298
+ let O = P ? t.outerHTML : t.innerHTML;
299
+ return P && T2["!doctype"] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && h(At, t.ownerDocument.doctype.name) && (O = "<!DOCTYPE " + t.ownerDocument.doctype.name + `>
300
+ ` + O), U2 && fe([Ee2, _e2, ge2], (w2) => {
301
+ O = K(O, w2, " ");
302
+ }), g && ae2 ? g.createHTML(O) : O;
303
+ }, o.setConfig = function() {
304
+ let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
305
+ Le2(i), he2 = true;
306
+ }, o.clearConfig = function() {
307
+ G2 = null, he2 = false;
308
+ }, o.isValidAttribute = function(i, e, t) {
309
+ G2 || Le2({});
310
+ let n = p(i), f = p(e);
311
+ return it(n, f, t);
312
+ }, o.addHook = function(i, e) {
313
+ typeof e == "function" && q(A2[i], e);
314
+ }, o.removeHook = function(i, e) {
315
+ if (e !== void 0) {
316
+ let t = Vt(A2[i], e);
317
+ return t === -1 ? void 0 : $t(A2[i], t, 1)[0];
318
+ }
319
+ return ft(A2[i]);
320
+ }, o.removeHooks = function(i) {
321
+ A2[i] = [];
322
+ }, o.removeAllHooks = function() {
323
+ A2 = Et();
324
+ }, o;
915
325
  }
916
- var entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor, freeze, seal, create, apply, construct, arrayForEach, arrayLastIndexOf, arrayPop, arrayPush, arraySplice, stringToLowerCase, stringToString, stringMatch, stringReplace, stringIndexOf, stringTrim, objectHasOwnProperty, regExpTest, typeErrorCreate, html$1, svg$1, svgFilters, svgDisallowed, mathMl$1, mathMlDisallowed, text, html, svg, mathMl, xml, MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_ALLOWED_URI, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, DOCTYPE_NAME, CUSTOM_ELEMENT, EXPRESSIONS, NODE_TYPE, getGlobal, _createTrustedTypesPolicy, _createHooksMap, purify;
917
- var init_purify_es = __esm({
918
- "node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/dist/purify.es.mjs"() {
919
- ({
920
- entries,
921
- setPrototypeOf,
922
- isFrozen,
923
- getPrototypeOf,
924
- getOwnPropertyDescriptor
925
- } = Object);
926
- ({
927
- freeze,
928
- seal,
929
- create
930
- } = Object);
931
- ({
932
- apply,
933
- construct
934
- } = typeof Reflect !== "undefined" && Reflect);
935
- if (!freeze) {
936
- freeze = function freeze2(x) {
937
- return x;
938
- };
939
- }
940
- if (!seal) {
941
- seal = function seal2(x) {
942
- return x;
943
- };
944
- }
945
- if (!apply) {
946
- apply = function apply2(func, thisArg) {
947
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
948
- args[_key - 2] = arguments[_key];
949
- }
950
- return func.apply(thisArg, args);
951
- };
952
- }
953
- if (!construct) {
954
- construct = function construct2(Func) {
955
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
956
- args[_key2 - 1] = arguments[_key2];
957
- }
958
- return new Func(...args);
959
- };
960
- }
961
- arrayForEach = unapply(Array.prototype.forEach);
962
- arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
963
- arrayPop = unapply(Array.prototype.pop);
964
- arrayPush = unapply(Array.prototype.push);
965
- arraySplice = unapply(Array.prototype.splice);
966
- stringToLowerCase = unapply(String.prototype.toLowerCase);
967
- stringToString = unapply(String.prototype.toString);
968
- stringMatch = unapply(String.prototype.match);
969
- stringReplace = unapply(String.prototype.replace);
970
- stringIndexOf = unapply(String.prototype.indexOf);
971
- stringTrim = unapply(String.prototype.trim);
972
- objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
973
- regExpTest = unapply(RegExp.prototype.test);
974
- typeErrorCreate = unconstruct(TypeError);
975
- html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
976
- svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
977
- svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
978
- svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
979
- mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
980
- mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
981
- text = freeze(["#text"]);
982
- html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
983
- svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
984
- mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
985
- xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
986
- MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
987
- ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
988
- TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
989
- DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
990
- ARIA_ATTR = seal(/^aria-[\-\w]+$/);
991
- IS_ALLOWED_URI = seal(
992
- /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
993
- // eslint-disable-line no-useless-escape
994
- );
995
- IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
996
- ATTR_WHITESPACE = seal(
997
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
998
- // eslint-disable-line no-control-regex
999
- );
1000
- DOCTYPE_NAME = seal(/^html$/i);
1001
- CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1002
- EXPRESSIONS = /* @__PURE__ */ Object.freeze({
1003
- __proto__: null,
1004
- ARIA_ATTR,
1005
- ATTR_WHITESPACE,
1006
- CUSTOM_ELEMENT,
1007
- DATA_ATTR,
1008
- DOCTYPE_NAME,
1009
- ERB_EXPR,
1010
- IS_ALLOWED_URI,
1011
- IS_SCRIPT_OR_DATA,
1012
- MUSTACHE_EXPR,
1013
- TMPLIT_EXPR
326
+ var _t, ct, Yt, Xt, jt, S, b, me, ve, Ue, fe, Vt, ft, q, $t, pe, Ie, Me, K, qt, Kt, y, h, Z, ut, we, xe, Qt, Pe, en, mt, pt, ke, Tt, ue, tn, nn, on, an, rn, gt, sn, ln, At, cn, dt, Q, fn, un, Et, mn;
327
+ var init_OP3JQ447 = __esm({
328
+ "iife:/home/runner/work/transportr/transportr/dist/OP3JQ447.js"() {
329
+ ({ entries: _t, setPrototypeOf: ct, isFrozen: Yt, getPrototypeOf: Xt, getOwnPropertyDescriptor: jt } = Object);
330
+ ({ freeze: S, seal: b, create: me } = Object);
331
+ ({ apply: ve, construct: Ue } = typeof Reflect < "u" && Reflect);
332
+ S || (S = function(o) {
333
+ return o;
1014
334
  });
1015
- NODE_TYPE = {
1016
- element: 1,
1017
- attribute: 2,
1018
- text: 3,
1019
- cdataSection: 4,
1020
- entityReference: 5,
1021
- // Deprecated
1022
- entityNode: 6,
1023
- // Deprecated
1024
- progressingInstruction: 7,
1025
- comment: 8,
1026
- document: 9,
1027
- documentType: 10,
1028
- documentFragment: 11,
1029
- notation: 12
1030
- // Deprecated
1031
- };
1032
- getGlobal = function getGlobal2() {
1033
- return typeof window === "undefined" ? null : window;
335
+ b || (b = function(o) {
336
+ return o;
337
+ });
338
+ ve || (ve = function(o, l) {
339
+ for (var a = arguments.length, c = new Array(a > 2 ? a - 2 : 0), D2 = 2; D2 < a; D2++) c[D2 - 2] = arguments[D2];
340
+ return o.apply(l, c);
341
+ });
342
+ Ue || (Ue = function(o) {
343
+ for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++) a[c - 1] = arguments[c];
344
+ return new o(...a);
345
+ });
346
+ fe = R(Array.prototype.forEach);
347
+ Vt = R(Array.prototype.lastIndexOf);
348
+ ft = R(Array.prototype.pop);
349
+ q = R(Array.prototype.push);
350
+ $t = R(Array.prototype.splice);
351
+ pe = R(String.prototype.toLowerCase);
352
+ Ie = R(String.prototype.toString);
353
+ Me = R(String.prototype.match);
354
+ K = R(String.prototype.replace);
355
+ qt = R(String.prototype.indexOf);
356
+ Kt = R(String.prototype.trim);
357
+ y = R(Object.prototype.hasOwnProperty);
358
+ h = R(RegExp.prototype.test);
359
+ Z = Zt(TypeError);
360
+ ut = S(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
361
+ we = S(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
362
+ xe = S(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
363
+ Qt = S(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
364
+ Pe = S(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
365
+ en = S(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
366
+ mt = S(["#text"]);
367
+ pt = S(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
368
+ ke = S(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
369
+ Tt = S(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
370
+ ue = S(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
371
+ tn = b(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
372
+ nn = b(/<%[\w\W]*|[\w\W]*%>/gm);
373
+ on = b(/\$\{[\w\W]*/gm);
374
+ an = b(/^data-[\-\w.\u00B7-\uFFFF]+$/);
375
+ rn = b(/^aria-[\-\w]+$/);
376
+ gt = b(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
377
+ sn = b(/^(?:\w+script|data):/i);
378
+ ln = b(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
379
+ At = b(/^html$/i);
380
+ cn = b(/^[a-z][.\w]*(-[.\w]+)+$/i);
381
+ dt = Object.freeze({ __proto__: null, ARIA_ATTR: rn, ATTR_WHITESPACE: ln, CUSTOM_ELEMENT: cn, DATA_ATTR: an, DOCTYPE_NAME: At, ERB_EXPR: nn, IS_ALLOWED_URI: gt, IS_SCRIPT_OR_DATA: sn, MUSTACHE_EXPR: tn, TMPLIT_EXPR: on });
382
+ Q = { element: 1, attribute: 2, text: 3, cdataSection: 4, entityReference: 5, entityNode: 6, progressingInstruction: 7, comment: 8, document: 9, documentType: 10, documentFragment: 11, notation: 12 };
383
+ fn = function() {
384
+ return typeof window > "u" ? null : window;
1034
385
  };
1035
- _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
1036
- if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
1037
- return null;
1038
- }
1039
- let suffix = null;
1040
- const ATTR_NAME = "data-tt-policy-suffix";
1041
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
1042
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
1043
- }
1044
- const policyName = "dompurify" + (suffix ? "#" + suffix : "");
386
+ un = function(o, l) {
387
+ if (typeof o != "object" || typeof o.createPolicy != "function") return null;
388
+ let a = null, c = "data-tt-policy-suffix";
389
+ l && l.hasAttribute(c) && (a = l.getAttribute(c));
390
+ let D2 = "dompurify" + (a ? "#" + a : "");
1045
391
  try {
1046
- return trustedTypes.createPolicy(policyName, {
1047
- createHTML(html2) {
1048
- return html2;
1049
- },
1050
- createScriptURL(scriptUrl) {
1051
- return scriptUrl;
1052
- }
1053
- });
1054
- } catch (_) {
1055
- console.warn("TrustedTypes policy " + policyName + " could not be created.");
1056
- return null;
392
+ return o.createPolicy(D2, { createHTML(v2) {
393
+ return v2;
394
+ }, createScriptURL(v2) {
395
+ return v2;
396
+ } });
397
+ } catch {
398
+ return console.warn("TrustedTypes policy " + D2 + " could not be created."), null;
1057
399
  }
1058
400
  };
1059
- _createHooksMap = function _createHooksMap2() {
1060
- return {
1061
- afterSanitizeAttributes: [],
1062
- afterSanitizeElements: [],
1063
- afterSanitizeShadowDOM: [],
1064
- beforeSanitizeAttributes: [],
1065
- beforeSanitizeElements: [],
1066
- beforeSanitizeShadowDOM: [],
1067
- uponSanitizeAttribute: [],
1068
- uponSanitizeElement: [],
1069
- uponSanitizeShadowNode: []
1070
- };
401
+ Et = function() {
402
+ return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] };
1071
403
  };
1072
- purify = createDOMPurify();
404
+ mn = ht();
1073
405
  }
1074
406
  });
1075
407
 
1076
- // src/transportr.ts
1077
- var transportr_exports = {};
1078
- __export(transportr_exports, {
1079
- Transportr: () => Transportr
1080
- });
1081
-
1082
- // node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/dist/media-type.js
1083
- var o = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
1084
- var y = /(["\\])/ug;
1085
- var d = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
1086
- var c = class r extends Map {
1087
- constructor(t = []) {
1088
- super(t);
408
+ // iife:/home/runner/work/transportr/transportr/dist/transportr.js
409
+ var L = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
410
+ var Ce = /(["\\])/ug;
411
+ var Ue2 = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
412
+ var ie = class ae extends Map {
413
+ constructor(e = []) {
414
+ super(e);
1089
415
  }
1090
- static isValid(t, e) {
1091
- return o.test(t) && d.test(e);
416
+ static isValid(e, t) {
417
+ return L.test(e) && Ue2.test(t);
1092
418
  }
1093
- get(t) {
1094
- return super.get(t.toLowerCase());
419
+ get(e) {
420
+ return super.get(e.toLowerCase());
1095
421
  }
1096
- has(t) {
1097
- return super.has(t.toLowerCase());
422
+ has(e) {
423
+ return super.has(e.toLowerCase());
1098
424
  }
1099
- set(t, e) {
1100
- if (!r.isValid(t, e)) throw new Error(`Invalid media type parameter name/value: ${t}/${e}`);
1101
- return super.set(t.toLowerCase(), e), this;
425
+ set(e, t) {
426
+ if (!ae.isValid(e, t)) throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);
427
+ return super.set(e.toLowerCase(), t), this;
1102
428
  }
1103
- delete(t) {
1104
- return super.delete(t.toLowerCase());
429
+ delete(e) {
430
+ return super.delete(e.toLowerCase());
1105
431
  }
1106
432
  toString() {
1107
- return Array.from(this).map(([t, e]) => `;${t}=${!e || !o.test(e) ? `"${e.replace(y, "\\$1")}"` : e}`).join("");
433
+ return Array.from(this).map(([e, t]) => `;${e}=${!t || !L.test(t) ? `"${t.replace(Ce, "\\$1")}"` : t}`).join("");
1108
434
  }
1109
435
  get [Symbol.toStringTag]() {
1110
436
  return "MediaTypeParameters";
1111
437
  }
1112
438
  };
1113
- var m = /* @__PURE__ */ new Set([" ", " ", `
439
+ var xe2 = /* @__PURE__ */ new Set([" ", " ", `
1114
440
  `, "\r"]);
1115
- var b = /[ \t\n\r]+$/u;
1116
- var f = /^[ \t\n\r]+|[ \t\n\r]+$/ug;
1117
- var u = class r2 {
1118
- static parse(t) {
1119
- t = t.replace(f, "");
1120
- let e = 0, [s, i] = r2.collect(t, e, ["/"]);
1121
- if (e = i, !s.length || e >= t.length || !o.test(s)) throw new TypeError(r2.generateErrorMessage("type", s));
1122
- ++e;
1123
- let [n2, a] = r2.collect(t, e, [";"], true, true);
1124
- if (e = a, !n2.length || !o.test(n2)) throw new TypeError(r2.generateErrorMessage("subtype", n2));
1125
- let g = new c();
1126
- for (; e < t.length; ) {
1127
- for (++e; m.has(t[e]); ) ++e;
1128
- let l2;
1129
- if ([l2, e] = r2.collect(t, e, [";", "="], false), e >= t.length || t[e] === ";") continue;
1130
- ++e;
1131
- let p;
1132
- if (t[e] === '"') for ([p, e] = r2.collectHttpQuotedString(t, e); e < t.length && t[e] !== ";"; ) ++e;
1133
- else if ([p, e] = r2.collect(t, e, [";"], false, true), !p) continue;
1134
- l2 && c.isValid(l2, p) && !g.has(l2) && g.set(l2, p);
1135
- }
1136
- return { type: s, subtype: n2, parameters: g };
441
+ var Le = /[ \t\n\r]+$/u;
442
+ var Ie2 = /^[ \t\n\r]+|[ \t\n\r]+$/ug;
443
+ var Me2 = class w {
444
+ static parse(e) {
445
+ e = e.replace(Ie2, "");
446
+ let t = 0, [n, r2] = w.collect(e, t, ["/"]);
447
+ if (t = r2, !n.length || t >= e.length || !L.test(n)) throw new TypeError(w.generateErrorMessage("type", n));
448
+ ++t;
449
+ let [o, i] = w.collect(e, t, [";"], true, true);
450
+ if (t = i, !o.length || !L.test(o)) throw new TypeError(w.generateErrorMessage("subtype", o));
451
+ let a = new ie();
452
+ for (; t < e.length; ) {
453
+ for (++t; xe2.has(e[t]); ) ++t;
454
+ let d;
455
+ if ([d, t] = w.collect(e, t, [";", "="], false), t >= e.length || e[t] === ";") continue;
456
+ ++t;
457
+ let R2;
458
+ if (e[t] === '"') for ([R2, t] = w.collectHttpQuotedString(e, t); t < e.length && e[t] !== ";"; ) ++t;
459
+ else if ([R2, t] = w.collect(e, t, [";"], false, true), !R2) continue;
460
+ d && ie.isValid(d, R2) && !a.has(d) && a.set(d, R2);
461
+ }
462
+ return { type: n, subtype: o, parameters: a };
1137
463
  }
1138
464
  get [Symbol.toStringTag]() {
1139
465
  return "MediaTypeParser";
1140
466
  }
1141
- static collect(t, e, s, i = true, n2 = false) {
1142
- let a = "";
1143
- for (let { length: g } = t; e < g && !s.includes(t[e]); e++) a += t[e];
1144
- return i && (a = a.toLowerCase()), n2 && (a = a.replace(b, "")), [a, e];
467
+ static collect(e, t, n, r2 = true, o = false) {
468
+ let i = "";
469
+ for (let { length: a } = e; t < a && !n.includes(e[t]); t++) i += e[t];
470
+ return r2 && (i = i.toLowerCase()), o && (i = i.replace(Le, "")), [i, t];
1145
471
  }
1146
- static collectHttpQuotedString(t, e) {
1147
- let s = "";
1148
- for (let i = t.length, n2; ++e < i && (n2 = t[e]) !== '"'; ) s += n2 == "\\" && ++e < i ? t[e] : n2;
1149
- return [s, e];
472
+ static collectHttpQuotedString(e, t) {
473
+ let n = "";
474
+ for (let r2 = e.length, o; ++t < r2 && (o = e[t]) !== '"'; ) n += o == "\\" && ++t < r2 ? e[t] : o;
475
+ return [n, t];
1150
476
  }
1151
- static generateErrorMessage(t, e) {
1152
- return `Invalid ${t} "${e}": only HTTP token code points are valid.`;
477
+ static generateErrorMessage(e, t) {
478
+ return `Invalid ${e} "${t}": only HTTP token code points are valid.`;
1153
479
  }
1154
480
  };
1155
- var h = class r3 {
481
+ var T = class ue2 {
1156
482
  _type;
1157
483
  _subtype;
1158
484
  _parameters;
1159
- constructor(t, e = {}) {
1160
- if (e === null || typeof e != "object" || Array.isArray(e)) throw new TypeError("The parameters argument must be an object");
1161
- ({ type: this._type, subtype: this._subtype, parameters: this._parameters } = u.parse(t));
1162
- for (let [s, i] of Object.entries(e)) this._parameters.set(s, i);
485
+ constructor(e, t = {}) {
486
+ if (t === null || typeof t != "object" || Array.isArray(t)) throw new TypeError("The parameters argument must be an object");
487
+ ({ type: this._type, subtype: this._subtype, parameters: this._parameters } = Me2.parse(e));
488
+ for (let [n, r2] of Object.entries(t)) this._parameters.set(n, r2);
1163
489
  }
1164
- static parse(t) {
490
+ static parse(e) {
1165
491
  try {
1166
- return new r3(t);
492
+ return new ue2(e);
1167
493
  } catch {
1168
494
  }
1169
495
  return null;
@@ -1180,8 +506,8 @@ var __mod = (() => {
1180
506
  get parameters() {
1181
507
  return this._parameters;
1182
508
  }
1183
- matches(t) {
1184
- return typeof t == "string" ? this.essence.includes(t) : this._type === t._type && this._subtype === t._subtype;
509
+ matches(e) {
510
+ return typeof e == "string" ? this.essence.includes(e) : this._type === e._type && this._subtype === e._subtype;
1185
511
  }
1186
512
  toString() {
1187
513
  return `${this.essence}${this._parameters.toString()}`;
@@ -1190,34 +516,32 @@ var __mod = (() => {
1190
516
  return "MediaType";
1191
517
  }
1192
518
  };
1193
-
1194
- // node_modules/.pnpm/@d1g1tal+subscribr@4.1.13/node_modules/@d1g1tal/subscribr/dist/subscribr.js
1195
- var n = class extends Map {
1196
- set(t, e) {
1197
- return super.set(t, e instanceof Set ? e : (super.get(t) ?? /* @__PURE__ */ new Set()).add(e)), this;
1198
- }
1199
- getOrInsert(t, e) {
1200
- return this.has(t) ? super.get(t) : (super.set(t, e instanceof Set ? e : (super.get(t) ?? /* @__PURE__ */ new Set()).add(e)), e);
1201
- }
1202
- getOrInsertComputed(t, e) {
1203
- if (this.has(t)) return super.get(t);
1204
- let s = e(t);
1205
- return super.set(t, s instanceof Set ? s : (super.get(t) ?? /* @__PURE__ */ new Set()).add(s)), s;
1206
- }
1207
- find(t, e) {
1208
- let s = this.get(t);
1209
- if (s !== void 0) return Array.from(s).find(e);
1210
- }
1211
- hasValue(t, e) {
1212
- let s = super.get(t);
1213
- return s ? s.has(e) : false;
1214
- }
1215
- deleteValue(t, e) {
1216
- if (e === void 0) return this.delete(t);
1217
- let s = super.get(t);
1218
- if (s) {
1219
- let r4 = s.delete(e);
1220
- return s.size === 0 && super.delete(t), r4;
519
+ var Ne = class extends Map {
520
+ set(s2, e) {
521
+ return super.set(s2, e instanceof Set ? e : (super.get(s2) ?? /* @__PURE__ */ new Set()).add(e)), this;
522
+ }
523
+ getOrInsert(s2, e) {
524
+ return this.has(s2) ? super.get(s2) : (super.set(s2, e instanceof Set ? e : (super.get(s2) ?? /* @__PURE__ */ new Set()).add(e)), e);
525
+ }
526
+ getOrInsertComputed(s2, e) {
527
+ if (this.has(s2)) return super.get(s2);
528
+ let t = e(s2);
529
+ return super.set(s2, t instanceof Set ? t : (super.get(s2) ?? /* @__PURE__ */ new Set()).add(t)), t;
530
+ }
531
+ find(s2, e) {
532
+ let t = this.get(s2);
533
+ if (t !== void 0) return Array.from(t).find(e);
534
+ }
535
+ hasValue(s2, e) {
536
+ let t = super.get(s2);
537
+ return t ? t.has(e) : false;
538
+ }
539
+ deleteValue(s2, e) {
540
+ if (e === void 0) return this.delete(s2);
541
+ let t = super.get(s2);
542
+ if (t) {
543
+ let n = t.delete(e);
544
+ return t.size === 0 && super.delete(s2), n;
1221
545
  }
1222
546
  return false;
1223
547
  }
@@ -1225,24 +549,24 @@ var __mod = (() => {
1225
549
  return "SetMultiMap";
1226
550
  }
1227
551
  };
1228
- var o2 = class {
552
+ var De = class {
1229
553
  context;
1230
554
  eventHandler;
1231
- constructor(t, e) {
1232
- this.context = t, this.eventHandler = e;
555
+ constructor(s2, e) {
556
+ this.context = s2, this.eventHandler = e;
1233
557
  }
1234
- handle(t, e) {
1235
- this.eventHandler.call(this.context, t, e);
558
+ handle(s2, e) {
559
+ this.eventHandler.call(this.context, s2, e);
1236
560
  }
1237
561
  get [Symbol.toStringTag]() {
1238
562
  return "ContextEventHandler";
1239
563
  }
1240
564
  };
1241
- var l = class {
565
+ var _e = class {
1242
566
  _eventName;
1243
567
  _contextEventHandler;
1244
- constructor(t, e) {
1245
- this._eventName = t, this._contextEventHandler = e;
568
+ constructor(s2, e) {
569
+ this._eventName = s2, this._contextEventHandler = e;
1246
570
  }
1247
571
  get eventName() {
1248
572
  return this._eventName;
@@ -1254,43 +578,43 @@ var __mod = (() => {
1254
578
  return "Subscription";
1255
579
  }
1256
580
  };
1257
- var d2 = class {
1258
- subscribers = new n();
581
+ var I = class {
582
+ subscribers = new Ne();
1259
583
  errorHandler;
1260
- setErrorHandler(t) {
1261
- this.errorHandler = t;
1262
- }
1263
- subscribe(t, e, s = e, r4) {
1264
- if (this.validateEventName(t), r4?.once) {
1265
- let p = e;
1266
- e = (v, m2) => {
1267
- p.call(s, v, m2), this.unsubscribe(h2);
584
+ setErrorHandler(s2) {
585
+ this.errorHandler = s2;
586
+ }
587
+ subscribe(s2, e, t = e, n) {
588
+ if (this.validateEventName(s2), n?.once) {
589
+ let i = e;
590
+ e = (a, d) => {
591
+ i.call(t, a, d), this.unsubscribe(o);
1268
592
  };
1269
593
  }
1270
- let i = new o2(s, e);
1271
- this.subscribers.set(t, i);
1272
- let h2 = new l(t, i);
1273
- return h2;
594
+ let r2 = new De(t, e);
595
+ this.subscribers.set(s2, r2);
596
+ let o = new _e(s2, r2);
597
+ return o;
1274
598
  }
1275
- unsubscribe({ eventName: t, contextEventHandler: e }) {
1276
- let s = this.subscribers.get(t) ?? /* @__PURE__ */ new Set(), r4 = s.delete(e);
1277
- return r4 && s.size === 0 && this.subscribers.delete(t), r4;
599
+ unsubscribe({ eventName: s2, contextEventHandler: e }) {
600
+ let t = this.subscribers.get(s2) ?? /* @__PURE__ */ new Set(), n = t.delete(e);
601
+ return n && t.size === 0 && this.subscribers.delete(s2), n;
1278
602
  }
1279
- publish(t, e = new CustomEvent(t), s) {
1280
- this.validateEventName(t), this.subscribers.get(t)?.forEach((r4) => {
603
+ publish(s2, e = new CustomEvent(s2), t) {
604
+ this.validateEventName(s2), this.subscribers.get(s2)?.forEach((n) => {
1281
605
  try {
1282
- r4.handle(e, s);
1283
- } catch (i) {
1284
- this.errorHandler ? this.errorHandler(i, t, e, s) : console.error(`Error in event handler for '${t}':`, i);
606
+ n.handle(e, t);
607
+ } catch (r2) {
608
+ this.errorHandler ? this.errorHandler(r2, s2, e, t) : console.error(`Error in event handler for '${s2}':`, r2);
1285
609
  }
1286
610
  });
1287
611
  }
1288
- isSubscribed({ eventName: t, contextEventHandler: e }) {
1289
- return this.subscribers.get(t)?.has(e) ?? false;
612
+ isSubscribed({ eventName: s2, contextEventHandler: e }) {
613
+ return this.subscribers.get(s2)?.has(e) ?? false;
1290
614
  }
1291
- validateEventName(t) {
1292
- if (!t || typeof t != "string") throw new TypeError("Event name must be a non-empty string");
1293
- if (t.trim() !== t) throw new Error("Event name cannot have leading or trailing whitespace");
615
+ validateEventName(s2) {
616
+ if (!s2 || typeof s2 != "string") throw new TypeError("Event name must be a non-empty string");
617
+ if (s2.trim() !== s2) throw new Error("Event name cannot have leading or trailing whitespace");
1294
618
  }
1295
619
  destroy() {
1296
620
  this.subscribers.clear();
@@ -1299,1800 +623,715 @@ var __mod = (() => {
1299
623
  return "Subscribr";
1300
624
  }
1301
625
  };
1302
-
1303
- // src/http-error.ts
1304
- var HttpError = class extends Error {
626
+ var k = class extends Error {
1305
627
  _entity;
1306
628
  responseStatus;
1307
629
  _url;
1308
630
  _method;
1309
631
  _timing;
1310
- /**
1311
- * Creates an instance of HttpError.
1312
- * @param status The status code and status text of the {@link Response}.
1313
- * @param httpErrorOptions The http error options.
1314
- */
1315
- constructor(status, { message, cause, entity, url, method, timing } = {}) {
1316
- super(message, { cause });
1317
- this._entity = entity;
1318
- this.responseStatus = status;
1319
- this._url = url;
1320
- this._method = method;
1321
- this._timing = timing;
1322
- }
1323
- /**
1324
- * It returns the value of the private variable #entity.
1325
- * @returns The entity property of the class.
1326
- */
632
+ constructor(e, { message: t, cause: n, entity: r2, url: o, method: i, timing: a } = {}) {
633
+ super(t, { cause: n }), this._entity = r2, this.responseStatus = e, this._url = o, this._method = i, this._timing = a;
634
+ }
1327
635
  get entity() {
1328
636
  return this._entity;
1329
637
  }
1330
- /**
1331
- * It returns the status code of the {@link Response}.
1332
- * @returns The status code of the {@link Response}.
1333
- */
1334
638
  get statusCode() {
1335
639
  return this.responseStatus.code;
1336
640
  }
1337
- /**
1338
- * It returns the status text of the {@link Response}.
1339
- * @returns The status code and status text of the {@link Response}.
1340
- */
1341
641
  get statusText() {
1342
642
  return this.responseStatus?.text;
1343
643
  }
1344
- /**
1345
- * The request URL that caused the error.
1346
- * @returns The URL or undefined.
1347
- */
1348
644
  get url() {
1349
645
  return this._url;
1350
646
  }
1351
- /**
1352
- * The HTTP method that was used for the failed request.
1353
- * @returns The method string or undefined.
1354
- */
1355
647
  get method() {
1356
648
  return this._method;
1357
649
  }
1358
- /**
1359
- * Timing information for the failed request.
1360
- * @returns The timing object or undefined.
1361
- */
1362
650
  get timing() {
1363
651
  return this._timing;
1364
652
  }
1365
- /**
1366
- * A String value representing the name of the error.
1367
- * @returns The name of the error.
1368
- */
1369
653
  get name() {
1370
654
  return "HttpError";
1371
655
  }
1372
- /**
1373
- * A String value that is used in the creation of the default string
1374
- * description of an object. Called by the built-in method {@link Object.prototype.toString}.
1375
- * @returns The default string description of this object.
1376
- */
1377
656
  get [Symbol.toStringTag]() {
1378
657
  return this.name;
1379
658
  }
1380
659
  };
1381
-
1382
- // src/response-status.ts
1383
- var ResponseStatus = class {
660
+ var v = class {
1384
661
  _code;
1385
662
  _text;
1386
- /**
1387
- *
1388
- * @param code The status code from the {@link Response}
1389
- * @param text The status text from the {@link Response}
1390
- */
1391
- constructor(code, text2) {
1392
- this._code = code;
1393
- this._text = text2;
1394
- }
1395
- /**
1396
- * Returns the status code from the {@link Response}
1397
- *
1398
- * @returns The status code.
1399
- */
663
+ constructor(e, t) {
664
+ this._code = e, this._text = t;
665
+ }
1400
666
  get code() {
1401
667
  return this._code;
1402
668
  }
1403
- /**
1404
- * Returns the status text from the {@link Response}.
1405
- *
1406
- * @returns The status text.
1407
- */
1408
669
  get text() {
1409
670
  return this._text;
1410
671
  }
1411
- /**
1412
- * A String value that is used in the creation of the default string
1413
- * description of an object. Called by the built-in method {@link Object.prototype.toString}.
1414
- *
1415
- * @returns The default string description of this object.
1416
- */
1417
672
  get [Symbol.toStringTag]() {
1418
673
  return "ResponseStatus";
1419
674
  }
1420
- /**
1421
- * tostring method for the class.
1422
- *
1423
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}
1424
- * @returns The status code and status text.
1425
- */
1426
675
  toString() {
1427
676
  return `${this._code} ${this._text}`;
1428
677
  }
1429
678
  };
1430
-
1431
- // src/constants.ts
1432
- var charset = { charset: "utf-8" };
1433
- var endsWithSlashRegEx = /\/$/;
1434
- var XSRF_COOKIE_NAME = "XSRF-TOKEN";
1435
- var XSRF_HEADER_NAME = "X-XSRF-TOKEN";
1436
- var mediaTypes = {
1437
- PNG: new h("image/png"),
1438
- TEXT: new h("text/plain", charset),
1439
- JSON: new h("application/json", charset),
1440
- HTML: new h("text/html", charset),
1441
- JAVA_SCRIPT: new h("text/javascript", charset),
1442
- CSS: new h("text/css", charset),
1443
- XML: new h("application/xml", charset),
1444
- BIN: new h("application/octet-stream"),
1445
- EVENT_STREAM: new h("text/event-stream", charset),
1446
- NDJSON: new h("application/x-ndjson", charset)
1447
- };
1448
- var defaultMediaType = mediaTypes.JSON.toString();
1449
- var defaultOrigin = globalThis.location?.origin ?? "http://localhost";
1450
- var RequestCachingPolicy = {
1451
- DEFAULT: "default",
1452
- FORCE_CACHE: "force-cache",
1453
- NO_CACHE: "no-cache",
1454
- NO_STORE: "no-store",
1455
- ONLY_IF_CACHED: "only-if-cached",
1456
- RELOAD: "reload"
1457
- };
1458
- var RequestEvent = {
1459
- CONFIGURED: "configured",
1460
- SUCCESS: "success",
1461
- ERROR: "error",
1462
- ABORTED: "aborted",
1463
- TIMEOUT: "timeout",
1464
- RETRY: "retry",
1465
- COMPLETE: "complete",
1466
- ALL_COMPLETE: "all-complete"
1467
- };
1468
- var SignalEvents = {
1469
- ABORT: "abort",
1470
- TIMEOUT: "timeout"
1471
- };
1472
- var SignalErrors = {
1473
- ABORT: "AbortError",
1474
- TIMEOUT: "TimeoutError"
1475
- };
1476
- var eventListenerOptions = { once: true, passive: true };
1477
- var abortEvent = () => new CustomEvent(SignalEvents.ABORT, { detail: { cause: SignalErrors.ABORT } });
1478
- var timeoutEvent = () => new CustomEvent(SignalEvents.TIMEOUT, { detail: { cause: SignalErrors.TIMEOUT } });
1479
- var requestBodyMethods = ["POST", "PUT", "PATCH", "DELETE"];
1480
- var internalServerError = new ResponseStatus(500, "Internal Server Error");
1481
- var aborted = new ResponseStatus(499, "Aborted");
1482
- var timedOut = new ResponseStatus(504, "Request Timeout");
1483
- var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
1484
- var retryMethods = ["GET", "PUT", "HEAD", "DELETE", "OPTIONS"];
1485
- var retryDelay = 300;
1486
- var retryBackoffFactor = 2;
1487
-
1488
- // src/signal-controller.ts
1489
- var SignalController = class {
679
+ var q2 = { charset: "utf-8" };
680
+ var de = /\/$/;
681
+ var le = "XSRF-TOKEN";
682
+ var ce = "X-XSRF-TOKEN";
683
+ var m = { PNG: new T("image/png"), TEXT: new T("text/plain", q2), JSON: new T("application/json", q2), HTML: new T("text/html", q2), JAVA_SCRIPT: new T("text/javascript", q2), CSS: new T("text/css", q2), XML: new T("application/xml", q2), BIN: new T("application/octet-stream"), EVENT_STREAM: new T("text/event-stream", q2), NDJSON: new T("application/x-ndjson", q2) };
684
+ var $ = m.JSON.toString();
685
+ var G = globalThis.location?.origin ?? "http://localhost";
686
+ var pe2 = { DEFAULT: "default", FORCE_CACHE: "force-cache", NO_CACHE: "no-cache", NO_STORE: "no-store", ONLY_IF_CACHED: "only-if-cached", RELOAD: "reload" };
687
+ var b2 = { CONFIGURED: "configured", SUCCESS: "success", ERROR: "error", ABORTED: "aborted", TIMEOUT: "timeout", RETRY: "retry", COMPLETE: "complete", ALL_COMPLETE: "all-complete" };
688
+ var H = { ABORT: "abort", TIMEOUT: "timeout" };
689
+ var A = { ABORT: "AbortError", TIMEOUT: "TimeoutError" };
690
+ var U = { once: true, passive: true };
691
+ var M = () => new CustomEvent(H.ABORT, { detail: { cause: A.ABORT } });
692
+ var fe2 = () => new CustomEvent(H.TIMEOUT, { detail: { cause: A.TIMEOUT } });
693
+ var Re = ["POST", "PUT", "PATCH", "DELETE"];
694
+ var he = new v(500, "Internal Server Error");
695
+ var ge = new v(499, "Aborted");
696
+ var me2 = new v(504, "Request Timeout");
697
+ var X = [408, 413, 429, 500, 502, 503, 504];
698
+ var V = ["GET", "PUT", "HEAD", "DELETE", "OPTIONS"];
699
+ var N = 300;
700
+ var D = 2;
701
+ var _ = class {
1490
702
  abortSignal;
1491
703
  abortController = new AbortController();
1492
704
  events = /* @__PURE__ */ new Map();
1493
- /**
1494
- * Creates a new SignalController instance.
1495
- * @param options - The options for the SignalController.
1496
- * @param options.signal - The signal to listen for abort events. Defaults to the internal abort signal.
1497
- * @param options.timeout - The timeout value in milliseconds. Defaults to Infinity.
1498
- * @throws {RangeError} If the timeout value is negative.
1499
- */
1500
- constructor({ signal, timeout = Infinity } = {}) {
1501
- if (timeout < 0) {
1502
- throw new RangeError("The timeout cannot be negative");
1503
- }
1504
- const signals = [this.abortController.signal];
1505
- if (signal != null) {
1506
- signals.push(signal);
1507
- }
1508
- if (timeout !== Infinity) {
1509
- signals.push(AbortSignal.timeout(timeout));
1510
- }
1511
- (this.abortSignal = AbortSignal.any(signals)).addEventListener(SignalEvents.ABORT, this, eventListenerOptions);
1512
- }
1513
- /**
1514
- * Handles the 'abort' event. If the event is caused by a timeout, the 'timeout' event is dispatched.
1515
- * Guards against a timeout firing after a manual abort to prevent spurious timeout events.
1516
- * @param event The event to abort with
1517
- * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#specifying_this_using_bind
1518
- */
1519
- handleEvent({ target: { reason } }) {
1520
- if (this.abortController.signal.aborted) {
1521
- return;
1522
- }
1523
- if (reason instanceof DOMException && reason.name === SignalErrors.TIMEOUT) {
1524
- this.abortSignal.dispatchEvent(timeoutEvent());
1525
- }
705
+ constructor({ signal: e, timeout: t = 1 / 0 } = {}) {
706
+ if (t < 0) throw new RangeError("The timeout cannot be negative");
707
+ let n = [this.abortController.signal];
708
+ e != null && n.push(e), t !== 1 / 0 && n.push(AbortSignal.timeout(t)), (this.abortSignal = AbortSignal.any(n)).addEventListener(H.ABORT, this, U);
709
+ }
710
+ handleEvent({ target: { reason: e } }) {
711
+ this.abortController.signal.aborted || e instanceof DOMException && e.name === A.TIMEOUT && this.abortSignal.dispatchEvent(fe2());
1526
712
  }
1527
- /**
1528
- * Gets the signal. This signal will be able to abort the request, but will not be notified if the request is aborted by the timeout.
1529
- * @returns The signal
1530
- */
1531
713
  get signal() {
1532
714
  return this.abortSignal;
1533
715
  }
1534
- /**
1535
- * Adds an event listener for the 'abort' event.
1536
- *
1537
- * @param eventListener The listener to add
1538
- * @returns The SignalController
1539
- */
1540
- onAbort(eventListener) {
1541
- return this.addEventListener(SignalEvents.ABORT, eventListener);
1542
- }
1543
- /**
1544
- * Adds an event listener for the 'timeout' event.
1545
- *
1546
- * @param eventListener The listener to add
1547
- * @returns The SignalController
1548
- */
1549
- onTimeout(eventListener) {
1550
- return this.addEventListener(SignalEvents.TIMEOUT, eventListener);
1551
- }
1552
- /**
1553
- * Aborts the signal.
1554
- *
1555
- * @param event The event to abort with
1556
- */
1557
- abort(event = abortEvent()) {
1558
- this.abortController.abort(event.detail?.cause);
1559
- }
1560
- /**
1561
- * Removes all event listeners from the signal.
1562
- *
1563
- * @returns The SignalController
1564
- */
716
+ onAbort(e) {
717
+ return this.addEventListener(H.ABORT, e);
718
+ }
719
+ onTimeout(e) {
720
+ return this.addEventListener(H.TIMEOUT, e);
721
+ }
722
+ abort(e = M()) {
723
+ this.abortController.abort(e.detail?.cause);
724
+ }
1565
725
  destroy() {
1566
- this.abortSignal.removeEventListener(SignalEvents.ABORT, this, eventListenerOptions);
1567
- for (const [eventListener, type] of this.events) {
1568
- this.abortSignal.removeEventListener(type, eventListener, eventListenerOptions);
1569
- }
1570
- this.events.clear();
1571
- return this;
1572
- }
1573
- /**
1574
- * Adds an event listener for the specified event type.
1575
- *
1576
- * @param type The event type to listen for
1577
- * @param eventListener The listener to add
1578
- * @returns The SignalController
1579
- */
1580
- addEventListener(type, eventListener) {
1581
- this.abortSignal.addEventListener(type, eventListener, eventListenerOptions);
1582
- this.events.set(eventListener, type);
1583
- return this;
1584
- }
1585
- /**
1586
- * A String value that is used in the creation of the default string
1587
- * description of an object. Called by the built-in method {@link Object.prototype.toString}.
1588
- *
1589
- * @returns The default string description of this object.
1590
- */
726
+ this.abortSignal.removeEventListener(H.ABORT, this, U);
727
+ for (let [e, t] of this.events) this.abortSignal.removeEventListener(t, e, U);
728
+ return this.events.clear(), this;
729
+ }
730
+ addEventListener(e, t) {
731
+ return this.abortSignal.addEventListener(e, t, U), this.events.set(t, e), this;
732
+ }
1591
733
  get [Symbol.toStringTag]() {
1592
734
  return "SignalController";
1593
735
  }
1594
736
  };
1595
-
1596
- // src/response-handlers.ts
1597
- var domReady;
1598
- var purifyReady;
1599
- var getSanitize = () => purifyReady ??= Promise.resolve().then(() => (init_purify_es(), purify_es_exports)).then(({ default: p }) => (dirty) => p.sanitize(dirty));
1600
- var ensureDom = async () => {
1601
- if (typeof document !== "undefined" && typeof DOMParser !== "undefined" && typeof DocumentFragment !== "undefined") {
1602
- return Promise.resolve();
1603
- }
1604
- return domReady ??= import("jsdom").then(({ JSDOM }) => {
1605
- const { window: window2 } = new JSDOM("<!DOCTYPE html><html><head></head><body></body></html>", { url: "http://localhost" });
1606
- globalThis.window = window2;
1607
- Object.assign(globalThis, { document: window2.document, DOMParser: window2.DOMParser, DocumentFragment: window2.DocumentFragment });
1608
- }).catch(() => {
1609
- domReady = void 0;
1610
- throw new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom");
1611
- });
1612
- };
1613
- var handleText = async (response) => await response.text();
1614
- var handleScript = async (response) => {
1615
- await ensureDom();
1616
- const objectURL = URL.createObjectURL(await response.blob());
1617
- return new Promise((resolve, reject) => {
1618
- const script = document.createElement("script");
1619
- Object.assign(script, { src: objectURL, type: "text/javascript", async: true });
1620
- script.onload = () => {
1621
- URL.revokeObjectURL(objectURL);
1622
- document.head.removeChild(script);
1623
- resolve();
1624
- };
1625
- script.onerror = () => {
1626
- URL.revokeObjectURL(objectURL);
1627
- document.head.removeChild(script);
1628
- reject(new Error("Script failed to load"));
1629
- };
1630
- document.head.appendChild(script);
737
+ var ye;
738
+ var je;
739
+ var z = () => je ??= Promise.resolve().then(() => (init_OP3JQ447(), OP3JQ447_exports)).then(({ default: s2 }) => (e) => s2.sanitize(e));
740
+ var B = async () => typeof document < "u" && typeof DOMParser < "u" && typeof DocumentFragment < "u" ? Promise.resolve() : ye ??= import("jsdom").then(({ JSDOM: s2 }) => {
741
+ let { window: e } = new s2("<!DOCTYPE html><html><head></head><body></body></html>", { url: "http://localhost" });
742
+ globalThis.window = e, Object.assign(globalThis, { document: e.document, DOMParser: e.DOMParser, DocumentFragment: e.DocumentFragment });
743
+ }).catch(() => {
744
+ throw ye = void 0, new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom");
745
+ });
746
+ var be = async (s2) => await s2.text();
747
+ var K2 = async (s2) => {
748
+ await B();
749
+ let e = URL.createObjectURL(await s2.blob());
750
+ return new Promise((t, n) => {
751
+ let r2 = document.createElement("script");
752
+ Object.assign(r2, { src: e, type: "text/javascript", async: true }), r2.onload = () => {
753
+ URL.revokeObjectURL(e), document.head.removeChild(r2), t();
754
+ }, r2.onerror = () => {
755
+ URL.revokeObjectURL(e), document.head.removeChild(r2), n(new Error("Script failed to load"));
756
+ }, document.head.appendChild(r2);
1631
757
  });
1632
758
  };
1633
- var handleCss = async (response) => {
1634
- await ensureDom();
1635
- const objectURL = URL.createObjectURL(await response.blob());
1636
- return new Promise((resolve, reject) => {
1637
- const link = document.createElement("link");
1638
- Object.assign(link, { href: objectURL, type: "text/css", rel: "stylesheet" });
1639
- link.onload = () => resolve(URL.revokeObjectURL(objectURL));
1640
- link.onerror = () => {
1641
- URL.revokeObjectURL(objectURL);
1642
- document.head.removeChild(link);
1643
- reject(new Error("Stylesheet load failed"));
1644
- };
1645
- document.head.appendChild(link);
759
+ var W = async (s2) => {
760
+ await B();
761
+ let e = URL.createObjectURL(await s2.blob());
762
+ return new Promise((t, n) => {
763
+ let r2 = document.createElement("link");
764
+ Object.assign(r2, { href: e, type: "text/css", rel: "stylesheet" }), r2.onload = () => t(URL.revokeObjectURL(e)), r2.onerror = () => {
765
+ URL.revokeObjectURL(e), document.head.removeChild(r2), n(new Error("Stylesheet load failed"));
766
+ }, document.head.appendChild(r2);
1646
767
  });
1647
768
  };
1648
- var handleJson = async (response) => await response.json();
1649
- var handleBlob = async (response) => await response.blob();
1650
- var handleImage = async (response) => {
1651
- await ensureDom();
1652
- const objectURL = URL.createObjectURL(await response.blob());
1653
- return new Promise((resolve, reject) => {
1654
- const img = new Image();
1655
- img.onload = () => {
1656
- URL.revokeObjectURL(objectURL);
1657
- resolve(img);
1658
- };
1659
- img.onerror = () => {
1660
- URL.revokeObjectURL(objectURL);
1661
- reject(new Error("Image failed to load"));
1662
- };
1663
- img.src = objectURL;
769
+ var Y = async (s2) => await s2.json();
770
+ var Te = async (s2) => await s2.blob();
771
+ var Q2 = async (s2) => {
772
+ await B();
773
+ let e = URL.createObjectURL(await s2.blob());
774
+ return new Promise((t, n) => {
775
+ let r2 = new Image();
776
+ r2.onload = () => {
777
+ URL.revokeObjectURL(e), t(r2);
778
+ }, r2.onerror = () => {
779
+ URL.revokeObjectURL(e), n(new Error("Image failed to load"));
780
+ }, r2.src = e;
1664
781
  });
1665
782
  };
1666
- var handleBuffer = async (response) => await response.arrayBuffer();
1667
- var handleReadableStream = async (response) => Promise.resolve(response.body);
1668
- var handleXml = async (response) => {
1669
- await ensureDom();
1670
- const sanitize = await getSanitize();
1671
- return new DOMParser().parseFromString(sanitize(await response.text()), "application/xml");
783
+ var Ee = async (s2) => await s2.arrayBuffer();
784
+ var Z2 = async (s2) => Promise.resolve(s2.body);
785
+ var ee = async (s2) => {
786
+ await B();
787
+ let e = await z();
788
+ return new DOMParser().parseFromString(e(await s2.text()), "application/xml");
1672
789
  };
1673
- var handleHtml = async (response) => {
1674
- await ensureDom();
1675
- const sanitize = await getSanitize();
1676
- return new DOMParser().parseFromString(sanitize(await response.text()), "text/html");
790
+ var te = async (s2) => {
791
+ await B();
792
+ let e = await z();
793
+ return new DOMParser().parseFromString(e(await s2.text()), "text/html");
1677
794
  };
1678
- var handleHtmlFragment = async (response) => {
1679
- await ensureDom();
1680
- const sanitize = await getSanitize();
1681
- return document.createRange().createContextualFragment(sanitize(await response.text()));
795
+ var Se = async (s2) => {
796
+ await B();
797
+ let e = await z();
798
+ return document.createRange().createContextualFragment(e(await s2.text()));
1682
799
  };
1683
- var handleEventStream = (response) => {
1684
- return {
1685
- /** @returns An async iterator for SSE events. */
1686
- [Symbol.asyncIterator]() {
1687
- const reader = response.body.getReader();
1688
- const decoder = new TextDecoder();
1689
- let buffer = "";
1690
- let done = false;
1691
- return {
1692
- /** @returns The next parsed SSE event or done signal. */
1693
- async next() {
1694
- while (!done) {
1695
- const eventEnd = buffer.indexOf("\n\n");
1696
- if (eventEnd !== -1) {
1697
- const rawEvent = buffer.slice(0, eventEnd);
1698
- buffer = buffer.slice(eventEnd + 2);
1699
- const sse = { event: "message", data: "", id: "", retry: void 0 };
1700
- const dataLines = [];
1701
- const lines = rawEvent.split("\n");
1702
- for (let i = 0; i < lines.length; i++) {
1703
- const line = lines[i];
1704
- if (line.startsWith(":")) {
1705
- continue;
1706
- }
1707
- const colonIndex = line.indexOf(":");
1708
- let field;
1709
- let value;
1710
- if (colonIndex === -1) {
1711
- field = line;
1712
- value = "";
1713
- } else {
1714
- field = line.slice(0, colonIndex);
1715
- value = line.slice(colonIndex + 1);
1716
- if (value.charCodeAt(0) === 32) {
1717
- value = value.slice(1);
1718
- }
1719
- }
1720
- switch (field) {
1721
- case "event":
1722
- sse.event = value;
1723
- break;
1724
- case "data":
1725
- dataLines.push(value);
1726
- break;
1727
- case "id":
1728
- sse.id = value;
1729
- break;
1730
- case "retry": {
1731
- const n2 = parseInt(value, 10);
1732
- if (!isNaN(n2)) sse.retry = n2;
1733
- break;
1734
- }
1735
- }
1736
- }
1737
- sse.data = dataLines.join("\n");
1738
- if (sse.data || sse.event !== "message") {
1739
- return { value: sse, done: false };
1740
- }
1741
- continue;
1742
- }
1743
- const result = await reader.read();
1744
- if (result.done) {
1745
- done = true;
800
+ var Oe = (s2) => ({ [Symbol.asyncIterator]() {
801
+ let e = s2.body.getReader(), t = new TextDecoder(), n = "", r2 = false;
802
+ return { async next() {
803
+ for (; !r2; ) {
804
+ let o = n.indexOf(`
805
+
806
+ `);
807
+ if (o !== -1) {
808
+ let a = n.slice(0, o);
809
+ n = n.slice(o + 2);
810
+ let d = { event: "message", data: "", id: "", retry: void 0 }, R2 = [], g = a.split(`
811
+ `);
812
+ for (let h2 = 0; h2 < g.length; h2++) {
813
+ let p = g[h2];
814
+ if (p.startsWith(":")) continue;
815
+ let l = p.indexOf(":"), u, c;
816
+ switch (l === -1 ? (u = p, c = "") : (u = p.slice(0, l), c = p.slice(l + 1), c.charCodeAt(0) === 32 && (c = c.slice(1))), u) {
817
+ case "event":
818
+ d.event = c;
1746
819
  break;
1747
- }
1748
- buffer += decoder.decode(result.value, { stream: true });
1749
- }
1750
- return { value: void 0, done: true };
1751
- },
1752
- /** @returns Done signal after cancelling the reader. */
1753
- async return() {
1754
- await reader.cancel();
1755
- done = true;
1756
- return { value: void 0, done: true };
1757
- }
1758
- };
1759
- }
1760
- };
1761
- };
1762
- var handleNdjsonStream = (response) => {
1763
- return {
1764
- /** @returns An async iterator for NDJSON lines. */
1765
- [Symbol.asyncIterator]() {
1766
- const reader = response.body.getReader();
1767
- const decoder = new TextDecoder();
1768
- let buffer = "";
1769
- let done = false;
1770
- return {
1771
- /** @returns The next parsed JSON value or done signal. */
1772
- async next() {
1773
- while (!done) {
1774
- const lineEnd = buffer.indexOf("\n");
1775
- if (lineEnd !== -1) {
1776
- const line = buffer.slice(0, lineEnd).trim();
1777
- buffer = buffer.slice(lineEnd + 1);
1778
- if (line) {
1779
- return { value: JSON.parse(line), done: false };
1780
- }
1781
- continue;
1782
- }
1783
- const result = await reader.read();
1784
- if (result.done) {
1785
- done = true;
1786
- const remaining = (buffer + decoder.decode()).trim();
1787
- buffer = "";
1788
- if (remaining) {
1789
- return { value: JSON.parse(remaining), done: false };
1790
- }
820
+ case "data":
821
+ R2.push(c);
822
+ break;
823
+ case "id":
824
+ d.id = c;
825
+ break;
826
+ case "retry": {
827
+ let S2 = parseInt(c, 10);
828
+ isNaN(S2) || (d.retry = S2);
1791
829
  break;
1792
830
  }
1793
- buffer += decoder.decode(result.value, { stream: true });
1794
831
  }
1795
- return { value: void 0, done: true };
1796
- },
1797
- /** @returns Done signal after cancelling the reader. */
1798
- async return() {
1799
- await reader.cancel();
1800
- done = true;
1801
- return { value: void 0, done: true };
1802
832
  }
1803
- };
1804
- }
1805
- };
1806
- };
1807
-
1808
- // src/utils.ts
1809
- var isRequestBodyMethod = (method) => method !== void 0 && requestBodyMethods.includes(method);
1810
- var isRawBody = (body) => body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof ReadableStream || body instanceof URLSearchParams || ArrayBuffer.isView(body);
1811
- var getCookieValue = (name) => {
1812
- if (typeof document === "undefined" || !document.cookie) {
1813
- return;
1814
- }
1815
- const prefix = `${name}=`;
1816
- const cookies = document.cookie.split(";");
1817
- for (let i = 0, length = cookies.length; i < length; i++) {
1818
- const cookie = cookies[i].trim();
1819
- if (cookie.startsWith(prefix)) {
1820
- return decodeURIComponent(cookie.slice(prefix.length));
1821
- }
1822
- }
1823
- return void 0;
1824
- };
1825
- var serialize = (data) => JSON.stringify(data);
1826
- var isString = (value) => value !== null && typeof value === "string";
1827
- var isArrayBuffer = (value) => value instanceof ArrayBuffer || Object.prototype.toString.call(value) === "[object ArrayBuffer]";
1828
- var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
1829
- var objectMerge = (...objects) => {
1830
- const length = objects.length;
1831
- if (length === 0) {
1832
- return void 0;
1833
- }
1834
- if (length === 1) {
1835
- const [obj] = objects;
1836
- if (!isObject(obj)) {
1837
- return obj;
1838
- }
1839
- return deepClone(obj);
1840
- }
1841
- const target = {};
1842
- for (const source of objects) {
1843
- if (!isObject(source)) {
1844
- return void 0;
1845
- }
1846
- for (const [property, sourceValue] of Object.entries(source)) {
1847
- const targetValue = target[property];
1848
- if (Array.isArray(sourceValue)) {
1849
- target[property] = [...sourceValue, ...Array.isArray(targetValue) ? targetValue.filter((item) => !sourceValue.includes(item)) : []];
1850
- } else if (isObject(sourceValue)) {
1851
- target[property] = isObject(targetValue) ? objectMerge(targetValue, sourceValue) : deepClone(sourceValue);
1852
- } else {
1853
- target[property] = sourceValue;
833
+ if (d.data = R2.join(`
834
+ `), d.data || d.event !== "message") return { value: d, done: false };
835
+ continue;
1854
836
  }
1855
- }
837
+ let i = await e.read();
838
+ if (i.done) {
839
+ r2 = true;
840
+ break;
841
+ }
842
+ n += t.decode(i.value, { stream: true });
843
+ }
844
+ return { value: void 0, done: true };
845
+ }, async return() {
846
+ return await e.cancel(), r2 = true, { value: void 0, done: true };
847
+ } };
848
+ } });
849
+ var we2 = (s2) => ({ [Symbol.asyncIterator]() {
850
+ let e = s2.body.getReader(), t = new TextDecoder(), n = "", r2 = false;
851
+ return { async next() {
852
+ for (; !r2; ) {
853
+ let o = n.indexOf(`
854
+ `);
855
+ if (o !== -1) {
856
+ let a = n.slice(0, o).trim();
857
+ if (n = n.slice(o + 1), a) return { value: JSON.parse(a), done: false };
858
+ continue;
859
+ }
860
+ let i = await e.read();
861
+ if (i.done) {
862
+ r2 = true;
863
+ let a = (n + t.decode()).trim();
864
+ if (n = "", a) return { value: JSON.parse(a), done: false };
865
+ break;
866
+ }
867
+ n += t.decode(i.value, { stream: true });
868
+ }
869
+ return { value: void 0, done: true };
870
+ }, async return() {
871
+ return await e.cancel(), r2 = true, { value: void 0, done: true };
872
+ } };
873
+ } });
874
+ var ve2 = (s2) => s2 !== void 0 && Re.includes(s2);
875
+ var qe = (s2) => s2 instanceof FormData || s2 instanceof Blob || s2 instanceof ArrayBuffer || s2 instanceof ReadableStream || s2 instanceof URLSearchParams || ArrayBuffer.isView(s2);
876
+ var Pe2 = (s2) => {
877
+ if (typeof document > "u" || !document.cookie) return;
878
+ let e = `${s2}=`, t = document.cookie.split(";");
879
+ for (let n = 0, r2 = t.length; n < r2; n++) {
880
+ let o = t[n].trim();
881
+ if (o.startsWith(e)) return decodeURIComponent(o.slice(e.length));
1856
882
  }
1857
- return target;
1858
883
  };
1859
- function deepClone(object) {
1860
- if (isObject(object)) {
1861
- const cloned = {};
1862
- const keys = Object.keys(object);
1863
- for (let i = 0, length = keys.length, key; i < length; i++) {
1864
- key = keys[i];
1865
- cloned[key] = deepClone(object[key]);
1866
- }
1867
- return cloned;
884
+ var He = (s2) => JSON.stringify(s2);
885
+ var j = (s2) => s2 !== null && typeof s2 == "string";
886
+ var Ae = (s2) => s2 instanceof ArrayBuffer || Object.prototype.toString.call(s2) === "[object ArrayBuffer]";
887
+ var y2 = (s2) => s2 !== null && typeof s2 == "object" && !Array.isArray(s2) && Object.getPrototypeOf(s2) === Object.prototype;
888
+ var F = (...s2) => {
889
+ let e = s2.length;
890
+ if (e === 0) return;
891
+ if (e === 1) {
892
+ let [n] = s2;
893
+ return y2(n) ? se(n) : n;
894
+ }
895
+ let t = {};
896
+ for (let n of s2) {
897
+ if (!y2(n)) return;
898
+ for (let [r2, o] of Object.entries(n)) {
899
+ let i = t[r2];
900
+ Array.isArray(o) ? t[r2] = [...o, ...Array.isArray(i) ? i.filter((a) => !o.includes(a)) : []] : y2(o) ? t[r2] = y2(i) ? F(i, o) : se(o) : t[r2] = o;
901
+ }
902
+ }
903
+ return t;
904
+ };
905
+ function se(s2) {
906
+ if (y2(s2)) {
907
+ let e = {}, t = Object.keys(s2);
908
+ for (let n = 0, r2 = t.length, o; n < r2; n++) o = t[n], e[o] = se(s2[o]);
909
+ return e;
1868
910
  }
1869
- return object;
911
+ return s2;
1870
912
  }
1871
-
1872
- // src/transportr.ts
1873
- var Transportr = class _Transportr {
913
+ var ke2 = class s {
1874
914
  _baseUrl;
1875
915
  _options;
1876
916
  subscribr;
1877
917
  hooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
1878
- static globalSubscribr = new d2();
918
+ static globalSubscribr = new I();
1879
919
  static globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
1880
920
  static signalControllers = /* @__PURE__ */ new Set();
1881
- /** Map of in-flight deduplicated requests keyed by URL + method */
1882
921
  static inflightRequests = /* @__PURE__ */ new Map();
1883
- /** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */
1884
- static mediaTypeCache = new Map(Object.values(mediaTypes).map((mediaType) => [mediaType.toString(), mediaType]));
1885
- static contentTypeHandlers = [
1886
- [mediaTypes.TEXT.type, handleText],
1887
- [mediaTypes.JSON.subtype, handleJson],
1888
- [mediaTypes.BIN.subtype, handleReadableStream],
1889
- [mediaTypes.HTML.subtype, handleHtml],
1890
- [mediaTypes.XML.subtype, handleXml],
1891
- [mediaTypes.PNG.type, handleImage],
1892
- [mediaTypes.JAVA_SCRIPT.subtype, handleScript],
1893
- [mediaTypes.CSS.subtype, handleCss]
1894
- ];
1895
- /**
1896
- * Create a new Transportr instance with the provided location or origin and context path.
1897
- *
1898
- * @param url The URL for {@link fetch} requests.
1899
- * @param options The default {@link RequestOptions} for this instance.
1900
- */
1901
- constructor(url = defaultOrigin, options = {}) {
1902
- if (isObject(url)) {
1903
- [url, options] = [defaultOrigin, url];
1904
- }
1905
- this._baseUrl = _Transportr.getBaseUrl(url);
1906
- this._options = _Transportr.createOptions(options, _Transportr.defaultRequestOptions);
1907
- this.subscribr = new d2();
1908
- }
1909
- /** Credentials Policy */
1910
- static CredentialsPolicy = {
1911
- INCLUDE: "include",
1912
- OMIT: "omit",
1913
- SAME_ORIGIN: "same-origin"
1914
- };
1915
- /** Request Mode */
1916
- static RequestMode = {
1917
- CORS: "cors",
1918
- NAVIGATE: "navigate",
1919
- NO_CORS: "no-cors",
1920
- SAME_ORIGIN: "same-origin"
1921
- };
1922
- /** Request Priority */
1923
- static RequestPriority = {
1924
- HIGH: "high",
1925
- LOW: "low",
1926
- AUTO: "auto"
1927
- };
1928
- /** Redirect Policy */
1929
- static RedirectPolicy = {
1930
- ERROR: "error",
1931
- FOLLOW: "follow",
1932
- MANUAL: "manual"
1933
- };
1934
- /** Referrer Policy */
1935
- static ReferrerPolicy = {
1936
- NO_REFERRER: "no-referrer",
1937
- NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade",
1938
- ORIGIN: "origin",
1939
- ORIGIN_WHEN_CROSS_ORIGIN: "origin-when-cross-origin",
1940
- SAME_ORIGIN: "same-origin",
1941
- STRICT_ORIGIN: "strict-origin",
1942
- STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin",
1943
- UNSAFE_URL: "unsafe-url"
1944
- };
1945
- /** Request Event */
1946
- static RequestEvent = RequestEvent;
1947
- /** Default Request Options */
1948
- static defaultRequestOptions = {
1949
- body: void 0,
1950
- cache: RequestCachingPolicy.NO_STORE,
1951
- credentials: _Transportr.CredentialsPolicy.SAME_ORIGIN,
1952
- headers: new Headers({ "content-type": defaultMediaType, "accept": defaultMediaType }),
1953
- searchParams: void 0,
1954
- integrity: void 0,
1955
- keepalive: void 0,
1956
- method: "GET",
1957
- mode: _Transportr.RequestMode.CORS,
1958
- priority: _Transportr.RequestPriority.AUTO,
1959
- redirect: _Transportr.RedirectPolicy.FOLLOW,
1960
- referrer: "about:client",
1961
- referrerPolicy: _Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,
1962
- signal: void 0,
1963
- timeout: 3e4,
1964
- global: true
1965
- };
1966
- /**
1967
- * @internal
1968
- * @param event The event to subscribe to.
1969
- * @param handler The event handler.
1970
- * @param context The context to bind the handler to.
1971
- * @returns A new {@link EventRegistration} instance.
1972
- */
1973
- static register(event, handler, context) {
1974
- return _Transportr.globalSubscribr.subscribe(event, handler, context);
1975
- }
1976
- /**
1977
- * Removes a {@link EventRegistration} from the global event handler.
1978
- *
1979
- * @param eventRegistration The {@link EventRegistration} to remove.
1980
- * @returns True if the {@link EventRegistration} was removed, false otherwise.
1981
- */
1982
- static unregister(eventRegistration) {
1983
- return _Transportr.globalSubscribr.unsubscribe(eventRegistration);
1984
- }
1985
- /**
1986
- * Aborts all active requests.
1987
- * This is useful for when the user navigates away from the current page.
1988
- * This will also clear the {@link Transportr#signalControllers} set.
1989
- */
922
+ static mediaTypeCache = new Map(Object.values(m).map((e) => [e.toString(), e]));
923
+ static contentTypeHandlers = [[m.TEXT.type, be], [m.JSON.subtype, Y], [m.BIN.subtype, Z2], [m.HTML.subtype, te], [m.XML.subtype, ee], [m.PNG.type, Q2], [m.JAVA_SCRIPT.subtype, K2], [m.CSS.subtype, W]];
924
+ constructor(e = G, t = {}) {
925
+ y2(e) && ([e, t] = [G, e]), this._baseUrl = s.getBaseUrl(e), this._options = s.createOptions(t, s.defaultRequestOptions), this.subscribr = new I();
926
+ }
927
+ static CredentialsPolicy = { INCLUDE: "include", OMIT: "omit", SAME_ORIGIN: "same-origin" };
928
+ static RequestMode = { CORS: "cors", NAVIGATE: "navigate", NO_CORS: "no-cors", SAME_ORIGIN: "same-origin" };
929
+ static RequestPriority = { HIGH: "high", LOW: "low", AUTO: "auto" };
930
+ static RedirectPolicy = { ERROR: "error", FOLLOW: "follow", MANUAL: "manual" };
931
+ 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" };
932
+ static RequestEvent = b2;
933
+ static defaultRequestOptions = { body: void 0, cache: pe2.NO_STORE, credentials: s.CredentialsPolicy.SAME_ORIGIN, headers: new Headers({ "content-type": $, accept: $ }), searchParams: void 0, integrity: void 0, keepalive: void 0, method: "GET", mode: s.RequestMode.CORS, priority: s.RequestPriority.AUTO, redirect: s.RedirectPolicy.FOLLOW, referrer: "about:client", referrerPolicy: s.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN, signal: void 0, timeout: 3e4, global: true };
934
+ static register(e, t, n) {
935
+ return s.globalSubscribr.subscribe(e, t, n);
936
+ }
937
+ static unregister(e) {
938
+ return s.globalSubscribr.unsubscribe(e);
939
+ }
1990
940
  static abortAll() {
1991
- for (const signalController of this.signalControllers) {
1992
- signalController.abort(abortEvent());
1993
- }
941
+ for (let e of this.signalControllers) e.abort(M());
1994
942
  this.signalControllers.clear();
1995
943
  }
1996
- /**
1997
- * Executes multiple requests concurrently and resolves when all complete.
1998
- * @param requests An array of promises from Transportr request methods.
1999
- * @returns A promise resolving to an array of all results.
2000
- */
2001
- static all(requests) {
2002
- return Promise.all(requests);
2003
- }
2004
- /**
2005
- * Races multiple requests concurrently. The first to settle wins; all others are aborted.
2006
- * Each factory receives an AbortSignal that the caller should pass to the request options.
2007
- * @template T The expected result type.
2008
- * @param requests An array of functions that accept an AbortSignal and return a promise.
2009
- * @returns A promise resolving to the first settled result.
2010
- * @example
2011
- * ```typescript
2012
- * const result = await Transportr.race([
2013
- * (signal) => api.getJson('/primary', { signal }),
2014
- * (signal) => api.getJson('/fallback', { signal })
2015
- * ]);
2016
- * ```
2017
- */
2018
- static async race(requests) {
2019
- const controllers = [];
2020
- const promises = new Array(requests.length);
2021
- for (let i = 0; i < requests.length; i++) {
2022
- const controller = new AbortController();
2023
- controllers.push(controller);
2024
- promises[i] = requests[i](controller.signal);
944
+ static all(e) {
945
+ return Promise.all(e);
946
+ }
947
+ static async race(e) {
948
+ let t = [], n = new Array(e.length);
949
+ for (let r2 = 0; r2 < e.length; r2++) {
950
+ let o = new AbortController();
951
+ t.push(o), n[r2] = e[r2](o.signal);
2025
952
  }
2026
953
  try {
2027
- return await Promise.race(promises);
954
+ return await Promise.race(n);
2028
955
  } finally {
2029
- for (const controller_1 of controllers) {
2030
- controller_1.abort();
2031
- }
956
+ for (let r2 of t) r2.abort();
2032
957
  }
2033
958
  }
2034
- /**
2035
- * Registers a custom content-type response handler.
2036
- * The handler will be matched against response content-type headers using MediaType matching.
2037
- * New handlers are prepended so they take priority over built-in handlers.
2038
- *
2039
- * @param contentType The content-type string to match (e.g. 'application/pdf', 'text', 'csv').
2040
- * @param handler The response handler function.
2041
- */
2042
- static registerContentTypeHandler(contentType, handler) {
2043
- _Transportr.contentTypeHandlers.unshift([contentType, handler]);
2044
- }
2045
- /**
2046
- * Removes a previously registered content-type response handler.
2047
- *
2048
- * @param contentType The content-type string to remove.
2049
- * @returns True if the handler was found and removed, false otherwise.
2050
- */
2051
- static unregisterContentTypeHandler(contentType) {
2052
- const index = _Transportr.contentTypeHandlers.findIndex(([type]) => type === contentType);
2053
- if (index === -1) {
2054
- return false;
2055
- }
2056
- _Transportr.contentTypeHandlers.splice(index, 1);
2057
- return true;
959
+ static registerContentTypeHandler(e, t) {
960
+ s.contentTypeHandlers.unshift([e, t]);
2058
961
  }
2059
- /**
2060
- * Registers global lifecycle hooks that run on all requests from all instances.
2061
- * Global hooks execute before instance and per-request hooks.
2062
- *
2063
- * @param hooks The hooks to register globally.
2064
- */
2065
- static addHooks(hooks) {
2066
- if (hooks.beforeRequest) {
2067
- _Transportr.globalHooks.beforeRequest.push(...hooks.beforeRequest);
2068
- }
2069
- if (hooks.afterResponse) {
2070
- _Transportr.globalHooks.afterResponse.push(...hooks.afterResponse);
2071
- }
2072
- if (hooks.beforeError) {
2073
- _Transportr.globalHooks.beforeError.push(...hooks.beforeError);
2074
- }
962
+ static unregisterContentTypeHandler(e) {
963
+ let t = s.contentTypeHandlers.findIndex(([n]) => n === e);
964
+ return t === -1 ? false : (s.contentTypeHandlers.splice(t, 1), true);
965
+ }
966
+ static addHooks(e) {
967
+ e.beforeRequest && s.globalHooks.beforeRequest.push(...e.beforeRequest), e.afterResponse && s.globalHooks.afterResponse.push(...e.afterResponse), e.beforeError && s.globalHooks.beforeError.push(...e.beforeError);
2075
968
  }
2076
- /**
2077
- * Removes all global lifecycle hooks.
2078
- */
2079
969
  static clearHooks() {
2080
- _Transportr.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
970
+ s.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };
2081
971
  }
2082
- /**
2083
- * Tears down all global state: aborts in-flight requests, clears global event subscriptions,
2084
- * hooks, in-flight deduplication map, and media type cache (retaining built-in entries).
2085
- */
2086
972
  static unregisterAll() {
2087
- _Transportr.abortAll();
2088
- _Transportr.globalSubscribr = new d2();
2089
- _Transportr.clearHooks();
2090
- _Transportr.inflightRequests.clear();
2091
- }
2092
- /**
2093
- * It returns the base {@link URL} for the API.
2094
- *
2095
- * @returns The baseUrl property.
2096
- */
973
+ s.abortAll(), s.globalSubscribr = new I(), s.clearHooks(), s.inflightRequests.clear();
974
+ }
2097
975
  get baseUrl() {
2098
976
  return this._baseUrl;
2099
977
  }
2100
- /**
2101
- * @internal
2102
- * @param event The event to subscribe to.
2103
- * @param handler The event handler.
2104
- * @param context The context to bind the handler to.
2105
- * @returns An object that can be used to remove the event handler.
2106
- */
2107
- register(event, handler, context) {
2108
- return this.subscribr.subscribe(event, handler, context);
2109
- }
2110
- /**
2111
- * Unregisters an event handler from a {@link Transportr} instance.
2112
- *
2113
- * @param eventRegistration The event registration to remove.
2114
- * @returns True if the {@link EventRegistration} was removed, false otherwise.
2115
- */
2116
- unregister(eventRegistration) {
2117
- return this.subscribr.unsubscribe(eventRegistration);
2118
- }
2119
- /**
2120
- * Registers instance-level lifecycle hooks that run on all requests from this instance.
2121
- * Instance hooks execute after global hooks but before per-request hooks.
2122
- *
2123
- * @param hooks The hooks to register on this instance.
2124
- * @returns This instance for method chaining.
2125
- */
2126
- addHooks(hooks) {
2127
- if (hooks.beforeRequest) {
2128
- this.hooks.beforeRequest.push(...hooks.beforeRequest);
2129
- }
2130
- if (hooks.afterResponse) {
2131
- this.hooks.afterResponse.push(...hooks.afterResponse);
2132
- }
2133
- if (hooks.beforeError) {
2134
- this.hooks.beforeError.push(...hooks.beforeError);
2135
- }
2136
- return this;
978
+ register(e, t, n) {
979
+ return this.subscribr.subscribe(e, t, n);
980
+ }
981
+ unregister(e) {
982
+ return this.subscribr.unsubscribe(e);
983
+ }
984
+ addHooks(e) {
985
+ return e.beforeRequest && this.hooks.beforeRequest.push(...e.beforeRequest), e.afterResponse && this.hooks.afterResponse.push(...e.afterResponse), e.beforeError && this.hooks.beforeError.push(...e.beforeError), this;
2137
986
  }
2138
- /**
2139
- * Removes all instance-level lifecycle hooks.
2140
- * @returns This instance for method chaining.
2141
- */
2142
987
  clearHooks() {
2143
- this.hooks.beforeRequest.length = 0;
2144
- this.hooks.afterResponse.length = 0;
2145
- this.hooks.beforeError.length = 0;
2146
- return this;
2147
- }
2148
- /**
2149
- * Updates the instance's default options after construction.
2150
- * Mirrors what the constructor accepts: headers and searchParams are merged onto
2151
- * the existing defaults; all other options overwrite the current value; hooks
2152
- * are appended via {@link addHooks}.
2153
- *
2154
- * @param options The options to apply. Accepts the same shape as the constructor.
2155
- * @returns This instance for method chaining.
2156
- */
2157
- configure({ headers, searchParams, hooks, ...options }) {
2158
- if (headers) {
2159
- _Transportr.mergeHeaders(this._options.headers, headers);
2160
- }
2161
- if (searchParams) {
2162
- _Transportr.mergeSearchParams(this._options.searchParams, searchParams);
2163
- }
2164
- if (Object.keys(options).length > 0) {
2165
- Object.assign(this._options, options);
2166
- }
2167
- if (hooks) {
2168
- this.addHooks(hooks);
2169
- }
2170
- return this;
988
+ return this.hooks.beforeRequest.length = 0, this.hooks.afterResponse.length = 0, this.hooks.beforeError.length = 0, this;
989
+ }
990
+ configure({ headers: e, searchParams: t, hooks: n, ...r2 }) {
991
+ return e && s.mergeHeaders(this._options.headers, e), t && s.mergeSearchParams(this._options.searchParams, t), Object.keys(r2).length > 0 && Object.assign(this._options, r2), n && this.addHooks(n), this;
2171
992
  }
2172
- /**
2173
- * Tears down this instance: clears all instance subscriptions and hooks.
2174
- * The instance should not be used after calling this method.
2175
- */
2176
993
  destroy() {
2177
- this.clearHooks();
2178
- this.subscribr.destroy();
2179
- }
2180
- /**
2181
- * This function returns a promise that resolves to the result of a request to the specified path with
2182
- * the specified options, where the method is GET.
2183
- *
2184
- * @async
2185
- * @param path The path to the resource you want to get.
2186
- * @param options The options for the request.
2187
- * @returns A promise that resolves to the response of the request.
2188
- */
2189
- async get(path, options) {
2190
- return this._get(path, options);
2191
- }
2192
- /**
2193
- * This function makes a POST request to the given path with the given body and options.
2194
- *
2195
- * @async
2196
- * @template T The expected response type (defaults to ResponseBody)
2197
- * @param path The path to the endpoint you want to call.
2198
- * @param body The body of the request.
2199
- * @param options The options for the request.
2200
- * @returns A promise that resolves to the response body.
2201
- */
2202
- async post(path, body, options) {
2203
- return this.executeBodyMethod("POST", path, body, options);
2204
- }
2205
- /**
2206
- * This function returns a promise that resolves to the result of a request to the specified path with
2207
- * the specified options, where the method is PUT.
2208
- *
2209
- * @async
2210
- * @template T The expected response type (defaults to ResponseBody)
2211
- * @param path The path to the endpoint you want to call.
2212
- * @param body The body of the request.
2213
- * @param options The options for the request.
2214
- * @returns The return value of the #request method.
2215
- */
2216
- async put(path, body, options) {
2217
- return this.executeBodyMethod("PUT", path, body, options);
2218
- }
2219
- /**
2220
- * It takes a path and options, and returns a request with the method set to PATCH.
2221
- *
2222
- * @async
2223
- * @template T The expected response type (defaults to ResponseBody)
2224
- * @param path The path to the endpoint you want to hit.
2225
- * @param body The body of the request.
2226
- * @param options The options for the request.
2227
- * @returns A promise that resolves to the response of the request.
2228
- */
2229
- async patch(path, body, options) {
2230
- return this.executeBodyMethod("PATCH", path, body, options);
2231
- }
2232
- /**
2233
- * It takes a path and options, and returns a request with the method set to DELETE.
2234
- *
2235
- * @async
2236
- * @param path The path to the resource you want to access.
2237
- * @param body The body of the request.
2238
- * @param options The options for the request.
2239
- * @returns The result of the request.
2240
- */
2241
- async delete(path, body, options) {
2242
- return this.executeBodyMethod("DELETE", path, body, options);
2243
- }
2244
- /**
2245
- * Returns the response headers of a request to the given path.
2246
- *
2247
- * @async
2248
- * @param path The path to the resource you want to access.
2249
- * @param options The options for the request.
2250
- * @returns A promise that resolves to the response object.
2251
- */
2252
- async head(path, options) {
2253
- return this.execute(path, options, { method: "HEAD" });
2254
- }
2255
- /**
2256
- * It returns a promise that resolves to the allowed request methods for the given resource path.
2257
- *
2258
- * @async
2259
- * @param path The path to the resource.
2260
- * @param options The options for the request.
2261
- * @returns A promise that resolves to an array of allowed request methods for this resource.
2262
- */
2263
- async options(path, options = {}) {
2264
- if (isObject(path)) {
2265
- [path, options] = [void 0, path];
2266
- }
2267
- const requestConfig = this.processRequestOptions(options, { method: "OPTIONS" });
2268
- const { requestOptions } = requestConfig;
2269
- const unwrap = requestOptions.unwrap !== false;
2270
- const requestHooks = requestOptions.hooks;
2271
- try {
2272
- let url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2273
- const beforeRequestHookSets = [_Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest];
2274
- for (const hooks of beforeRequestHookSets) {
2275
- if (!hooks) {
2276
- continue;
2277
- }
2278
- for (const hook of hooks) {
2279
- const result = await hook(requestOptions, url);
2280
- if (result) {
2281
- Object.assign(requestOptions, result);
2282
- if (result.searchParams !== void 0) {
2283
- url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2284
- }
2285
- }
2286
- }
2287
- }
2288
- let response = await this._request(path, requestConfig);
2289
- const afterResponseHookSets = [_Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse];
2290
- for (const hooks of afterResponseHookSets) {
2291
- if (!hooks) {
2292
- continue;
2293
- }
2294
- for (const hook of hooks) {
2295
- const result = await hook(response, requestOptions);
2296
- if (result) {
2297
- response = result;
2298
- }
2299
- }
2300
- }
2301
- const allowedMethods = response.headers.get("allow")?.split(",").map((method) => method.trim());
2302
- this.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });
2303
- return unwrap ? allowedMethods : [true, allowedMethods];
2304
- } catch (error) {
2305
- if (!unwrap) return [false, error];
2306
- throw error;
2307
- }
994
+ this.clearHooks(), this.subscribr.destroy();
2308
995
  }
2309
- /**
2310
- * It takes a path and options, and makes a request to the server
2311
- * @async
2312
- * @param path The path to the endpoint you want to hit.
2313
- * @param options The options for the request.
2314
- * @returns The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.
2315
- * @throws {HttpError} If an error occurs during the request.
2316
- */
2317
- async request(path, options = {}) {
2318
- if (isObject(path)) {
2319
- [path, options] = [void 0, path];
2320
- }
2321
- const requestConfig = this.processRequestOptions(options, {});
2322
- const unwrap = requestConfig.requestOptions.unwrap !== false;
2323
- try {
2324
- const response = await this._request(path, requestConfig);
2325
- this.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });
2326
- return unwrap ? response : [true, response];
2327
- } catch (error) {
2328
- if (!unwrap) return [false, error];
2329
- throw error;
2330
- }
996
+ async get(e, t) {
997
+ return this._get(e, t);
2331
998
  }
2332
- /**
2333
- * It gets the JSON representation of the resource at the given path.
2334
- *
2335
- * @async
2336
- * @template T The expected JSON response type (defaults to JsonObject)
2337
- * @param path The path to the resource.
2338
- * @param options The options object to pass to the request.
2339
- * @returns A promise that resolves to the response body as a typed JSON value.
2340
- */
2341
- async getJson(path, options) {
2342
- return this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);
2343
- }
2344
- /**
2345
- * It gets the XML representation of the resource at the given path.
2346
- *
2347
- * @async
2348
- * @param path The path to the resource you want to get.
2349
- * @param options The options for the request.
2350
- * @returns The result of the function call to #get.
2351
- */
2352
- async getXml(path, options) {
2353
- return this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);
2354
- }
2355
- /**
2356
- * Get the HTML content of the specified path.
2357
- * When a selector is provided, returns only the first matching element from the parsed document.
2358
- *
2359
- * @async
2360
- * @param path The path to the resource.
2361
- * @param options The options for the request.
2362
- * @param selector An optional CSS selector to extract a specific element from the parsed HTML.
2363
- * @returns A promise that resolves to a Document, an Element (if selector matched), or void.
2364
- */
2365
- async getHtml(path, options, selector) {
2366
- const doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);
2367
- if (Array.isArray(doc)) return doc;
2368
- return selector && doc ? doc.querySelector(selector) : doc;
2369
- }
2370
- /**
2371
- * It returns a promise that resolves to the HTML fragment at the given path.
2372
- * When a selector is provided, returns only the first matching element from the parsed fragment.
2373
- *
2374
- * @async
2375
- * @param path The path to the resource.
2376
- * @param options The options for the request.
2377
- * @param selector An optional CSS selector to extract a specific element from the parsed fragment.
2378
- * @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.
2379
- */
2380
- async getHtmlFragment(path, options, selector) {
2381
- const fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtmlFragment);
2382
- if (Array.isArray(fragment)) return fragment;
2383
- return selector && fragment ? fragment.querySelector(selector) : fragment;
2384
- }
2385
- /**
2386
- * It gets a script from the server, and appends the script to the Document HTMLHeadElement
2387
- * @param path The path to the script.
2388
- * @param options The options for the request.
2389
- * @returns A promise that resolves to void.
2390
- */
2391
- async getScript(path, options) {
2392
- return this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);
2393
- }
2394
- /**
2395
- * Gets a stylesheet from the server, and adds it as a Blob URL.
2396
- * @param path The path to the stylesheet.
2397
- * @param options The options for the request.
2398
- * @returns A promise that resolves to void.
2399
- */
2400
- async getStylesheet(path, options) {
2401
- return this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);
2402
- }
2403
- /**
2404
- * It returns a blob from the specified path.
2405
- * @param path The path to the resource.
2406
- * @param options The options for the request.
2407
- * @returns A promise that resolves to a Blob or void.
2408
- */
2409
- async getBlob(path, options) {
2410
- return this._get(path, options, { headers: { accept: "application/octet-stream" } }, handleBlob);
2411
- }
2412
- /**
2413
- * It returns a promise that resolves to an `HTMLImageElement`.
2414
- * The object URL created to load the image is automatically revoked to prevent memory leaks.
2415
- * Works in both browser and Node.js (via JSDOM) environments.
2416
- * @param path The path to the image.
2417
- * @param options The options for the request.
2418
- * @returns A promise that resolves to an `HTMLImageElement` or `void`.
2419
- */
2420
- async getImage(path, options) {
2421
- return this._get(path, options, { headers: { accept: "image/*" } }, handleImage);
2422
- }
2423
- /**
2424
- * It gets a buffer from the specified path
2425
- * @param path The path to the resource.
2426
- * @param options The options for the request.
2427
- * @returns A promise that resolves to an ArrayBuffer or void.
2428
- */
2429
- async getBuffer(path, options) {
2430
- return this._get(path, options, { headers: { accept: "application/octet-stream" } }, handleBuffer);
2431
- }
2432
- /**
2433
- * It returns a readable stream of the response body from the specified path.
2434
- * @param path The path to the resource.
2435
- * @param options The options for the request.
2436
- * @returns A promise that resolves to a ReadableStream, null, or void.
2437
- */
2438
- async getStream(path, options) {
2439
- return this._get(path, options, { headers: { accept: "application/octet-stream" } }, handleReadableStream);
2440
- }
2441
- /**
2442
- * Opens a Server-Sent Events stream and returns an AsyncIterable of typed events.
2443
- * Follows the EventStream specification for parsing event, data, id, and retry fields.
2444
- * Iteration ends when the server closes the stream or the request is aborted.
2445
- *
2446
- * @async
2447
- * @param path The path to the SSE endpoint.
2448
- * @param options The options for the request.
2449
- * @returns An AsyncIterable of parsed ServerSentEvent objects.
2450
- * @example
2451
- * ```typescript
2452
- * for await (const event of api.getEventStream('/chat/completions', { body: { prompt } })) {
2453
- * console.log(event.event, event.data);
2454
- * }
2455
- * ```
2456
- */
2457
- async getEventStream(path, options) {
2458
- if (isObject(path)) {
2459
- [path, options] = [void 0, path];
2460
- }
2461
- const requestConfig = this.processRequestOptions(options ?? {}, { method: options?.body ? "POST" : "GET", headers: { accept: `${mediaTypes.EVENT_STREAM}` } });
2462
- const { requestOptions } = requestConfig;
2463
- const unwrap = requestOptions.unwrap !== false;
2464
- const requestHooks = requestOptions.hooks;
2465
- try {
2466
- let url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2467
- const beforeRequestHookSets = [_Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest];
2468
- for (const hooks of beforeRequestHookSets) {
2469
- if (!hooks) {
2470
- continue;
2471
- }
2472
- for (const hook of hooks) {
2473
- const result = await hook(requestOptions, url);
2474
- if (result) {
2475
- Object.assign(requestOptions, result);
2476
- if (result.searchParams !== void 0) {
2477
- url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2478
- }
2479
- }
2480
- }
2481
- }
2482
- const response = await this._request(path, requestConfig);
2483
- let afterResponse = response;
2484
- const afterResponseHookSets = [_Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse];
2485
- for (const hooks of afterResponseHookSets) {
2486
- if (!hooks) {
2487
- continue;
2488
- }
2489
- for (const hook of hooks) {
2490
- const result = await hook(afterResponse, requestOptions);
2491
- if (result) {
2492
- afterResponse = result;
2493
- }
2494
- }
2495
- }
2496
- this.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });
2497
- const stream = handleEventStream(afterResponse);
2498
- return unwrap ? stream : [true, stream];
2499
- } catch (error) {
2500
- if (!unwrap) return [false, error];
2501
- throw error;
2502
- }
999
+ async post(e, t, n) {
1000
+ return this.executeBodyMethod("POST", e, t, n);
2503
1001
  }
2504
- /**
2505
- * Opens an NDJSON (Newline Delimited JSON) stream and returns an AsyncIterable of typed JSON values.
2506
- * Each line is independently parsed as JSON, making it suitable for streaming large datasets
2507
- * or real-time JSON feeds.
2508
- *
2509
- * @async
2510
- * @template T The expected type of each JSON line (defaults to Json).
2511
- * @param path The path to the NDJSON endpoint.
2512
- * @param options The options for the request.
2513
- * @returns An AsyncIterable of parsed JSON values.
2514
- * @example
2515
- * ```typescript
2516
- * for await (const user of api.getJsonStream<User>('/users/export')) {
2517
- * processUser(user);
2518
- * }
2519
- * ```
2520
- */
2521
- async getJsonStream(path, options) {
2522
- if (isObject(path)) {
2523
- [path, options] = [void 0, path];
2524
- }
2525
- const requestConfig = this.processRequestOptions(options ?? {}, { method: "GET", headers: { accept: `${mediaTypes.NDJSON}` } });
2526
- const { requestOptions } = requestConfig;
2527
- const unwrap = requestOptions.unwrap !== false;
2528
- const requestHooks = requestOptions.hooks;
1002
+ async put(e, t, n) {
1003
+ return this.executeBodyMethod("PUT", e, t, n);
1004
+ }
1005
+ async patch(e, t, n) {
1006
+ return this.executeBodyMethod("PATCH", e, t, n);
1007
+ }
1008
+ async delete(e, t, n) {
1009
+ return this.executeBodyMethod("DELETE", e, t, n);
1010
+ }
1011
+ async head(e, t) {
1012
+ return this.execute(e, t, { method: "HEAD" });
1013
+ }
1014
+ async options(e, t = {}) {
1015
+ y2(e) && ([e, t] = [void 0, e]);
1016
+ let n = this.processRequestOptions(t, { method: "OPTIONS" }), { requestOptions: r2 } = n, o = r2.unwrap !== false, i = r2.hooks;
2529
1017
  try {
2530
- let url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2531
- const beforeRequestHookSets = [_Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest];
2532
- for (const hooks of beforeRequestHookSets) {
2533
- if (!hooks) {
2534
- continue;
2535
- }
2536
- for (const hook of hooks) {
2537
- const result = await hook(requestOptions, url);
2538
- if (result) {
2539
- Object.assign(requestOptions, result);
2540
- if (result.searchParams !== void 0) {
2541
- url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2542
- }
2543
- }
2544
- }
2545
- }
2546
- const response = await this._request(path, requestConfig);
2547
- let afterResponse = response;
2548
- const afterResponseHookSets = [_Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse];
2549
- for (const hooks of afterResponseHookSets) {
2550
- if (!hooks) {
2551
- continue;
2552
- }
2553
- for (const hook of hooks) {
2554
- const result = await hook(afterResponse, requestOptions);
2555
- if (result) {
2556
- afterResponse = result;
2557
- }
2558
- }
2559
- }
2560
- this.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });
2561
- const stream = handleNdjsonStream(afterResponse);
2562
- return unwrap ? stream : [true, stream];
2563
- } catch (error) {
2564
- if (!unwrap) return [false, error];
2565
- throw error;
1018
+ let a = s.createUrl(this._baseUrl, e, r2.searchParams), d = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, i?.beforeRequest];
1019
+ for (let p of d) if (p) for (let l of p) {
1020
+ let u = await l(r2, a);
1021
+ u && (Object.assign(r2, u), u.searchParams !== void 0 && (a = s.createUrl(this._baseUrl, e, r2.searchParams)));
1022
+ }
1023
+ let R2 = await this._request(e, n), g = [s.globalHooks.afterResponse, this.hooks.afterResponse, i?.afterResponse];
1024
+ for (let p of g) if (p) for (let l of p) {
1025
+ let u = await l(R2, r2);
1026
+ u && (R2 = u);
1027
+ }
1028
+ let h2 = R2.headers.get("allow")?.split(",").map((p) => p.trim());
1029
+ return this.publish({ name: b2.SUCCESS, data: h2, global: t.global }), o ? h2 : [true, h2];
1030
+ } catch (a) {
1031
+ if (!o) return [false, a];
1032
+ throw a;
1033
+ }
1034
+ }
1035
+ async request(e, t = {}) {
1036
+ y2(e) && ([e, t] = [void 0, e]);
1037
+ let n = this.processRequestOptions(t, {}), r2 = n.requestOptions.unwrap !== false;
1038
+ try {
1039
+ let o = await this._request(e, n);
1040
+ return this.publish({ name: b2.SUCCESS, data: o, global: t.global }), r2 ? o : [true, o];
1041
+ } catch (o) {
1042
+ if (!r2) return [false, o];
1043
+ throw o;
2566
1044
  }
2567
1045
  }
2568
- /**
2569
- * Handles a GET request.
2570
- * @async
2571
- * @param path The path to the resource.
2572
- * @param userOptions The user options for the request.
2573
- * @param options The options for the request.
2574
- * @param responseHandler The response handler for the request.
2575
- * @returns A promise that resolves to the response body or void.
2576
- */
2577
- async _get(path, userOptions, options = {}, responseHandler) {
2578
- return this.execute(path, userOptions, { ...options, method: "GET", body: void 0 }, responseHandler);
2579
- }
2580
- /**
2581
- * It processes the request options and returns a new object with the processed options.
2582
- * @param path The path to the resource.
2583
- * @param processedRequestOptions The user options for the request.
2584
- * @returns A new object with the processed options.
2585
- */
2586
- async _request(path, { signalController, requestOptions, global }) {
2587
- _Transportr.signalControllers.add(signalController);
2588
- const retryConfig = _Transportr.normalizeRetryOptions(requestOptions.retry);
2589
- const method = requestOptions.method ?? "GET";
2590
- const canRetry = retryConfig.limit > 0 && retryConfig.methods.includes(method);
2591
- const canDedupe = requestOptions.dedupe === true && (method === "GET" || method === "HEAD");
2592
- let attempt = 0;
2593
- const startTime = performance.now();
2594
- const getTiming = () => {
2595
- const end = performance.now();
2596
- return { start: startTime, end, duration: end - startTime };
1046
+ async getJson(e, t) {
1047
+ return this._get(e, t, { headers: { accept: `${m.JSON}` } }, Y);
1048
+ }
1049
+ async getXml(e, t) {
1050
+ return this._get(e, t, { headers: { accept: `${m.XML}` } }, ee);
1051
+ }
1052
+ async getHtml(e, t, n) {
1053
+ let r2 = await this._get(e, t, { headers: { accept: `${m.HTML}` } }, te);
1054
+ return Array.isArray(r2) ? r2 : n && r2 ? r2.querySelector(n) : r2;
1055
+ }
1056
+ async getHtmlFragment(e, t, n) {
1057
+ let r2 = await this._get(e, t, { headers: { accept: `${m.HTML}` } }, Se);
1058
+ return Array.isArray(r2) ? r2 : n && r2 ? r2.querySelector(n) : r2;
1059
+ }
1060
+ async getScript(e, t) {
1061
+ return this._get(e, t, { headers: { accept: `${m.JAVA_SCRIPT}` } }, K2);
1062
+ }
1063
+ async getStylesheet(e, t) {
1064
+ return this._get(e, t, { headers: { accept: `${m.CSS}` } }, W);
1065
+ }
1066
+ async getBlob(e, t) {
1067
+ return this._get(e, t, { headers: { accept: "application/octet-stream" } }, Te);
1068
+ }
1069
+ async getImage(e, t) {
1070
+ return this._get(e, t, { headers: { accept: "image/*" } }, Q2);
1071
+ }
1072
+ async getBuffer(e, t) {
1073
+ return this._get(e, t, { headers: { accept: "application/octet-stream" } }, Ee);
1074
+ }
1075
+ async getStream(e, t) {
1076
+ return this._get(e, t, { headers: { accept: "application/octet-stream" } }, Z2);
1077
+ }
1078
+ async getEventStream(e, t) {
1079
+ y2(e) && ([e, t] = [void 0, e]);
1080
+ let n = this.processRequestOptions(t ?? {}, { method: t?.body ? "POST" : "GET", headers: { accept: `${m.EVENT_STREAM}` } }), { requestOptions: r2 } = n, o = r2.unwrap !== false, i = r2.hooks;
1081
+ try {
1082
+ let a = s.createUrl(this._baseUrl, e, r2.searchParams), d = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, i?.beforeRequest];
1083
+ for (let l of d) if (l) for (let u of l) {
1084
+ let c = await u(r2, a);
1085
+ c && (Object.assign(r2, c), c.searchParams !== void 0 && (a = s.createUrl(this._baseUrl, e, r2.searchParams)));
1086
+ }
1087
+ let g = await this._request(e, n), h2 = [s.globalHooks.afterResponse, this.hooks.afterResponse, i?.afterResponse];
1088
+ for (let l of h2) if (l) for (let u of l) {
1089
+ let c = await u(g, r2);
1090
+ c && (g = c);
1091
+ }
1092
+ this.publish({ name: b2.SUCCESS, data: g, global: n.global });
1093
+ let p = Oe(g);
1094
+ return o ? p : [true, p];
1095
+ } catch (a) {
1096
+ if (!o) return [false, a];
1097
+ throw a;
1098
+ }
1099
+ }
1100
+ async getJsonStream(e, t) {
1101
+ y2(e) && ([e, t] = [void 0, e]);
1102
+ let n = this.processRequestOptions(t ?? {}, { method: "GET", headers: { accept: `${m.NDJSON}` } }), { requestOptions: r2 } = n, o = r2.unwrap !== false, i = r2.hooks;
1103
+ try {
1104
+ let a = s.createUrl(this._baseUrl, e, r2.searchParams), d = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, i?.beforeRequest];
1105
+ for (let l of d) if (l) for (let u of l) {
1106
+ let c = await u(r2, a);
1107
+ c && (Object.assign(r2, c), c.searchParams !== void 0 && (a = s.createUrl(this._baseUrl, e, r2.searchParams)));
1108
+ }
1109
+ let g = await this._request(e, n), h2 = [s.globalHooks.afterResponse, this.hooks.afterResponse, i?.afterResponse];
1110
+ for (let l of h2) if (l) for (let u of l) {
1111
+ let c = await u(g, r2);
1112
+ c && (g = c);
1113
+ }
1114
+ this.publish({ name: b2.SUCCESS, data: g, global: n.global });
1115
+ let p = we2(g);
1116
+ return o ? p : [true, p];
1117
+ } catch (a) {
1118
+ if (!o) return [false, a];
1119
+ throw a;
1120
+ }
1121
+ }
1122
+ async _get(e, t, n = {}, r2) {
1123
+ return this.execute(e, t, { ...n, method: "GET", body: void 0 }, r2);
1124
+ }
1125
+ async _request(e, { signalController: t, requestOptions: n, global: r2 }) {
1126
+ s.signalControllers.add(t);
1127
+ let o = s.normalizeRetryOptions(n.retry), i = n.method ?? "GET", a = o.limit > 0 && o.methods.includes(i), d = n.dedupe === true && (i === "GET" || i === "HEAD"), R2 = 0, g = performance.now(), h2 = () => {
1128
+ let p = performance.now();
1129
+ return { start: g, end: p, duration: p - g };
2597
1130
  };
2598
1131
  try {
2599
- const url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2600
- const dedupeKey = canDedupe ? `${method}:${url.href}` : "";
2601
- if (canDedupe) {
2602
- const inflight = _Transportr.inflightRequests.get(dedupeKey);
2603
- if (inflight) {
2604
- return (await inflight).clone();
2605
- }
2606
- }
2607
- const originalBody = requestOptions.body;
2608
- const onUploadProgress = requestOptions.onUploadProgress;
2609
- const wrapUploadBody = async () => {
2610
- if (!onUploadProgress || originalBody == null) {
2611
- return;
2612
- }
2613
- let bytes = null;
2614
- if (typeof originalBody === "string") {
2615
- bytes = new TextEncoder().encode(originalBody);
2616
- } else if (originalBody instanceof Blob) {
2617
- bytes = new Uint8Array(await originalBody.arrayBuffer());
2618
- } else if (isArrayBuffer(originalBody)) {
2619
- bytes = new Uint8Array(originalBody);
2620
- } else if (ArrayBuffer.isView(originalBody)) {
2621
- bytes = new Uint8Array(originalBody.buffer, originalBody.byteOffset, originalBody.byteLength);
2622
- } else if (!(originalBody instanceof ReadableStream)) {
2623
- return;
2624
- }
2625
- const total = bytes ? bytes.byteLength : null;
2626
- const readable = bytes ? new ReadableStream({
2627
- /** @param controller The stream controller. */
2628
- start(controller) {
2629
- controller.enqueue(bytes);
2630
- controller.close();
2631
- }
2632
- }) : originalBody;
2633
- let loaded = 0;
2634
- const transform = new TransformStream({
2635
- /**
2636
- * Tracks bytes and invokes upload progress callback.
2637
- * @param chunk The data chunk.
2638
- * @param controller The transform controller.
2639
- */
2640
- transform(chunk, controller) {
2641
- loaded += chunk.byteLength;
2642
- onUploadProgress({
2643
- loaded,
2644
- total,
2645
- percentage: total !== null && total > 0 ? Math.round(loaded / total * 100) : null
2646
- });
2647
- controller.enqueue(chunk);
2648
- }
2649
- });
2650
- requestOptions.body = readable.pipeThrough(transform);
2651
- Object.assign(requestOptions, { duplex: "half" });
2652
- };
2653
- const doFetch = async () => {
2654
- while (true) {
2655
- try {
2656
- await wrapUploadBody();
2657
- const response = await fetch(url, requestOptions);
2658
- if (!response.ok) {
2659
- if (canRetry && attempt < retryConfig.limit && retryConfig.statusCodes.includes(response.status)) {
2660
- attempt++;
2661
- this.publish({ name: RequestEvent.RETRY, data: { attempt, status: response.status, method, path, timing: getTiming() }, global });
2662
- await _Transportr.retryDelay(retryConfig, attempt);
2663
- continue;
2664
- }
2665
- let entity;
2666
- try {
2667
- entity = await response.text();
2668
- } catch {
2669
- }
2670
- throw await this.handleError(path, response, { entity, url, method, timing: getTiming() }, requestOptions);
2671
- }
2672
- return response;
2673
- } catch (cause) {
2674
- if (cause instanceof HttpError) {
2675
- throw cause;
2676
- }
2677
- if (canRetry && attempt < retryConfig.limit) {
2678
- attempt++;
2679
- this.publish({ name: RequestEvent.RETRY, data: { attempt, error: cause.message, method, path, timing: getTiming() }, global });
2680
- await _Transportr.retryDelay(retryConfig, attempt);
1132
+ let p = s.createUrl(this._baseUrl, e, n.searchParams), l = d ? `${i}:${p.href}` : "";
1133
+ if (d) {
1134
+ let f = s.inflightRequests.get(l);
1135
+ if (f) return (await f).clone();
1136
+ }
1137
+ let u = n.body, c = n.onUploadProgress, S2 = async () => {
1138
+ if (!c || u == null) return;
1139
+ let f = null;
1140
+ if (typeof u == "string") f = new TextEncoder().encode(u);
1141
+ else if (u instanceof Blob) f = new Uint8Array(await u.arrayBuffer());
1142
+ else if (Ae(u)) f = new Uint8Array(u);
1143
+ else if (ArrayBuffer.isView(u)) f = new Uint8Array(u.buffer, u.byteOffset, u.byteLength);
1144
+ else if (!(u instanceof ReadableStream)) return;
1145
+ let E = f ? f.byteLength : null, x = f ? new ReadableStream({ start(P) {
1146
+ P.enqueue(f), P.close();
1147
+ } }) : u, O = 0, C2 = new TransformStream({ transform(P, J2) {
1148
+ O += P.byteLength, c({ loaded: O, total: E, percentage: E !== null && E > 0 ? Math.round(O / E * 100) : null }), J2.enqueue(P);
1149
+ } });
1150
+ n.body = x.pipeThrough(C2), Object.assign(n, { duplex: "half" });
1151
+ }, ne = async () => {
1152
+ for (; ; ) try {
1153
+ await S2();
1154
+ let f = await fetch(p, n);
1155
+ if (!f.ok) {
1156
+ if (a && R2 < o.limit && o.statusCodes.includes(f.status)) {
1157
+ R2++, this.publish({ name: b2.RETRY, data: { attempt: R2, status: f.status, method: i, path: e, timing: h2() }, global: r2 }), await s.retryDelay(o, R2);
2681
1158
  continue;
2682
1159
  }
2683
- throw await this.handleError(path, void 0, { cause, url, method, timing: getTiming() }, requestOptions);
1160
+ let E;
1161
+ try {
1162
+ E = await f.text();
1163
+ } catch {
1164
+ }
1165
+ throw await this.handleError(e, f, { entity: E, url: p, method: i, timing: h2() }, n);
2684
1166
  }
2685
- }
2686
- };
2687
- const wrapProgress = (response) => {
2688
- const onDownloadProgress = requestOptions.onDownloadProgress;
2689
- if (!onDownloadProgress || !response.body) return response;
2690
- const contentLength = response.headers.get("content-length");
2691
- const total = contentLength ? parseInt(contentLength, 10) : null;
2692
- let loaded = 0;
2693
- const transform = new TransformStream({
2694
- /**
2695
- * Tracks bytes and invokes progress callback.
2696
- * @param chunk The data chunk.
2697
- * @param controller The transform controller.
2698
- */
2699
- transform(chunk, controller) {
2700
- loaded += chunk.byteLength;
2701
- onDownloadProgress({
2702
- loaded,
2703
- total,
2704
- percentage: total !== null && total > 0 ? Math.round(loaded / total * 100) : null
2705
- });
2706
- controller.enqueue(chunk);
1167
+ return f;
1168
+ } catch (f) {
1169
+ if (f instanceof k) throw f;
1170
+ if (a && R2 < o.limit) {
1171
+ R2++, this.publish({ name: b2.RETRY, data: { attempt: R2, error: f.message, method: i, path: e, timing: h2() }, global: r2 }), await s.retryDelay(o, R2);
1172
+ continue;
2707
1173
  }
2708
- });
2709
- const body = response.body.pipeThrough(transform);
2710
- return new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
1174
+ throw await this.handleError(e, void 0, { cause: f, url: p, method: i, timing: h2() }, n);
1175
+ }
1176
+ }, re = (f) => {
1177
+ let E = n.onDownloadProgress;
1178
+ if (!E || !f.body) return f;
1179
+ let x = f.headers.get("content-length"), O = x ? parseInt(x, 10) : null, C2 = 0, P = new TransformStream({ transform(oe, Be) {
1180
+ C2 += oe.byteLength, E({ loaded: C2, total: O, percentage: O !== null && O > 0 ? Math.round(C2 / O * 100) : null }), Be.enqueue(oe);
1181
+ } }), J2 = f.body.pipeThrough(P);
1182
+ return new Response(J2, { status: f.status, statusText: f.statusText, headers: f.headers });
2711
1183
  };
2712
- if (canDedupe) {
2713
- const promise = doFetch();
2714
- _Transportr.inflightRequests.set(dedupeKey, promise);
1184
+ if (d) {
1185
+ let f = ne();
1186
+ s.inflightRequests.set(l, f);
2715
1187
  try {
2716
- const response = await promise;
2717
- return wrapProgress(response);
1188
+ let E = await f;
1189
+ return re(E);
2718
1190
  } finally {
2719
- _Transportr.inflightRequests.delete(dedupeKey);
1191
+ s.inflightRequests.delete(l);
2720
1192
  }
2721
1193
  }
2722
- return wrapProgress(await doFetch());
1194
+ return re(await ne());
2723
1195
  } finally {
2724
- _Transportr.signalControllers.delete(signalController.destroy());
2725
- if (!requestOptions.signal?.aborted) {
2726
- const timing = getTiming();
2727
- this.publish({ name: RequestEvent.COMPLETE, data: { timing }, global });
2728
- if (_Transportr.signalControllers.size === 0) {
2729
- this.publish({ name: RequestEvent.ALL_COMPLETE, global });
2730
- }
1196
+ if (s.signalControllers.delete(t.destroy()), !n.signal?.aborted) {
1197
+ let p = h2();
1198
+ this.publish({ name: b2.COMPLETE, data: { timing: p }, global: r2 }), s.signalControllers.size === 0 && this.publish({ name: b2.ALL_COMPLETE, global: r2 });
2731
1199
  }
2732
1200
  }
2733
1201
  }
2734
- /**
2735
- * Normalizes a retry option into a full RetryOptions object.
2736
- * @param retry The retry option from request options.
2737
- * @returns Normalized retry configuration.
2738
- */
2739
- static normalizeRetryOptions(retry) {
2740
- if (retry === void 0) {
2741
- return { limit: 0, statusCodes: [], methods: [], delay: retryDelay, backoffFactor: retryBackoffFactor };
2742
- }
2743
- if (typeof retry === "number") {
2744
- return { limit: retry, statusCodes: [...retryStatusCodes], methods: [...retryMethods], delay: retryDelay, backoffFactor: retryBackoffFactor };
2745
- }
2746
- return {
2747
- limit: retry.limit ?? 0,
2748
- statusCodes: retry.statusCodes ?? [...retryStatusCodes],
2749
- methods: retry.methods ?? [...retryMethods],
2750
- delay: retry.delay ?? retryDelay,
2751
- backoffFactor: retry.backoffFactor ?? retryBackoffFactor
2752
- };
1202
+ static normalizeRetryOptions(e) {
1203
+ return e === void 0 ? { limit: 0, statusCodes: [], methods: [], delay: N, backoffFactor: D } : typeof e == "number" ? { limit: e, statusCodes: [...X], methods: [...V], delay: N, backoffFactor: D } : { limit: e.limit ?? 0, statusCodes: e.statusCodes ?? [...X], methods: e.methods ?? [...V], delay: e.delay ?? N, backoffFactor: e.backoffFactor ?? D };
2753
1204
  }
2754
- /**
2755
- * Waits for the appropriate delay before a retry attempt.
2756
- * @param config The retry configuration.
2757
- * @param attempt The current attempt number (1-based).
2758
- * @returns A promise that resolves after the delay.
2759
- */
2760
- static retryDelay(config, attempt) {
2761
- const ms = typeof config.delay === "function" ? config.delay(attempt) : config.delay * config.backoffFactor ** (attempt - 1);
2762
- return new Promise((resolve) => setTimeout(resolve, ms));
2763
- }
2764
- /**
2765
- * Shared implementation for body-accepting HTTP methods (POST, PUT, PATCH, DELETE).
2766
- * @param method The HTTP method to use.
2767
- * @param path The request path, or the request body when called without a path.
2768
- * @param body The request body, or options when called without a path.
2769
- * @param options Additional request options.
2770
- * @param responseHandler Optional response handler override.
2771
- * @returns A promise that resolves to the response body.
2772
- */
2773
- executeBodyMethod(method, path, body, options, responseHandler) {
2774
- const [resolvedPath, resolvedBody, resolvedOptions] = isString(path) ? [path, body, options] : [void 0, path, body];
2775
- return this.execute(resolvedPath, Object.assign(resolvedOptions ?? {}, { body: resolvedBody, method }), {}, responseHandler);
2776
- }
2777
- /**
2778
- * It returns a response handler based on the content type of the response.
2779
- * @param path The path to the resource.
2780
- * @param userOptions The user options for the request.
2781
- * @param options The options for the request.
2782
- * @param responseHandler The response handler for the request.
2783
- * @returns A response handler function.
2784
- */
2785
- async execute(path, userOptions = {}, options = {}, responseHandler) {
2786
- if (isObject(path)) {
2787
- [path, userOptions] = [void 0, path];
2788
- }
2789
- const requestConfig = this.processRequestOptions(userOptions, options);
2790
- const { requestOptions } = requestConfig;
2791
- const unwrap = requestOptions.unwrap !== false;
2792
- const requestHooks = requestOptions.hooks;
1205
+ static retryDelay(e, t) {
1206
+ let n = typeof e.delay == "function" ? e.delay(t) : e.delay * e.backoffFactor ** (t - 1);
1207
+ return new Promise((r2) => setTimeout(r2, n));
1208
+ }
1209
+ executeBodyMethod(e, t, n, r2, o) {
1210
+ let [i, a, d] = j(t) ? [t, n, r2] : [void 0, t, n];
1211
+ return this.execute(i, Object.assign(d ?? {}, { body: a, method: e }), {}, o);
1212
+ }
1213
+ async execute(e, t = {}, n = {}, r2) {
1214
+ y2(e) && ([e, t] = [void 0, e]);
1215
+ let o = this.processRequestOptions(t, n), { requestOptions: i } = o, a = i.unwrap !== false, d = i.hooks;
2793
1216
  try {
2794
- let url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2795
- const beforeRequestHookSets = [_Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest];
2796
- for (const hooks of beforeRequestHookSets) {
2797
- if (!hooks) {
2798
- continue;
2799
- }
2800
- for (const hook of hooks) {
2801
- const result = await hook(requestOptions, url);
2802
- if (result) {
2803
- Object.assign(requestOptions, result);
2804
- if (result.searchParams !== void 0) {
2805
- url = _Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);
2806
- }
2807
- }
2808
- }
1217
+ let R2 = s.createUrl(this._baseUrl, e, i.searchParams), g = [s.globalHooks.beforeRequest, this.hooks.beforeRequest, d?.beforeRequest];
1218
+ for (let l of g) if (l) for (let u of l) {
1219
+ let c = await u(i, R2);
1220
+ c && (Object.assign(i, c), c.searchParams !== void 0 && (R2 = s.createUrl(this._baseUrl, e, i.searchParams)));
2809
1221
  }
2810
- let response = await this._request(path, requestConfig);
2811
- const afterResponseHookSets = [_Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse];
2812
- for (const hooks of afterResponseHookSets) {
2813
- if (!hooks) {
2814
- continue;
2815
- }
2816
- for (const hook of hooks) {
2817
- const result = await hook(response, requestOptions);
2818
- if (result) {
2819
- response = result;
2820
- }
2821
- }
1222
+ let h2 = await this._request(e, o), p = [s.globalHooks.afterResponse, this.hooks.afterResponse, d?.afterResponse];
1223
+ for (let l of p) if (l) for (let u of l) {
1224
+ let c = await u(h2, i);
1225
+ c && (h2 = c);
2822
1226
  }
2823
1227
  try {
2824
- if (!responseHandler && response.status !== 204) {
2825
- responseHandler = this.getResponseHandler(response.headers.get("content-type"));
2826
- }
2827
- const data = await responseHandler?.(response);
2828
- this.publish({ name: RequestEvent.SUCCESS, data, global: requestConfig.global });
2829
- return unwrap ? data : [true, data];
2830
- } catch (cause) {
2831
- throw await this.handleError(path, response, { cause }, requestOptions);
2832
- }
2833
- } catch (error) {
2834
- if (!unwrap) return [false, error];
2835
- throw error;
2836
- }
2837
- }
2838
- /**
2839
- * Creates a new set of options for a request.
2840
- * @param options The user options for the request.
2841
- * @param userOptions The default options for the request.
2842
- * @returns A new set of options for the request.
2843
- */
2844
- static createOptions({ headers: userHeaders, searchParams: userSearchParams, ...userOptions }, { headers, searchParams, ...options }) {
2845
- headers = _Transportr.mergeHeaders(new Headers(), userHeaders, headers);
2846
- searchParams = _Transportr.mergeSearchParams(new URLSearchParams(), userSearchParams, searchParams);
2847
- return { ...objectMerge(options, userOptions), headers, searchParams };
2848
- }
2849
- /**
2850
- * Merges user and request headers into the target Headers object.
2851
- * @param target The target Headers object.
2852
- * @param headerSources Variable number of header sources to merge.
2853
- * @returns The merged Headers object.
2854
- */
2855
- static mergeHeaders(target, ...headerSources) {
2856
- for (const headers of headerSources) {
2857
- if (headers === void 0) {
2858
- continue;
2859
- }
2860
- if (headers instanceof Headers) {
2861
- headers.forEach((value, name) => target.set(name, value));
2862
- } else if (Array.isArray(headers)) {
2863
- for (const [name, value] of headers) {
2864
- target.set(name, value);
2865
- }
2866
- } else if (isObject(headers)) {
2867
- for (const [name, value] of Object.entries(headers)) {
2868
- if (value !== void 0) {
2869
- target.set(name, value);
2870
- }
2871
- }
2872
- }
2873
- }
2874
- return target;
2875
- }
2876
- /**
2877
- * Merges user and request search parameters into the target URLSearchParams object.
2878
- * @param target The target URLSearchParams object.
2879
- * @param sources The search parameters to merge.
2880
- * @returns The merged URLSearchParams object.
2881
- */
2882
- static mergeSearchParams(target, ...sources) {
2883
- for (const searchParams of sources) {
2884
- if (searchParams === void 0) {
2885
- continue;
2886
- }
2887
- if (searchParams instanceof URLSearchParams) {
2888
- searchParams.forEach((value, name) => target.set(name, value));
2889
- } else if (isString(searchParams) || Array.isArray(searchParams)) {
2890
- for (const [name, value] of new URLSearchParams(searchParams)) {
2891
- target.set(name, value);
2892
- }
2893
- } else {
2894
- const keys = Object.keys(searchParams);
2895
- for (let i = 0; i < keys.length; i++) {
2896
- const name = keys[i];
2897
- const value = searchParams[name];
2898
- if (value !== void 0) {
2899
- target.set(name, String(value));
2900
- }
2901
- }
2902
- }
2903
- }
2904
- return target;
2905
- }
2906
- /**
2907
- * Processes request options by merging user, instance, and method-specific options.
2908
- * This method optimizes performance by using cached instance options and performing
2909
- * shallow merges where possible instead of deep object cloning.
2910
- * @param userOptions The user-provided options for the request.
2911
- * @param options Additional method-specific options.
2912
- * @returns Processed request options with signal controller and global flag.
2913
- */
2914
- processRequestOptions({ body: userBody, headers: userHeaders, searchParams: userSearchParams, ...userOptions }, { headers, searchParams, ...options }) {
2915
- const requestOptions = {
2916
- // Spread instance options (already merged with defaults)
2917
- ...this._options,
2918
- // Spread user options (shallow merge, sufficient for flat properties)
2919
- ...userOptions,
2920
- // Spread method-specific options (e.g., method: 'POST')
2921
- ...options,
2922
- // Deep merge required for headers and searchParams
2923
- headers: _Transportr.mergeHeaders(new Headers(), this._options.headers, userHeaders, headers),
2924
- searchParams: _Transportr.mergeSearchParams(new URLSearchParams(), this._options.searchParams, userSearchParams, searchParams)
2925
- };
2926
- if (isRequestBodyMethod(requestOptions.method)) {
2927
- if (isRawBody(userBody)) {
2928
- Object.assign(requestOptions, { body: userBody });
2929
- requestOptions.headers.delete("content-type");
2930
- } else {
2931
- const instanceBody = this._options.body;
2932
- const body = isObject(instanceBody) && isObject(userBody) ? objectMerge(instanceBody, userBody) : userBody !== void 0 ? userBody : instanceBody;
2933
- const isJson = requestOptions.headers.get("content-type")?.includes("json") ?? false;
2934
- Object.assign(requestOptions, { body: isJson && isObject(body) ? serialize(body) : body });
2935
- }
2936
- } else {
2937
- requestOptions.headers.delete("content-type");
2938
- if (requestOptions.body instanceof URLSearchParams) {
2939
- _Transportr.mergeSearchParams(requestOptions.searchParams, requestOptions.body);
2940
- }
2941
- requestOptions.body = void 0;
2942
- }
2943
- const { signal, timeout, global = false, xsrf } = requestOptions;
2944
- if (xsrf) {
2945
- const { cookieName, headerName } = typeof xsrf === "object" ? xsrf : {};
2946
- const token = getCookieValue(cookieName ?? XSRF_COOKIE_NAME);
2947
- if (token) {
2948
- requestOptions.headers.set(headerName ?? XSRF_HEADER_NAME, token);
2949
- }
2950
- }
2951
- const signalController = new SignalController({ signal, timeout }).onAbort((event) => this.publish({ name: RequestEvent.ABORTED, event, global })).onTimeout((event) => this.publish({ name: RequestEvent.TIMEOUT, event, global }));
2952
- requestOptions.signal = signalController.signal;
2953
- this.publish({ name: RequestEvent.CONFIGURED, data: requestOptions, global });
2954
- return { signalController, requestOptions, global };
2955
- }
2956
- /**
2957
- * Gets the base URL from a URL or string.
2958
- * @param url The URL or string to parse.
2959
- * @returns The base URL.
2960
- */
2961
- static getBaseUrl(url) {
2962
- if (url instanceof URL) {
2963
- return url;
2964
- }
2965
- if (!isString(url)) {
2966
- throw new TypeError("Invalid URL");
2967
- }
2968
- return new URL(url, url.startsWith("/") ? globalThis.location.origin : void 0);
2969
- }
2970
- /**
2971
- * Parses a content-type string into a MediaType instance with caching.
2972
- * This method caches parsed MediaType instances to avoid re-parsing the same content-type strings,
2973
- * which significantly improves performance for repeated requests with the same content types.
2974
- * @param contentType The content-type string to parse.
2975
- * @returns The parsed MediaType instance, or undefined if parsing fails.
2976
- */
2977
- static getOrParseMediaType(contentType) {
2978
- if (contentType === null) {
2979
- return;
2980
- }
2981
- let mediaType = _Transportr.mediaTypeCache.get(contentType);
2982
- if (mediaType !== void 0) {
2983
- return mediaType;
2984
- }
2985
- mediaType = h.parse(contentType) ?? void 0;
2986
- if (mediaType !== void 0) {
2987
- if (_Transportr.mediaTypeCache.size >= 100) {
2988
- const oldestEntry = _Transportr.mediaTypeCache.keys().next();
2989
- if (!oldestEntry.done) {
2990
- _Transportr.mediaTypeCache.delete(oldestEntry.value);
2991
- }
2992
- }
2993
- _Transportr.mediaTypeCache.set(contentType, mediaType);
2994
- }
2995
- return mediaType;
2996
- }
2997
- /**
2998
- * Creates a new URL with the given path and search parameters.
2999
- * @param url The base URL.
3000
- * @param path The path to append to the base URL.
3001
- * @param searchParams The search parameters to append to the URL.
3002
- * @returns A new URL with the given path and search parameters.
3003
- */
3004
- static createUrl(url, path, searchParams) {
3005
- const requestUrl = path ? new URL(`${url.pathname.replace(endsWithSlashRegEx, "")}${path}`, url.origin) : new URL(url);
3006
- if (searchParams) {
3007
- _Transportr.mergeSearchParams(requestUrl.searchParams, searchParams);
3008
- }
3009
- return requestUrl;
3010
- }
3011
- /**
3012
- * It generates a ResponseStatus object from an error name and a Response object.
3013
- * @param errorName The name of the error.
3014
- * @param response The Response object.
3015
- * @returns A ResponseStatus object.
3016
- */
3017
- static generateResponseStatusFromError(errorName, { status, statusText } = new Response()) {
3018
- switch (errorName) {
3019
- case SignalErrors.ABORT:
3020
- return aborted;
3021
- case SignalErrors.TIMEOUT:
3022
- return timedOut;
1228
+ !r2 && h2.status !== 204 && (r2 = this.getResponseHandler(h2.headers.get("content-type")));
1229
+ let l = await r2?.(h2);
1230
+ return this.publish({ name: b2.SUCCESS, data: l, global: o.global }), a ? l : [true, l];
1231
+ } catch (l) {
1232
+ throw await this.handleError(e, h2, { cause: l }, i);
1233
+ }
1234
+ } catch (R2) {
1235
+ if (!a) return [false, R2];
1236
+ throw R2;
1237
+ }
1238
+ }
1239
+ static createOptions({ headers: e, searchParams: t, ...n }, { headers: r2, searchParams: o, ...i }) {
1240
+ return r2 = s.mergeHeaders(new Headers(), e, r2), o = s.mergeSearchParams(new URLSearchParams(), t, o), { ...F(i, n), headers: r2, searchParams: o };
1241
+ }
1242
+ static mergeHeaders(e, ...t) {
1243
+ for (let n of t) if (n !== void 0) {
1244
+ if (n instanceof Headers) n.forEach((r2, o) => e.set(o, r2));
1245
+ else if (Array.isArray(n)) for (let [r2, o] of n) e.set(r2, o);
1246
+ else if (y2(n)) for (let [r2, o] of Object.entries(n)) o !== void 0 && e.set(r2, o);
1247
+ }
1248
+ return e;
1249
+ }
1250
+ static mergeSearchParams(e, ...t) {
1251
+ for (let n of t) if (n !== void 0) if (n instanceof URLSearchParams) n.forEach((r2, o) => e.set(o, r2));
1252
+ else if (j(n) || Array.isArray(n)) for (let [r2, o] of new URLSearchParams(n)) e.set(r2, o);
1253
+ else {
1254
+ let r2 = Object.keys(n);
1255
+ for (let o = 0; o < r2.length; o++) {
1256
+ let i = r2[o], a = n[i];
1257
+ a !== void 0 && e.set(i, String(a));
1258
+ }
1259
+ }
1260
+ return e;
1261
+ }
1262
+ processRequestOptions({ body: e, headers: t, searchParams: n, ...r2 }, { headers: o, searchParams: i, ...a }) {
1263
+ let d = { ...this._options, ...r2, ...a, headers: s.mergeHeaders(new Headers(), this._options.headers, t, o), searchParams: s.mergeSearchParams(new URLSearchParams(), this._options.searchParams, n, i) };
1264
+ if (ve2(d.method)) if (qe(e)) Object.assign(d, { body: e }), d.headers.delete("content-type");
1265
+ else {
1266
+ let u = this._options.body, c = y2(u) && y2(e) ? F(u, e) : e !== void 0 ? e : u, S2 = d.headers.get("content-type")?.includes("json") ?? false;
1267
+ Object.assign(d, { body: S2 && y2(c) ? He(c) : c });
1268
+ }
1269
+ else d.headers.delete("content-type"), d.body instanceof URLSearchParams && s.mergeSearchParams(d.searchParams, d.body), d.body = void 0;
1270
+ let { signal: R2, timeout: g, global: h2 = false, xsrf: p } = d;
1271
+ if (p) {
1272
+ let { cookieName: u, headerName: c } = typeof p == "object" ? p : {}, S2 = Pe2(u ?? le);
1273
+ S2 && d.headers.set(c ?? ce, S2);
1274
+ }
1275
+ let l = new _({ signal: R2, timeout: g }).onAbort((u) => this.publish({ name: b2.ABORTED, event: u, global: h2 })).onTimeout((u) => this.publish({ name: b2.TIMEOUT, event: u, global: h2 }));
1276
+ return d.signal = l.signal, this.publish({ name: b2.CONFIGURED, data: d, global: h2 }), { signalController: l, requestOptions: d, global: h2 };
1277
+ }
1278
+ static getBaseUrl(e) {
1279
+ if (e instanceof URL) return e;
1280
+ if (!j(e)) throw new TypeError("Invalid URL");
1281
+ return new URL(e, e.startsWith("/") ? globalThis.location.origin : void 0);
1282
+ }
1283
+ static getOrParseMediaType(e) {
1284
+ if (e === null) return;
1285
+ let t = s.mediaTypeCache.get(e);
1286
+ if (t !== void 0) return t;
1287
+ if (t = T.parse(e) ?? void 0, t !== void 0) {
1288
+ if (s.mediaTypeCache.size >= 100) {
1289
+ let n = s.mediaTypeCache.keys().next();
1290
+ n.done || s.mediaTypeCache.delete(n.value);
1291
+ }
1292
+ s.mediaTypeCache.set(e, t);
1293
+ }
1294
+ return t;
1295
+ }
1296
+ static createUrl(e, t, n) {
1297
+ let r2 = t ? new URL(`${e.pathname.replace(de, "")}${t}`, e.origin) : new URL(e);
1298
+ return n && s.mergeSearchParams(r2.searchParams, n), r2;
1299
+ }
1300
+ static generateResponseStatusFromError(e, { status: t, statusText: n } = new Response()) {
1301
+ switch (e) {
1302
+ case A.ABORT:
1303
+ return ge;
1304
+ case A.TIMEOUT:
1305
+ return me2;
3023
1306
  default:
3024
- return status >= 400 ? new ResponseStatus(status, statusText) : internalServerError;
1307
+ return t >= 400 ? new v(t, n) : he;
3025
1308
  }
3026
1309
  }
3027
- /**
3028
- * Handles an error that occurs during a request.
3029
- * @param path The path of the request.
3030
- * @param response The Response object.
3031
- * @param options Additional error context including cause, entity, url, method, and timing.
3032
- * @param requestOptions The original request options that led to the error, used for hooks context.
3033
- * @returns An HttpError object.
3034
- */
3035
- async handleError(path, response, { cause, entity, url, method, timing } = {}, requestOptions) {
3036
- const message = method && url ? `${method} ${url.href} failed${response ? ` with status ${response.status}` : ""}` : `An error has occurred with your request to: '${path}'`;
3037
- let error = new HttpError(_Transportr.generateResponseStatusFromError(cause?.name, response), { message, cause, entity, url, method, timing });
3038
- const beforeErrorHookSets = [_Transportr.globalHooks.beforeError, this.hooks.beforeError, requestOptions?.hooks?.beforeError];
3039
- for (const hooks of beforeErrorHookSets) {
3040
- if (!hooks) {
3041
- continue;
3042
- }
3043
- for (const hook of hooks) {
3044
- const result = await hook(error);
3045
- if (result instanceof HttpError) {
3046
- error = result;
3047
- }
3048
- }
1310
+ async handleError(e, t, { cause: n, entity: r2, url: o, method: i, timing: a } = {}, d) {
1311
+ let R2 = i && o ? `${i} ${o.href} failed${t ? ` with status ${t.status}` : ""}` : `An error has occurred with your request to: '${e}'`, g = new k(s.generateResponseStatusFromError(n?.name, t), { message: R2, cause: n, entity: r2, url: o, method: i, timing: a }), h2 = [s.globalHooks.beforeError, this.hooks.beforeError, d?.hooks?.beforeError];
1312
+ for (let p of h2) if (p) for (let l of p) {
1313
+ let u = await l(g);
1314
+ u instanceof k && (g = u);
3049
1315
  }
3050
- this.publish({ name: RequestEvent.ERROR, data: error });
3051
- return error;
3052
- }
3053
- /**
3054
- * Publishes an event to the global and instance event handlers.
3055
- * @param eventObject The event object to publish.
3056
- */
3057
- publish({ name, event = new CustomEvent(name), data, global = true }) {
3058
- if (global) {
3059
- _Transportr.globalSubscribr.publish(name, event, data);
3060
- }
3061
- this.subscribr.publish(name, event, data);
3062
- }
3063
- /**
3064
- * It returns a response handler based on the content type of the response.
3065
- * @param contentType The content type of the response.
3066
- * @returns A response handler function.
3067
- */
3068
- getResponseHandler(contentType) {
3069
- if (!contentType) {
3070
- return;
3071
- }
3072
- const mediaType = _Transportr.getOrParseMediaType(contentType);
3073
- if (!mediaType) {
3074
- return;
3075
- }
3076
- for (const [contentType2, responseHandler] of _Transportr.contentTypeHandlers) {
3077
- if (mediaType.matches(contentType2)) {
3078
- return responseHandler;
3079
- }
1316
+ return this.publish({ name: b2.ERROR, data: g }), g;
1317
+ }
1318
+ publish({ name: e, event: t = new CustomEvent(e), data: n, global: r2 = true }) {
1319
+ r2 && s.globalSubscribr.publish(e, t, n), this.subscribr.publish(e, t, n);
1320
+ }
1321
+ getResponseHandler(e) {
1322
+ if (!e) return;
1323
+ let t = s.getOrParseMediaType(e);
1324
+ if (t) {
1325
+ for (let [n, r2] of s.contentTypeHandlers) if (t.matches(n)) return r2;
3080
1326
  }
3081
- return void 0;
3082
1327
  }
3083
- /**
3084
- * A string representation of the Transportr instance.
3085
- * @returns The string 'Transportr'.
3086
- */
3087
1328
  get [Symbol.toStringTag]() {
3088
1329
  return "Transportr";
3089
1330
  }
3090
1331
  };
3091
- return __toCommonJS(transportr_exports);
3092
1332
  })();
3093
1333
  /*! Bundled license information:
3094
1334
 
3095
1335
  dompurify/dist/purify.es.mjs:
3096
1336
  (*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE *)
3097
1337
  */
3098
- globalThis.Transportr = __mod.Transportr;