@d1g1tal/transportr 3.3.2 → 3.3.3
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.
- package/CHANGELOG.md +13 -0
- package/dist/iife/content-type.js +6 -0
- package/dist/iife/content-type.js.map +7 -0
- package/dist/iife/request-header.js +6 -0
- package/dist/iife/request-header.js.map +7 -0
- package/dist/iife/request-method.js +6 -0
- package/dist/iife/request-method.js.map +7 -0
- package/dist/iife/response-header.js +6 -0
- package/dist/iife/response-header.js.map +7 -0
- package/dist/iife/transportr.js +1283 -0
- package/dist/iife/transportr.js.map +7 -0
- package/dist/transportr.js.map +2 -2
- package/package.json +6 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/src/utils.ts", "../../node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/src/tags.ts", "../../node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/src/attrs.ts", "../../node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/src/regexp.ts", "../../node_modules/.pnpm/dompurify@3.3.3/node_modules/dompurify/src/purify.ts", "../../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/utils.ts", "../../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/media-type-parameters.ts", "../../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/media-type-parser.ts", "../../node_modules/.pnpm/@d1g1tal+media-type@6.0.8/node_modules/@d1g1tal/media-type/src/media-type.ts", "../../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/node_modules/.pnpm/@d1g1tal+collections@2.2.1/node_modules/@d1g1tal/collections/src/set-multi-map.ts", "../../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/src/context-event-handler.ts", "../../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/src/subscription.ts", "../../node_modules/.pnpm/@d1g1tal+subscribr@4.2.0/node_modules/@d1g1tal/subscribr/src/subscribr.ts", "../../src/http-error.ts", "../../src/response-status.ts", "../../src/constants.ts", "../../src/signal-controller.ts", "../../src/response-handlers.ts", "../../src/utils.ts", "../../src/transportr.ts"],
|
|
4
|
+
"sourcesContent": ["const {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n} = Object;\n\nlet { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports\nlet { apply, construct } = typeof Reflect !== 'undefined' && Reflect;\n\nif (!freeze) {\n freeze = function <T>(x: T): T {\n return x;\n };\n}\n\nif (!seal) {\n seal = function <T>(x: T): T {\n return x;\n };\n}\n\nif (!apply) {\n apply = function <T>(\n func: (thisArg: any, ...args: any[]) => T,\n thisArg: any,\n ...args: any[]\n ): T {\n return func.apply(thisArg, args);\n };\n}\n\nif (!construct) {\n construct = function <T>(Func: new (...args: any[]) => T, ...args: any[]): T {\n return new Func(...args);\n };\n}\n\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayIndexOf = unapply(Array.prototype.indexOf);\nconst arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySlice = unapply(Array.prototype.slice);\nconst arraySplice = unapply(Array.prototype.splice);\n\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\n\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\n\nconst regExpTest = unapply(RegExp.prototype.test);\n\nconst typeErrorCreate = unconstruct(TypeError);\n\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param func - The function to be wrapped and called.\n * @returns A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply<T>(\n func: (thisArg: any, ...args: any[]) => T\n): (thisArg: any, ...args: any[]) => T {\n return (thisArg: any, ...args: any[]): T => {\n if (thisArg instanceof RegExp) {\n thisArg.lastIndex = 0;\n }\n\n return apply(func, thisArg, args);\n };\n}\n\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param func - The constructor function to be wrapped and called.\n * @returns A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct<T>(\n Func: new (...args: any[]) => T\n): (...args: any[]) => T {\n return (...args: any[]): T => construct(Func, args);\n}\n\n/**\n * Add properties to a lookup table\n *\n * @param set - The set to which elements will be added.\n * @param array - The array containing elements to be added to the set.\n * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns The modified set with added elements.\n */\nfunction addToSet(\n set: Record<string, any>,\n array: readonly any[],\n transformCaseFunc: ReturnType<typeof unapply<string>> = stringToLowerCase\n): Record<string, any> {\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n (array as any[])[l] = lcElement;\n }\n\n element = lcElement;\n }\n }\n\n set[element] = true;\n }\n\n return set;\n}\n\n/**\n * Clean up an array to harden against CSPP\n *\n * @param array - The array to be cleaned.\n * @returns The cleaned version of the array\n */\nfunction cleanArray<T>(array: T[]): Array<T | null> {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n\n return array;\n}\n\n/**\n * Shallow clone an object\n *\n * @param object - The object to be cloned.\n * @returns A new object that copies the original.\n */\nfunction clone<T extends Record<string, any>>(object: T): T {\n const newObject = create(null);\n\n for (const [property, value] of entries(object)) {\n const isPropertyExist = objectHasOwnProperty(object, property);\n\n if (isPropertyExist) {\n if (Array.isArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (\n value &&\n typeof value === 'object' &&\n value.constructor === Object\n ) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n\n return newObject;\n}\n\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param object - The object to look up the getter function in its prototype chain.\n * @param prop - The property name for which to find the getter function.\n * @returns The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter<T extends Record<string, any>>(\n object: T,\n prop: string\n): ReturnType<typeof unapply<any>> | (() => null) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n\n object = getPrototypeOf(object);\n }\n\n function fallbackValue(): null {\n return null;\n }\n\n return fallbackValue;\n}\n\nexport {\n // Array\n arrayForEach,\n arrayIndexOf,\n arrayLastIndexOf,\n arrayPop,\n arrayPush,\n arraySlice,\n arraySplice,\n // Object\n entries,\n freeze,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n isFrozen,\n setPrototypeOf,\n seal,\n clone,\n create,\n objectHasOwnProperty,\n // RegExp\n regExpTest,\n // String\n stringIndexOf,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringTrim,\n // Errors\n typeErrorCreate,\n // Other\n lookupGetter,\n addToSet,\n // Reflect\n unapply,\n unconstruct,\n};\n", "import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'a',\n 'abbr',\n 'acronym',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blink',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'content',\n 'data',\n 'datalist',\n 'dd',\n 'decorator',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'element',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'font',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'map',\n 'mark',\n 'marquee',\n 'menu',\n 'menuitem',\n 'meter',\n 'nav',\n 'nobr',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'search',\n 'section',\n 'select',\n 'shadow',\n 'slot',\n 'small',\n 'source',\n 'spacer',\n 'span',\n 'strike',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'track',\n 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const);\n\nexport const svg = freeze([\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'enterkeyhint',\n 'exportparts',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'inputmode',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'part',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern',\n] as const);\n\nexport const svgFilters = freeze([\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n] as const);\n\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nexport const svgDisallowed = freeze([\n 'animate',\n 'color-profile',\n 'cursor',\n 'discard',\n 'font-face',\n 'font-face-format',\n 'font-face-name',\n 'font-face-src',\n 'font-face-uri',\n 'foreignobject',\n 'hatch',\n 'hatchpath',\n 'mesh',\n 'meshgradient',\n 'meshpatch',\n 'meshrow',\n 'missing-glyph',\n 'script',\n 'set',\n 'solidcolor',\n 'unknown',\n 'use',\n] as const);\n\nexport const mathMl = freeze([\n 'math',\n 'menclose',\n 'merror',\n 'mfenced',\n 'mfrac',\n 'mglyph',\n 'mi',\n 'mlabeledtr',\n 'mmultiscripts',\n 'mn',\n 'mo',\n 'mover',\n 'mpadded',\n 'mphantom',\n 'mroot',\n 'mrow',\n 'ms',\n 'mspace',\n 'msqrt',\n 'mstyle',\n 'msub',\n 'msup',\n 'msubsup',\n 'mtable',\n 'mtd',\n 'mtext',\n 'mtr',\n 'munder',\n 'munderover',\n 'mprescripts',\n] as const);\n\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nexport const mathMlDisallowed = freeze([\n 'maction',\n 'maligngroup',\n 'malignmark',\n 'mlongdiv',\n 'mscarries',\n 'mscarry',\n 'msgroup',\n 'mstack',\n 'msline',\n 'msrow',\n 'semantics',\n 'annotation',\n 'annotation-xml',\n 'mprescripts',\n 'none',\n] as const);\n\nexport const text = freeze(['#text'] as const);\n", "import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'accept',\n 'action',\n 'align',\n 'alt',\n 'autocapitalize',\n 'autocomplete',\n 'autopictureinpicture',\n 'autoplay',\n 'background',\n 'bgcolor',\n 'border',\n 'capture',\n 'cellpadding',\n 'cellspacing',\n 'checked',\n 'cite',\n 'class',\n 'clear',\n 'color',\n 'cols',\n 'colspan',\n 'controls',\n 'controlslist',\n 'coords',\n 'crossorigin',\n 'datetime',\n 'decoding',\n 'default',\n 'dir',\n 'disabled',\n 'disablepictureinpicture',\n 'disableremoteplayback',\n 'download',\n 'draggable',\n 'enctype',\n 'enterkeyhint',\n 'exportparts',\n 'face',\n 'for',\n 'headers',\n 'height',\n 'hidden',\n 'high',\n 'href',\n 'hreflang',\n 'id',\n 'inert',\n 'inputmode',\n 'integrity',\n 'ismap',\n 'kind',\n 'label',\n 'lang',\n 'list',\n 'loading',\n 'loop',\n 'low',\n 'max',\n 'maxlength',\n 'media',\n 'method',\n 'min',\n 'minlength',\n 'multiple',\n 'muted',\n 'name',\n 'nonce',\n 'noshade',\n 'novalidate',\n 'nowrap',\n 'open',\n 'optimum',\n 'part',\n 'pattern',\n 'placeholder',\n 'playsinline',\n 'popover',\n 'popovertarget',\n 'popovertargetaction',\n 'poster',\n 'preload',\n 'pubdate',\n 'radiogroup',\n 'readonly',\n 'rel',\n 'required',\n 'rev',\n 'reversed',\n 'role',\n 'rows',\n 'rowspan',\n 'spellcheck',\n 'scope',\n 'selected',\n 'shape',\n 'size',\n 'sizes',\n 'slot',\n 'span',\n 'srclang',\n 'start',\n 'src',\n 'srcset',\n 'step',\n 'style',\n 'summary',\n 'tabindex',\n 'title',\n 'translate',\n 'type',\n 'usemap',\n 'valign',\n 'value',\n 'width',\n 'wrap',\n 'xmlns',\n 'slot',\n] as const);\n\nexport const svg = freeze([\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'amplitude',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'exponent',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'intercept',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'mask-type',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'slope',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'tablevalues',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan',\n] as const);\n\nexport const mathMl = freeze([\n 'accent',\n 'accentunder',\n 'align',\n 'bevelled',\n 'close',\n 'columnsalign',\n 'columnlines',\n 'columnspan',\n 'denomalign',\n 'depth',\n 'dir',\n 'display',\n 'displaystyle',\n 'encoding',\n 'fence',\n 'frame',\n 'height',\n 'href',\n 'id',\n 'largeop',\n 'length',\n 'linethickness',\n 'lspace',\n 'lquote',\n 'mathbackground',\n 'mathcolor',\n 'mathsize',\n 'mathvariant',\n 'maxsize',\n 'minsize',\n 'movablelimits',\n 'notation',\n 'numalign',\n 'open',\n 'rowalign',\n 'rowlines',\n 'rowspacing',\n 'rowspan',\n 'rspace',\n 'rquote',\n 'scriptlevel',\n 'scriptminsize',\n 'scriptsizemultiplier',\n 'selection',\n 'separator',\n 'separators',\n 'stretchy',\n 'subscriptshift',\n 'supscriptshift',\n 'symmetric',\n 'voffset',\n 'width',\n 'xmlns',\n]);\n\nexport const xml = freeze([\n 'xlink:href',\n 'xml:id',\n 'xlink:title',\n 'xml:space',\n 'xmlns:xlink',\n] as const);\n", "import { seal } from './utils.js';\n\n// eslint-disable-next-line unicorn/better-regex\nexport const MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode\nexport const ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\nexport const TMPLIT_EXPR = seal(/\\$\\{[\\w\\W]*/gm); // eslint-disable-line unicorn/better-regex\nexport const DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]+$/); // eslint-disable-line no-useless-escape\nexport const ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nexport const IS_ALLOWED_URI = seal(\n /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nexport const IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nexport const ATTR_WHITESPACE = seal(\n /[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nexport const DOCTYPE_NAME = seal(/^html$/i);\nexport const CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n", "/* eslint-disable @typescript-eslint/indent */\n\nimport type {\n TrustedHTML,\n TrustedTypesWindow,\n} from 'trusted-types/lib/index.js';\nimport type { Config, UseProfilesConfig } from './config';\nimport * as TAGS from './tags.js';\nimport * as ATTRS from './attrs.js';\nimport * as EXPRESSIONS from './regexp.js';\nimport {\n addToSet,\n clone,\n entries,\n freeze,\n arrayForEach,\n arrayLastIndexOf,\n arrayPop,\n arrayPush,\n arraySplice,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringIndexOf,\n stringTrim,\n regExpTest,\n typeErrorCreate,\n lookupGetter,\n create,\n objectHasOwnProperty,\n} from './utils.js';\n\nexport type { Config } from './config';\n\ndeclare const VERSION: string;\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5, // Deprecated\n entityNode: 6, // Deprecated\n progressingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12, // Deprecated\n};\n\nconst getGlobal = function (): WindowLike {\n return typeof window === 'undefined' ? null : window;\n};\n\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param trustedTypes The policy factory.\n * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function (\n trustedTypes: TrustedTypePolicyFactory,\n purifyHostElement: HTMLScriptElement\n) {\n if (\n typeof trustedTypes !== 'object' ||\n typeof trustedTypes.createPolicy !== 'function'\n ) {\n return null;\n }\n\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n },\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn(\n 'TrustedTypes policy ' + policyName + ' could not be created.'\n );\n return null;\n }\n};\n\nconst _createHooksMap = function (): HooksMap {\n return {\n afterSanitizeAttributes: [],\n afterSanitizeElements: [],\n afterSanitizeShadowDOM: [],\n beforeSanitizeAttributes: [],\n beforeSanitizeElements: [],\n beforeSanitizeShadowDOM: [],\n uponSanitizeAttribute: [],\n uponSanitizeElement: [],\n uponSanitizeShadowNode: [],\n };\n};\n\nfunction createDOMPurify(window: WindowLike = getGlobal()): DOMPurify {\n const DOMPurify: DOMPurify = (root: WindowLike) => createDOMPurify(root);\n\n DOMPurify.version = VERSION;\n\n DOMPurify.removed = [];\n\n if (\n !window ||\n !window.document ||\n window.document.nodeType !== NODE_TYPE.document ||\n !window.Element\n ) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n\n return DOMPurify;\n }\n\n let { document } = window;\n\n const originalDocument = document;\n const currentScript: HTMLScriptElement =\n originalDocument.currentScript as HTMLScriptElement;\n const {\n DocumentFragment,\n HTMLTemplateElement,\n Node,\n Element,\n NodeFilter,\n NamedNodeMap = window.NamedNodeMap || (window as any).MozNamedAttrMap,\n HTMLFormElement,\n DOMParser,\n trustedTypes,\n } = window;\n\n const ElementPrototype = Element.prototype;\n\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const remove = lookupGetter(ElementPrototype, 'remove');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n\n let trustedTypesPolicy;\n let emptyHTML = '';\n\n const {\n implementation,\n createNodeIterator,\n createDocumentFragment,\n getElementsByTagName,\n } = document;\n const { importNode } = originalDocument;\n\n let hooks = _createHooksMap();\n\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported =\n typeof entries === 'function' &&\n typeof getParentNode === 'function' &&\n implementation &&\n implementation.createHTMLDocument !== undefined;\n\n const {\n MUSTACHE_EXPR,\n ERB_EXPR,\n TMPLIT_EXPR,\n DATA_ATTR,\n ARIA_ATTR,\n IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE,\n CUSTOM_ELEMENT,\n } = EXPRESSIONS;\n\n let { IS_ALLOWED_URI } = EXPRESSIONS;\n\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [\n ...TAGS.html,\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.mathMl,\n ...TAGS.text,\n ]);\n\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [\n ...ATTRS.html,\n ...ATTRS.svg,\n ...ATTRS.mathMl,\n ...ATTRS.xml,\n ]);\n\n /*\n * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(\n create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false,\n },\n })\n );\n\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n\n /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */\n const EXTRA_ELEMENT_HANDLING = Object.seal(\n create(null, {\n tagCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n attributeCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n })\n );\n\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n\n /* Decide if document with <html>... should be returned */\n let WHOLE_DOCUMENT = false;\n\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES: UseProfilesConfig | false = {};\n\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, [\n 'annotation-xml',\n 'audio',\n 'colgroup',\n 'desc',\n 'foreignobject',\n 'head',\n 'iframe',\n 'math',\n 'mi',\n 'mn',\n 'mo',\n 'ms',\n 'mtext',\n 'noembed',\n 'noframes',\n 'noscript',\n 'plaintext',\n 'script',\n 'style',\n 'svg',\n 'template',\n 'thead',\n 'title',\n 'video',\n 'xmp',\n ]);\n\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, [\n 'audio',\n 'video',\n 'img',\n 'source',\n 'image',\n 'track',\n ]);\n\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [\n 'alt',\n 'class',\n 'for',\n 'id',\n 'label',\n 'name',\n 'pattern',\n 'placeholder',\n 'role',\n 'summary',\n 'title',\n 'value',\n 'style',\n 'xmlns',\n ]);\n\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet(\n {},\n [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE],\n stringToString\n );\n\n let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [\n 'mi',\n 'mo',\n 'mn',\n 'ms',\n 'mtext',\n ]);\n\n let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);\n\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [\n 'title',\n 'style',\n 'font',\n 'a',\n 'script',\n ]);\n\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE: null | DOMParserSupportedType = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc: null | Parameters<typeof addToSet>[2] = null;\n\n /* Keep a reference to config to pass to hooks */\n let CONFIG: Config | null = null;\n\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n\n const formElement = document.createElement('form');\n\n const isRegexOrFunction = function (\n testValue: unknown\n ): testValue is Function | RegExp {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n\n /**\n * _parseConfig\n *\n * @param cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function (cfg: Config = {}): void {\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1\n ? DEFAULT_PARSER_MEDIA_TYPE\n : cfg.PARSER_MEDIA_TYPE;\n\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc =\n PARSER_MEDIA_TYPE === 'application/xhtml+xml'\n ? stringToString\n : stringToLowerCase;\n\n /* Set configuration parameters */\n ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS')\n ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc)\n : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR')\n ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc)\n : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES')\n ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString)\n : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR')\n ? addToSet(\n clone(DEFAULT_URI_SAFE_ATTRIBUTES),\n cfg.ADD_URI_SAFE_ATTR,\n transformCaseFunc\n )\n : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS')\n ? addToSet(\n clone(DEFAULT_DATA_URI_TAGS),\n cfg.ADD_DATA_URI_TAGS,\n transformCaseFunc\n )\n : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS')\n ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc)\n : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS')\n ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc)\n : clone({});\n FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR')\n ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc)\n : clone({});\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES')\n ? cfg.USE_PROFILES\n : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI = cfg.ALLOWED_URI_REGEXP || EXPRESSIONS.IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n MATHML_TEXT_INTEGRATION_POINTS =\n cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;\n HTML_INTEGRATION_POINTS =\n cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;\n\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements ===\n 'boolean'\n ) {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements =\n cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, TAGS.text);\n ALLOWED_ATTR = create(null);\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, TAGS.html);\n addToSet(ALLOWED_ATTR, ATTRS.html);\n }\n\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, TAGS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, TAGS.svgFilters);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, TAGS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n }\n\n /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */\n if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {\n EXTRA_ELEMENT_HANDLING.tagCheck = null;\n }\n\n if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {\n EXTRA_ELEMENT_HANDLING.attributeCheck = null;\n }\n\n /* Merge configuration parameters */\n if (cfg.ADD_TAGS) {\n if (typeof cfg.ADD_TAGS === 'function') {\n EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;\n } else {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n }\n\n if (cfg.ADD_ATTR) {\n if (typeof cfg.ADD_ATTR === 'function') {\n EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;\n } else {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n }\n\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n\n if (cfg.ADD_FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n\n addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);\n }\n\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.'\n );\n }\n\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.'\n );\n }\n\n // Overwrite existing TrustedTypes policy.\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n\n // Sign local variables required by `sanitize`.\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n // Uninitialized policy, attempt to initialize the internal dompurify policy.\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(\n trustedTypes,\n currentScript\n );\n }\n\n // If creating the internal policy succeeded sign internal variables.\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n\n CONFIG = cfg;\n };\n\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.svgDisallowed,\n ]);\n const ALL_MATHML_TAGS = addToSet({}, [\n ...TAGS.mathMl,\n ...TAGS.mathMlDisallowed,\n ]);\n\n /**\n * @param element a DOM element whose namespace is being checked\n * @returns Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function (element: Element): boolean {\n let parent = getParentNode(element);\n\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template',\n };\n }\n\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n\n if (element.namespaceURI === SVG_NAMESPACE) {\n // The only way to switch from HTML namespace to SVG\n // is via <svg>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n\n // The only way to switch from MathML to SVG is via`\n // svg if parent is either <annotation-xml> or MathML\n // text integration points.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return (\n tagName === 'svg' &&\n (parentTagName === 'annotation-xml' ||\n MATHML_TEXT_INTEGRATION_POINTS[parentTagName])\n );\n }\n\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n }\n\n if (element.namespaceURI === MATHML_NAMESPACE) {\n // The only way to switch from HTML namespace to MathML\n // is via <math>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n\n // The only way to switch from SVG to MathML is via\n // <math> and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n }\n\n if (element.namespaceURI === HTML_NAMESPACE) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (\n parent.namespaceURI === SVG_NAMESPACE &&\n !HTML_INTEGRATION_POINTS[parentTagName]\n ) {\n return false;\n }\n\n if (\n parent.namespaceURI === MATHML_NAMESPACE &&\n !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]\n ) {\n return false;\n }\n\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return (\n !ALL_MATHML_TAGS[tagName] &&\n (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName])\n );\n }\n\n // For XHTML and XML documents that support custom namespaces\n if (\n PARSER_MEDIA_TYPE === 'application/xhtml+xml' &&\n ALLOWED_NAMESPACES[element.namespaceURI]\n ) {\n return true;\n }\n\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n\n /**\n * _forceRemove\n *\n * @param node a DOM node\n */\n const _forceRemove = function (node: Node): void {\n arrayPush(DOMPurify.removed, { element: node });\n\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n getParentNode(node).removeChild(node);\n } catch (_) {\n remove(node);\n }\n };\n\n /**\n * _removeAttribute\n *\n * @param name an Attribute name\n * @param element a DOM node\n */\n const _removeAttribute = function (name: string, element: Element): void {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: element.getAttributeNode(name),\n from: element,\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: element,\n });\n }\n\n element.removeAttribute(name);\n\n // We void attribute values for unremovable \"is\" attributes\n if (name === 'is') {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(element);\n } catch (_) {}\n } else {\n try {\n element.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n\n /**\n * _initDocument\n *\n * @param dirty - a string of dirty markup\n * @return a DOM, filled with the dirty markup\n */\n const _initDocument = function (dirty: string): Document {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n\n if (FORCE_BODY) {\n dirty = '<remove></remove>' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n\n if (\n PARSER_MEDIA_TYPE === 'application/xhtml+xml' &&\n NAMESPACE === HTML_NAMESPACE\n ) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty =\n '<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>' +\n dirty +\n '</body></html>';\n }\n\n const dirtyPayload = trustedTypesPolicy\n ? trustedTypesPolicy.createHTML(dirty)\n : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT\n ? emptyHTML\n : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n\n const body = doc.body || doc.documentElement;\n\n if (dirty && leadingWhitespace) {\n body.insertBefore(\n document.createTextNode(leadingWhitespace),\n body.childNodes[0] || null\n );\n }\n\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(\n doc,\n WHOLE_DOCUMENT ? 'html' : 'body'\n )[0];\n }\n\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param root The root element or node to start traversing on.\n * @return The created NodeIterator\n */\n const _createNodeIterator = function (root: Node): NodeIterator {\n return createNodeIterator.call(\n root.ownerDocument || root,\n root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT |\n NodeFilter.SHOW_COMMENT |\n NodeFilter.SHOW_TEXT |\n NodeFilter.SHOW_PROCESSING_INSTRUCTION |\n NodeFilter.SHOW_CDATA_SECTION,\n null\n );\n };\n\n /**\n * _isClobbered\n *\n * @param element element to check for clobbering attacks\n * @return true if clobbered, false if safe\n */\n const _isClobbered = function (element: Element): boolean {\n return (\n element instanceof HTMLFormElement &&\n (typeof element.nodeName !== 'string' ||\n typeof element.textContent !== 'string' ||\n typeof element.removeChild !== 'function' ||\n !(element.attributes instanceof NamedNodeMap) ||\n typeof element.removeAttribute !== 'function' ||\n typeof element.setAttribute !== 'function' ||\n typeof element.namespaceURI !== 'string' ||\n typeof element.insertBefore !== 'function' ||\n typeof element.hasChildNodes !== 'function')\n );\n };\n\n /**\n * Checks whether the given object is a DOM node.\n *\n * @param value object to check whether it's a DOM node\n * @return true is object is a DOM node\n */\n const _isNode = function (value: unknown): value is Node {\n return typeof Node === 'function' && value instanceof Node;\n };\n\n function _executeHooks<T extends HookFunction>(\n hooks: HookFunction[],\n currentNode: Parameters<T>[0],\n data: Parameters<T>[1]\n ): void {\n arrayForEach(hooks, (hook: T) => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n }\n\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n * @param currentNode to check for permission to exist\n * @return true if node was killed, false if left alive\n */\n const _sanitizeElements = function (currentNode: any): boolean {\n let content = null;\n\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeElements, currentNode, null);\n\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(currentNode.nodeName);\n\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeElement, currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS,\n });\n\n /* Detect mXSS attempts abusing namespace confusion */\n if (\n SAFE_FOR_XML &&\n currentNode.hasChildNodes() &&\n !_isNode(currentNode.firstElementChild) &&\n regExpTest(/<[/\\w!]/g, currentNode.innerHTML) &&\n regExpTest(/<[/\\w!]/g, currentNode.textContent)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove any occurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove any kind of possibly harmful comments */\n if (\n SAFE_FOR_XML &&\n currentNode.nodeType === NODE_TYPE.comment &&\n regExpTest(/<[/\\w]/g, currentNode.data)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove element if anything forbids its presence */\n if (\n !(\n EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function &&\n EXTRA_ELEMENT_HANDLING.tagCheck(tagName)\n ) &&\n (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])\n ) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {\n if (\n CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)\n ) {\n return false;\n }\n\n if (\n CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)\n ) {\n return false;\n }\n }\n\n /* Keep content except for bad-listed elements */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode) || currentNode.parentNode;\n const childNodes = getChildNodes(currentNode) || currentNode.childNodes;\n\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n\n for (let i = childCount - 1; i >= 0; --i) {\n const childClone = cloneNode(childNodes[i], true);\n childClone.__removalCount = (currentNode.__removalCount || 0) + 1;\n parentNode.insertBefore(childClone, getNextSibling(currentNode));\n }\n }\n }\n\n _forceRemove(currentNode);\n return true;\n }\n\n /* Check whether element has a valid namespace */\n if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if (\n (tagName === 'noscript' ||\n tagName === 'noembed' ||\n tagName === 'noframes') &&\n regExpTest(/<\\/no(script|embed|frames)/i, currentNode.innerHTML)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n content = currentNode.textContent;\n\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => {\n content = stringReplace(content, expr, ' ');\n });\n\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });\n currentNode.textContent = content;\n }\n }\n\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeElements, currentNode, null);\n\n return false;\n };\n\n /**\n * _isValidAttribute\n *\n * @param lcTag Lowercase tag name of containing element.\n * @param lcName Lowercase attribute name.\n * @param value Attribute value.\n * @return Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function (\n lcTag: string,\n lcName: string,\n value: string\n ): boolean {\n /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */\n if (FORBID_ATTR[lcName]) {\n return false;\n }\n\n /* Make sure attribute cannot clobber */\n if (\n SANITIZE_DOM &&\n (lcName === 'id' || lcName === 'name') &&\n (value in document || value in formElement)\n ) {\n return false;\n }\n\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (\n ALLOW_DATA_ATTR &&\n !FORBID_ATTR[lcName] &&\n regExpTest(DATA_ATTR, lcName)\n ) {\n // This attribute is safe\n } else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) {\n // This attribute is safe\n /* Check if ADD_ATTR function allows this attribute */\n } else if (\n EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function &&\n EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)\n ) {\n // This attribute is safe\n /* Otherwise, check the name is permitted */\n } else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {\n if (\n // First condition does a very basic check if a) it's basically a valid custom element tagname AND\n // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck\n (_isBasicCustomElement(lcTag) &&\n ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag)) ||\n (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag))) &&\n ((CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName)) ||\n (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)))) ||\n // Alternative, second condition checks if it's an `is`-attribute, AND\n // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n (lcName === 'is' &&\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements &&\n ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)) ||\n (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))))\n ) {\n // If user has supplied a regexp or function in CUSTOM_ELEMENT_HANDLING.tagNameCheck, we need to also allow derived custom elements using the same tagName test.\n // Additionally, we need to allow attributes passing the CUSTOM_ELEMENT_HANDLING.attributeNameCheck user has configured, as custom elements can define these at their own discretion.\n } else {\n return false;\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n } else if (URI_SAFE_ATTRIBUTES[lcName]) {\n // This attribute is safe\n /* Check no script, data or unknown possibly unsafe URI\n unless we know URI values are safe for that attribute */\n } else if (\n regExpTest(IS_ALLOWED_URI, stringReplace(value, ATTR_WHITESPACE, ''))\n ) {\n // This attribute is safe\n /* Keep image data URIs alive if src/xlink:href is allowed */\n /* Further prevent gadget XSS for dynamically built script tags */\n } else if (\n (lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') &&\n lcTag !== 'script' &&\n stringIndexOf(value, 'data:') === 0 &&\n DATA_URI_TAGS[lcTag]\n ) {\n // This attribute is safe\n /* Allow unknown protocols: This provides support for links that\n are handled by protocol handlers which may be unknown ahead of\n time, e.g. fb:, spotify: */\n } else if (\n ALLOW_UNKNOWN_PROTOCOLS &&\n !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))\n ) {\n // This attribute is safe\n /* Check for binary attributes */\n } else if (value) {\n return false;\n } else {\n // Binary attributes are safe at this point\n /* Anything else, presume unsafe, do not add it back */\n }\n\n return true;\n };\n\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param tagName name of the tag of the node to sanitize\n * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function (tagName: string): RegExpMatchArray {\n return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);\n };\n\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param currentNode to sanitize\n */\n const _sanitizeAttributes = function (currentNode: Element): void {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);\n\n const { attributes } = currentNode;\n\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes || _isClobbered(currentNode)) {\n return;\n }\n\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n forceKeepAttr: undefined,\n };\n let l = attributes.length;\n\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const { name, namespaceURI, value: attrValue } = attr;\n const lcName = transformCaseFunc(name);\n\n const initValue = attrValue;\n let value = name === 'value' ? initValue : stringTrim(initValue);\n\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);\n value = hookEvent.attrValue;\n\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode);\n\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n\n /* Work around a security issue with comments inside attributes */\n if (\n SAFE_FOR_XML &&\n regExpTest(\n /((--!?|])>)|<\\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,\n value\n )\n ) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Make sure we cannot easily use animated hrefs, even if animations are allowed */\n if (lcName === 'attributename' && stringMatch(value, 'href')) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Did the hooks approve of the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\\/>/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => {\n value = stringReplace(value, expr, ' ');\n });\n }\n\n /* Is `value` valid for this attribute? */\n const lcTag = transformCaseFunc(currentNode.nodeName);\n if (!_isValidAttribute(lcTag, lcName, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Handle attributes that require Trusted Types */\n if (\n trustedTypesPolicy &&\n typeof trustedTypes === 'object' &&\n typeof trustedTypes.getAttributeType === 'function'\n ) {\n if (namespaceURI) {\n /* Namespaces are not yet supported, see https://bugs.chromium.org/p/chromium/issues/detail?id=1305293 */\n } else {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML': {\n value = trustedTypesPolicy.createHTML(value);\n break;\n }\n\n case 'TrustedScriptURL': {\n value = trustedTypesPolicy.createScriptURL(value);\n break;\n }\n\n default: {\n break;\n }\n }\n }\n }\n\n /* Handle invalid data-* attribute set by try-catching it */\n if (value !== initValue) {\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n } else {\n arrayPop(DOMPurify.removed);\n }\n } catch (_) {\n _removeAttribute(name, currentNode);\n }\n }\n }\n\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);\n };\n\n /**\n * _sanitizeShadowDOM\n *\n * @param fragment to iterate over recursively\n */\n const _sanitizeShadowDOM = function (fragment: DocumentFragment): void {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);\n\n while ((shadowNode = shadowIterator.nextNode())) {\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);\n\n /* Sanitize tags and elements */\n _sanitizeElements(shadowNode);\n\n /* Check attributes next */\n _sanitizeAttributes(shadowNode);\n\n /* Deep shadow DOM detected */\n if (shadowNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(shadowNode.content);\n }\n }\n\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);\n };\n\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty, cfg = {}) {\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '<!-->';\n }\n\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n if (typeof dirty.toString === 'function') {\n dirty = dirty.toString();\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n } else {\n throw typeErrorCreate('toString is not a function');\n }\n }\n\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n\n /* Assign config vars */\n if (!SET_CONFIG) {\n _parseConfig(cfg);\n }\n\n /* Clean up removed elements */\n DOMPurify.removed = [];\n\n /* Check if dirty is correctly typed for IN_PLACE */\n if (typeof dirty === 'string') {\n IN_PLACE = false;\n }\n\n if (IN_PLACE) {\n /* Do some early pre-sanitization to avoid unsafe root nodes */\n if ((dirty as Node).nodeName) {\n const tagName = transformCaseFunc((dirty as Node).nodeName);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate(\n 'root node is forbidden and cannot be sanitized in-place'\n );\n }\n }\n } else if (dirty instanceof Node) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('<!---->');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (\n importedNode.nodeType === NODE_TYPE.element &&\n importedNode.nodeName === 'BODY'\n ) {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n } else {\n /* Exit directly if we have nothing to do */\n if (\n !RETURN_DOM &&\n !SAFE_FOR_TEMPLATES &&\n !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1\n ) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE\n ? trustedTypesPolicy.createHTML(dirty)\n : dirty;\n }\n\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n\n /* Get node iterator */\n const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);\n\n /* Now start iterating over the created document */\n while ((currentNode = nodeIterator.nextNode())) {\n /* Sanitize tags and elements */\n _sanitizeElements(currentNode);\n\n /* Check attributes next */\n _sanitizeAttributes(currentNode);\n\n /* Shadow DOM detected, sanitize it */\n if (currentNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(currentNode.content);\n }\n }\n\n /* If we sanitized `dirty` in-place, return it. */\n if (IN_PLACE) {\n return dirty;\n }\n\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n\n return returnNode;\n }\n\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n\n /* Serialize doctype if allowed */\n if (\n WHOLE_DOCUMENT &&\n ALLOWED_TAGS['!doctype'] &&\n body.ownerDocument &&\n body.ownerDocument.doctype &&\n body.ownerDocument.doctype.name &&\n regExpTest(EXPRESSIONS.DOCTYPE_NAME, body.ownerDocument.doctype.name)\n ) {\n serializedHTML =\n '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\\n' + serializedHTML;\n }\n\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr: RegExp) => {\n serializedHTML = stringReplace(serializedHTML, expr, ' ');\n });\n }\n\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE\n ? trustedTypesPolicy.createHTML(serializedHTML)\n : serializedHTML;\n };\n\n DOMPurify.setConfig = function (cfg = {}) {\n _parseConfig(cfg);\n SET_CONFIG = true;\n };\n\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n };\n\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n\n DOMPurify.addHook = function (\n entryPoint: keyof HooksMap,\n hookFunction: HookFunction\n ) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n\n arrayPush(hooks[entryPoint], hookFunction);\n };\n\n DOMPurify.removeHook = function (\n entryPoint: keyof HooksMap,\n hookFunction: HookFunction\n ) {\n if (hookFunction !== undefined) {\n const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);\n\n return index === -1\n ? undefined\n : arraySplice(hooks[entryPoint], index, 1)[0];\n }\n\n return arrayPop(hooks[entryPoint]);\n };\n\n DOMPurify.removeHooks = function (entryPoint: keyof HooksMap) {\n hooks[entryPoint] = [];\n };\n\n DOMPurify.removeAllHooks = function () {\n hooks = _createHooksMap();\n };\n\n return DOMPurify;\n}\n\nexport default createDOMPurify();\n\nexport interface DOMPurify {\n /**\n * Creates a DOMPurify instance using the given window-like object. Defaults to `window`.\n */\n (root?: WindowLike): DOMPurify;\n\n /**\n * Version label, exposed for easier checks\n * if DOMPurify is up to date or not\n */\n version: string;\n\n /**\n * Array of elements that DOMPurify removed during sanitation.\n * Empty if nothing was removed.\n */\n removed: Array<RemovedElement | RemovedAttribute>;\n\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n isSupported: boolean;\n\n /**\n * Set the configuration once.\n *\n * @param cfg configuration object\n */\n setConfig(cfg?: Config): void;\n\n /**\n * Removes the configuration.\n */\n clearConfig(): void;\n\n /**\n * Provides core sanitation functionality.\n *\n * @param dirty string or DOM node\n * @param cfg object\n * @returns Sanitized TrustedHTML.\n */\n sanitize(\n dirty: string | Node,\n cfg: Config & { RETURN_TRUSTED_TYPE: true }\n ): TrustedHTML;\n\n /**\n * Provides core sanitation functionality.\n *\n * @param dirty DOM node\n * @param cfg object\n * @returns Sanitized DOM node.\n */\n sanitize(dirty: Node, cfg: Config & { IN_PLACE: true }): Node;\n\n /**\n * Provides core sanitation functionality.\n *\n * @param dirty string or DOM node\n * @param cfg object\n * @returns Sanitized DOM node.\n */\n sanitize(dirty: string | Node, cfg: Config & { RETURN_DOM: true }): Node;\n\n /**\n * Provides core sanitation functionality.\n *\n * @param dirty string or DOM node\n * @param cfg object\n * @returns Sanitized document fragment.\n */\n sanitize(\n dirty: string | Node,\n cfg: Config & { RETURN_DOM_FRAGMENT: true }\n ): DocumentFragment;\n\n /**\n * Provides core sanitation functionality.\n *\n * @param dirty string or DOM node\n * @param cfg object\n * @returns Sanitized string.\n */\n sanitize(dirty: string | Node, cfg?: Config): string;\n\n /**\n * Checks if an attribute value is valid.\n * Uses last set config, if any. Otherwise, uses config defaults.\n *\n * @param tag Tag name of containing element.\n * @param attr Attribute name.\n * @param value Attribute value.\n * @returns Returns true if `value` is valid. Otherwise, returns false.\n */\n isValidAttribute(tag: string, attr: string, value: string): boolean;\n\n /**\n * Adds a DOMPurify hook.\n *\n * @param entryPoint entry point for the hook to add\n * @param hookFunction function to execute\n */\n addHook(entryPoint: BasicHookName, hookFunction: NodeHook): void;\n\n /**\n * Adds a DOMPurify hook.\n *\n * @param entryPoint entry point for the hook to add\n * @param hookFunction function to execute\n */\n addHook(entryPoint: ElementHookName, hookFunction: ElementHook): void;\n\n /**\n * Adds a DOMPurify hook.\n *\n * @param entryPoint entry point for the hook to add\n * @param hookFunction function to execute\n */\n addHook(\n entryPoint: DocumentFragmentHookName,\n hookFunction: DocumentFragmentHook\n ): void;\n\n /**\n * Adds a DOMPurify hook.\n *\n * @param entryPoint entry point for the hook to add\n * @param hookFunction function to execute\n */\n addHook(\n entryPoint: 'uponSanitizeElement',\n hookFunction: UponSanitizeElementHook\n ): void;\n\n /**\n * Adds a DOMPurify hook.\n *\n * @param entryPoint entry point for the hook to add\n * @param hookFunction function to execute\n */\n addHook(\n entryPoint: 'uponSanitizeAttribute',\n hookFunction: UponSanitizeAttributeHook\n ): void;\n\n /**\n * Remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if hook not specified)\n *\n * @param entryPoint entry point for the hook to remove\n * @param hookFunction optional specific hook to remove\n * @returns removed hook\n */\n removeHook(\n entryPoint: BasicHookName,\n hookFunction?: NodeHook\n ): NodeHook | undefined;\n\n /**\n * Remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if hook not specified)\n *\n * @param entryPoint entry point for the hook to remove\n * @param hookFunction optional specific hook to remove\n * @returns removed hook\n */\n removeHook(\n entryPoint: ElementHookName,\n hookFunction?: ElementHook\n ): ElementHook | undefined;\n\n /**\n * Remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if hook not specified)\n *\n * @param entryPoint entry point for the hook to remove\n * @param hookFunction optional specific hook to remove\n * @returns removed hook\n */\n removeHook(\n entryPoint: DocumentFragmentHookName,\n hookFunction?: DocumentFragmentHook\n ): DocumentFragmentHook | undefined;\n\n /**\n * Remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if hook not specified)\n *\n * @param entryPoint entry point for the hook to remove\n * @param hookFunction optional specific hook to remove\n * @returns removed hook\n */\n removeHook(\n entryPoint: 'uponSanitizeElement',\n hookFunction?: UponSanitizeElementHook\n ): UponSanitizeElementHook | undefined;\n\n /**\n * Remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if hook not specified)\n *\n * @param entryPoint entry point for the hook to remove\n * @param hookFunction optional specific hook to remove\n * @returns removed hook\n */\n removeHook(\n entryPoint: 'uponSanitizeAttribute',\n hookFunction?: UponSanitizeAttributeHook\n ): UponSanitizeAttributeHook | undefined;\n\n /**\n * Removes all DOMPurify hooks at a given entryPoint\n *\n * @param entryPoint entry point for the hooks to remove\n */\n removeHooks(entryPoint: HookName): void;\n\n /**\n * Removes all DOMPurify hooks.\n */\n removeAllHooks(): void;\n}\n\n/**\n * An element removed by DOMPurify.\n */\nexport interface RemovedElement {\n /**\n * The element that was removed.\n */\n element: Node;\n}\n\n/**\n * An element removed by DOMPurify.\n */\nexport interface RemovedAttribute {\n /**\n * The attribute that was removed.\n */\n attribute: Attr | null;\n\n /**\n * The element that the attribute was removed.\n */\n from: Node;\n}\n\ntype BasicHookName =\n | 'beforeSanitizeElements'\n | 'afterSanitizeElements'\n | 'uponSanitizeShadowNode';\ntype ElementHookName = 'beforeSanitizeAttributes' | 'afterSanitizeAttributes';\ntype DocumentFragmentHookName =\n | 'beforeSanitizeShadowDOM'\n | 'afterSanitizeShadowDOM';\ntype UponSanitizeElementHookName = 'uponSanitizeElement';\ntype UponSanitizeAttributeHookName = 'uponSanitizeAttribute';\n\ninterface HooksMap {\n beforeSanitizeElements: NodeHook[];\n afterSanitizeElements: NodeHook[];\n beforeSanitizeShadowDOM: DocumentFragmentHook[];\n uponSanitizeShadowNode: NodeHook[];\n afterSanitizeShadowDOM: DocumentFragmentHook[];\n beforeSanitizeAttributes: ElementHook[];\n afterSanitizeAttributes: ElementHook[];\n uponSanitizeElement: UponSanitizeElementHook[];\n uponSanitizeAttribute: UponSanitizeAttributeHook[];\n}\n\ntype ArrayElement<T> = T extends Array<infer U> ? U : never;\n\ntype HookFunction = ArrayElement<HooksMap[keyof HooksMap]>;\n\nexport type HookName =\n | BasicHookName\n | ElementHookName\n | DocumentFragmentHookName\n | UponSanitizeElementHookName\n | UponSanitizeAttributeHookName;\n\nexport type NodeHook = (\n this: DOMPurify,\n currentNode: Node,\n hookEvent: null,\n config: Config\n) => void;\n\nexport type ElementHook = (\n this: DOMPurify,\n currentNode: Element,\n hookEvent: null,\n config: Config\n) => void;\n\nexport type DocumentFragmentHook = (\n this: DOMPurify,\n currentNode: DocumentFragment,\n hookEvent: null,\n config: Config\n) => void;\n\nexport type UponSanitizeElementHook = (\n this: DOMPurify,\n currentNode: Node,\n hookEvent: UponSanitizeElementHookEvent,\n config: Config\n) => void;\n\nexport type UponSanitizeAttributeHook = (\n this: DOMPurify,\n currentNode: Element,\n hookEvent: UponSanitizeAttributeHookEvent,\n config: Config\n) => void;\n\nexport interface UponSanitizeElementHookEvent {\n tagName: string;\n allowedTags: Record<string, boolean>;\n}\n\nexport interface UponSanitizeAttributeHookEvent {\n attrName: string;\n attrValue: string;\n keepAttr: boolean;\n allowedAttributes: Record<string, boolean>;\n forceKeepAttr: boolean | undefined;\n}\n\n/**\n * A `Window`-like object containing the properties and types that DOMPurify requires.\n */\nexport type WindowLike = Pick<\n typeof globalThis,\n | 'DocumentFragment'\n | 'HTMLTemplateElement'\n | 'Node'\n | 'Element'\n | 'NodeFilter'\n | 'NamedNodeMap'\n | 'HTMLFormElement'\n | 'DOMParser'\n> & {\n document?: Document;\n MozNamedAttrMap?: typeof window.NamedNodeMap;\n} & Pick<TrustedTypesWindow, 'trustedTypes'>;\n", "export const httpTokenCodePoints: RegExp = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;", "import { httpTokenCodePoints } from './utils.js';\n\nconst matcher: RegExp = /([\"\\\\])/ug;\nconst httpQuotedStringTokenCodePoints: RegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]*$/u;\n\n/**\n * Class representing the parameters for a media type record.\n * This class extends a JavaScript Map<string, string>.\n *\n * However, MediaTypeParameters methods will always interpret their arguments\n * as appropriate for media types, so parameter names will be lowercased,\n * and attempting to set invalid characters will throw an Error.\n *\n * @see https://mimesniff.spec.whatwg.org\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParameters extends Map<string, string> {\n\t/**\n\t * Create a new MediaTypeParameters instance.\n\t *\n\t * @param entries An array of [ name, value ] tuples.\n\t */\n\tconstructor(entries: Iterable<[string, string]> = []) {\n\t\tsuper(entries);\n\t}\n\n\t/**\n\t * Indicates whether the supplied name and value are valid media type parameters.\n\t *\n\t * @param name The name of the media type parameter to validate.\n\t * @param value The media type parameter value to validate.\n\t * @returns true if the media type parameter is valid, false otherwise.\n\t */\n\tstatic isValid(name: string, value: string): boolean {\n\t\treturn httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);\n\t}\n\n\t/**\n\t * Gets the media type parameter value for the supplied name.\n\t *\n\t * @param name The name of the media type parameter to retrieve.\n\t * @returns The media type parameter value.\n\t */\n\toverride get(name: string): string | undefined {\n\t\treturn super.get(name.toLowerCase());\n\t}\n\n\t/**\n\t * Indicates whether the media type parameter with the specified name exists or not.\n\t *\n\t * @param name The name of the media type parameter to check.\n\t * @returns true if the media type parameter exists, false otherwise.\n\t */\n\toverride has(name: string): boolean {\n\t\treturn super.has(name.toLowerCase());\n\t}\n\n\t/**\n\t * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.\n\t * If an parameter with the same name already exists, the parameter will be updated.\n\t *\n\t * @param name The name of the media type parameter to set.\n\t * @param value The media type parameter value.\n\t * @returns This instance.\n\t */\n\toverride set(name: string, value: string): this {\n\t\tif (!MediaTypeParameters.isValid(name, value)) {\n\t\t\tthrow new Error(`Invalid media type parameter name/value: ${name}/${value}`);\n\t\t}\n\n\t\tsuper.set(name.toLowerCase(), value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the media type parameter using the specified name.\n\t *\n\t * @param name The name of the media type parameter to delete.\n\t * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.\n\t */\n\toverride delete(name: string): boolean {\n\t\treturn super.delete(name.toLowerCase());\n\t}\n\n\t/**\n\t * Returns a string representation of the media type parameters.\n\t *\n\t * @returns The string representation of the media type parameters.\n\t */\n\toverride toString(): string {\n\t\treturn Array.from(this).map(([ name, value ]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `\"${value.replace(matcher, '\\\\$1')}\"` : value}`).join('');\n\t}\n\n\t/**\n\t * Returns the name of this class.\n\t *\n\t * @returns The name of this class.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParameters';\n\t}\n}", "import { MediaTypeParameters } from './media-type-parameters.js';\nimport { httpTokenCodePoints } from './utils.js';\n\nconst whitespaceChars = new Set([' ', '\\t', '\\n', '\\r']);\nconst trailingWhitespace: RegExp = /[ \\t\\n\\r]+$/u;\nconst leadingAndTrailingWhitespace: RegExp = /^[ \\t\\n\\r]+|[ \\t\\n\\r]+$/ug;\n\nexport interface MediaTypeComponent {\n\tposition?: number;\n\tinput: string;\n\tlowerCase?: boolean;\n\ttrim?: boolean;\n}\n\nexport interface ParsedMediaType {\n\ttype: string;\n\tsubtype: string;\n\tparameters: MediaTypeParameters;\n}\n\n/**\n * Parser for media types.\n * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParser {\n\t/**\n\t * Function to parse a media type.\n\t * @param input The media type to parse\n\t * @returns An object populated with the parsed media type properties and any parameters.\n\t */\n\tstatic parse(input: string): ParsedMediaType {\n\t\tinput = input.replace(leadingAndTrailingWhitespace, '');\n\n\t\tlet position = 0;\n\t\tconst [ type, typeEnd ] = MediaTypeParser.collect(input, position, ['/']);\n\t\tposition = typeEnd;\n\n\t\tif (!type.length || position >= input.length || !httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('type', type));\n\t\t}\n\n\t\t++position; // Skip \"/\"\n\t\tconst [ subtype, subtypeEnd ] = MediaTypeParser.collect(input, position, [';'], true, true);\n\t\tposition = subtypeEnd;\n\n\t\tif (!subtype.length || !httpTokenCodePoints.test(subtype)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('subtype', subtype));\n\t\t}\n\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position < input.length) {\n\t\t\t++position; // Skip \";\"\n\t\t\twhile (whitespaceChars.has(input[position]!)) { ++position }\n\n\t\t\tlet name: string;\n\t\t\t[name, position] = MediaTypeParser.collect(input, position, [';', '='], false);\n\n\t\t\tif (position >= input.length || input[position] === ';') { continue }\n\n\t\t\t++position; // Skip \"=\"\n\n\t\t\tlet value: string;\n\t\t\tif (input[position] === '\"') {\n\t\t\t\t[ value, position ] = MediaTypeParser.collectHttpQuotedString(input, position);\n\t\t\t\twhile (position < input.length && input[position] !== ';') { ++position }\n\t\t\t} else {\n\t\t\t\t[ value, position ] = MediaTypeParser.collect(input, position, [';'], false, true);\n\t\t\t\tif (!value) { continue }\n\t\t\t}\n\n\t\t\tif (name && MediaTypeParameters.isValid(name, value) && !parameters.has(name)) {\n\t\t\t\tparameters.set(name, value);\n\t\t\t}\n\t\t}\n\n\t\treturn { type, subtype, parameters };\n\t}\n\n\t/**\n\t * Gets the name of this class.\n\t * @returns The string tag of this class.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParser';\n\t}\n\n\t/**\n\t * Collects characters from `input` starting at `pos` until a stop character is found.\n\t * @param input The input string.\n\t * @param pos The starting position.\n\t * @param stopChars Characters that end collection.\n\t * @param lowerCase Whether to ASCII-lowercase the result.\n\t * @param trim Whether to strip trailing HTTP whitespace.\n\t * @returns A tuple of the collected string and the updated position.\n\t */\n\tprivate static collect(input: string, pos: number, stopChars: string[], lowerCase = true, trim = false): [string, number] {\n\t\tlet result = '';\n\t\tfor (const { length } = input; pos < length && !stopChars.includes(input[pos]!); pos++) {\n\t\t\tresult += input[pos];\n\t\t}\n\n\t\tif (lowerCase) { result = result.toLowerCase() }\n\t\tif (trim) { result = result.replace(trailingWhitespace, '') }\n\n\t\treturn [result, pos];\n\t}\n\n\t/**\n\t * Collects all the HTTP quoted strings.\n\t * This variant only implements it with the extract-value flag set.\n\t * @param input The string to process.\n\t * @param position The starting position.\n\t * @returns An array that includes the resulting string and updated position.\n\t */\n\tprivate static collectHttpQuotedString(input: string, position: number): [string, number] {\n\t\tlet value = '';\n\n\t\tfor (let length = input.length, char; ++position < length;) {\n\t\t\tif ((char = input[position]) === '\"') { break }\n\n\t\t\tvalue += char == '\\\\' && ++position < length ? input[position] : char;\n\t\t}\n\n\t\treturn [ value, position ];\n\t}\n\n\t/**\n\t * Generates an error message.\n\t * @param component The component name.\n\t * @param value The component value.\n\t * @returns The error message.\n\t */\n\tprivate static generateErrorMessage(component: string, value: string): string {\n\t\treturn `Invalid ${component} \"${value}\": only HTTP token code points are valid.`;\n\t}\n}", "import { MediaTypeParser } from './media-type-parser.js';\nimport { MediaTypeParameters } from './media-type-parameters.js';\n\n/**\n * Class used to parse media types.\n * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types\n */\nexport class MediaType {\n\tprivate readonly _type: string;\n\tprivate readonly _subtype: string;\n\tprivate readonly _parameters: MediaTypeParameters;\n\n\t/**\n\t * Create a new MediaType instance from a string representation.\n\t * @param mediaType The media type to parse.\n\t * @param parameters Optional parameters.\n\t */\n\tconstructor(mediaType: string, parameters: Record<string, string> = {}) {\n\t\tif (parameters === null || typeof parameters !== 'object' || Array.isArray(parameters)) {\n\t\t\tthrow new TypeError('The parameters argument must be an object');\n\t\t}\n\n\t\t({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));\n\n\t\tfor (const [ name, value ] of Object.entries(parameters)) { this._parameters.set(name, value) }\n\t}\n\n\t/**\n\t * Parses a media type string.\n\t * @param mediaType The media type to parse.\n\t * @returns The parsed media type or null if the mediaType cannot be parsed.\n\t */\n\tstatic parse(mediaType: string): MediaType | null {\n\t\ttry {\n\t\t\treturn new MediaType(mediaType);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the type.\n\t * @returns The type.\n\t */\n\tget type(): string {\n\t\treturn this._type;\n\t}\n\n\t/**\n\t * Gets the subtype.\n\t * @returns The subtype.\n\t */\n\tget subtype(): string {\n\t\treturn this._subtype;\n\t}\n\n\t/**\n\t * Gets the media type essence (type/subtype).\n\t * @returns The media type without any parameters\n\t */\n\tget essence(): string {\n\t\treturn `${this._type}/${this._subtype}`;\n\t}\n\n\t/**\n\t * Gets the parameters.\n\t * @returns The media type parameters.\n\t */\n\tget parameters(): MediaTypeParameters {\n\t\treturn this._parameters;\n\t}\n\n\t/**\n\t * Checks if the media type matches the specified type.\n\t *\n\t * @param mediaType The media type to check.\n\t * @returns true if the media type matches the specified type, false otherwise.\n\t */\n\tmatches(mediaType: MediaType | string): boolean {\n\t\treturn typeof mediaType === 'string' ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;\n\t}\n\n\t/**\n\t * Gets the serialized version of the media type.\n\t *\n\t * @returns The serialized media type.\n\t */\n\ttoString(): string {\n\t\treturn `${this.essence}${this._parameters.toString()}`;\n\t}\n\n\t/**\n\t * Gets the name of the class.\n\t * @returns The class name\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaType';\n\t}\n}", "/** A {@link Map} that can contain multiple, unique, values for the same key. */\nexport class SetMultiMap<K, V> extends Map<K, Set<V>>{\n\t/**\n\t * Adds a new element with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key - The key to set.\n\t * @param value - The value to add to the SetMultiMap.\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: V): this;\n\t/**\n\t * Adds a new Set with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key - The key to set.\n\t * @param value - The set of values to add to the SetMultiMap.\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: Set<V>): this;\n\t/**\n\t * Adds a new element with a specified key and value to the SetMultiMap.\n\t * If an element with the same key already exists, the value will be added to the underlying {@link Set}.\n\t * If the value already exists in the {@link Set}, it will not be added again.\n\t *\n\t * @param key The key to set.\n\t * @param value The value to add to the SetMultiMap\n\t * @returns The SetMultiMap with the updated key and value.\n\t */\n\toverride set(key: K, value: V | Set<V>) {\n\t\tsuper.set(key, value instanceof Set ? value : (super.get(key) ?? new Set<V>()).add(value));\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: V): V;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: Set<V>): Set<V>;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will insert the default value and return it.\n\t * @param key The key to get the value for.\n\t * @param defaultValue The default value to insert if the key does not exist.\n\t * @returns The value associated with the specified key, or the default value if the key does not exist.\n\t */\n\toverride getOrInsert(key: K, defaultValue: V | Set<V>): V | Set<V> {\n\t\tif (this.has(key)) { return super.get(key)! }\n\n\t\tsuper.set(key, defaultValue instanceof Set ? defaultValue : (super.get(key) ?? new Set<V>()).add(defaultValue));\n\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => V): V;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => Set<V>): Set<V>;\n\n\t/**\n\t * Gets the value associated with the specified key. If the key does not exist, it will compute the value using the provided function, insert it, and return it.\n\t * @param key The key to get the value for.\n\t * @param compute The function to compute the value if the key does not exist.\n\t * @returns The value associated with the specified key, or the computed value if the key does not exist.\n\t */\n\toverride getOrInsertComputed(key: K, compute: (key: K) => V | Set<V>): V | Set<V> {\n\t\tif (this.has(key)) { return super.get(key)! }\n\n\t\tconst defaultValue = compute(key);\n\t\tsuper.set(key, defaultValue instanceof Set ? defaultValue : (super.get(key) ?? new Set<V>()).add(defaultValue));\n\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Finds a specific value for a specific key using an iterator function.\n\t * @param key The key to find the value for.\n\t * @param iterator The iterator function to use to find the value.\n\t * @returns The value for the specified key\n\t */\n\tfind(key: K, iterator: (value: V) => boolean): V | undefined {\n\t\tconst values = this.get(key);\n\n\t\tif (values !== undefined) {\n\t\t\treturn Array.from(values).find(iterator);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Checks if a specific key has a specific value.\n\t *\n\t * @param key The key to check.\n\t * @param value The value to check.\n\t * @returns True if the key has the value, false otherwise.\n\t */\n\thasValue(key: K, value: V): boolean {\n\t\tconst values = super.get(key);\n\n\t\treturn values ? values.has(value) : false;\n\t}\n\n\t/**\n\t * Removes a specific value from a specific key.\n\t * @param key The key to remove the value from.\n\t * @param value The value to remove.\n\t * @returns True if the value was removed, false otherwise.\n\t */\n\tdeleteValue(key: K, value: V | undefined): boolean {\n\t\tif (value === undefined) { return this.delete(key) }\n\n\t\tconst values = super.get(key);\n\t\tif (values) {\n\t\t\tconst deleted = values.delete(value);\n\n\t\t\tif (values.size === 0) {\n\t\t\t\tsuper.delete(key);\n\t\t\t}\n\n\t\t\treturn deleted;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * The string tag of the SetMultiMap.\n\t * @returns The string tag of the SetMultiMap.\n\t */\n\toverride get [Symbol.toStringTag]() {\n\t\treturn 'SetMultiMap';\n\t}\n}", "import type { EventHandler } from './@types';\n\n/** A wrapper for an event handler that binds a context to the event handler. */\nexport class ContextEventHandler {\n\tprivate readonly context: unknown;\n\tprivate readonly eventHandler: EventHandler;\n\n\t/**\n\t * @param context The context to bind to the event handler.\n\t * @param eventHandler The event handler to call when the event is published.\n\t */\n\tconstructor(context: unknown, eventHandler: EventHandler) {\n\t\tthis.context = context;\n\t\tthis.eventHandler = eventHandler;\n\t}\n\n\t/**\n\t * Call the event handler for the provided event.\n\t *\n\t * @param event The event to handle\n\t * @param data The value to be passed to the event handler as a parameter.\n\t */\n\thandle(event: Event, data?: unknown): void {\n\t\tthis.eventHandler.call(this.context, event, data);\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'ContextEventHandler';\n\t}\n}", "import type { ContextEventHandler } from './context-event-handler';\n\n/** Represents a subscription to an event. */\nexport class Subscription {\n\tprivate readonly _eventName: string;\n\tprivate readonly _contextEventHandler: ContextEventHandler;\n\n\t/**\n\t * @param eventName The event name.\n\t * @param contextEventHandler The context event handler.\n\t */\n\tconstructor(eventName: string, contextEventHandler: ContextEventHandler) {\n\t\tthis._eventName = eventName;\n\t\tthis._contextEventHandler = contextEventHandler;\n\t}\n\n\t/**\n\t * Gets the event name for the subscription.\n\t *\n\t * @returns The event name.\n\t */\n\tget eventName(): string {\n\t\treturn this._eventName;\n\t}\n\n\t/**\n\t * Gets the context event handler.\n\t *\n\t * @returns The context event handler\n\t */\n\tget contextEventHandler(): ContextEventHandler {\n\t\treturn this._contextEventHandler;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Subscription';\n\t}\n}", "import { SetMultiMap } from '@d1g1tal/collections';\nimport { ContextEventHandler } from './context-event-handler';\nimport { Subscription } from './subscription';\nimport type { EventHandler, ErrorHandler, SubscriptionOptions } from './@types';\n\n/** A class that allows objects to subscribe to events and be notified when the event is published. */\nexport class Subscribr {\n\tprivate readonly subscribers: SetMultiMap<string, ContextEventHandler> = new SetMultiMap();\n\tprivate errorHandler?: ErrorHandler;\n\n\t/**\n\t * Set a custom error handler for handling errors that occur in event listeners.\n\t * If not set, errors will be logged to the console.\n\t *\n\t * @param errorHandler The error handler function to call when an error occurs in an event listener.\n\t */\n\tsetErrorHandler(errorHandler: ErrorHandler): void {\n\t\tthis.errorHandler = errorHandler;\n\t}\n\n\t/**\n\t * Subscribe to an event\n\t *\n\t * @param eventName The event name to subscribe to.\n\t * @param eventHandler The event handler to call when the event is published.\n\t * @param context The context to bind to the event handler.\n\t * @param options Subscription options.\n\t * @returns An object used to check if the subscription still exists and to unsubscribe from the event.\n\t */\n\tsubscribe(eventName: string, eventHandler: EventHandler, context: unknown = eventHandler, options?: SubscriptionOptions): Subscription {\n\t\tthis.validateEventName(eventName);\n\n\t\t// If once option is set, wrap the handler to auto-unsubscribe\n\t\tif (options?.once) {\n\t\t\tconst originalHandler = eventHandler;\n\t\t\teventHandler = (event: Event, data?: unknown) => {\n\t\t\t\toriginalHandler.call(context, event, data);\n\t\t\t\tthis.unsubscribe(subscription);\n\t\t\t};\n\t\t}\n\n\t\tconst contextEventHandler = new ContextEventHandler(context, eventHandler);\n\t\tthis.subscribers.set(eventName, contextEventHandler);\n\n\t\tconst subscription = new Subscription(eventName, contextEventHandler);\n\n\t\treturn subscription;\n\t}\n\n\t/**\n\t * Unsubscribe from the event\n\t *\n\t * @param subscription The subscription to unsubscribe.\n\t * @returns true if eventListener has been removed successfully. false if the value is not found or if the value is not an object.\n\t */\n\tunsubscribe({ eventName, contextEventHandler }: Subscription): boolean {\n\t\tconst contextEventHandlers = this.subscribers.get(eventName) ?? new Set();\n\t\tconst removed = contextEventHandlers.delete(contextEventHandler);\n\n\t\tif (removed && contextEventHandlers.size === 0) {\tthis.subscribers.delete(eventName) }\n\n\t\treturn removed;\n\t}\n\n\t/**\n\t * Publish an event\n\t *\n\t * @template T\n\t * @param eventName The name of the event.\n\t * @param event The event to be handled.\n\t * @param data The value to be passed to the event handler as a parameter.\n\t */\n\tpublish<T>(eventName: string, event: Event = new CustomEvent(eventName), data?: T): void {\n\t\tthis.validateEventName(eventName);\n\t\tthis.subscribers.get(eventName)?.forEach((contextEventHandler: ContextEventHandler) => {\n\t\t\ttry {\n\t\t\t\tcontextEventHandler.handle(event, data);\n\t\t\t} catch (error) {\n\t\t\t\tif (this.errorHandler) {\n\t\t\t\t\tthis.errorHandler(error as Error, eventName, event, data);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`Error in event handler for '${eventName}':`, error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if the event and handler are subscribed.\n\t *\n\t * @param subscription The subscription object.\n\t * @returns true if the event name and handler are subscribed, false otherwise.\n\t */\n\tisSubscribed({ eventName, contextEventHandler }: Subscription): boolean {\n\t\treturn this.subscribers.get(eventName)?.has(contextEventHandler) ?? false;\n\t}\n\n\t/**\n\t * Validate the event name\n\t *\n\t * @param eventName The event name to validate.\n\t * @throws {TypeError} If the event name is not a non-empty string.\n\t * @throws {Error} If the event name has leading or trailing whitespace.\n\t */\n\tprivate validateEventName(eventName: string): void {\n\t\tif (!eventName || typeof eventName !== 'string') {\n\t\t\tthrow new TypeError('Event name must be a non-empty string');\n\t\t}\n\n\t\tif (eventName.trim() !== eventName) {\n\t\t\tthrow new Error('Event name cannot have leading or trailing whitespace');\n\t\t}\n\t}\n\n\t/**\n\t * Clears all subscriptions. The instance should not be used after calling this method.\n\t */\n\tdestroy(): void {\n\t\tthis.subscribers.clear();\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Subscribr';\n\t}\n}", "import type { ResponseStatus } from '@src/response-status';\nimport type { ResponseBody, RequestTiming, HttpErrorOptions } from '@src/@types/core';\n\n/**\n * An error that represents an HTTP error response.\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nclass HttpError extends Error {\n\tprivate readonly _entity: ResponseBody;\n\tprivate readonly responseStatus: ResponseStatus;\n\tprivate readonly _url: URL | undefined;\n\tprivate readonly _method: string | undefined;\n\tprivate readonly _timing: RequestTiming | undefined;\n\n\t/**\n\t * Creates an instance of HttpError.\n\t * @param status The status code and status text of the {@link Response}.\n\t * @param httpErrorOptions The http error options.\n\t */\n\tconstructor(status: ResponseStatus, { message, cause, entity, url, method, timing }: HttpErrorOptions = {}) {\n\t\tsuper(message, { cause });\n\t\tthis._entity = entity;\n\t\tthis.responseStatus = status;\n\t\tthis._url = url;\n\t\tthis._method = method;\n\t\tthis._timing = timing;\n\t}\n\n\t/**\n\t * It returns the value of the private variable #entity.\n\t * @returns The entity property of the class.\n\t */\n\tget entity(): ResponseBody {\n\t\treturn this._entity;\n\t}\n\n\t/**\n\t * It returns the status code of the {@link Response}.\n\t * @returns The status code of the {@link Response}.\n\t */\n\tget statusCode(): number {\n\t\treturn this.responseStatus.code;\n\t}\n\n\t/**\n\t * It returns the status text of the {@link Response}.\n\t * @returns The status code and status text of the {@link Response}.\n\t */\n\tget statusText(): string {\n\t\treturn this.responseStatus?.text;\n\t}\n\n\t/**\n\t * The request URL that caused the error.\n\t * @returns The URL or undefined.\n\t */\n\tget url(): URL | undefined {\n\t\treturn this._url;\n\t}\n\n\t/**\n\t * The HTTP method that was used for the failed request.\n\t * @returns The method string or undefined.\n\t */\n\tget method(): string | undefined {\n\t\treturn this._method;\n\t}\n\n\t/**\n\t * Timing information for the failed request.\n\t * @returns The timing object or undefined.\n\t */\n\tget timing(): RequestTiming | undefined {\n\t\treturn this._timing;\n\t}\n\n\t/**\n\t * A String value representing the name of the error.\n\t * @returns The name of the error.\n\t */\n\toverride get name(): string {\n\t\treturn 'HttpError';\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn this.name;\n\t}\n}\n\nexport { HttpError };", "/**\n * A class that holds a status code and a status text, typically from a {@link Response}\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status|Response.status\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class ResponseStatus {\n\tprivate readonly _code: number;\n\tprivate readonly _text: string;\n\n\t/**\n\t *\n\t * @param code The status code from the {@link Response}\n\t * @param text The status text from the {@link Response}\n\t */\n\tconstructor(code: number, text: string) {\n\t\tthis._code = code;\n\t\tthis._text = text;\n\t}\n\n\t/**\n\t * Returns the status code from the {@link Response}\n\t *\n\t * @returns The status code.\n\t */\n\tget code(): number {\n\t\treturn this._code;\n\t}\n\n\t/**\n\t * Returns the status text from the {@link Response}.\n\t *\n\t * @returns The status text.\n\t */\n\tget text(): string {\n\t\treturn this._text;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'ResponseStatus';\n\t}\n\n\t/**\n\t * tostring method for the class.\n\t *\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString|Object.prototype.toString}\n\t * @returns The status code and status text.\n\t */\n\ttoString(): string {\n\t\treturn `${this._code} ${this._text}`;\n\t}\n}", "import { MediaType } from '@d1g1tal/media-type';\nimport { ResponseStatus } from './response-status';\nimport type { AbortEvent, TimeoutEvent, RequestMethod } from '@types';\n\nconst charset = { charset: 'utf-8' };\nconst endsWithSlashRegEx: RegExp = /\\/$/;\n/** Default XSRF cookie name */\nconst XSRF_COOKIE_NAME = 'XSRF-TOKEN';\n/** Default XSRF header name */\nconst XSRF_HEADER_NAME = 'X-XSRF-TOKEN';\n\ntype MediaTypeKey = 'PNG' | 'TEXT' | 'JSON' | 'HTML' | 'JAVA_SCRIPT' | 'CSS' | 'XML' | 'BIN' | 'EVENT_STREAM' | 'NDJSON';\n\nconst mediaTypes: { [key in MediaTypeKey]: MediaType } = {\n\tPNG: new MediaType('image/png'),\n\tTEXT: new MediaType('text/plain', charset),\n\tJSON: new MediaType('application/json', charset),\n\tHTML: new MediaType('text/html', charset),\n\tJAVA_SCRIPT: new MediaType('text/javascript', charset),\n\tCSS: new MediaType('text/css', charset),\n\tXML: new MediaType('application/xml', charset),\n\tBIN: new MediaType('application/octet-stream'),\n\tEVENT_STREAM: new MediaType('text/event-stream', charset),\n\tNDJSON: new MediaType('application/x-ndjson', charset)\n} as const;\n\nconst defaultMediaType: string = mediaTypes.JSON.toString();\nconst defaultOrigin: string = globalThis.location?.origin ?? 'http://localhost';\n\n/** Constant object for caching policies */\nconst RequestCachingPolicy = {\n\tDEFAULT: 'default',\n\tFORCE_CACHE: 'force-cache',\n\tNO_CACHE: 'no-cache',\n\tNO_STORE: 'no-store',\n\tONLY_IF_CACHED: 'only-if-cached',\n\tRELOAD: 'reload'\n} as const;\n\n/** Constant object for request events */\nexport const RequestEvent = {\n\tCONFIGURED: 'configured',\n\tSUCCESS: 'success',\n\tERROR: 'error',\n\tABORTED: 'aborted',\n\tTIMEOUT: 'timeout',\n\tRETRY: 'retry',\n\tCOMPLETE: 'complete',\n\tALL_COMPLETE: 'all-complete'\n} as const;\n\n/** Constant object for signal events */\nconst SignalEvents = {\n\tABORT: 'abort',\n\tTIMEOUT: 'timeout'\n} as const;\n\n/** Constant object for signal errors */\nconst SignalErrors = {\n\tABORT: 'AbortError',\n\tTIMEOUT: 'TimeoutError'\n} as const;\n\n/** Options for adding event listeners */\nconst eventListenerOptions: AddEventListenerOptions = { once: true, passive: true };\n\n/**\n * Creates a new custom abort event.\n * @returns A new AbortEvent instance.\n */\nconst abortEvent = (): AbortEvent => new CustomEvent(SignalEvents.ABORT, { detail: { cause: SignalErrors.ABORT } });\n\n/**\n * Creates a new custom timeout event.\n * @returns A new TimeoutEvent instance.\n */\nconst timeoutEvent = (): TimeoutEvent => new CustomEvent(SignalEvents.TIMEOUT, { detail: { cause: SignalErrors.TIMEOUT } });\n\n/** Array of request body methods */\nconst requestBodyMethods: ReadonlyArray<RequestMethod> = [ 'POST', 'PUT', 'PATCH', 'DELETE' ];\n\n/** Response status for internal server error */\nconst internalServerError: ResponseStatus = new ResponseStatus(500, 'Internal Server Error');\n\n/** Response status for aborted request */\nconst aborted: ResponseStatus = new ResponseStatus(499, 'Aborted');\n\n/** Response status for timed out request */\nconst timedOut: ResponseStatus = new ResponseStatus(504, 'Request Timeout');\n\n/** Default HTTP status codes that trigger a retry */\nconst retryStatusCodes: Array<number> = [ 408, 413, 429, 500, 502, 503, 504 ];\n\n/** Default HTTP methods allowed to retry (idempotent methods only) */\nconst retryMethods: Array<RequestMethod> = [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS' ];\n\n/** Default delay in ms before the first retry */\nconst retryDelay: number = 300;\n\n/** Default backoff factor applied after each retry attempt */\nconst retryBackoffFactor: number = 2;\n\nexport { aborted, abortEvent, endsWithSlashRegEx, eventListenerOptions, internalServerError, mediaTypes, defaultMediaType, defaultOrigin, requestBodyMethods, RequestCachingPolicy, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, SignalErrors, SignalEvents, timedOut, timeoutEvent, XSRF_COOKIE_NAME, XSRF_HEADER_NAME };\nexport type RequestEvent = (typeof RequestEvent)[keyof typeof RequestEvent];\n", "import { SignalErrors, SignalEvents, abortEvent, eventListenerOptions, timeoutEvent } from './constants.js';\nimport type { AbortConfiguration, AbortEvent, AbortSignalEvent } from '@types';\n\n/** Class representing a controller for abort signals, allowing for aborting requests and handling timeout events */\nexport class SignalController {\n\tprivate readonly abortSignal: AbortSignal;\n\tprivate readonly abortController = new AbortController();\n\tprivate readonly events = new Map<EventListener, string>();\n\n\t/**\n\t * Creates a new SignalController instance.\n\t * @param options - The options for the SignalController.\n\t * @param options.signal - The signal to listen for abort events. Defaults to the internal abort signal.\n\t * @param options.timeout - The timeout value in milliseconds. Defaults to Infinity.\n\t * @throws {RangeError} If the timeout value is negative.\n\t */\n\tconstructor({ signal, timeout = Infinity }: AbortConfiguration = {}) {\n\t\tif (timeout < 0) { throw new RangeError('The timeout cannot be negative') }\n\n\t\tconst signals = [ this.abortController.signal ];\n\t\tif (signal != null) { signals.push(signal) }\n\t\tif (timeout !== Infinity) { signals.push(AbortSignal.timeout(timeout)) }\n\n\t\t(this.abortSignal = AbortSignal.any(signals)).addEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\t}\n\n\t/**\n\t * Handles the 'abort' event. If the event is caused by a timeout, the 'timeout' event is dispatched.\n\t * Guards against a timeout firing after a manual abort to prevent spurious timeout events.\n\t * @param event The event to abort with\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#specifying_this_using_bind\n\t */\n\thandleEvent({ target: { reason } }: AbortSignalEvent): void {\n\t\tif (this.abortController.signal.aborted) { return }\n\t\tif (reason instanceof DOMException && reason.name === SignalErrors.TIMEOUT) { this.abortSignal.dispatchEvent(timeoutEvent()) }\n\t}\n\n\t/**\n\t * 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.\n\t * @returns The signal\n\t */\n\tget signal(): AbortSignal {\n\t\treturn this.abortSignal;\n\t}\n\n\t/**\n\t * Adds an event listener for the 'abort' event.\n\t *\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tonAbort(eventListener: EventListener): SignalController {\n\t\treturn this.addEventListener(SignalEvents.ABORT, eventListener);\n\t}\n\n\t/**\n\t * Adds an event listener for the 'timeout' event.\n\t *\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tonTimeout(eventListener: EventListener): SignalController {\n\t\treturn this.addEventListener(SignalEvents.TIMEOUT, eventListener);\n\t}\n\n\t/**\n\t * Aborts the signal.\n\t *\n\t * @param event The event to abort with\n\t */\n\tabort(event: AbortEvent = abortEvent()): void {\n\t\tthis.abortController.abort(event.detail?.cause);\n\t}\n\n\t/**\n\t * Removes all event listeners from the signal.\n\t *\n\t * @returns The SignalController\n\t */\n\tdestroy(): SignalController {\n\t\tthis.abortSignal.removeEventListener(SignalEvents.ABORT, this, eventListenerOptions);\n\n\t\tfor (const [ eventListener, type ] of this.events) {\n\t\t\tthis.abortSignal.removeEventListener(type, eventListener, eventListenerOptions);\n\t\t}\n\n\t\tthis.events.clear();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an event listener for the specified event type.\n\t *\n\t * @param type The event type to listen for\n\t * @param eventListener The listener to add\n\t * @returns The SignalController\n\t */\n\tprivate addEventListener(type: string, eventListener: EventListener): SignalController {\n\t\tthis.abortSignal.addEventListener(type, eventListener, eventListenerOptions);\n\t\tthis.events.set(eventListener, type);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A String value that is used in the creation of the default string\n\t * description of an object. Called by the built-in method {@link Object.prototype.toString}.\n\t *\n\t * @returns The default string description of this object.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'SignalController';\n\t}\n}", "import type { DOMPurify } from 'dompurify';\nimport type { Json, ResponseHandler, ServerSentEvent } from '@types';\n\n/** Cached promise for lazy DOM + DOMPurify initialization \u2014 resolved once, reused thereafter */\nlet domReady: Promise<void> | undefined;\n/** DOMPurify instance \u2014 set once domReady resolves */\nlet purify: DOMPurify | undefined;\n\n/**\n * Ensures a DOM environment is available (document, DOMParser, DocumentFragment) and\n * initializes DOMPurify. In browser environments the DOM is already present so only\n * DOMPurify is imported. In Node.js jsdom is lazily set up first.\n * @returns A Promise that resolves when the DOM environment and DOMPurify are ready.\n */\nconst ensureDom = (): Promise<void> => {\n\tif (domReady) { return domReady }\n\n\tconst domSetup: Promise<void> = typeof document === 'undefined' || typeof DOMParser === 'undefined' || typeof DocumentFragment === 'undefined' ?\n\t\timport('jsdom').then(({ JSDOM }) => {\n\t\t\tconst { window } = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', { url: 'http://localhost' });\n\n\t\t\tglobalThis.window = window as unknown as Window & typeof globalThis;\n\n\t\t\tObject.assign(globalThis, { document: window.document, DOMParser: window.DOMParser, DocumentFragment: window.DocumentFragment });\n\t\t}).catch(() => {\n\t\t\tdomReady = undefined;\n\t\t\tthrow new Error('jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom');\n\t\t}) : Promise.resolve();\n\n\treturn domReady = domSetup.then(() => import('dompurify')).then(({ default: p }) => { purify = p });\n};\n\n/**\n * Sanitizes the response text and parses it as a DOM Document using DOMParser.\n * @param response The response to parse.\n * @param mimeType The MIME type to use when parsing the document.\n * @returns A Promise that resolves to a parsed Document.\n */\nconst parseSanitizedDocument = async (response: Response, mimeType: DOMParserSupportedType): Promise<Document> => {\n\tawait ensureDom();\n\n\treturn new DOMParser().parseFromString(purify!.sanitize(await response.text()), mimeType);\n};\n\n/**\n * Creates an object URL from the response blob, constructs a Promise with the given executor,\n * and ensures the URL is revoked after the promise settles.\n * @param response The response to create the object URL from.\n * @param executor A function receiving the object URL, resolve, and reject callbacks.\n * @returns A Promise that resolves to the value produced by the executor.\n */\nconst withObjectURL = async <T>(response: Response, executor: (objectURL: string, resolve: (value: T) => void, reject: (reason?: unknown) => void) => void): Promise<T> => {\n\tawait ensureDom();\n\n\tconst objectURL = URL.createObjectURL(await response.blob());\n\ttry {\n\t\treturn new Promise<T>((res, rej) => executor(objectURL, res, rej));\n\t} finally {\n\t\tURL.revokeObjectURL(objectURL);\n\t}\n};\n\n/**\n * Handles a text response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a string\n */\nconst handleText: ResponseHandler<string> = async (response) => await response.text();\n\n/**\n * Handles a script response by appending it to the Document HTMLHeadElement\n * Only available in browser environments with DOM support.\n *\n * **Security Warning:** This handler executes arbitrary JavaScript from the server response.\n * Only use with fully trusted content sources. No sanitization is applied to script content.\n * Consider using a Content Security Policy (CSP) nonce for additional protection.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to void\n */\nconst handleScript: ResponseHandler<void> = (response) => {\n\treturn withObjectURL(response, (objectURL, resolve, reject) => {\n\t\tconst script = document.createElement('script');\n\t\tObject.assign(script, { src: objectURL, type: 'text/javascript', async: true });\n\n\t\t/** Resolve the promise once the script has loaded. */\n\t\tscript.onload = () => {\n\t\t\tdocument.head.removeChild(script);\n\t\t\tresolve();\n\t\t};\n\n\t\t/** Reject the promise if the script fails to load. */\n\t\tscript.onerror = () => {\n\t\t\tdocument.head.removeChild(script);\n\t\t\treject(new Error('Script failed to load'));\n\t\t};\n\n\t\tdocument.head.appendChild(script);\n\t});\n};\n\n/**\n * Handles a CSS response by appending it to the Document HTMLHeadElement.\n * Only available in browser environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to void\n */\nconst handleCss: ResponseHandler<void> = (response) => {\n\treturn withObjectURL(response, (objectURL, resolve, reject) => {\n\t\tconst link = document.createElement('link');\n\t\tObject.assign(link, { href: objectURL, type: 'text/css', rel: 'stylesheet' });\n\n\t\tlink.onload = () => resolve();\n\n\t\t/** Remove the link element and reject the promise if the stylesheet fails to load. */\n\t\tlink.onerror = () => {\n\t\t\tdocument.head.removeChild(link);\n\t\t\treject(new Error('Stylesheet load failed'));\n\t\t};\n\n\t\tdocument.head.appendChild(link);\n\t});\n};\n\n/**\n * Handles a JSON response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a JsonObject\n */\nconst handleJson: ResponseHandler<Json> = async (response) => await response.json() as Json;\n\n/**\n * Handles a Blob response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Blob\n */\nconst handleBlob: ResponseHandler<Blob> = async (response) => await response.blob();\n\n/**\n * Handles an image response by creating an object URL and returning an HTMLImageElement.\n * The object URL is revoked once the image is loaded to prevent memory leaks.\n * Works in both browser and Node.js (via JSDOM) environments.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to an HTMLImageElement\n */\nconst handleImage: ResponseHandler<HTMLImageElement> = (response) => withObjectURL(response, (objectURL, resolve, reject) => {\n\tconst img = new Image();\n\n\timg.onload = () => resolve(img);\n\timg.onerror = () => reject(new Error('Image failed to load'));\n\n\timg.src = objectURL;\n});\n\n/**\n * Handles a buffer response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to an ArrayBuffer\n */\nconst handleBuffer: ResponseHandler<ArrayBuffer> = async (response) => await response.arrayBuffer();\n\n/**\n * Handles a ReadableStream response.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a ReadableStream\n */\nconst handleReadableStream: ResponseHandler<ReadableStream<Uint8Array> | null> = async (response) => Promise.resolve(response.body);\n\n/**\n * Handles an XML response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Document\n */\nconst handleXml: ResponseHandler<Document> = async (response) => parseSanitizedDocument(response, 'application/xml');\n\n/**\n * Handles an HTML response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a Document\n */\nconst handleHtml: ResponseHandler<Document> = async (response) => parseSanitizedDocument(response, 'text/html');\n\n/**\n * Handles an HTML fragment response.\n * Only available in environments with DOM support.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a DocumentFragment\n */\nconst handleHtmlFragment: ResponseHandler<DocumentFragment> = async (response) => {\n\tawait ensureDom();\n\n\treturn document.createRange().createContextualFragment(purify!.sanitize(await response.text()));\n};\n\n/**\n * Handles an HTML fragment response without sanitization.\n * Only available in environments with DOM support.\n *\n * **Security Warning:** DOMPurify is bypassed entirely. Scripts, inline event handlers,\n * and all other content are preserved as-is. Only use with fully trusted same-origin content.\n * @param response The response object from the fetch request.\n * @returns A Promise that resolves to a DocumentFragment\n */\nconst handleHtmlFragmentWithScripts: ResponseHandler<DocumentFragment> = async (response) => {\n\tawait ensureDom();\n\n\treturn document.createRange().createContextualFragment(await response.text());\n};\n\n/**\n * Reads delimited segments from a ReadableStream, yielding each segment as a string.\n * Handles buffering, decoding, and automatic reader cancellation on early exit or error.\n * @param body The ReadableStream to read from.\n * @param delimiter The delimiter string that separates segments.\n * @param flushRemaining Whether to yield remaining buffered content when the stream ends.\n * @yields {string} Each delimited segment as a raw string.\n */\nasync function* readDelimited(body: ReadableStream<Uint8Array>, delimiter: string, flushRemaining: boolean): AsyncGenerator<string> {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffer = '';\n\n\ttry {\n\t\tfor (;;) {\n\t\t\tlet index: number;\n\t\t\twhile ((index = buffer.indexOf(delimiter)) !== -1) {\n\t\t\t\tyield buffer.slice(0, index);\n\t\t\t\tbuffer = buffer.slice(index + delimiter.length);\n\t\t\t}\n\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) { break }\n\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t}\n\n\t\tif (flushRemaining) {\n\t\t\tconst remaining = (buffer + decoder.decode()).trim();\n\t\t\tif (remaining) { yield remaining }\n\t\t}\n\t} finally {\n\t\tawait reader.cancel();\n\t}\n}\n\n/**\n * Parses a raw SSE event block into a ServerSentEvent object.\n * Follows the EventStream specification for field parsing (event, data, id, retry).\n * @param rawEvent The raw event text (lines separated by \\n, without the trailing \\n\\n delimiter).\n * @returns A parsed ServerSentEvent, or undefined for empty dispatch events.\n */\nconst parseServerSentEvent = (rawEvent: string): ServerSentEvent | undefined => {\n\tlet event = 'message';\n\tlet id = '';\n\tlet retry: number | undefined;\n\tconst dataLines: string[] = [];\n\n\tconst lines = rawEvent.split('\\n');\n\tfor (let i = 0, length = lines.length; i < length; i++) {\n\t\tconst line = lines[i]!;\n\t\t// comment line\n\t\tif (line.charCodeAt(0) === 58) { continue }\n\n\t\tconst colonIndex = line.indexOf(':');\n\t\tlet field: string;\n\t\tlet value: string;\n\t\tif (colonIndex === -1) {\n\t\t\tfield = line;\n\t\t\tvalue = '';\n\t\t} else {\n\t\t\tfield = line.slice(0, colonIndex);\n\t\t\t// strip single leading space after colon per spec\n\t\t\tvalue = line.charCodeAt(colonIndex + 1) === 32\t? line.slice(colonIndex + 2)\t: line.slice(colonIndex + 1);\n\t\t}\n\n\t\tswitch (field) {\n\t\t\tcase 'event': event = value; break;\n\t\t\tcase 'data': dataLines.push(value); break;\n\t\t\tcase 'id': id = value; break;\n\t\t\tcase 'retry': {\n\t\t\t\tconst n = parseInt(value, 10);\n\t\t\t\tif (!isNaN(n)) { retry = n }\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (dataLines.length > 0 || event !== 'message') ? { event, data: dataLines.join('\\n'), id, retry } : undefined;\n};\n\n/**\n * Parses a text/event-stream response into an AsyncIterable of ServerSentEvent objects.\n * Follows the EventStream specification for field parsing (event, data, id, retry).\n * The returned iterable respects abort signals \u2014 iteration ends when the stream closes or is aborted.\n * @param response The response object from the fetch request.\n * @returns An AsyncIterable of parsed ServerSentEvent objects.\n */\nconst handleEventStream = (response: Response): AsyncIterable<ServerSentEvent> => ({\n\t/** @yields {ServerSentEvent} Parsed ServerSentEvent objects from the stream. */\n\tasync *[Symbol.asyncIterator]() {\n\t\tfor await (const rawEvent of readDelimited(response.body!, '\\n\\n', false)) {\n\t\t\tif (!rawEvent) { continue }\n\t\t\tconst sse = parseServerSentEvent(rawEvent);\n\t\t\tif (sse) { yield sse }\n\t\t}\n\t}\n});\n\n/**\n * Parses an NDJSON (Newline Delimited JSON) response into an AsyncIterable of typed JSON values.\n * Each line of the response is parsed as an independent JSON object.\n * The returned iterable respects abort signals \u2014 iteration ends when the stream closes or is aborted.\n * @param response The response object from the fetch request.\n * @returns An AsyncIterable of parsed JSON values.\n */\nconst handleNdjsonStream = <T = Json>(response: Response): AsyncIterable<T> => ({\n\t/** @yields {T} Parsed JSON values from the NDJSON stream. */\n\tasync *[Symbol.asyncIterator]() {\n\t\tfor await (const line of readDelimited(response.body!, '\\n', true)) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (trimmed) { yield JSON.parse(trimmed) as T }\n\t\t}\n\t}\n});\n\nexport {\n\thandleText,\n\thandleScript,\n\thandleCss,\n\thandleJson,\n\thandleBlob,\n\thandleImage,\n\thandleBuffer,\n\thandleReadableStream,\n\thandleXml,\n\thandleHtml,\n\thandleHtmlFragment,\n\thandleHtmlFragmentWithScripts,\n\thandleEventStream,\n\thandleNdjsonStream\n};\n", "import { requestBodyMethods } from './constants';\nimport type { JsonString, JsonValue, RequestBodyMethod, RequestMethod } from '@types';\n\n/**\n * Type guard to check if a request method accepts a body.\n * @param method The request method to check.\n * @returns True if the method accepts a body, false otherwise.\n */\nexport const isRequestBodyMethod = (method: RequestMethod | undefined): method is RequestBodyMethod =>\n\tmethod !== undefined && requestBodyMethods.includes(method);\n\n/**\n * Checks whether a body value is a raw BodyInit type that should be sent as-is\n * (no JSON serialization) and should have its Content-Type deleted so the runtime\n * can set it automatically (e.g. multipart/form-data boundary for FormData).\n * @param body The request body to check.\n * @returns True if the body is a FormData, Blob, ArrayBuffer, TypedArray, DataView, ReadableStream, or URLSearchParams.\n */\nexport const isRawBody = (body: unknown): body is Exclude<BodyInit, string> =>\n\tbody instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof ReadableStream || body instanceof URLSearchParams || ArrayBuffer.isView(body);\n\n/**\n * Reads a cookie value by name from document.cookie.\n * Returns undefined in non-browser environments or when the cookie is not found.\n * @param name The cookie name to look up.\n * @returns The cookie value or undefined.\n */\nexport const getCookieValue = (name: string): string | undefined => {\n\tif (typeof document === 'undefined' || !document.cookie) { return }\n\n\tconst prefix = `${name}=`;\n\tconst cookies = document.cookie.split(';');\n\tfor (let i = 0, length = cookies.length; i < length; i++) {\n\t\tconst cookie = cookies[i]!.trim();\n\t\tif (cookie.startsWith(prefix)) { return decodeURIComponent(cookie.slice(prefix.length)) }\n\t}\n\n\treturn undefined;\n};\n\n/**\n * Serialize an object of type T into a JSON string.\n * The type system ensures only JSON-serializable values can be passed.\n * @template T The type of data to serialize (will be validated for JSON compatibility)\n * @param data The object to serialize - must be JSON-serializable.\n * @returns The serialized JSON string.\n */\nexport const serialize = <const T>(data: JsonValue<T>): JsonString<T> => JSON.stringify(data) as JsonString<T>;\n\n/**\n * Type predicate to check if a value is a string\n * @param value The value to check\n * @returns True if value is a string, with type narrowing\n */\nexport const isString = (value: unknown): value is string => value !== null && typeof value === 'string';\n\n/**\n * Type predicate to check if a value is an ArrayBuffer (cross-realm safe).\n * @param value The value to check.\n * @returns True if value is an ArrayBuffer, with type narrowing.\n */\nexport const isArrayBuffer = (value: unknown): value is ArrayBuffer =>\n\tvalue instanceof ArrayBuffer || Object.prototype.toString.call(value) === '[object ArrayBuffer]';\n\n/**\n * Type predicate to check if a value is an object (not array or null)\n * @param value The value to check\n * @returns True if value is an object, with type narrowing\n */\nexport const isObject = <T = object>(value: unknown): value is T extends object ? T : never => value !== null && typeof value === 'object' && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;\n\n/**\n * Performs a deep merge of multiple objects\n * @param objects The objects to merge\n * @returns The merged object\n */\nexport const objectMerge = (...objects: Record<string, unknown>[]): Record<string, unknown> | undefined => {\n\t// Early return for empty input\n\tconst length = objects.length;\n\tif (length === 0) { return undefined }\n\n\t// Early return for single object - just clone it\n\tif (length === 1) {\n\t\tconst [ obj ] = objects;\n\t\tif (!isObject(obj)) { return obj }\n\t\treturn deepClone(obj);\n\t}\n\n\tconst target = {} as Record<string, unknown>;\n\n\tfor (const source of objects) {\n\t\tif (!isObject(source)) { return undefined }\n\n\t\tfor (const [property, sourceValue] of Object.entries(source)) {\n\t\t\tconst targetValue = target[property];\n\t\t\tif (Array.isArray(sourceValue)) {\n\t\t\t\t// Handle arrays - source values come first, then unique target values\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\ttarget[property] = [ ...sourceValue, ...(Array.isArray(targetValue) ? targetValue.filter((item) => !sourceValue.includes(item)) : []) ];\n\t\t\t} else if (isObject<Record<string, unknown>>(sourceValue)) {\n\t\t\t\t// Handle plain objects using the isObject function | I am already testing that the targetValue is an object\n\t\t\t\ttarget[property] = isObject<Record<string, unknown>>(targetValue) ? objectMerge(targetValue, sourceValue)! : deepClone(sourceValue);\n\t\t\t} else {\n\t\t\t\t// Primitive values and null/undefined\n\t\t\t\ttarget[property] = sourceValue;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn target;\n};\n\n/**\n * Creates a deep clone of an object for better performance than spread operator in merge scenarios\n * @param object The object to clone\n * @returns The cloned object\n */\nfunction deepClone<T = Record<PropertyKey, unknown>>(object: T): T {\n\tif (isObject<Record<PropertyKey, unknown>>(object)) {\n\t\tconst cloned: Record<PropertyKey, unknown> = {};\n\t\tconst keys = Object.keys(object);\n\t\tfor (let i = 0, length = keys.length, key; i < length; i++) {\n\t\t\tkey = keys[i]!;\n\t\t\tcloned[key] = deepClone(object[key]);\n\t\t}\n\n\t\treturn cloned as T;\n\t}\n\n\t// For other object types (Date, RegExp, etc.), return as-is\n\treturn object;\n}\n", "import { MediaType } from '@d1g1tal/media-type';\nimport { Subscribr } from '@d1g1tal/subscribr';\nimport { HttpError } from './http-error';\nimport { ResponseStatus } from './response-status';\nimport { SignalController } from './signal-controller.js';\nimport { handleText, handleScript, handleCss, handleJson, handleBlob, handleImage, handleBuffer, handleReadableStream, handleXml, handleHtml, handleHtmlFragment, handleHtmlFragmentWithScripts, handleEventStream, handleNdjsonStream } from './response-handlers';\nimport { isRequestBodyMethod, isRawBody, getCookieValue, isString, isArrayBuffer, isObject, objectMerge, serialize } from './utils';\nimport { RequestCachingPolicy, RequestEvent, SignalErrors, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, defaultOrigin, endsWithSlashRegEx, internalServerError, mediaTypes, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut } from './constants';\nimport type {\tRequestBody, RequestBodyMethod, RequestOptions, ResponseBody, RequestEventHandler, SearchParameters, EventRegistration, ResponseHandler, RequestHeaders, TypedResponse, Json, Entries, HookOptions, HttpErrorOptions, NormalizedRetryOptions, PublishOptions, RetryOptions, RequestTiming, XsrfOptions, ServerSentEvent, RequestEventDataMap, TypedRequestEventHandler, Result } from '@types';\n\ndeclare function fetch<R = unknown>(input: RequestInfo | URL, requestOptions?: RequestOptions): Promise<TypedResponse<R>>;\n\ntype RequestConfiguration = {\n\tsignalController: NonNullable<SignalController>,\n\trequestOptions: RequestOptions,\n\tglobal: boolean\n};\n\n/**\n * A wrapper around the fetch API that makes it easier to make HTTP requests.\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class Transportr {\n\tprivate readonly _baseUrl: URL;\n\tprivate readonly _options: RequestOptions;\n\tprivate readonly subscribr: Subscribr;\n\tprivate readonly hooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\tprivate static globalSubscribr = new Subscribr();\n\tprivate static globalHooks: Required<HookOptions> = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\tprivate static signalControllers = new Set<SignalController>();\n\t/** Map of in-flight deduplicated requests keyed by URL + method */\n\tprivate static inflightRequests = new Map<string, Promise<Response>>();\n\t/** Cached config for the common \"no retry\" case (retry === undefined) */\n\tprivate static readonly noRetryConfig: NormalizedRetryOptions = { limit: 0, statusCodes: [], methods: [], delay: retryDelay, backoffFactor: retryBackoffFactor };\n\t/** Cache for parsed MediaType instances to avoid re-parsing the same content-type strings */\n\tprivate static mediaTypeCache = new Map(Object.values(mediaTypes).map((mediaType) => [ mediaType.toString(), mediaType ]));\n\tprivate static contentTypeHandlers: Entries<string, ResponseHandler<ResponseBody>> = [\n\t\t[ mediaTypes.TEXT.type, handleText ],\n\t\t[ mediaTypes.JSON.subtype, handleJson ],\n\t\t[ mediaTypes.BIN.subtype, handleReadableStream ],\n\t\t[ mediaTypes.HTML.subtype, handleHtml ],\n\t\t[ mediaTypes.XML.subtype, handleXml ],\n\t\t[ mediaTypes.PNG.type, handleImage as ResponseHandler<ResponseBody> ],\n\t\t[ mediaTypes.JAVA_SCRIPT.subtype, handleScript as ResponseHandler<ResponseBody> ],\n\t\t[ mediaTypes.CSS.subtype, handleCss as ResponseHandler<ResponseBody> ]\n\t];\n\n\t/**\n\t * Create a new Transportr instance with the provided location or origin and context path.\n\t *\n\t * @param url The URL for {@link fetch} requests.\n\t * @param options The default {@link RequestOptions} for this instance.\n\t */\n\tconstructor(url: URL | string | RequestOptions = defaultOrigin, options: RequestOptions = {}) {\n\t\tif (isObject(url)) { [ url, options ] = [ defaultOrigin, url ] }\n\n\t\tthis._baseUrl = Transportr.getBaseUrl(url);\n\t\tthis._options = Transportr.createOptions(options, Transportr.defaultRequestOptions);\n\t\tthis.subscribr = new Subscribr();\n\t}\n\n\t/** Credentials Policy */\n\tstatic readonly CredentialsPolicy = {\n\t\tINCLUDE: 'include',\n\t\tOMIT: 'omit',\n\t\tSAME_ORIGIN: 'same-origin'\n\t} as const;\n\n\t/** Request Mode */\n\tstatic readonly RequestMode = {\n\t\tCORS: 'cors',\n\t\tNAVIGATE: 'navigate',\n\t\tNO_CORS: 'no-cors',\n\t\tSAME_ORIGIN: 'same-origin'\n\t} as const;\n\n\t/** Request Priority */\n\tstatic readonly RequestPriority = {\n\t\tHIGH: 'high',\n\t\tLOW: 'low',\n\t\tAUTO: 'auto'\n\t} as const;\n\n\t/** Redirect Policy */\n\tstatic readonly RedirectPolicy = {\n\t\tERROR: 'error',\n\t\tFOLLOW: 'follow',\n\t\tMANUAL: 'manual'\n\t} as const;\n\n\t/** Referrer Policy */\n\tstatic readonly ReferrerPolicy = {\n\t\tNO_REFERRER: 'no-referrer',\n\t\tNO_REFERRER_WHEN_DOWNGRADE: 'no-referrer-when-downgrade',\n\t\tORIGIN: 'origin',\n\t\tORIGIN_WHEN_CROSS_ORIGIN: 'origin-when-cross-origin',\n\t\tSAME_ORIGIN: 'same-origin',\n\t\tSTRICT_ORIGIN: 'strict-origin',\n\t\tSTRICT_ORIGIN_WHEN_CROSS_ORIGIN: 'strict-origin-when-cross-origin',\n\t\tUNSAFE_URL: 'unsafe-url'\n\t} as const;\n\n\t/** Request Event */\n\tstatic readonly RequestEvent: typeof RequestEvent = RequestEvent;\n\n\t/** Default Request Options */\n\tprivate static readonly defaultRequestOptions: RequestOptions = {\n\t\tbody: undefined,\n\t\tcache: RequestCachingPolicy.NO_STORE,\n\t\tcredentials: Transportr.CredentialsPolicy.SAME_ORIGIN,\n\t\theaders: new Headers({ 'content-type': defaultMediaType, 'accept': defaultMediaType }),\n\t\tsearchParams: undefined,\n\t\tintegrity: undefined,\n\t\tkeepalive: undefined,\n\t\tmethod: 'GET',\n\t\tmode: Transportr.RequestMode.CORS,\n\t\tpriority: Transportr.RequestPriority.AUTO,\n\t\tredirect: Transportr.RedirectPolicy.FOLLOW,\n\t\treferrer: 'about:client',\n\t\treferrerPolicy: Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,\n\t\tsignal: undefined,\n\t\ttimeout: 30000,\n\t\tglobal: true\n\t};\n\n\t/**\n\t * Returns a {@link EventRegistration} used for subscribing to global events with typed data.\n\t *\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler with typed data parameter.\n\t * @param context The context to bind the handler to.\n\t * @returns A new {@link EventRegistration} instance.\n\t */\n\tstatic register<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;\n\n\t/**\n\t * @internal\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler.\n\t * @param context The context to bind the handler to.\n\t * @returns A new {@link EventRegistration} instance.\n\t */\n\tstatic register(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\treturn Transportr.globalSubscribr.subscribe(event, handler, context);\n\t}\n\n\t/**\n\t * Removes a {@link EventRegistration} from the global event handler.\n\t *\n\t * @param eventRegistration The {@link EventRegistration} to remove.\n\t * @returns True if the {@link EventRegistration} was removed, false otherwise.\n\t */\n\tstatic unregister(eventRegistration: EventRegistration): boolean {\n\t\treturn Transportr.globalSubscribr.unsubscribe(eventRegistration);\n\t}\n\n\t/**\n\t * Aborts all active requests.\n\t * This is useful for when the user navigates away from the current page.\n\t * This will also clear the {@link Transportr#signalControllers} set.\n\t */\n\tstatic abortAll(): void {\n\t\tfor (const signalController of this.signalControllers) {\n\t\t\tsignalController.abort(abortEvent());\n\t\t}\n\n\t\t// Clear the set after aborting all requests\n\t\tthis.signalControllers.clear();\n\t}\n\n\t/**\n\t * Executes multiple requests concurrently and resolves when all complete.\n\t * @param requests An array of promises from Transportr request methods.\n\t * @returns A promise resolving to an array of all results.\n\t */\n\tstatic all<T extends readonly Promise<unknown>[]>(requests: T): Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }> {\n\t\treturn Promise.all(requests) as Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }>;\n\t}\n\n\t/**\n\t * Races multiple requests concurrently. The first to settle wins; all others are aborted.\n\t * Each factory receives an AbortSignal that the caller should pass to the request options.\n\t * @template T The expected result type.\n\t * @param requests An array of functions that accept an AbortSignal and return a promise.\n\t * @returns A promise resolving to the first settled result.\n\t * @example\n\t * ```typescript\n\t * const result = await Transportr.race([\n\t * (signal) => api.getJson('/primary', { signal }),\n\t * (signal) => api.getJson('/fallback', { signal })\n\t * ]);\n\t * ```\n\t */\n\tstatic async race<T>(requests: ReadonlyArray<(signal: AbortSignal) => Promise<T>>): Promise<T> {\n\t\tconst controllers: AbortController[] = [];\n\n\t\tconst promises = new Array<Promise<T>>(requests.length);\n\t\tfor (let i = 0; i < requests.length; i++) {\n\t\t\tconst controller = new AbortController();\n\t\t\tcontrollers.push(controller);\n\t\t\tpromises[i] = requests[i]!(controller.signal);\n\t\t}\n\n\t\ttry {\n\t\t\treturn await Promise.race(promises);\n\t\t} finally {\n\t\t\tfor (const controller_1 of controllers) { controller_1.abort() }\n\t\t}\n\t}\n\n\t/**\n\t * Registers a custom content-type response handler.\n\t * The handler will be matched against response content-type headers using MediaType matching.\n\t * New handlers are prepended so they take priority over built-in handlers.\n\t *\n\t * @param contentType The content-type string to match (e.g. 'application/pdf', 'text', 'csv').\n\t * @param handler The response handler function.\n\t */\n\tstatic registerContentTypeHandler(contentType: string, handler: ResponseHandler): void {\n\t\t// Prepend so custom handlers take priority over built-in ones\n\t\tTransportr.contentTypeHandlers.unshift([ contentType, handler ]);\n\t}\n\n\t/**\n\t * Removes a previously registered content-type response handler.\n\t *\n\t * @param contentType The content-type string to remove.\n\t * @returns True if the handler was found and removed, false otherwise.\n\t */\n\tstatic unregisterContentTypeHandler(contentType: string): boolean {\n\t\tconst index = Transportr.contentTypeHandlers.findIndex(([ type ]) => type === contentType);\n\t\tif (index === -1) { return false }\n\n\t\tTransportr.contentTypeHandlers.splice(index, 1);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Registers global lifecycle hooks that run on all requests from all instances.\n\t * Global hooks execute before instance and per-request hooks.\n\t *\n\t * @param hooks The hooks to register globally.\n\t */\n\tstatic addHooks(hooks: HookOptions): void {\n\t\tif (hooks.beforeRequest) { Transportr.globalHooks.beforeRequest.push(...hooks.beforeRequest) }\n\t\tif (hooks.afterResponse) { Transportr.globalHooks.afterResponse.push(...hooks.afterResponse) }\n\t\tif (hooks.beforeError) { Transportr.globalHooks.beforeError.push(...hooks.beforeError) }\n\t}\n\n\t/**\n\t * Removes all global lifecycle hooks.\n\t */\n\tstatic clearHooks(): void {\n\t\tTransportr.globalHooks = { beforeRequest: [], afterResponse: [], beforeError: [] };\n\t}\n\n\t/**\n\t * Tears down all global state: aborts in-flight requests, clears global event subscriptions,\n\t * hooks, in-flight deduplication map, and media type cache (retaining built-in entries).\n\t */\n\tstatic unregisterAll(): void {\n\t\tTransportr.abortAll();\n\t\tTransportr.globalSubscribr = new Subscribr();\n\t\tTransportr.clearHooks();\n\t\tTransportr.inflightRequests.clear();\n\t}\n\n\t/**\n\t * It returns the base {@link URL} for the API.\n\t *\n\t * @returns The baseUrl property.\n\t */\n\tget baseUrl(): URL {\n\t\treturn this._baseUrl;\n\t}\n\n\t/**\n\t * Registers an event handler with a {@link Transportr} instance with typed data.\n\t *\n\t * @param event The name of the event to listen for.\n\t * @param handler The function to call when the event is triggered.\n\t * @param context The context to bind to the handler.\n\t * @returns An object that can be used to remove the event handler.\n\t */\n\tregister<E extends keyof RequestEventDataMap>(event: E, handler: TypedRequestEventHandler<E>, context?: unknown): EventRegistration;\n\n\t/**\n\t * @internal\n\t * @param event The event to subscribe to.\n\t * @param handler The event handler.\n\t * @param context The context to bind the handler to.\n\t * @returns An object that can be used to remove the event handler.\n\t */\n\tregister(event: RequestEvent, handler: RequestEventHandler, context?: unknown): EventRegistration {\n\t\treturn this.subscribr.subscribe(event, handler, context);\n\t}\n\n\t/**\n\t * Unregisters an event handler from a {@link Transportr} instance.\n\t *\n\t * @param eventRegistration The event registration to remove.\n\t * @returns True if the {@link EventRegistration} was removed, false otherwise.\n\t */\n\tunregister(eventRegistration: EventRegistration): boolean {\n\t\treturn this.subscribr.unsubscribe(eventRegistration);\n\t}\n\n\t/**\n\t * Registers instance-level lifecycle hooks that run on all requests from this instance.\n\t * Instance hooks execute after global hooks but before per-request hooks.\n\t *\n\t * @param hooks The hooks to register on this instance.\n\t * @returns This instance for method chaining.\n\t */\n\taddHooks(hooks: HookOptions): this {\n\t\tif (hooks.beforeRequest) { this.hooks.beforeRequest.push(...hooks.beforeRequest) }\n\t\tif (hooks.afterResponse) { this.hooks.afterResponse.push(...hooks.afterResponse) }\n\t\tif (hooks.beforeError) { this.hooks.beforeError.push(...hooks.beforeError) }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes all instance-level lifecycle hooks.\n\t * @returns This instance for method chaining.\n\t */\n\tclearHooks(): this {\n\t\tthis.hooks.beforeRequest.length = 0;\n\t\tthis.hooks.afterResponse.length = 0;\n\t\tthis.hooks.beforeError.length = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Updates the instance's default options after construction.\n\t * Mirrors what the constructor accepts: headers and searchParams are merged onto\n\t * the existing defaults; all other options overwrite the current value; hooks\n\t * are appended via {@link addHooks}.\n\t *\n\t * @param options The options to apply. Accepts the same shape as the constructor.\n\t * @returns This instance for method chaining.\n\t */\n\tconfigure({ headers, searchParams, hooks, ...options }: RequestOptions): this {\n\t\tif (headers) { Transportr.mergeHeaders(this._options.headers as Headers, headers) }\n\t\tif (searchParams) { Transportr.mergeSearchParams(this._options.searchParams as URLSearchParams, searchParams) }\n\t\tif (Object.keys(options).length > 0) { Object.assign(this._options, options) }\n\t\tif (hooks) { this.addHooks(hooks) }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Tears down this instance: clears all instance subscriptions and hooks.\n\t * The instance should not be used after calling this method.\n\t */\n\tdestroy(): void {\n\t\tthis.clearHooks();\n\t\tthis.subscribr.destroy();\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tget<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tget<T extends ResponseBody = ResponseBody>(path: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/**\n\t * This function returns a promise that resolves to the result of a request to the specified path with\n\t * the specified options, where the method is GET.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to get.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response of the request.\n\t */\n\tasync get<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this._get<T>(path, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tpost<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tpost<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/**\n\t * This function makes a POST request to the given path with the given body and options.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to call.\n\t * @param body The body of the request.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response body.\n\t */\n\tasync post<T extends ResponseBody = ResponseBody>(path?: string | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('POST', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tput<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tput<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/**\n\t * This function returns a promise that resolves to the result of a request to the specified path with\n\t * the specified options, where the method is PUT.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to call.\n\t * @param body The body of the request.\n\t * @param options The options for the request.\n\t * @returns The return value of the #request method.\n\t */\n\tasync put<T extends ResponseBody = ResponseBody>(path?: string | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('PUT', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tpatch<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tpatch<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/**\n\t * It takes a path and options, and returns a request with the method set to PATCH.\n\t *\n\t * @async\n\t * @template T The expected response type (defaults to ResponseBody)\n\t * @param path The path to the endpoint you want to hit.\n\t * @param body The body of the request.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response of the request.\n\t */\n\tasync patch<T extends ResponseBody = ResponseBody>(path?: string | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('PATCH', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tdelete<T extends ResponseBody = ResponseBody>(path: string | undefined, body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tdelete<T extends ResponseBody = ResponseBody>(body: RequestBody, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/**\n\t * It takes a path and options, and returns a request with the method set to DELETE.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to access.\n\t * @param body The body of the request.\n\t * @param options The options for the request.\n\t * @returns The result of the request.\n\t */\n\tasync delete<T extends ResponseBody = ResponseBody>(path?: string | RequestBody, body?: RequestBody | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.executeBodyMethod<T>('DELETE', path, body, options);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\thead<T extends ResponseBody = ResponseBody>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\thead<T extends ResponseBody = ResponseBody>(path: RequestOptions & { unwrap: false }): Promise<Result<T | undefined>>;\n\t/**\n\t * Returns the response headers of a request to the given path.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to access.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to the response object.\n\t */\n\tasync head<T extends ResponseBody = ResponseBody>(path?: string | RequestOptions, options?: RequestOptions): Promise<T | undefined | Result<T | undefined>> {\n\t\treturn this.execute<T>(path, options, { method: 'HEAD' });\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\toptions(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<string[] | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\toptions(path: RequestOptions & { unwrap: false }): Promise<Result<string[] | undefined>>;\n\t/**\n\t * It returns a promise that resolves to the allowed request methods for the given resource path.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an array of allowed request methods for this resource.\n\t */\n\tasync options(path?: string | RequestOptions, options: RequestOptions = {}): Promise<string[] | undefined | Result<string[] | undefined>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options, { method: 'OPTIONS' });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet response: Response = await this._request(path, requestConfig);\n\n\t\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\t\tif (result) { response = result }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst allowHeader = response.headers.get('allow');\n\t\t\tlet allowedMethods: string[] | undefined;\n\t\t\tif (allowHeader) {\n\t\t\t\tconst parts = allowHeader.split(',');\n\t\t\t\tallowedMethods = new Array(parts.length);\n\t\t\t\tfor (let i = 0, length = parts.length; i < length; i++) {\n\t\t\t\t\tallowedMethods[i] = parts[i]!.trim();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: allowedMethods, global: options.global });\n\n\t\t\treturn unwrap ? allowedMethods : [ true, allowedMethods ];\n\t\t} catch (error) {\n\t\t\tif (!unwrap) { return [ false, error as HttpError ] }\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\trequest<T = unknown>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<TypedResponse<T>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\trequest<T = unknown>(path: RequestOptions & { unwrap: false }): Promise<Result<TypedResponse<T>>>;\n\t/**\n\t * It takes a path and options, and makes a request to the server\n\t * @async\n\t * @param path The path to the endpoint you want to hit.\n\t * @param options The options for the request.\n\t * @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.\n\t * @throws {HttpError} If an error occurs during the request.\n\t */\n\tasync request<T = unknown>(path?: string | RequestOptions, options: RequestOptions = {}): Promise<TypedResponse<T> | Result<TypedResponse<T>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options, {});\n\t\tconst unwrap = requestConfig.requestOptions.unwrap !== false;\n\n\t\ttry {\n\t\t\tconst response = await this._request<T>(path, requestConfig);\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: response, global: options.global });\n\n\t\t\treturn unwrap ? response : [true, response] as Result<TypedResponse<T>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [false, error as HttpError] as Result<TypedResponse<T>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJson(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Json | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJson(path: RequestOptions & { unwrap: false }): Promise<Result<Json | undefined>>;\n\t/**\n\t * It gets the JSON representation of the resource at the given path.\n\t *\n\t * @async\n\t * @template T The expected JSON response type (defaults to JsonObject)\n\t * @param path The path to the resource.\n\t * @param options The options object to pass to the request.\n\t * @returns A promise that resolves to the response body as a typed JSON value.\n\t */\n\tasync getJson(path?: string | RequestOptions, options?: RequestOptions): Promise<Json | undefined | Result<Json | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JSON}` } }, handleJson);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetXml(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Document | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetXml(path: RequestOptions & { unwrap: false }): Promise<Result<Document | undefined>>;\n\t/**\n\t * It gets the XML representation of the resource at the given path.\n\t *\n\t * @async\n\t * @param path The path to the resource you want to get.\n\t * @param options The options for the request.\n\t * @returns The result of the function call to #get.\n\t */\n\tasync getXml(path?: string | RequestOptions, options?: RequestOptions): Promise<Document | undefined | Result<Document | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.XML}` } }, handleXml);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtml(path: string | undefined, options: RequestOptions & { unwrap: false }, selector?: string): Promise<Result<Document | Element | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtml(path: RequestOptions & { unwrap: false }): Promise<Result<Document | Element | null | undefined>>;\n\t/**\n\t * Get the HTML content of the specified path.\n\t * When a selector is provided, returns only the first matching element from the parsed document.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @param selector An optional CSS selector to extract a specific element from the parsed HTML.\n\t * @returns A promise that resolves to a Document, an Element (if selector matched), or void.\n\t */\n\tasync getHtml(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<Document | Element | null | undefined | Result<Document | Element | null | undefined>> {\n\t\tconst doc = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, handleHtml);\n\t\tif (Array.isArray(doc)) return doc;\n\t\treturn selector && doc ? doc.querySelector(selector) : doc;\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtmlFragment(path: string | undefined, options: RequestOptions & { unwrap: false }, selector?: string): Promise<Result<DocumentFragment | Element | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetHtmlFragment(path: RequestOptions & { unwrap: false }): Promise<Result<DocumentFragment | Element | null | undefined>>;\n\t/**\n\t * It returns a promise that resolves to the HTML fragment at the given path.\n\t * When a selector is provided, returns only the first matching element from the parsed fragment.\n\t *\n\t * @async\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @param selector An optional CSS selector to extract a specific element from the parsed fragment.\n\t * @returns A promise that resolves to a DocumentFragment, an Element (if selector matched), or void.\n\t */\n\tasync getHtmlFragment(path?: string | RequestOptions, options?: RequestOptions, selector?: string): Promise<DocumentFragment | Element | null | undefined | Result<DocumentFragment | Element | null | undefined>> {\n\t\tconst allowScripts = (isObject(path) ? path : options)?.allowScripts === true;\n\t\tconst fragment = await this._get(path, options, { headers: { accept: `${mediaTypes.HTML}` } }, allowScripts ? handleHtmlFragmentWithScripts : handleHtmlFragment);\n\t\tif (Array.isArray(fragment)) return fragment;\n\t\treturn selector && fragment ? fragment.querySelector(selector) : fragment;\n\t}\n\t/** Returns a Result tuple instead of throwing. */\n\tgetScript(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetScript(path: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/**\n\t * It gets a script from the server, and appends the script to the Document HTMLHeadElement\n\t * @param path The path to the script.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to void.\n\t */\n\tasync getScript(path?: string | RequestOptions, options?: RequestOptions): Promise<void | Result<void>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.JAVA_SCRIPT}` } }, handleScript);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStylesheet(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStylesheet(path: RequestOptions & { unwrap: false }): Promise<Result<void>>;\n\t/**\n\t * Gets a stylesheet from the server, and adds it as a Blob URL.\n\t * @param path The path to the stylesheet.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to void.\n\t */\n\tasync getStylesheet(path?: string | RequestOptions, options?: RequestOptions): Promise<void | Result<void>> {\n\t\treturn this._get(path, options, { headers: { accept: `${mediaTypes.CSS}` } }, handleCss);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBlob(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<Blob | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBlob(path: RequestOptions & { unwrap: false }): Promise<Result<Blob | undefined>>;\n\t/**\n\t * It returns a blob from the specified path.\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to a Blob or void.\n\t */\n\tasync getBlob(path?: string | RequestOptions, options?: RequestOptions): Promise<Blob | undefined | Result<Blob | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBlob);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetImage(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<HTMLImageElement | undefined>>;\n\t/**\n\t * It returns a promise that resolves to an `HTMLImageElement`.\n\t * The object URL created to load the image is automatically revoked to prevent memory leaks.\n\t * Works in both browser and Node.js (via JSDOM) environments.\n\t * @param path The path to the image.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an `HTMLImageElement` or `void`.\n\t */\n\tasync getImage(path?: string, options?: RequestOptions): Promise<HTMLImageElement | undefined | Result<HTMLImageElement | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'image/*' } }, handleImage);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBuffer(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<ArrayBuffer | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetBuffer(path: RequestOptions & { unwrap: false }): Promise<Result<ArrayBuffer | undefined>>;\n\t/**\n\t * It gets a buffer from the specified path\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to an ArrayBuffer or void.\n\t */\n\tasync getBuffer(path?: string | RequestOptions, options?: RequestOptions): Promise<ArrayBuffer | undefined | Result<ArrayBuffer | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleBuffer);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStream(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetStream(path: RequestOptions & { unwrap: false }): Promise<Result<ReadableStream<Uint8Array> | null | undefined>>;\n\t/**\n\t * It returns a readable stream of the response body from the specified path.\n\t * @param path The path to the resource.\n\t * @param options The options for the request.\n\t * @returns A promise that resolves to a ReadableStream, null, or void.\n\t */\n\tasync getStream(path?: string | RequestOptions, options?: RequestOptions): Promise<ReadableStream<Uint8Array> | null | undefined | Result<ReadableStream<Uint8Array> | null | undefined>> {\n\t\treturn this._get(path, options, { headers: { accept: 'application/octet-stream' } }, handleReadableStream);\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetEventStream(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<ServerSentEvent>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetEventStream(path: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<ServerSentEvent>>>;\n\t/**\n\t * Opens a Server-Sent Events stream and returns an AsyncIterable of typed events.\n\t * Follows the EventStream specification for parsing event, data, id, and retry fields.\n\t * Iteration ends when the server closes the stream or the request is aborted.\n\t *\n\t * @async\n\t * @param path The path to the SSE endpoint.\n\t * @param options The options for the request.\n\t * @returns An AsyncIterable of parsed ServerSentEvent objects.\n\t * @example\n\t * ```typescript\n\t * for await (const event of api.getEventStream('/chat/completions', { body: { prompt } })) {\n\t * console.log(event.event, event.data);\n\t * }\n\t * ```\n\t */\n\tasync getEventStream(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<ServerSentEvent> | Result<AsyncIterable<ServerSentEvent>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options ?? {}, { method: options?.body ? 'POST' : 'GET', headers: { accept: `${mediaTypes.EVENT_STREAM}` } });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst response = await this._request(path, requestConfig);\n\n\t\t\tlet afterResponse: Response = response;\n\t\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(afterResponse, requestOptions);\n\t\t\t\t\tif (result) { afterResponse = result }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });\n\n\t\t\tconst stream = handleEventStream(afterResponse);\n\t\t\treturn unwrap ? stream : [true, stream] as Result<AsyncIterable<ServerSentEvent>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [false, error as HttpError] as Result<AsyncIterable<ServerSentEvent>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJsonStream<T = Json>(path: string | undefined, options: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<T>>>;\n\t/** Returns a Result tuple instead of throwing. */\n\tgetJsonStream<T = Json>(path: RequestOptions & { unwrap: false }): Promise<Result<AsyncIterable<T>>>;\n\t/**\n\t * Opens an NDJSON (Newline Delimited JSON) stream and returns an AsyncIterable of typed JSON values.\n\t * Each line is independently parsed as JSON, making it suitable for streaming large datasets\n\t * or real-time JSON feeds.\n\t *\n\t * @async\n\t * @template T The expected type of each JSON line (defaults to Json).\n\t * @param path The path to the NDJSON endpoint.\n\t * @param options The options for the request.\n\t * @returns An AsyncIterable of parsed JSON values.\n\t * @example\n\t * ```typescript\n\t * for await (const user of api.getJsonStream<User>('/users/export')) {\n\t * processUser(user);\n\t * }\n\t * ```\n\t */\n\tasync getJsonStream<T = Json>(path?: string | RequestOptions, options?: RequestOptions): Promise<AsyncIterable<T> | Result<AsyncIterable<T>>> {\n\t\tif (isObject(path)) { [ path, options ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(options ?? {}, { method: 'GET', headers: { accept: `${mediaTypes.NDJSON}` } });\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tconst beforeRequestHookSets = [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ];\n\t\t\tfor (const hooks of beforeRequestHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst response = await this._request(path, requestConfig);\n\n\t\t\tlet afterResponse: Response = response;\n\t\t\tconst afterResponseHookSets = [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ];\n\t\t\tfor (const hooks of afterResponseHookSets) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(afterResponse, requestOptions);\n\t\t\t\t\tif (result) { afterResponse = result }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data: afterResponse, global: requestConfig.global });\n\n\t\t\tconst stream = handleNdjsonStream<T>(afterResponse);\n\t\t\treturn unwrap ? stream : [ true, stream ] as Result<AsyncIterable<T>>;\n\t\t} catch (error) {\n\t\t\tif (!unwrap) return [ false, error as HttpError ] as Result<AsyncIterable<T>>;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Handles a GET request.\n\t * @async\n\t * @param path The path to the resource.\n\t * @param userOptions The user options for the request.\n\t * @param options The options for the request.\n\t * @param responseHandler The response handler for the request.\n\t * @returns A promise that resolves to the response body or void.\n\t */\n\tprivate async _get<T extends ResponseBody>(path?: string | RequestOptions, userOptions?: RequestOptions, options: RequestOptions = {}, responseHandler?: ResponseHandler<T>): Promise<T | undefined | Result<T | undefined>> {\n\t\toptions.method = 'GET';\n\t\toptions.body = undefined;\n\t\treturn this.execute<T>(path, userOptions, options, responseHandler);\n\t}\n\n\t/**\n\t * It processes the request options and returns a new object with the processed options.\n\t * @param path The path to the resource.\n\t * @param processedRequestOptions The user options for the request.\n\t * @returns A new object with the processed options.\n\t */\n\tprivate async _request<T = unknown>(path: string | undefined, { signalController, requestOptions, global }: RequestConfiguration): Promise<TypedResponse<T>> {\n\t\tTransportr.signalControllers.add(signalController);\n\n\t\tconst retryConfig = Transportr.normalizeRetryOptions(requestOptions.retry);\n\t\tconst method = requestOptions.method ?? 'GET';\n\t\tconst canRetry = retryConfig.limit > 0 && retryConfig.methods.includes(method);\n\t\tconst canDedupe = requestOptions.dedupe === true && (method === 'GET' || method === 'HEAD');\n\t\tlet attempt = 0;\n\t\tconst startTime = performance.now();\n\n\t\t/**\n\t\t * Creates a RequestTiming snapshot from the start time to now.\n\t\t * @returns Timing information for the request.\n\t\t */\n\t\tconst getTiming = (): RequestTiming => {\n\t\t\tconst end = performance.now();\n\t\t\treturn { start: startTime, end, duration: end - startTime };\n\t\t};\n\n\t\ttry {\n\t\t\tconst url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\t\t\tlet dedupeKey: string | undefined;\n\n\t\t\t// If deduplication is enabled and an in-flight request exists, clone its response\n\t\t\tif (canDedupe) {\n\t\t\t\tdedupeKey = `${method}:${url.href}`;\n\t\t\t\tconst inflight = Transportr.inflightRequests.get(dedupeKey);\n\t\t\t\tif (inflight) { return (await inflight).clone() as TypedResponse<T> }\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Performs the fetch with retry logic.\n\t\t\t * @returns A promise resolving to the typed response.\n\t\t\t */\n\t\t\tconst originalBody = requestOptions.body;\n\t\t\tconst onUploadProgress = requestOptions.onUploadProgress;\n\n\t\t\t/**\n\t\t\t * Wraps the request body with a progress-tracking TransformStream when onUploadProgress is set.\n\t\t\t * Re-creates the stream from the original body on each call so retries get a fresh stream.\n\t\t\t */\n\t\t\tconst wrapUploadBody = async (): Promise<void> => {\n\t\t\t\tif (!onUploadProgress || originalBody == null) { return }\n\n\t\t\t\tlet bytes: Uint8Array | null = null;\n\n\t\t\t\tif (typeof originalBody === 'string') {\n\t\t\t\t\tbytes = new TextEncoder().encode(originalBody);\n\t\t\t\t} else if (originalBody instanceof Blob) {\n\t\t\t\t\tbytes = new Uint8Array(await originalBody.arrayBuffer());\n\t\t\t\t} else if (isArrayBuffer(originalBody)) {\n\t\t\t\t\tbytes = new Uint8Array(originalBody);\n\t\t\t\t} else if (ArrayBuffer.isView(originalBody)) {\n\t\t\t\t\tbytes = new Uint8Array(originalBody.buffer, originalBody.byteOffset, originalBody.byteLength);\n\t\t\t\t} else if (!(originalBody instanceof ReadableStream)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst total = bytes ? bytes.byteLength : null;\n\t\t\t\tconst readable: ReadableStream<Uint8Array> = bytes\n\t\t\t\t\t? new ReadableStream<Uint8Array>({\n\t\t\t\t\t\t/** @param controller The stream controller. */\n\t\t\t\t\t\tstart(controller) { controller.enqueue(bytes); controller.close() }\n\t\t\t\t\t})\n\t\t\t\t\t: originalBody as ReadableStream<Uint8Array>;\n\n\t\t\t\tlet loaded = 0;\n\t\t\t\tconst transform = new TransformStream<Uint8Array, Uint8Array>({\n\t\t\t\t\t/**\n\t\t\t\t\t * Tracks bytes and invokes upload progress callback.\n\t\t\t\t\t * @param chunk The data chunk.\n\t\t\t\t\t * @param controller The transform controller.\n\t\t\t\t\t */\n\t\t\t\t\ttransform(chunk, controller) {\n\t\t\t\t\t\tloaded += chunk.byteLength;\n\t\t\t\t\t\tonUploadProgress({\n\t\t\t\t\t\t\tloaded,\n\t\t\t\t\t\t\ttotal,\n\t\t\t\t\t\t\tpercentage: total !== null && total > 0 ? Math.round((loaded / total) * 100) : null\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\trequestOptions.body = readable.pipeThrough(transform);\n\t\t\t\tObject.assign(requestOptions, { duplex: 'half' });\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Performs the fetch with upload progress wrapping and retry logic.\n\t\t\t * @returns The typed response.\n\t\t\t */\n\t\t\tconst doFetch = async (): Promise<TypedResponse<T>> => {\n\t\t\t\twhile (true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait wrapUploadBody();\n\t\t\t\t\t\tconst response = await fetch<T>(url, requestOptions);\n\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\tif (canRetry && attempt < retryConfig.limit && retryConfig.statusCodes.includes(response.status)) {\n\t\t\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, status: response.status, method, path, timing: getTiming() }, global });\n\t\t\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Capture response body for error diagnostics\n\t\t\t\t\t\t\tlet entity: ResponseBody | undefined;\n\t\t\t\t\t\t\ttry { entity = await response.text() } catch { /* body may be unavailable */ }\n\t\t\t\t\t\t\tthrow await this.handleError(path, response, { entity, url, method, timing: getTiming() }, requestOptions);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t} catch (cause) {\n\t\t\t\t\t\tif (cause instanceof HttpError) { throw cause }\n\n\t\t\t\t\t\t// Network error \u2014 retry if allowed\n\t\t\t\t\t\tif (canRetry && attempt < retryConfig.limit) {\n\t\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\t\tthis.publish({ name: RequestEvent.RETRY, data: { attempt, error: (cause as Error).message, method, path, timing: getTiming() }, global });\n\t\t\t\t\t\t\tawait Transportr.retryDelay(retryConfig, attempt);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthrow await this.handleError(path, undefined, { cause: cause as Error, url, method, timing: getTiming() }, requestOptions);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Wraps the response body with a progress-tracking TransformStream when onDownloadProgress is set.\n\t\t\t * @param response The response to potentially wrap.\n\t\t\t * @returns The original response or a new response with progress tracking.\n\t\t\t */\n\t\t\tconst wrapProgress = (response: TypedResponse<T>): TypedResponse<T> => {\n\t\t\t\tconst onDownloadProgress = requestOptions.onDownloadProgress;\n\t\t\t\tif (!onDownloadProgress || !response.body) return response;\n\n\t\t\t\tconst contentLength = response.headers.get('content-length');\n\t\t\t\tconst total = contentLength ? parseInt(contentLength, 10) : null;\n\t\t\t\tlet loaded = 0;\n\n\t\t\t\tconst transform = new TransformStream<Uint8Array, Uint8Array>({\n\t\t\t\t\t/**\n\t\t\t\t\t * Tracks bytes and invokes progress callback.\n\t\t\t\t\t * @param chunk The data chunk.\n\t\t\t\t\t * @param controller The transform controller.\n\t\t\t\t\t */\n\t\t\t\t\ttransform(chunk, controller) {\n\t\t\t\t\t\tloaded += chunk.byteLength;\n\t\t\t\t\t\tonDownloadProgress({ loaded, total, percentage: total !== null && total > 0 ? Math.round((loaded / total) * 100) : null });\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\treturn new Response(response.body.pipeThrough(transform), { status: response.status, statusText: response.statusText, headers: response.headers }) as TypedResponse<T>;\n\t\t\t};\n\n\t\t\tif (canDedupe) {\n\t\t\t\tconst typedResponse = doFetch();\n\t\t\t\tTransportr.inflightRequests.set(dedupeKey!, typedResponse);\n\t\t\t\ttry {\n\t\t\t\t\treturn wrapProgress(await typedResponse);\n\t\t\t\t} finally {\n\t\t\t\t\tTransportr.inflightRequests.delete(dedupeKey!);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn wrapProgress(await doFetch());\n\t\t} finally {\n\t\t\tTransportr.signalControllers.delete(signalController.destroy());\n\t\t\tif (!requestOptions.signal?.aborted) {\n\t\t\t\tthis.publish({ name: RequestEvent.COMPLETE, data: { timing: getTiming() }, global });\n\t\t\t\tif (Transportr.signalControllers.size === 0) {\n\t\t\t\t\tthis.publish({ name: RequestEvent.ALL_COMPLETE, global });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Normalizes a retry option into a full RetryOptions object.\n\t * @param retry The retry option from request options.\n\t * @returns Normalized retry configuration.\n\t */\n\tprivate static normalizeRetryOptions(retry?: number | RetryOptions): NormalizedRetryOptions {\n\t\tif (retry === undefined) { return Transportr.noRetryConfig }\n\t\tif (typeof retry === 'number') { return { limit: retry, statusCodes: retryStatusCodes, methods: retryMethods, delay: retryDelay, backoffFactor: retryBackoffFactor } }\n\n\t\treturn {\n\t\t\tlimit: retry.limit ?? 0,\n\t\t\tstatusCodes: retry.statusCodes ?? retryStatusCodes,\n\t\t\tmethods: retry.methods ?? retryMethods,\n\t\t\tdelay: retry.delay ?? retryDelay,\n\t\t\tbackoffFactor: retry.backoffFactor ?? retryBackoffFactor\n\t\t};\n\t}\n\n\t/**\n\t * Waits for the appropriate delay before a retry attempt.\n\t * @param config The retry configuration.\n\t * @param attempt The current attempt number (1-based).\n\t * @returns A promise that resolves after the delay.\n\t */\n\tprivate static retryDelay(config: NormalizedRetryOptions, attempt: number): Promise<void> {\n\t\tconst ms = typeof config.delay === 'function' ? config.delay(attempt) : config.delay * (config.backoffFactor ** (attempt - 1));\n\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\t/**\n\t * Shared implementation for body-accepting HTTP methods (POST, PUT, PATCH, DELETE).\n\t * @param method The HTTP method to use.\n\t * @param path The request path, or the request body when called without a path.\n\t * @param body The request body, or options when called without a path.\n\t * @param options Additional request options.\n\t * @param responseHandler Optional response handler override.\n\t * @returns A promise that resolves to the response body.\n\t */\n\tprivate executeBodyMethod<T extends ResponseBody>(method: RequestBodyMethod, path: string | RequestBody | undefined, body?: RequestBody | RequestOptions, options?: RequestOptions, responseHandler?: ResponseHandler<NoInfer<T>>): Promise<T | undefined | Result<T | undefined>> {\n\t\tconst [ resolvedPath, resolvedBody, resolvedOptions ] = isString(path) ? [ path, body as RequestBody, options ] : [ undefined, path, body as RequestOptions ];\n\n\t\treturn this.execute<T>(resolvedPath, Object.assign(resolvedOptions ?? {}, { body: resolvedBody, method }), {}, responseHandler);\n\t}\n\n\t/**\n\t * It returns a response handler based on the content type of the response.\n\t * @param path The path to the resource.\n\t * @param userOptions The user options for the request.\n\t * @param options The options for the request.\n\t * @param responseHandler The response handler for the request.\n\t * @returns A response handler function.\n\t */\n\tprivate async execute<T extends ResponseBody>(path?: string | RequestOptions, userOptions: RequestOptions = {}, options: RequestOptions = {}, responseHandler?: ResponseHandler<NoInfer<T>>): Promise<T | undefined | Result<T | undefined>> {\n\t\tif (isObject(path)) { [ path, userOptions ] = [ undefined, path ] }\n\n\t\tconst requestConfig = this.processRequestOptions(userOptions, options);\n\t\tconst { requestOptions } = requestConfig;\n\t\tconst unwrap = requestOptions.unwrap !== false;\n\t\tconst requestHooks = requestOptions.hooks;\n\n\t\ttry {\n\t\t\t// Run beforeRequest hooks: global \u2192 instance \u2192 per-request\n\t\t\tlet url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams);\n\n\t\t\tfor (const hooks of [ Transportr.globalHooks.beforeRequest, this.hooks.beforeRequest, requestHooks?.beforeRequest ]) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(requestOptions, url);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tObject.assign(requestOptions, result);\n\t\t\t\t\t\tif (result.searchParams !== undefined) { url = Transportr.createUrl(this._baseUrl, path, requestOptions.searchParams) }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet response = await this._request<T>(path, requestConfig);\n\n\t\t\t// Run afterResponse hooks: global \u2192 instance \u2192 per-request\n\t\t\tfor (const hooks of [ Transportr.globalHooks.afterResponse, this.hooks.afterResponse, requestHooks?.afterResponse ]) {\n\t\t\t\tif (!hooks) { continue }\n\t\t\t\tfor (const hook of hooks) {\n\t\t\t\t\tconst result = await hook(response, requestOptions);\n\t\t\t\t\tif (result) { response = result as TypedResponse<T> }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tif (!responseHandler && response.status !== 204) {\n\t\t\t\t\tresponseHandler = this.getResponseHandler<T>(response.headers.get('content-type'));\n\t\t\t\t}\n\n\t\t\t\tconst data = await responseHandler?.(response);\n\n\t\t\t\tthis.publish({ name: RequestEvent.SUCCESS, data, global: requestConfig.global });\n\n\t\t\t\treturn unwrap ? data : [ true, data ];\n\t\t\t} catch (cause) {\n\t\t\t\tthrow await this.handleError(path as string, response, { cause: cause as Error }, requestOptions);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!unwrap) { return [ false, error as HttpError ] }\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Creates a new set of options for a request.\n\t * @param options The user options for the request.\n\t * @param userOptions The default options for the request.\n\t * @returns A new set of options for the request.\n\t */\n\tprivate static createOptions({ headers: userHeaders, searchParams: userSearchParams, ...userOptions }: RequestOptions, { headers, searchParams, ...options }: RequestOptions): RequestOptions {\n\t\theaders = Transportr.mergeHeaders(new Headers(), userHeaders, headers);\n\t\tsearchParams = Transportr.mergeSearchParams(new URLSearchParams(), userSearchParams, searchParams);\n\n\t\treturn { ...objectMerge(options, userOptions)!, headers, searchParams };\n\t}\n\n\t/**\n\t * Merges user and request headers into the target Headers object.\n\t * @param target The target Headers object.\n\t * @param headerSources Variable number of header sources to merge.\n\t * @returns The merged Headers object.\n\t */\n\tprivate static mergeHeaders(target: Headers, ...headerSources: (RequestHeaders | undefined)[]): Headers {\n\t\tfor (const headers of headerSources) {\n\t\t\tif (headers === undefined) { continue }\n\n\t\t\t// Handle different input types\n\t\t\tif (headers instanceof Headers) {\n\t\t\t\t// Use the native forEach method for Headers\n\t\t\t\theaders.forEach((value, name) => target.set(name, value));\n\t\t\t} else if (Array.isArray(headers)) {\n\t\t\t\t// Handle array of tuples format\n\t\t\t\tfor (const [ name, value ] of headers) { target.set(name, value) }\n\t\t\t} else {\n\t\t\t\t// Handle Record<string, string> format - use Object.keys() to avoid intermediate tuple array\n\t\t\t\tconst keys = Object.keys(headers);\n\t\t\t\tfor (let i = 0, length = keys.length; i < length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = (headers as Record<string, string | undefined>)[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, value) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn target;\n\t}\n\n\t/**\n\t * Merges user and request search parameters into the target URLSearchParams object.\n\t * @param target The target URLSearchParams object.\n\t * @param sources The search parameters to merge.\n\t * @returns The merged URLSearchParams object.\n\t */\n\tprivate static mergeSearchParams(target: URLSearchParams, ...sources: (SearchParameters | undefined)[]): URLSearchParams {\n\t\tfor (const searchParams of sources) {\n\t\t\tif (searchParams === undefined) { continue }\n\n\t\t\t// Handle different input types\n\t\t\tif (searchParams instanceof URLSearchParams) {\n\t\t\t\t// Use the native forEach method for URLSearchParams\n\t\t\t\tsearchParams.forEach((value, name) => target.set(name, value));\n\t\t\t} else if (isString(searchParams) || Array.isArray(searchParams)) {\n\t\t\t\tfor (const [name, value] of new URLSearchParams(searchParams)) { target.set(name, value) }\n\t\t\t} else {\n\t\t\t\t// Handle Record<string, string> format - use Object.keys() for better performance\n\t\t\t\tconst keys = Object.keys(searchParams);\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tconst name = keys[i]!;\n\t\t\t\t\tconst value = searchParams[name];\n\t\t\t\t\tif (value !== undefined) { target.set(name, typeof value === 'string' ? value : String(value)) }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn target;\n\t}\n\n\t/**\n\t * Processes request options by merging user, instance, and method-specific options.\n\t * This method optimizes performance by using cached instance options and performing\n\t * shallow merges where possible instead of deep object cloning.\n\t * @param userOptions The user-provided options for the request.\n\t * @param options Additional method-specific options.\n\t * @returns Processed request options with signal controller and global flag.\n\t */\n\tprivate processRequestOptions({ body: userBody, headers: userHeaders, searchParams: userSearchParams, ...userOptions }: RequestOptions, { headers, searchParams, ...options }: RequestOptions): RequestConfiguration {\n\t\t// Native copy constructors for Headers/URLSearchParams skip JS-level merge of instance defaults\n\t\tconst requestOptions = {\n\t\t\t...this._options,\n\t\t\t...userOptions,\n\t\t\t...options,\n\t\t\theaders: Transportr.mergeHeaders(new Headers(this._options.headers), userHeaders, headers),\n\t\t\tsearchParams: Transportr.mergeSearchParams(new URLSearchParams(this._options.searchParams), userSearchParams, searchParams)\n\t\t};\n\n\t\tif (isRequestBodyMethod(requestOptions.method)) {\n\t\t\tif (isRawBody(userBody)) {\n\t\t\t\t// Raw BodyInit \u2014 send as-is, delete Content-Type so the runtime sets it automatically\n\t\t\t\tObject.assign(requestOptions, { body: userBody });\n\t\t\t\trequestOptions.headers.delete('content-type');\n\t\t\t} else {\n\t\t\t\tconst instanceBody = this._options.body;\n\t\t\t\tconst body = isObject<Record<string, unknown>>(instanceBody) && isObject<Record<string, unknown>>(userBody)\t? objectMerge(instanceBody, userBody)\t: (userBody !== undefined ? userBody : instanceBody);\n\t\t\t\tconst isJson = requestOptions.headers.get('content-type')?.includes('json') ?? false;\n\t\t\t\tObject.assign(requestOptions, { body: isJson && isObject(body) ? serialize(body) : body });\n\t\t\t}\n\t\t} else {\n\t\t\trequestOptions.headers.delete('content-type');\n\t\t\tif (requestOptions.body instanceof URLSearchParams) {\n\t\t\t\tTransportr.mergeSearchParams(requestOptions.searchParams, requestOptions.body);\n\t\t\t}\n\t\t\trequestOptions.body = undefined;\n\t\t}\n\n\t\tconst { signal, timeout, global = false, xsrf } = requestOptions;\n\n\t\t// XSRF/CSRF protection: read token from cookie and set as request header\n\t\tif (xsrf) {\n\t\t\tconst { cookieName, headerName }: XsrfOptions = typeof xsrf === 'object' ? xsrf : {};\n\t\t\tconst token = getCookieValue(cookieName ?? XSRF_COOKIE_NAME);\n\t\t\tif (token) { requestOptions.headers.set(headerName ?? XSRF_HEADER_NAME, token) }\n\t\t}\n\n\t\tconst signalController = new SignalController({ signal, timeout })\n\t\t\t.onAbort((event) => this.publish({ name: RequestEvent.ABORTED, event, global }))\n\t\t\t.onTimeout((event) => this.publish({ name: RequestEvent.TIMEOUT, event, global }));\n\n\t\trequestOptions.signal = signalController.signal;\n\t\tthis.publish({ name: RequestEvent.CONFIGURED, data: requestOptions, global });\n\n\t\treturn { signalController, requestOptions, global } as RequestConfiguration;\n\t}\n\n\t/**\n\t * Gets the base URL from a URL or string.\n\t * @param url The URL or string to parse.\n\t * @returns The base URL.\n\t */\n\tprivate static getBaseUrl(url: URL | string): URL {\n\t\tif (url instanceof URL) { return url }\n\n\t\tif (!isString(url)) { throw new TypeError('Invalid URL') }\n\n\t\treturn new URL(url, url.startsWith('/') ? globalThis.location.origin : undefined);\n\t}\n\n\t/**\n\t * Parses a content-type string into a MediaType instance with caching.\n\t * This method caches parsed MediaType instances to avoid re-parsing the same content-type strings,\n\t * which significantly improves performance for repeated requests with the same content types.\n\t * @param contentType The content-type string to parse.\n\t * @returns The parsed MediaType instance, or undefined if parsing fails.\n\t */\n\tprivate static getOrParseMediaType(contentType: string | null): MediaType | undefined {\n\t\tif (contentType === null) { return }\n\n\t\t// Check the predefined mediaTypes map first (fastest lookup) or the cache\n\t\tlet mediaType = Transportr.mediaTypeCache.get(contentType);\n\n\t\tif (mediaType !== undefined) { return mediaType }\n\n\t\t// Parse and cache the new MediaType\n\t\tmediaType = MediaType.parse(contentType) ?? undefined;\n\n\t\tif (mediaType !== undefined) {\n\t\t\t// Evict oldest entry when cache exceeds limit to prevent unbounded growth\n\t\t\tif (Transportr.mediaTypeCache.size >= 100) {\n\t\t\t\tTransportr.mediaTypeCache.delete(Transportr.mediaTypeCache.keys().next().value!);\n\t\t\t}\n\t\t\tTransportr.mediaTypeCache.set(contentType, mediaType);\n\t\t}\n\n\t\treturn mediaType;\n\t}\n\n\t/**\n\t * Creates a new URL with the given path and search parameters.\n\t * @param url The base URL.\n\t * @param path The path to append to the base URL.\n\t * @param searchParams The search parameters to append to the URL.\n\t * @returns A new URL with the given path and search parameters.\n\t */\n\tprivate static createUrl(url: URL, path?: string, searchParams?: SearchParameters): URL {\n\t\tconst requestUrl = path ? new URL(`${url.pathname.replace(endsWithSlashRegEx, '')}${path}`, url.origin) : new URL(url);\n\n\t\tif (searchParams) {\n\t\t\tTransportr.mergeSearchParams(requestUrl.searchParams, searchParams);\n\t\t}\n\n\t\treturn requestUrl;\n\t}\n\n\t/**\n\t * It generates a ResponseStatus object from an error name and a Response object.\n\t * @param errorName The name of the error.\n\t * @param response The Response object.\n\t * @returns A ResponseStatus object.\n\t */\n\tprivate static generateResponseStatusFromError(errorName?: string, { status, statusText }: Response = new Response()): ResponseStatus {\n\t\tswitch (errorName) {\n\t\t\tcase SignalErrors.ABORT: return aborted;\n\t\t\tcase SignalErrors.TIMEOUT: return timedOut;\n\t\t\tdefault: return status >= 400 ? new ResponseStatus(status, statusText) : internalServerError;\n\t\t}\n\t}\n\n\t/**\n\t * Handles an error that occurs during a request.\n\t * @param path The path of the request.\n\t * @param response The Response object.\n\t * @param options Additional error context including cause, entity, url, method, and timing.\n\t * @param requestOptions The original request options that led to the error, used for hooks context.\n\t * @returns An HttpError object.\n\t */\n\tprivate async handleError(path?: string, response?: Response, { cause, entity, url, method, timing }: Omit<HttpErrorOptions, 'message'> = {}, requestOptions?: RequestOptions): Promise<HttpError> {\n\t\tconst message = method && url\t? `${method} ${url.href} failed${response ? ` with status ${response.status}` : ''}` : `An error has occurred with your request to: '${path}'`;\n\t\tlet error = new HttpError(Transportr.generateResponseStatusFromError(cause?.name, response), { message, cause, entity, url, method, timing });\n\n\t\t// Run beforeError hooks: global \u2192 instance \u2192 per-request\n\t\tfor (const hooks of [ Transportr.globalHooks.beforeError, this.hooks.beforeError, requestOptions?.hooks?.beforeError ]) {\n\t\t\tif (!hooks) { continue }\n\t\t\tfor (const hook of hooks) {\n\t\t\t\tconst result = await hook(error);\n\t\t\t\tif (result instanceof HttpError) { error = result }\n\t\t\t}\n\t\t}\n\n\t\tthis.publish({ name: RequestEvent.ERROR, data: error });\n\n\t\treturn error;\n\t}\n\n\t/**\n\t * Publishes an event to the global and instance event handlers.\n\t * @param eventObject The event object to publish.\n\t */\n\tprivate publish({ name, event = new CustomEvent(name), data, global = true }: PublishOptions): void {\n\t\tif (global) { Transportr.globalSubscribr.publish(name, event, data) }\n\t\tthis.subscribr.publish(name, event, data);\n\t}\n\n\t/**\n\t * It returns a response handler based on the content type of the response.\n\t * @param contentType The content type of the response.\n\t * @returns A response handler function.\n\t */\n\tprivate getResponseHandler<T extends ResponseBody>(contentType?: string | null): ResponseHandler<T> | undefined {\n\t\tif (!contentType) { return }\n\n\t\tconst mediaType = Transportr.getOrParseMediaType(contentType);\n\n\t\tif (!mediaType) { return }\n\n\t\tfor (const [ contentType, responseHandler ] of Transportr.contentTypeHandlers) {\n\t\t\tif (mediaType.matches(contentType)) { return responseHandler as ResponseHandler<T> }\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * A string representation of the Transportr instance.\n\t * @returns The string 'Transportr'.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'Transportr';\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAAA;;;;AAkEA,SAASA,EACPC,IAAyC;AAEzC,SAAO,SAACC,GAAmC;AACrCA,iBAAmBC,WACrBD,EAAQE,YAAY;AACrB,aAAAC,IAAAC,UAAAC,QAHsBC,IAAW,IAAAC,MAAAJ,IAAAA,IAAAA,IAAA,IAAA,CAAA,GAAAK,IAAA,GAAAA,IAAAL,GAAAK,IAAXF,GAAWE,IAAAJ,CAAAA,IAAAA,UAAAI,CAAA;AAKlC,WAAOC,GAAMV,IAAMC,GAASM,CAAI;EAAA;AAEpC;AAQA,SAASI,GACPC,IAA+B;AAE/B,SAAO,WAAA;AAAA,aAAAC,IAAAR,UAAAC,QAAIC,IAAWC,IAAAA,MAAAK,CAAA,GAAAC,IAAA,GAAAA,IAAAD,GAAAC,IA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tD,IAaMuG,KAAa9Q,EAAQoU,OAAO3P,UAAU+P,IAAI;AAbhD,IAeM3S,IAAuB7B,EAAQuC,OAAOkC,UAAUgQ,cAAc;AAfpE,IAiBMtF,IAAanP,EAAQG,OAAOsE,UAAUiQ,IAAI;AAjBhD,IAmBMpJ,IAAkB1K,GAAY+T,SAAS;ACxDtC,IAAMhK,KAAOc,EAAO,CACzB,KACA,QACA,WACA,WACA,QACA,WACA,SACA,SACA,KACA,OACA,OACA,OACA,SACA,cACA,QACA,MACA,UACA,UACA,WACA,UACA,QACA,QACA,OACA,YACA,WACA,QACA,YACA,MACA,aACA,OACA,WACA,OACA,UACA,OACA,OACA,MACA,MACA,WACA,MACA,YACA,cACA,UACA,QACA,UACA,QACA,MACA,MACA,MACA,MACA,MACA,MACA,QACA,UACA,UACA,MACA,QACA,KACA,OACA,SACA,OACA,OACA,SACA,UACA,MACA,QACA,OACA,QACA,WACA,QACA,YACA,SACA,OACA,QACA,MACA,YACA,UACA,UACA,KACA,WACA,OACA,YACA,KACA,MACA,MACA,QACA,KACA,QACA,UACA,WACA,UACA,UACA,QACA,SACA,UACA,UACA,QACA,UACA,UACA,SACA,OACA,WACA,OACA,SACA,SACA,MACA,YACA,YACA,SACA,MACA,SACA,QACA,MACA,SACA,MACA,KACA,MACA,OACA,SACA,KAAK,CACG;AAxHH,IA0HMb,KAAMa,EAAO,CACxB,OACA,KACA,YACA,eACA,gBACA,gBACA,iBACA,oBACA,UACA,YACA,QACA,QACA,WACA,gBACA,eACA,UACA,QACA,KACA,SACA,YACA,SACA,SACA,aACA,QACA,kBACA,UACA,QACA,YACA,SACA,QACA,QACA,WACA,WACA,YACA,kBACA,QACA,QACA,SACA,UACA,UACA,QACA,YACA,SACA,QACA,SACA,QACA,OAAO,CACC;AA1KH,IA4KMZ,KAAaY,EAAO,CAC/B,WACA,iBACA,uBACA,eACA,oBACA,qBACA,qBACA,kBACA,gBACA,WACA,WACA,WACA,WACA,WACA,kBACA,WACA,WACA,eACA,gBACA,YACA,gBACA,sBACA,eACA,UACA,cAAc,CACN;AAtMH,IA4MM2H,KAAgB3H,EAAO,CAClC,WACA,iBACA,UACA,WACA,aACA,oBACA,kBACA,iBACA,iBACA,iBACA,SACA,aACA,QACA,gBACA,aACA,WACA,iBACA,UACA,OACA,cACA,WACA,KAAK,CACG;AAnOH,IAqOMX,KAASW,EAAO,CAC3B,QACA,YACA,UACA,WACA,SACA,UACA,MACA,cACA,iBACA,MACA,MACA,SACA,WACA,YACA,SACA,QACA,MACA,UACA,SACA,UACA,QACA,QACA,WACA,UACA,OACA,SACA,OACA,UACA,cACA,aAAa,CACL;AApQH,IAwQM4H,KAAmB5H,EAAO,CACrC,WACA,eACA,cACA,YACA,aACA,WACA,WACA,UACA,UACA,SACA,aACA,cACA,kBACA,eACA,MAAM,CACE;AAxRH,IA0RMmE,KAAOnE,EAAO,CAAC,OAAO,CAAU;AA1RtC,ICAMd,KAAOc,EAAO,CACzB,UACA,UACA,SACA,OACA,kBACA,gBACA,wBACA,YACA,cACA,WACA,UACA,WACA,eACA,eACA,WACA,QACA,SACA,SACA,SACA,QACA,WACA,YACA,gBACA,UACA,eACA,YACA,YACA,WACA,OACA,YACA,2BACA,yBACA,YACA,aACA,WACA,gBACA,eACA,QACA,OACA,WACA,UACA,UACA,QACA,QACA,YACA,MACA,SACA,aACA,aACA,SACA,QACA,SACA,QACA,QACA,WACA,QACA,OACA,OACA,aACA,SACA,UACA,OACA,aACA,YACA,SACA,QACA,SACA,WACA,cACA,UACA,QACA,WACA,QACA,WACA,eACA,eACA,WACA,iBACA,uBACA,UACA,WACA,WACA,cACA,YACA,OACA,YACA,OACA,YACA,QACA,QACA,WACA,cACA,SACA,YACA,SACA,QACA,SACA,QACA,QACA,WACA,SACA,OACA,UACA,QACA,SACA,WACA,YACA,SACA,aACA,QACA,UACA,UACA,SACA,SACA,QACA,SACA,MAAM,CACE;ADtHH,ICwHMb,KAAMa,EAAO,CACxB,iBACA,cACA,YACA,sBACA,aACA,UACA,iBACA,iBACA,WACA,iBACA,kBACA,SACA,QACA,MACA,SACA,QACA,iBACA,aACA,aACA,SACA,uBACA,+BACA,iBACA,mBACA,MACA,MACA,KACA,MACA,MACA,mBACA,aACA,WACA,WACA,OACA,YACA,aACA,OACA,YACA,QACA,gBACA,aACA,UACA,eACA,eACA,iBACA,eACA,aACA,oBACA,gBACA,cACA,gBACA,eACA,MACA,MACA,MACA,MACA,cACA,YACA,iBACA,qBACA,UACA,QACA,MACA,mBACA,MACA,OACA,aACA,KACA,MACA,MACA,MACA,MACA,WACA,aACA,cACA,YACA,QACA,gBACA,kBACA,gBACA,oBACA,kBACA,SACA,cACA,cACA,gBACA,gBACA,eACA,eACA,oBACA,aACA,OACA,QACA,aACA,SACA,UACA,QACA,OACA,QACA,cACA,UACA,YACA,WACA,SACA,UACA,eACA,UACA,YACA,eACA,QACA,cACA,uBACA,oBACA,gBACA,UACA,iBACA,uBACA,kBACA,KACA,MACA,MACA,UACA,QACA,QACA,eACA,aACA,WACA,UACA,UACA,SACA,QACA,mBACA,SACA,oBACA,oBACA,gBACA,eACA,gBACA,eACA,cACA,gBACA,oBACA,qBACA,kBACA,mBACA,qBACA,kBACA,UACA,gBACA,SACA,gBACA,kBACA,YACA,eACA,WACA,WACA,aACA,oBACA,eACA,mBACA,kBACA,cACA,QACA,MACA,MACA,WACA,UACA,WACA,cACA,WACA,cACA,iBACA,iBACA,SACA,gBACA,QACA,gBACA,oBACA,oBACA,KACA,MACA,MACA,SACA,KACA,MACA,MACA,KACA,YAAY,CACJ;ADrTH,ICuTMX,KAASW,EAAO,CAC3B,UACA,eACA,SACA,YACA,SACA,gBACA,eACA,cACA,cACA,SACA,OACA,WACA,gBACA,YACA,SACA,SACA,UACA,QACA,MACA,WACA,UACA,iBACA,UACA,UACA,kBACA,aACA,YACA,eACA,WACA,WACA,iBACA,YACA,YACA,QACA,YACA,YACA,cACA,WACA,UACA,UACA,eACA,iBACA,wBACA,aACA,aACA,cACA,YACA,kBACA,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AAAA;AAEL,eAAW,CAAE2J,GAAasB,EAAgB,KAAKhC,EAAW,oBACzD,KAAIjJ,EAAU,QAAQ2J,CAAW,EAAK,QAAOsB;IAAAA;EAI/C;EAMA,KAAK,OAAO,WAAW,IAAY;AAClC,WAAO;EACR;AACD;",
|
|
6
|
+
"names": ["unapply", "func", "thisArg", "RegExp", "lastIndex", "_len3", "arguments", "length", "args", "Array", "_key3", "apply", "unconstruct", "Func", "_len4", "_key4", "construct", "addToSet", "set", "array", "transformCaseFunc", "stringToLowerCase", "setPrototypeOf", "l", "element", "lcElement", "isFrozen", "cleanArray", "index", "objectHasOwnProperty", "clone", "object", "newObject", "create", "property", "value", "entries", "isArray", "constructor", "Object", "lookupGetter", "prop", "desc", "getOwnPropertyDescriptor", "get", "getPrototypeOf", "fallbackValue", "createDOMPurify", "window", "undefined", "getGlobal", "DOMPurify", "root", "version", "VERSION", "removed", "document", "nodeType", "NODE_TYPE", "Element", "isSupported", "originalDocument", "currentScript", "DocumentFragment", "HTMLTemplateElement", "Node", "NodeFilter", "NamedNodeMap", "MozNamedAttrMap", "HTMLFormElement", "DOMParser", "trustedTypes", "ElementPrototype", "prototype", "cloneNode", "remove", "getNextSibling", "getChildNodes", "getParentNode", "template", "createElement", "content", "ownerDocument", "trustedTypesPolicy", "emptyHTML", "implementation", "createNodeIterator", "createDocumentFragment", "getElementsByTagName", "importNode", "hooks", "_createHooksMap", "createHTMLDocument", "MUSTACHE_EXPR", "ERB_EXPR", "TMPLIT_EXPR", "DATA_ATTR", "ARIA_ATTR", "IS_SCRIPT_OR_DATA", "ATTR_WHITESPACE", "CUSTOM_ELEMENT", "EXPRESSIONS", "IS_ALLOWED_URI", "ALLOWED_TAGS", "DEFAULT_ALLOWED_TAGS", "TAGS", "ALLOWED_ATTR", "DEFAULT_ALLOWED_ATTR", "ATTRS", "CUSTOM_ELEMENT_HANDLING", "seal", "tagNameCheck", "writable", "configurable", "enumerable", "attributeNameCheck", "allowCustomizedBuiltInElements", "FORBID_TAGS", "FORBID_ATTR", "EXTRA_ELEMENT_HANDLING", "tagCheck", "attributeCheck", "ALLOW_ARIA_ATTR", "ALLOW_DATA_ATTR", "ALLOW_UNKNOWN_PROTOCOLS", "ALLOW_SELF_CLOSE_IN_ATTR", "SAFE_FOR_TEMPLATES", "SAFE_FOR_XML", "WHOLE_DOCUMENT", "SET_CONFIG", "FORCE_BODY", "RETURN_DOM", "RETURN_DOM_FRAGMENT", "RETURN_TRUSTED_TYPE", "SANITIZE_DOM", "SANITIZE_NAMED_PROPS", "SANITIZE_NAMED_PROPS_PREFIX", "KEEP_CONTENT", "IN_PLACE", "USE_PROFILES", "FORBID_CONTENTS", "DEFAULT_FORBID_CONTENTS", "DATA_URI_TAGS", "DEFAULT_DATA_URI_TAGS", "URI_SAFE_ATTRIBUTES", "DEFAULT_URI_SAFE_ATTRIBUTES", "MATHML_NAMESPACE", "SVG_NAMESPACE", "HTML_NAMESPACE", "NAMESPACE", "IS_EMPTY_INPUT", "ALLOWED_NAMESPACES", "DEFAULT_ALLOWED_NAMESPACES", "stringToString", "MATHML_TEXT_INTEGRATION_POINTS", "HTML_INTEGRATION_POINTS", "COMMON_SVG_AND_HTML_ELEMENTS", "PARSER_MEDIA_TYPE", "SUPPORTED_PARSER_MEDIA_TYPES", "DEFAULT_PARSER_MEDIA_TYPE", "CONFIG", "formElement", "isRegexOrFunction", "testValue", "Function", "_parseConfig", "cfg", "indexOf", "ADD_URI_SAFE_ATTR", "ADD_DATA_URI_TAGS", "ALLOWED_URI_REGEXP", "html", "svg", "svgFilters", "mathMl", "ADD_TAGS", "ADD_ATTR", "ADD_FORBID_CONTENTS", "table", "tbody", "TRUSTED_TYPES_POLICY", "createHTML", "typeErrorCreate", "createScriptURL", "_createTrustedTypesPolicy", "freeze", "ALL_SVG_TAGS", "ALL_MATHML_TAGS", "_checkValidNamespace", "parent", "tagName", "namespaceURI", "parentTagName", "Boolean", "_forceRemove", "node", "arrayPush", "removeChild", "_removeAttribute", "name", "attribute", "getAttributeNode", "from", "removeAttribute", "setAttribute", "_initDocument", "dirty", "doc", "leadingWhitespace", "matches", "stringMatch", "dirtyPayload", "parseFromString", "documentElement", "createDocument", "innerHTML", "body", "insertBefore", "createTextNode", "childNodes", "call", "_createNodeIterator", "SHOW_ELEMENT", "SHOW_COMMENT", "SHOW_TEXT", "SHOW_PROCESSING_INSTRUCTION", "SHOW_CDATA_SECTION", "_isClobbered", "nodeName", "textContent", "attributes", "hasChildNodes", "_isNode", "_executeHooks", "currentNode", "data", "arrayForEach", "hook", "_sanitizeElements", "beforeSanitizeElements", "uponSanitizeElement", "allowedTags", "firstElementChild", "regExpTest", "progressingInstruction", "comment", "_isBasicCustomElement", "parentNode", "childCount", "i", "childClone", "__removalCount", "text", "expr", "stringReplace", "afterSanitizeElements", "_isValidAttribute", "lcTag", "lcName", "stringIndexOf", "_sanitizeAttributes", "beforeSanitizeAttributes", "hookEvent", "attrName", "attrValue", "keepAttr", "allowedAttributes", "forceKeepAttr", "attr", "initValue", "stringTrim", "uponSanitizeAttribute", "getAttributeType", "setAttributeNS", "arrayPop", "afterSanitizeAttributes", "_sanitizeShadowDOM", "fragment", "shadowNode", "shadowIterator", "beforeSanitizeShadowDOM", "nextNode", "uponSanitizeShadowNode", "afterSanitizeShadowDOM", "sanitize", "importedNode", "returnNode", "toString", "appendChild", "firstChild", "nodeIterator", "shadowroot", "shadowrootmode", "serializedHTML", "outerHTML", "doctype", "setConfig", "clearConfig", "isValidAttribute", "tag", "addHook", "entryPoint", "hookFunction", "removeHook", "arrayLastIndexOf", "arraySplice", "removeHooks", "removeAllHooks", "svgDisallowed", "mathMlDisallowed", "xml", "DOCTYPE_NAME", "purify", "Reflect", "x", "_len", "_key", "_len2", "_key2", "forEach", "lastIndexOf", "pop", "push", "splice", "String", "toLowerCase", "match", "replace", "trim", "hasOwnProperty", "test", "TypeError", "cdataSection", "entityReference", "entityNode", "documentType", "documentFragment", "notation", "purifyHostElement", "createPolicy", "suffix", "ATTR_NAME", "hasAttribute", "getAttribute", "policyName", "scriptUrl", "console", "warn", "httpTokenCodePoints", "matcher", "httpQuotedStringTokenCodePoints", "MediaTypeParameters", "_MediaTypeParameters", "entries", "name", "value", "whitespaceChars", "trailingWhitespace", "leadingAndTrailingWhitespace", "MediaTypeParser", "_MediaTypeParser", "input", "position", "type", "typeEnd", "subtype", "subtypeEnd", "parameters", "pos", "stopChars", "lowerCase", "trim", "result", "length", "char", "component", "MediaType", "_MediaType", "mediaType", "SetMultiMap", "key", "defaultValue", "compute", "iterator", "values", "deleted", "ContextEventHandler", "context", "eventHandler", "event", "data", "Subscription", "eventName", "contextEventHandler", "Subscribr", "u", "errorHandler", "options", "originalHandler", "subscription", "contextEventHandlers", "removed", "error", "HttpError", "status", "message", "cause", "entity", "url", "method", "timing", "ResponseStatus", "code", "text", "charset", "endsWithSlashRegEx", "XSRF_COOKIE_NAME", "XSRF_HEADER_NAME", "mediaTypes", "h", "defaultMediaType", "defaultOrigin", "RequestCachingPolicy", "RequestEvent", "SignalEvents", "SignalErrors", "eventListenerOptions", "abortEvent", "timeoutEvent", "requestBodyMethods", "internalServerError", "aborted", "timedOut", "retryStatusCodes", "retryMethods", "retryDelay", "retryBackoffFactor", "SignalController", "signal", "timeout", "signals", "reason", "eventListener", "domReady", "purify", "ensureDom", "JSDOM", "window", "p", "parseSanitizedDocument", "response", "mimeType", "withObjectURL", "executor", "objectURL", "res", "rej", "handleText", "handleScript", "resolve", "reject", "script", "handleCss", "link", "handleJson", "handleBlob", "handleImage", "img", "handleBuffer", "handleReadableStream", "handleXml", "handleHtml", "handleHtmlFragment", "handleHtmlFragmentWithScripts", "readDelimited", "body", "delimiter", "flushRemaining", "reader", "decoder", "buffer", "index", "done", "remaining", "parseServerSentEvent", "rawEvent", "id", "retry", "dataLines", "lines", "line", "colonIndex", "field", "n", "handleEventStream", "sse", "handleNdjsonStream", "trimmed", "isRequestBodyMethod", "isRawBody", "getCookieValue", "prefix", "cookies", "i", "cookie", "serialize", "isString", "isArrayBuffer", "isObject", "objectMerge", "objects", "obj", "deepClone", "target", "source", "property", "sourceValue", "targetValue", "item", "object", "cloned", "keys", "Transportr", "_Transportr", "d", "handler", "eventRegistration", "signalController", "requests", "controllers", "promises", "controller", "controller_1", "contentType", "hooks", "headers", "searchParams", "path", "requestConfig", "requestOptions", "unwrap", "requestHooks", "beforeRequestHookSets", "hook", "afterResponseHookSets", "allowHeader", "allowedMethods", "parts", "selector", "doc", "allowScripts", "fragment", "afterResponse", "stream", "userOptions", "responseHandler", "global", "retryConfig", "canRetry", "canDedupe", "attempt", "startTime", "getTiming", "end", "dedupeKey", "inflight", "originalBody", "onUploadProgress", "wrapUploadBody", "bytes", "total", "readable", "loaded", "transform", "chunk", "doFetch", "wrapProgress", "onDownloadProgress", "contentLength", "typedResponse", "config", "ms", "resolvedPath", "resolvedBody", "resolvedOptions", "userHeaders", "userSearchParams", "headerSources", "sources", "userBody", "instanceBody", "isJson", "xsrf", "cookieName", "headerName", "token", "requestUrl", "errorName", "statusText"]
|
|
7
|
+
}
|