@d1g1tal/transportr 4.0.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +46 -1
- package/dist/CLKJRXYL.js +9 -0
- package/dist/CLKJRXYL.js.map +7 -0
- package/dist/iife/transportr.js +9 -9
- package/dist/iife/transportr.js.map +4 -4
- package/dist/transportr.d.ts +30 -3
- package/dist/transportr.js +5 -5
- package/dist/transportr.js.map +4 -4
- package/package.json +25 -16
- package/dist/E2K75FBD.js +0 -9
- package/dist/E2K75FBD.js.map +0 -7
package/dist/transportr.d.ts
CHANGED
|
@@ -621,6 +621,22 @@ type TypedHeaders = {
|
|
|
621
621
|
[RequestHeader.CONTENT_TYPE]?: MediaTypeValues;
|
|
622
622
|
};
|
|
623
623
|
type EventRegistration = Subscription;
|
|
624
|
+
type SanitizationPreset = 'strict' | 'balanced' | 'relaxed' | 'bypass';
|
|
625
|
+
type SanitizationPolicy = {
|
|
626
|
+
preset?: SanitizationPreset;
|
|
627
|
+
preserveTemplateScripts?: boolean;
|
|
628
|
+
templateScriptTypes?: string[];
|
|
629
|
+
/**
|
|
630
|
+
* Allows real, executable `<script>` elements (any `type`, including a remote `src`) to survive
|
|
631
|
+
* sanitization by adding `script` to DOMPurify's allowed tags — while all other markup (inline
|
|
632
|
+
* event handlers, `javascript:` URLs, `<iframe>`, etc.) is still sanitized normally.
|
|
633
|
+
*
|
|
634
|
+
* **Security Warning:** DOMPurify does not analyze or validate the JavaScript inside an allowed
|
|
635
|
+
* `<script>` element — any code present executes as-is when injected into the DOM. Only enable
|
|
636
|
+
* this for trusted content. Defaults to false.
|
|
637
|
+
*/
|
|
638
|
+
allowScripts?: boolean;
|
|
639
|
+
};
|
|
624
640
|
type MethodBody = {
|
|
625
641
|
method?: RequestBodyMethod;
|
|
626
642
|
body?: RequestBody;
|
|
@@ -648,8 +664,19 @@ type RequestOptions = Prettify<{
|
|
|
648
664
|
onUploadProgress?: (progress: DownloadProgress) => void;
|
|
649
665
|
/** When false, methods return Result tuples instead of throwing. Defaults to true (throw on error). */
|
|
650
666
|
unwrap?: boolean;
|
|
651
|
-
/**
|
|
652
|
-
|
|
667
|
+
/**
|
|
668
|
+
* User-friendly sanitization preset for HTML/XML/fragment responses.
|
|
669
|
+
* - strict: default DOMPurify behavior
|
|
670
|
+
* - balanced: standard DOMPurify with conservative compatibility options
|
|
671
|
+
* - relaxed: more permissive DOMPurify options for legacy-compatible markup
|
|
672
|
+
* - bypass: skip DOMPurify entirely (trusted content only)
|
|
673
|
+
*/
|
|
674
|
+
sanitizePreset?: SanitizationPreset;
|
|
675
|
+
/**
|
|
676
|
+
* Advanced sanitization policy for HTML/XML/fragment responses.
|
|
677
|
+
* Use this to preserve inert template scripts while keeping sanitization enabled.
|
|
678
|
+
*/
|
|
679
|
+
sanitization?: SanitizationPolicy;
|
|
653
680
|
} & Omit<RequestInit, 'headers' | 'body' | 'method'> & MethodBody>;
|
|
654
681
|
/** Configuration for retry behavior on failed requests. */
|
|
655
682
|
type RetryOptions = {
|
|
@@ -1175,4 +1202,4 @@ declare class Transportr {
|
|
|
1175
1202
|
}
|
|
1176
1203
|
|
|
1177
1204
|
export { ContentType, DownloadProgress, HttpError, HttpErrorOptions, Json, JsonArray, JsonObject, JsonPrimitive, JsonString, JsonValue, RequestCachingPolicy, RequestEvent, RequestHeader, RequestTiming, ResponseBody, ResponseStatus, Result, RetryInfo, ServerSentEvent, SignalErrors, SignalEvents, Transportr, XSRF_COOKIE_NAME, XSRF_HEADER_NAME, abortEvent, aborted, defaultMediaType, defaultOrigin, endsWithSlashRegEx, eventListenerOptions, internalServerError, mediaTypes, requestBodyMethods, retryBackoffFactor, retryDelay, retryMethods, retryStatusCodes, timedOut, timeoutEvent };
|
|
1178
|
-
export type { AbortConfiguration, AbortEvent, AbortSignalEvent, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Entries, EventRegistration, HookOptions, NormalizedRetryOptions, PublishOptions, ReadOnlyEntries, RequestBody, RequestBodyMethod, RequestEventDataMap, RequestEventHandler, RequestHeaders, RequestLifecycleEvent, RequestMethod, RequestOptions, ResponseHandler, RetryOptions, SearchParameters, TimeoutEvent, TypedArray, TypedRequestEventHandler, TypedResponse, XsrfOptions };
|
|
1205
|
+
export type { AbortConfiguration, AbortEvent, AbortSignalEvent, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Entries, EventRegistration, HookOptions, NormalizedRetryOptions, PublishOptions, ReadOnlyEntries, RequestBody, RequestBodyMethod, RequestEventDataMap, RequestEventHandler, RequestHeaders, RequestLifecycleEvent, RequestMethod, RequestOptions, ResponseHandler, RetryOptions, SanitizationPolicy, SanitizationPreset, SearchParameters, TimeoutEvent, TypedArray, TypedRequestEventHandler, TypedResponse, XsrfOptions };
|
package/dist/transportr.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var I=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,xe=/(["\\])/ug,ke=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,L=n=>{for(let e=0,t=n.length;e<t;e++){let s=n.charCodeAt(e);if(s>=65&&s<=90)return n.toLowerCase()}return n},oe=class ie extends Map{constructor(e=[]){super(e)}static isValid(e,t){return I.test(e)&&ke.test(t)}get(e){return super.get(L(e))}has(e){return super.has(L(e))}set(e,t){if(!ie.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(L(e),t),this}delete(e){return super.delete(L(e))}toString(){let e="";for(let[t,s]of this)e+=";",e+=t,e+="=",s.length===0||!I.test(s)?(e+='"',e+=s.replace(xe,"\\$1"),e+='"'):e+=s;return e}get[Symbol.toStringTag](){return"MediaTypeParameters"}},v=n=>n===32||n===9||n===10||n===13,Le=Map.prototype.set,Ie=Map.prototype.has,Me=class b{constructor(){}static parse(e){let t=0,s=e.length;for(;t<s&&v(e.charCodeAt(t));)t++;for(;s>t&&v(e.charCodeAt(s-1));)s--;(t!==0||s!==e.length)&&(e=e.slice(t,s));let r=e.length,o=0;for(;o<r&&e.charCodeAt(o)!==47;)o++;if(o===0||o>=r)throw new TypeError(b.#s("type",e.slice(0,o)));let i=e.slice(0,o);if(!I.test(i))throw new TypeError(b.#s("type",i));i=i.toLowerCase(),o++;let a=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let d=o;for(;d>a&&v(e.charCodeAt(d-1));)d--;if(d===a)throw new TypeError(b.#s("subtype",""));let u=e.slice(a,d);if(!I.test(u))throw new TypeError(b.#s("subtype",u));u=u.toLowerCase();let l=new oe;for(;o<r;){for(o++;o<r&&v(e.charCodeAt(o));)o++;let c=o;for(;o<r;){let p=e.charCodeAt(o);if(p===59||p===61)break;o++}let f=c===o?"":e.slice(c,o);if(o>=r||e.charCodeAt(o)===59)continue;o++;let R;if(o<r&&e.charCodeAt(o)===34){o=b.#t(e,o,r),R=b.#e;let p=e.indexOf(";",o);o=p===-1?r:p}else{let p=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let y=o;for(;y>p&&v(e.charCodeAt(y-1));)y--;if(y===p)continue;R=e.slice(p,y)}if(f.length!==0&&oe.isValid(f,R)){let p=f.toLowerCase();Ie.call(l,p)||Le.call(l,p,R)}}return{type:i,subtype:u,parameters:l}}static#e="";static#t(e,t,s){t++;let r=t;for(;t<s;){let i=e.charCodeAt(t);if(i===34||i===92)break;t++}if(t>=s)return b.#e=e.slice(r,t),t;if(e.charCodeAt(t)===34)return b.#e=e.slice(r,t),t+1;let o=e.slice(r,t);for(;t<s;){let i=e.charCodeAt(t);if(i===34){t++;break}i===92&&t+1<s&&t++,o+=e[t],t++}return b.#e=o,t}static#s(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},M=class ae{#e;#t;#s;#n;constructor(e,t){if({type:this.#e,subtype:this.#t,parameters:this.#n}=Me.parse(e),this.#s=this.#e+"/"+this.#t,t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.#n.set(s,t[s])}}static parse(e){try{return new ae(e)}catch{}return null}get type(){return this.#e}get subtype(){return this.#t}get essence(){return this.#s}get parameters(){return this.#n}matches(e){return typeof e=="string"?this.#s===e:this.#e===e.#e&&this.#t===e.#t}toString(){return this.#s+this.#n.toString()}get[Symbol.toStringTag](){return"MediaType"}};var Ue=class extends Map{set(n,e){return super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),this}getOrInsert(n,e){return this.has(n)?super.get(n):(super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),e)}getOrInsertComputed(n,e){if(this.has(n))return super.get(n);let t=e(n);return super.set(n,t instanceof Set?t:(super.get(n)??new Set).add(t)),t}find(n,e){let t=this.get(n);if(t!==void 0)return Array.from(t).find(e)}hasValue(n,e){let t=super.get(n);return t?t.has(e):!1}deleteValue(n,e){if(e===void 0)return this.delete(n);let t=super.get(n);if(t){let s=t.delete(e);return t.size===0&&super.delete(n),s}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},Ne=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}handle(n,e){this.#t.call(this.#e,n,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},De=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}get eventName(){return this.#e}get contextEventHandler(){return this.#t}get[Symbol.toStringTag](){return"Subscription"}},U=class{#e=new Ue;#t;setErrorHandler(n){this.#t=n}subscribe(n,e,t=e,s){if(this.#s(n),s?.once){let i=e;e=(a,d)=>{i.call(t,a,d),this.unsubscribe(o)}}let r=new Ne(t,e);this.#e.set(n,r);let o=new De(n,r);return o}unsubscribe({eventName:n,contextEventHandler:e}){let t=this.#e.get(n);if(!t)return!1;let s=t.delete(e);return s&&t.size===0&&this.#e.delete(n),s}publish(n,e=new CustomEvent(n),t){this.#s(n),this.#e.get(n)?.forEach(s=>{try{s.handle(e,t)}catch(r){this.#t?this.#t(r,n,e,t):console.error(`Error in event handler for '${n}':`,r)}})}isSubscribed({eventName:n,contextEventHandler:e}){return this.#e.get(n)?.has(e)??!1}#s(n){if(!n||typeof n!="string")throw new TypeError("Event name must be a non-empty string");if(n.trim()!==n)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.#e.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var O=class extends Error{#e;#t;#s;#n;#o;constructor(e,{message:t,cause:s,entity:r,url:o,method:i,timing:a}={}){super(t,{cause:s}),this.#e=r,this.#t=e,this.#s=o,this.#n=i,this.#o=a}get entity(){return this.#e}get statusCode(){return this.#t.code}get statusText(){return this.#t?.text}get url(){return this.#s}get method(){return this.#n}get timing(){return this.#o}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var E=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get code(){return this.#e}get text(){return this.#t}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this.#e} ${this.#t}`}};var ue="XSRF-TOKEN",de="X-XSRF-TOKEN",h={PNG:"image/png",TEXT:"text/plain",JSON:"application/json",HTML:"text/html",JAVA_SCRIPT:"text/javascript",CSS:"text/css",XML:"application/xml",BIN:"application/octet-stream",EVENT_STREAM:"text/event-stream",NDJSON:"application/x-ndjson"},Fe={charset:"utf-8"},A=new M(h.JSON,Fe),W=globalThis.location?.origin??"http://localhost",le={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},g={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},w={ABORT:"abort",TIMEOUT:"timeout"},q={ABORT:"AbortError",TIMEOUT:"TimeoutError"},B={once:!0,passive:!0},N=()=>new CustomEvent(w.ABORT,{detail:{cause:q.ABORT}}),ce=()=>new CustomEvent(w.TIMEOUT,{detail:{cause:q.TIMEOUT}}),pe=["POST","PUT","PATCH","DELETE"],fe=new E(500,"Internal Server Error"),Re=new E(499,"Aborted"),he=new E(504,"Request Timeout"),K=[408,413,429,500,502,503,504],Y=["GET","PUT","HEAD","DELETE","OPTIONS"],D=300,F=2;var j=class{#e;#t=new AbortController;#s;#n;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let s=e!=null,r=t!==1/0;if(!s&&!r){this.#e=this.#t.signal,this.#n=!1;return}let o=[this.#t.signal];s&&o.push(e),r&&o.push(AbortSignal.timeout(t)),this.#e=AbortSignal.any(o),this.#n=!0,r&&this.#e.addEventListener(w.ABORT,this,B)}handleEvent({target:{reason:e}}){this.#t.signal.aborted||e instanceof DOMException&&e.name===q.TIMEOUT&&this.#e.dispatchEvent(ce())}get signal(){return this.#e}onAbort(e){return this.#o(w.ABORT,e)}onTimeout(e){return this.#o(w.TIMEOUT,e)}abort(e=N()){this.#t.abort(e.detail?.cause)}destroy(){this.#n&&this.#e.removeEventListener(w.ABORT,this,B);let e=this.#s;if(e!==void 0){for(let[t,s]of e)this.#e.removeEventListener(s,t,B);e.clear()}return this}#o(e,t){return this.#e.addEventListener(e,t,B),(this.#s??=new Map).set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var J,$,G=()=>J||(J=(typeof document>"u"||typeof DOMParser>"u"||typeof DocumentFragment>"u"?import("jsdom").then(({JSDOM:e})=>{let{window:t}=new e("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=t,Object.assign(globalThis,{document:t.document,DOMParser:t.DOMParser,DocumentFragment:t.DocumentFragment})}).catch(()=>{throw J=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")}):Promise.resolve()).then(()=>import("./E2K75FBD.js")).then(({default:e})=>{$=e})),me=async(n,e)=>(await G(),new DOMParser().parseFromString($.sanitize(await n.text()),e)),Z=async(n,e)=>{await G();let t=URL.createObjectURL(await n.blob());try{return new Promise((s,r)=>e(t,s,r))}finally{URL.revokeObjectURL(t)}},ge=n=>n.text(),Q=n=>Z(n,(e,t,s)=>{let r=Object.assign(document.createElement("script"),{src:e,type:"text/javascript",async:!0});r.onload=()=>{document.head.removeChild(r),t()},r.onerror=()=>{document.head.removeChild(r),s(new Error("Script failed to load"))},document.head.appendChild(r)}),_=n=>Z(n,(e,t,s)=>{let r=Object.assign(document.createElement("link"),{href:e,type:"text/css",rel:"stylesheet"});r.onload=()=>t(),r.onerror=()=>{document.head.removeChild(r),s(new Error("Stylesheet load failed"))},document.head.appendChild(r)}),H=n=>n.json(),ye=n=>n.blob(),ee=n=>Z(n,(e,t,s)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>s(new Error("Image failed to load")),r.src=e}),be=n=>n.arrayBuffer(),te=n=>Promise.resolve(n.body),C=async n=>me(n,"application/xml"),ne=async n=>me(n,"text/html"),Te=async n=>(await G(),document.createRange().createContextualFragment($.sanitize(await n.text()))),Oe=async n=>{await G();let t=document.createRange().createContextualFragment($.sanitize(`<div>${await n.text()}</div>`,{ADD_TAGS:["script"]})).firstElementChild,s=document.createDocumentFragment();if(t)for(;t.firstChild;)s.append(t.firstChild);return s};async function*Ee(n,e,t){let s=n.getReader(),r=new TextDecoder,o=e.length,i="",a=0;try{for(;;){let d;for(;(d=i.indexOf(e,a))!==-1;)yield i.slice(a,d),a=d+o;a>0&&a>=i.length-a&&(i=a<i.length?i.slice(a):"",a=0);let{done:u,value:l}=await s.read();if(u)break;i+=r.decode(l,{stream:!0})}if(t){let u=((a<i.length?i.slice(a):"")+r.decode()).trim();u&&(yield u)}}finally{await s.cancel()}}var je=n=>{let e="message",t="",s,r,o,i=n.split(`
|
|
2
|
-
`);for(let d=0,u,l=i.length;d<l;d++){if(u=i[d],u.charCodeAt(0)===58)continue;let c=u.indexOf(":"),f
|
|
1
|
+
var D=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u,De=/(["\\])/ug,ze=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,N=n=>{for(let e=0,t=n.length;e<t;e++){let s=n.charCodeAt(e);if(s>=65&&s<=90)return n.toLowerCase()}return n},ae=class ue extends Map{constructor(e=[]){super(e)}static isValid(e,t){return D.test(e)&&ze.test(t)}get(e){return super.get(N(e))}has(e){return super.has(N(e))}set(e,t){if(!ue.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(N(e),t),this}delete(e){return super.delete(N(e))}toString(){let e="";for(let[t,s]of this)e+=";",e+=t,e+="=",s.length===0||!D.test(s)?(e+='"',e+=s.replace(De,"\\$1"),e+='"'):e+=s;return e}get[Symbol.toStringTag](){return"MediaTypeParameters"}},k=n=>n===32||n===9||n===10||n===13,Fe=Map.prototype.set,je=Map.prototype.has,Je=class O{constructor(){}static parse(e){let t=0,s=e.length;for(;t<s&&k(e.charCodeAt(t));)t++;for(;s>t&&k(e.charCodeAt(s-1));)s--;(t!==0||s!==e.length)&&(e=e.slice(t,s));let r=e.length,o=0;for(;o<r&&e.charCodeAt(o)!==47;)o++;if(o===0||o>=r)throw new TypeError(O.#s("type",e.slice(0,o)));let i=e.slice(0,o);if(!D.test(i))throw new TypeError(O.#s("type",i));i=i.toLowerCase(),o++;let a=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let d=o;for(;d>a&&k(e.charCodeAt(d-1));)d--;if(d===a)throw new TypeError(O.#s("subtype",""));let u=e.slice(a,d);if(!D.test(u))throw new TypeError(O.#s("subtype",u));u=u.toLowerCase();let l=new ae;for(;o<r;){for(o++;o<r&&k(e.charCodeAt(o));)o++;let c=o;for(;o<r;){let R=e.charCodeAt(o);if(R===59||R===61)break;o++}let p=c===o?"":e.slice(c,o);if(o>=r||e.charCodeAt(o)===59)continue;o++;let f;if(o<r&&e.charCodeAt(o)===34){o=O.#t(e,o,r),f=O.#e;let R=e.indexOf(";",o);o=R===-1?r:R}else{let R=o;for(;o<r&&e.charCodeAt(o)!==59;)o++;let h=o;for(;h>R&&k(e.charCodeAt(h-1));)h--;if(h===R)continue;f=e.slice(R,h)}if(p.length!==0&&ae.isValid(p,f)){let R=p.toLowerCase();je.call(l,R)||Fe.call(l,R,f)}}return{type:i,subtype:u,parameters:l}}static#e="";static#t(e,t,s){t++;let r=t;for(;t<s;){let i=e.charCodeAt(t);if(i===34||i===92)break;t++}if(t>=s)return O.#e=e.slice(r,t),t;if(e.charCodeAt(t)===34)return O.#e=e.slice(r,t),t+1;let o=e.slice(r,t);for(;t<s;){let i=e.charCodeAt(t);if(i===34){t++;break}i===92&&t+1<s&&t++,o+=e[t],t++}return O.#e=o,t}static#s(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}},z=class de{#e;#t;#s;#n;constructor(e,t){if({type:this.#e,subtype:this.#t,parameters:this.#n}=Je.parse(e),this.#s=this.#e+"/"+this.#t,t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.#n.set(s,t[s])}}static parse(e){try{return new de(e)}catch{}return null}get type(){return this.#e}get subtype(){return this.#t}get essence(){return this.#s}get parameters(){return this.#n}matches(e){return typeof e=="string"?this.#s===e:this.#e===e.#e&&this.#t===e.#t}toString(){return this.#s+this.#n.toString()}get[Symbol.toStringTag](){return"MediaType"}};var $e=class extends Map{set(n,e){return super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),this}getOrInsert(n,e){return this.has(n)?super.get(n):(super.set(n,e instanceof Set?e:(super.get(n)??new Set).add(e)),e)}getOrInsertComputed(n,e){if(this.has(n))return super.get(n);let t=e(n);return super.set(n,t instanceof Set?t:(super.get(n)??new Set).add(t)),t}find(n,e){let t=this.get(n);if(t!==void 0)return Array.from(t).find(e)}hasValue(n,e){let t=super.get(n);return t?t.has(e):!1}deleteValue(n,e){if(e===void 0)return this.delete(n);let t=super.get(n);if(t){let s=t.delete(e);return t.size===0&&super.delete(n),s}return!1}get[Symbol.toStringTag](){return"SetMultiMap"}},Ge=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}handle(n,e){this.#t.call(this.#e,n,e)}get[Symbol.toStringTag](){return"ContextEventHandler"}},We=class{#e;#t;constructor(n,e){this.#e=n,this.#t=e}get eventName(){return this.#e}get contextEventHandler(){return this.#t}get[Symbol.toStringTag](){return"Subscription"}},F=class{#e=new $e;#t;setErrorHandler(n){this.#t=n}subscribe(n,e,t=e,s){if(this.#s(n),s?.once){let i=e;e=(a,d)=>{i.call(t,a,d),this.unsubscribe(o)}}let r=new Ge(t,e);this.#e.set(n,r);let o=new We(n,r);return o}unsubscribe({eventName:n,contextEventHandler:e}){let t=this.#e.get(n);if(!t)return!1;let s=t.delete(e);return s&&t.size===0&&this.#e.delete(n),s}publish(n,e=new CustomEvent(n),t){this.#s(n),this.#e.get(n)?.forEach(s=>{try{s.handle(e,t)}catch(r){this.#t?this.#t(r,n,e,t):console.error(`Error in event handler for '${n}':`,r)}})}isSubscribed({eventName:n,contextEventHandler:e}){return this.#e.get(n)?.has(e)??!1}#s(n){if(!n||typeof n!="string")throw new TypeError("Event name must be a non-empty string");if(n.trim()!==n)throw new Error("Event name cannot have leading or trailing whitespace")}destroy(){this.#e.clear()}get[Symbol.toStringTag](){return"Subscribr"}};var q=class extends Error{#e;#t;#s;#n;#o;constructor(e,{message:t,cause:s,entity:r,url:o,method:i,timing:a}={}){super(t,{cause:s}),this.#e=r,this.#t=e,this.#s=o,this.#n=i,this.#o=a}get entity(){return this.#e}get statusCode(){return this.#t.code}get statusText(){return this.#t?.text}get url(){return this.#s}get method(){return this.#n}get timing(){return this.#o}get name(){return"HttpError"}get[Symbol.toStringTag](){return this.name}};var P=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get code(){return this.#e}get text(){return this.#t}get[Symbol.toStringTag](){return"ResponseStatus"}toString(){return`${this.#e} ${this.#t}`}};var le="XSRF-TOKEN",ce="X-XSRF-TOKEN",m={PNG:"image/png",TEXT:"text/plain",JSON:"application/json",HTML:"text/html",JAVA_SCRIPT:"text/javascript",CSS:"text/css",XML:"application/xml",BIN:"application/octet-stream",EVENT_STREAM:"text/event-stream",NDJSON:"application/x-ndjson"},Xe={charset:"utf-8"},L=new z(m.JSON,Xe),K=globalThis.location?.origin??"http://localhost",pe={DEFAULT:"default",FORCE_CACHE:"force-cache",NO_CACHE:"no-cache",NO_STORE:"no-store",ONLY_IF_CACHED:"only-if-cached",RELOAD:"reload"},y={CONFIGURED:"configured",SUCCESS:"success",ERROR:"error",ABORTED:"aborted",TIMEOUT:"timeout",RETRY:"retry",COMPLETE:"complete",ALL_COMPLETE:"all-complete"},A={ABORT:"abort",TIMEOUT:"timeout"},B={ABORT:"AbortError",TIMEOUT:"TimeoutError"},M={once:!0,passive:!0},j=()=>new CustomEvent(A.ABORT,{detail:{cause:B.ABORT}}),fe=()=>new CustomEvent(A.TIMEOUT,{detail:{cause:B.TIMEOUT}}),Re=["POST","PUT","PATCH","DELETE"],he=new P(500,"Internal Server Error"),me=new P(499,"Aborted"),ge=new P(504,"Request Timeout"),Y=[408,413,429,500,502,503,504],Z=["GET","PUT","HEAD","DELETE","OPTIONS"],J=300,$=2;var G=class{#e;#t=new AbortController;#s;#n;constructor({signal:e,timeout:t=1/0}={}){if(t<0)throw new RangeError("The timeout cannot be negative");let s=e!=null,r=t!==1/0;if(!s&&!r){this.#e=this.#t.signal,this.#n=!1;return}let o=[this.#t.signal];s&&o.push(e),r&&o.push(AbortSignal.timeout(t)),this.#e=AbortSignal.any(o),this.#n=!0,r&&this.#e.addEventListener(A.ABORT,this,M)}handleEvent({target:{reason:e}}){this.#t.signal.aborted||e instanceof DOMException&&e.name===B.TIMEOUT&&this.#e.dispatchEvent(fe())}get signal(){return this.#e}onAbort(e){return this.#o(A.ABORT,e)}onTimeout(e){return this.#o(A.TIMEOUT,e)}abort(e=j()){this.#t.abort(e.detail?.cause)}destroy(){this.#n&&this.#e.removeEventListener(A.ABORT,this,M);let e=this.#s;if(e!==void 0){for(let[t,s]of e)this.#e.removeEventListener(s,t,M);e.clear()}return this}#o(e,t){return this.#e.addEventListener(e,t,M),(this.#s??=new Map).set(t,e),this}get[Symbol.toStringTag](){return"SignalController"}};var ye=n=>n!==void 0&&Re.includes(n),Te=n=>n instanceof FormData||n instanceof Blob||n instanceof ArrayBuffer||n instanceof ReadableStream||n instanceof URLSearchParams||ArrayBuffer.isView(n),be=n=>{if(typeof document>"u")return;let e=document.cookie;if(!e)return;let t=`${n}=`,s=t.length,r=e.length,o=0;for(;o<r;){for(;o<r&&e.charCodeAt(o)===32;)o++;let i=e.indexOf(";",o);if(i===-1&&(i=r),i-o>=s&&e.startsWith(t,o))return decodeURIComponent(e.slice(o+s,i));o=i+1}},Oe=n=>JSON.stringify(n),H=n=>n!==null&&typeof n=="string",Se=n=>n instanceof ArrayBuffer||Object.prototype.toString.call(n)==="[object ArrayBuffer]",g=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype,W=(...n)=>{let e=n.length;if(e===0)return;if(e===1){let[s]=n;return g(s)?Q(s):s}let t={};for(let s=0,r=n.length;s<r;s++){let o=n[s];if(!g(o))return;let i=Object.keys(o);for(let a=0,d=i.length;a<d;a++){let u=i[a],l=o[u],c=t[u];if(Array.isArray(l))if(Array.isArray(c)){let p=l.slice();for(let f=0,R=c.length;f<R;f++){let h=c[f];l.includes(h)||p.push(h)}t[u]=p}else t[u]=l.slice();else g(l)?t[u]=g(c)?W(c,l):Q(l):t[u]=l}}return t};function Q(n){if(g(n)){let e={},t=Object.keys(n);for(let s=0,r=t.length,o;s<r;s++)o=t[s],e[o]=Q(n[o]);return e}return n}var Ve=n=>{throw new Error(`Unhandled sanitization preset: ${n}`)},we={ALLOW_ARIA_ATTR:!0,ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!0},Ke={...we,ALLOW_UNKNOWN_PROTOCOLS:!0},Ye=["text/x-jquery-tmpl","text/x-jquery-template","text/template","text/ng-template","text/x-handlebars-template","text/x-mustache-template"],X=n=>typeof n=="string"?{preset:n,preserveTemplateScripts:!1,templateScriptTypes:[],allowScripts:!1}:{preset:n.preset??"strict",preserveTemplateScripts:n.preserveTemplateScripts===!0,templateScriptTypes:n.templateScriptTypes??[],allowScripts:n.allowScripts===!0},Ee=n=>n.trim().toLowerCase(),V=n=>{let e=n.preserveTemplateScripts?[...Ye,...n.templateScriptTypes]:n.templateScriptTypes;return new Set(e.map(Ee).filter(Boolean))},Ze=(n,e)=>{if(e.size===0)return{markup:n,placeholders:new Map};let t=document.createRange().createContextualFragment(n),s=Array.from(t.querySelectorAll("script[type]"));if(s.length===0)return{markup:n,placeholders:new Map};let r=Math.random().toString(36).slice(2),o=new Map;for(let a=0,d=s.length;a<d;a++){let u=s[a];if(!e.has(Ee(u.getAttribute("type")??"")))continue;let l=`__TRANSPORTR_TEMPLATE_SCRIPT_${r}_${a}_${o.size}__`;o.set(l,{attributes:Array.from(u.attributes,({name:c,value:p})=>[c,p]),content:u.textContent??""}),u.replaceWith(document.createTextNode(l))}if(o.size===0)return{markup:n,placeholders:o};let i=document.createElement("div");return i.append(t),{markup:i.innerHTML,placeholders:o}},Qe=(n,e)=>{if(e.size===0)return n;let t=document.createElement("div");t.innerHTML=n;let s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),o;for(;o=r.nextNode();)s.push(o);for(let i=0,a=s.length;i<a;i++){let d=s[i];if(!d.parentNode)continue;let u=d.nodeValue;if(u===null)continue;let l=0,c=!1,p=document.createDocumentFragment();for(let f=-1,R="",h;;h=void 0){for(let[T,v]of e){let E=u.indexOf(T,l);E!==-1&&(f===-1||E<f)&&(f=E,R=T,h=v)}if(f===-1||!h)break;c=!0,f>l&&p.append(document.createTextNode(u.slice(l,f)));let w=document.createElement("script");for(let T=0,v=h.attributes.length;T<v;T++){let[E,b]=h.attributes[T];w.setAttribute(E,b)}w.textContent=h.content,p.append(w),l=f+R.length}c&&(l<u.length&&p.append(document.createTextNode(u.slice(l))),d.parentNode.replaceChild(p,d))}return t.innerHTML},_=class{#e;#t;domReady=()=>{if(this.#e)return this.#e;let e=typeof document<"u"&&typeof DOMParser<"u"&&typeof DocumentFragment<"u";return this.#e=e?Promise.resolve():import("jsdom").then(({JSDOM:t})=>{let{window:s}=new t("<!DOCTYPE html><html><head></head><body></body></html>",{url:"http://localhost"});globalThis.window=s,Object.assign(globalThis,{document:s.document,DOMParser:s.DOMParser,DocumentFragment:s.DocumentFragment})}).catch(()=>{throw this.#e=void 0,new Error("jsdom is required for HTML/XML/DOM features in Node.js environments. Install it with: npm install jsdom")})};getSanitizer=()=>{if(this.#t)return this.#t;let e=(async()=>{await this.domReady();let{default:t}=await import("./CLKJRXYL.js");return t})();return this.#t=e.catch(t=>{throw this.#t=void 0,t})}},S=new _,qe=async(n,e)=>(await S.domReady(),new DOMParser().parseFromString((await S.getSanitizer()).sanitize(await n.text()),e)),_e=n=>{let e;switch(n.preset){case"bypass":case"strict":e=void 0;break;case"balanced":e=we;break;case"relaxed":e=Ke;break;default:Ve(n.preset)}return n.allowScripts?{...e,ADD_TAGS:["script"]}:e},Pe=async(n,e)=>{let t=X(e);if(t.preset==="bypass")return n;let s=_e(t);if(t.allowScripts){let d=(await S.getSanitizer()).sanitize(n,s);return typeof d=="string"?d:String(d)}let{markup:r,placeholders:o}=Ze(n,V(t)),i=(await S.getSanitizer()).sanitize(r,s),a=typeof i=="string"?i:String(i);return Qe(a,o)},ve=async(n,e,t)=>{await S.domReady();let s=await Pe(await n.text(),t);return new DOMParser().parseFromString(s,e)},et=async(n,e)=>{await S.domReady();let t=await Pe(await n.text(),e);return document.createRange().createContextualFragment(t)},ee=async(n,e)=>{await S.domReady();let t=URL.createObjectURL(await n.blob());try{return new Promise((s,r)=>e(t,s,r))}finally{URL.revokeObjectURL(t)}},Ae=n=>n.text(),te=n=>ee(n,(e,t,s)=>{let r=Object.assign(document.createElement("script"),{src:e,type:"text/javascript",async:!0});r.onload=()=>{document.head.removeChild(r),t()},r.onerror=()=>{document.head.removeChild(r),s(new Error("Script failed to load"))},document.head.appendChild(r)}),ne=n=>ee(n,(e,t,s)=>{let r=Object.assign(document.createElement("link"),{href:e,type:"text/css",rel:"stylesheet"});r.onload=()=>t(),r.onerror=()=>{document.head.removeChild(r),s(new Error("Stylesheet load failed"))},document.head.appendChild(r)}),I=n=>n.json(),Be=n=>n.blob(),se=n=>ee(n,(e,t,s)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>s(new Error("Image failed to load")),r.src=e}),He=n=>n.arrayBuffer(),re=n=>Promise.resolve(n.body),U=async n=>qe(n,"application/xml"),oe=async n=>qe(n,"text/html"),tt=async n=>(await S.domReady(),document.createRange().createContextualFragment((await S.getSanitizer()).sanitize(await n.text()))),nt=async n=>(await S.domReady(),document.createRange().createContextualFragment(await n.text())),xe=n=>{let e=X(n);return e.preset==="strict"&&!e.allowScripts&&V(e).size===0?oe:async t=>ve(t,"text/html",e)},Ce=n=>{let e=X(n);return e.preset==="strict"&&!e.allowScripts&&V(e).size===0?U:async t=>ve(t,"application/xml",e)},ke=n=>{let e=X(n);return e.preset==="strict"&&!e.allowScripts&&V(e).size===0?tt:e.preset==="bypass"?nt:async t=>et(t,e)};async function*Le(n,e,t){let s=n.getReader(),r=new TextDecoder,o=e.length,i="",a=0;try{for(;;){let d;for(;(d=i.indexOf(e,a))!==-1;)yield i.slice(a,d),a=d+o;a>0&&a>=i.length-a&&(i=a<i.length?i.slice(a):"",a=0);let{done:u,value:l}=await s.read();if(u)break;i+=r.decode(l,{stream:!0})}if(t){let u=((a<i.length?i.slice(a):"")+r.decode()).trim();u&&(yield u)}}finally{await s.cancel()}}var st=n=>{let e="message",t="",s,r,o,i=n.split(`
|
|
2
|
+
`);for(let d=0,u,l=i.length;d<l;d++){if(u=i[d],u.charCodeAt(0)===58)continue;let c=u.indexOf(":"),p,f;switch(c===-1?(p=u,f=""):(p=u.slice(0,c),f=u.charCodeAt(c+1)===32?u.slice(c+2):u.slice(c+1)),p){case"event":{e=f;break}case"data":{r===void 0?r=f:(o??=[]).push(f);break}case"id":{t=f;break}case"retry":{let R=parseInt(f,10);isNaN(R)||(s=R);break}}}if(r===void 0&&e==="message")return;let a=o===void 0?r??"":`${r}
|
|
3
3
|
${o.join(`
|
|
4
|
-
`)}`;return{event:e,data:a,id:t,retry:s}},
|
|
4
|
+
`)}`;return{event:e,data:a,id:t,retry:s}},Me=n=>({async*[Symbol.asyncIterator](){for await(let e of Le(n.body,`
|
|
5
5
|
|
|
6
|
-
`,!1)){if(!e)continue;let t=
|
|
7
|
-
`,!0)){let t=e.trim();t&&(yield JSON.parse(t))}}});var Se=n=>n!==void 0&&pe.includes(n),Pe=n=>n instanceof FormData||n instanceof Blob||n instanceof ArrayBuffer||n instanceof ReadableStream||n instanceof URLSearchParams||ArrayBuffer.isView(n),ve=n=>{if(typeof document>"u")return;let e=document.cookie;if(!e)return;let t=`${n}=`,s=t.length,r=e.length,o=0;for(;o<r;){for(;o<r&&e.charCodeAt(o)===32;)o++;let i=e.indexOf(";",o);if(i===-1&&(i=r),i-o>=s&&e.startsWith(t,o))return decodeURIComponent(e.slice(o+s,i));o=i+1}},Ae=n=>JSON.stringify(n),z=n=>n!==null&&typeof n=="string",Be=n=>n instanceof ArrayBuffer||Object.prototype.toString.call(n)==="[object ArrayBuffer]",m=n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype,X=(...n)=>{let e=n.length;if(e===0)return;if(e===1){let[s]=n;return m(s)?se(s):s}let t={};for(let s=0,r=n.length;s<r;s++){let o=n[s];if(!m(o))return;let i=Object.keys(o);for(let a=0,d=i.length;a<d;a++){let u=i[a],l=o[u],c=t[u];if(Array.isArray(l))if(Array.isArray(c)){let f=l.slice();for(let R=0,p=c.length;R<p;R++){let y=c[R];l.includes(y)||f.push(y)}t[u]=f}else t[u]=l.slice();else m(l)?t[u]=m(c)?X(c,l):se(l):t[u]=l}}return t};function se(n){if(m(n)){let e={},t=Object.keys(n);for(let s=0,r=t.length,o;s<r;s++)o=t[s],e[o]=se(n[o]);return e}return n}var He=class n{#e;#t;#s;#n;#o;#h;#a={beforeRequest:[],afterResponse:[],beforeError:[]};#f={beforeRequest:0,afterResponse:0,beforeError:0};#u=Object.create(null);static#O=new U;static#c={beforeRequest:[],afterResponse:[],beforeError:[]};static#R={beforeRequest:0,afterResponse:0,beforeError:0};static#p=Object.create(null);static#m=new Set;static#E=new Map;static#L={limit:0,statusCodes:[],methods:[],delay:D,backoffFactor:F};static#C=new WeakMap;static#g=new Map([[A.toString(),A]]);static#d=new Map;static#w=[[h.TEXT,ge],[h.JSON,H],[h.BIN,te],[h.HTML,ne],[h.XML,C],[h.PNG,ee],[h.JAVA_SCRIPT,Q],[h.CSS,_]];constructor(e=W,t={}){m(e)&&([e,t]=[W,e]),this.#e=n.#j(e),this.#t=this.#e.origin;let s=this.#e.pathname;this.#s=s.length>0&&s.charCodeAt(s.length-1)===47?s.slice(0,-1):s,this.#n=n.#F(t,n.#I),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type"),this.#h=new U}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=g;static#I={body:void 0,cache:le.NO_STORE,credentials:n.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":A.toString(),accept:A.toString()}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:n.RequestMode.CORS,priority:n.RequestPriority.AUTO,redirect:n.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:n.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,s){let r=n.#O.subscribe(e,t,s);return n.#p[e]=(n.#p[e]??0)+1,r}static unregister(e){let t=n.#O.unsubscribe(e);if(t){let s=e.eventName,r=(n.#p[s]??1)-1;r<=0?delete n.#p[s]:n.#p[s]=r}return t}static abortAll(){for(let e of this.#m)e.abort(N());this.#m.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],s=new Array(e.length);for(let r=0;r<e.length;r++){let o=new AbortController;t.push(o),s[r]=e[r](o.signal)}try{return await Promise.race(s)}finally{for(let r of t)r.abort()}}static registerContentTypeHandler(e,t){n.#w.unshift([e,t]),n.#d.clear()}static unregisterContentTypeHandler(e){let t=n.#w.findIndex(([s])=>s===e);return t===-1?!1:(n.#w.splice(t,1),n.#d.clear(),!0)}static addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;t&&(n.#c.beforeRequest.push(...t),n.#R.beforeRequest+=t.length),s&&(n.#c.afterResponse.push(...s),n.#R.afterResponse+=s.length),r&&(n.#c.beforeError.push(...r),n.#R.beforeError+=r.length)}static clearHooks(){n.#c={beforeRequest:[],afterResponse:[],beforeError:[]},n.#R.beforeRequest=0,n.#R.afterResponse=0,n.#R.beforeError=0}static unregisterAll(){n.abortAll(),n.#O=new U,n.#p=Object.create(null),n.clearHooks(),n.#E.clear()}get baseUrl(){return this.#e}register(e,t,s){let r=this.#h.subscribe(e,t,s);return this.#u[e]=(this.#u[e]??0)+1,r}unregister(e){let t=this.#h.unsubscribe(e);if(t){let s=e.eventName,r=(this.#u[s]??1)-1;r<=0?delete this.#u[s]:this.#u[s]=r}return t}addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;return t&&(this.#a.beforeRequest.push(...t),this.#f.beforeRequest+=t.length),s&&(this.#a.afterResponse.push(...s),this.#f.afterResponse+=s.length),r&&(this.#a.beforeError.push(...r),this.#f.beforeError+=r.length),this}clearHooks(){return this.#a.beforeRequest.length=0,this.#a.afterResponse.length=0,this.#a.beforeError.length=0,this.#f.beforeRequest=0,this.#f.afterResponse=0,this.#f.beforeError=0,this}configure({headers:e,searchParams:t,hooks:s,...r}){return e&&(n.#B(this.#n.headers,e),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type")),t&&n.#b(this.#n.searchParams,t),Object.assign(this.#n,r),s&&this.addHooks(s),this}destroy(){this.clearHooks(),this.#h.destroy();for(let e in this.#u)delete this.#u[e]}async get(e,t){return this.#i(e,t)}async post(e,t,s){return this.#S("POST",e,t,s)}async put(e,t,s){return this.#S("PUT",e,t,s)}async patch(e,t,s){return this.#S("PATCH",e,t,s)}async delete(e,t,s){return this.#S("DELETE",e,t,s)}async head(e,t){return this.#A(e,t,{method:"HEAD"})}async options(e,t={}){m(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{method:"OPTIONS"}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s);d=await this.#v(d,r,i?.afterResponse);let u=d.headers.get("allow"),l;if(u){let c=u.split(",");l=new Array(c.length);for(let f=0,R=c.length;f<R;f++)l[f]=c[f].trim()}return this.#r({name:g.SUCCESS,data:l,global:t.global}),o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){m(e)&&([e,t]=[void 0,e]);let s=this.#T(t,{}),r=s.requestOptions.unwrap!==!1;try{let o=await this.#y(e,s);return this.#r({name:g.SUCCESS,data:o,global:t.global}),r?o:[!0,o]}catch(o){if(!r)return[!1,o];throw o}}async getJson(e,t){return this.#i(e,t,{headers:{accept:`${h.JSON}`}},H)}async getXml(e,t){return this.#i(e,t,{headers:{accept:`${h.XML}`}},C)}async getHtml(e,t,s){let r=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},ne);return Array.isArray(r)?r:s&&r?r.querySelector(s):r}async getHtmlFragment(e,t,s){let o=((m(e)?e:t)?.allowScripts??this.#n.allowScripts)===!0,i=await this.#i(e,t,{headers:{accept:`${h.HTML}`}},o?Oe:Te);return Array.isArray(i)?i:s&&i?i.querySelector(s):i}async getScript(e,t){return this.#i(e,t,{headers:{accept:`${h.JAVA_SCRIPT}`}},Q)}async getStylesheet(e,t){return this.#i(e,t,{headers:{accept:`${h.CSS}`}},_)}async getBlob(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},ye)}async getImage(e,t){return this.#i(e,t,{headers:{accept:"image/*"}},ee)}async getBuffer(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},be)}async getStream(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},te)}async getEventStream(e,t){m(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${h.EVENT_STREAM}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:g.SUCCESS,data:u,global:s.global});let l=we(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){m(e)&&([e,t]=[void 0,e]);let s=this.#T(t??{},{method:"GET",headers:{accept:`${h.NDJSON}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:g.SUCCESS,data:u,global:s.global});let l=qe(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async#i(e,t,s={},r){return s.method="GET",s.body=void 0,this.#A(e,t,s,r)}async#y(e,t){let{signalController:s,requestOptions:r,global:o}=t;n.#m.add(s);let i=n.#N(r.retry),a=r.method??"GET",d=i.limit>0&&i.methods.includes(a),u=r.dedupe===!0&&(a==="GET"||a==="HEAD"),l=performance.now();try{let c=n.#l(this,e,r.searchParams),f;if(u){f=`${a}:${c.href}`;let x=n.#E.get(f);if(x)return(await x).clone()}let R=r.onUploadProgress,p=r.body;R&&p!=null&&(r.duplex="half");let y=this.#M(c,r,e,a,d,i,p,R,l,o);if(u){n.#E.set(f,y);try{return n.#x(await y,r)}finally{n.#E.delete(f)}}return n.#x(await y,r)}finally{if(n.#m.delete(s.destroy()),!r.signal?.aborted){let c=performance.now();this.#r({name:g.COMPLETE,data:{timing:{start:l,end:c,duration:c-l}},global:o}),n.#m.size===0&&this.#r({name:g.ALL_COMPLETE,global:o})}}}async#M(e,t,s,r,o,i,a,d,u,l){let c=0;for(;;)try{d&&await n.#U(t,a,d);let f=await fetch(e,t);if(!f.ok){if(o&&c<i.limit&&i.statusCodes.includes(f.status)){c++,this.#r({name:g.RETRY,data:{attempt:c,status:f.status,method:r,path:s,timing:n.#q(u)},global:l}),await n.#k(i,c);continue}let R;if(t.captureErrorBody!==!1)try{R=await f.text()}catch{}throw await this.#H(s,f,{entity:R,url:e,method:r,timing:n.#q(u)},t)}return f}catch(f){if(f instanceof O)throw f;if(o&&c<i.limit){c++,this.#r({name:g.RETRY,data:{attempt:c,error:f.message,method:r,path:s,timing:n.#q(u)},global:l}),await n.#k(i,c);continue}throw await this.#H(s,void 0,{cause:f,url:e,method:r,timing:n.#q(u)},t)}}static async#U(e,t,s){if(t==null)return;let r=null;if(typeof t=="string")r=new TextEncoder().encode(t);else if(t instanceof Blob)r=new Uint8Array(await t.arrayBuffer());else if(Be(t))r=new Uint8Array(t);else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(!(t instanceof ReadableStream))return;let o=r?r.byteLength:null,i=r?new ReadableStream({start(u){u.enqueue(r),u.close()}}):t,a=0,d=new TransformStream({transform(u,l){a+=u.byteLength,s({loaded:a,total:o,percentage:o!==null&&o>0?Math.round(a/o*100):null}),l.enqueue(u)}});e.body=i.pipeThrough(d)}static#x(e,t){let s=t.onDownloadProgress;if(!s||!e.body)return e;let r=e.headers.get("content-length"),o=r?parseInt(r,10):null,i=0,a=new TransformStream({transform(d,u){i+=d.byteLength,s({loaded:i,total:o,percentage:o!==null&&o>0?Math.round(i/o*100):null}),u.enqueue(d)}});return new Response(e.body.pipeThrough(a),{status:e.status,statusText:e.statusText,headers:e.headers})}static#q(e){let t=performance.now();return{start:e,end:t,duration:t-e}}static#N(e){if(e===void 0)return n.#L;if(typeof e=="number")return{limit:e,statusCodes:K,methods:Y,delay:D,backoffFactor:F};let t=n.#C.get(e);if(t!==void 0)return t;let s={limit:e.limit??0,statusCodes:e.statusCodes??K,methods:e.methods??Y,delay:e.delay??D,backoffFactor:e.backoffFactor??F};return n.#C.set(e,s),s}static#k(e,t){let s=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(r=>setTimeout(r,s))}#S(e,t,s,r,o){let[i,a,d]=z(t)?[t,s,r]:[void 0,t,s],u=d!==void 0?Object.assign({},d,{body:a,method:e}):{body:a,method:e};return this.#A(i,u,{},o)}async#P(e,t,s,r){let o=n.#c.beforeRequest,i=this.#a.beforeRequest,a=r===void 0?0:r.length;if(o.length===0&&i.length===0&&a===0)return t;for(let d=0,u=o.length;d<u;d++){let l=await o[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0,u=i.length;d<u;d++){let l=await i[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0;d<a;d++){let u=await r[d](e,t);u&&(Object.assign(e,u),u.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}return t}async#v(e,t,s){let r=n.#c.afterResponse,o=this.#a.afterResponse,i=s===void 0?0:s.length;if(r.length===0&&o.length===0&&i===0)return e;for(let a=0,d=r.length;a<d;a++){let u=await r[a](e,t);u&&(e=u)}for(let a=0,d=o.length;a<d;a++){let u=await o[a](e,t);u&&(e=u)}for(let a=0;a<i;a++){let d=await s[a](e,t);d&&(e=d)}return e}async#D(e,t){let s=n.#c.beforeError,r=this.#a.beforeError,o=t===void 0?0:t.length;if(s.length===0&&r.length===0&&o===0)return e;for(let i=0,a=s.length;i<a;i++){let d=await s[i](e);d instanceof O&&(e=d)}for(let i=0,a=r.length;i<a;i++){let d=await r[i](e);d instanceof O&&(e=d)}for(let i=0;i<o;i++){let a=await t[i](e);a instanceof O&&(e=a)}return e}async#A(e,t={},s={},r){m(e)&&([e,t]=[void 0,e]);let o=this.#T(t,s),{requestOptions:i}=o,a=i.unwrap!==!1,d=i.hooks;try{let u=n.#l(this,e,i.searchParams);await this.#P(i,u,e,d?.beforeRequest);let l=await this.#y(e,o);l=await this.#v(l,i,d?.afterResponse);try{!r&&l.status!==204&&(r=this.#G(l.headers.get("content-type")));let c=await r?.(l);return this.#r({name:g.SUCCESS,data:c,global:o.global}),a?c:[!0,c]}catch(c){throw await this.#H(e,l,{cause:c},i)}}catch(u){if(!a)return[!1,u];throw u}}static#F({headers:e,searchParams:t,...s},{headers:r,searchParams:o,...i}){return r=n.#B(new Headers,e,r),o=n.#b(new URLSearchParams,t,o),{...X(i,s),headers:r,searchParams:o}}static#B(e,...t){for(let s of t)if(s!==void 0)if(s instanceof Headers)s.forEach((r,o)=>e.set(o,r));else if(Array.isArray(s))for(let[r,o]of s)e.set(r,o);else{let r=Object.keys(s);for(let o=0,i=r.length;o<i;o++){let a=r[o],d=s[a];d!==void 0&&e.set(a,d)}}return e}static#b(e,...t){for(let s of t)if(s!==void 0)if(s instanceof URLSearchParams)s.forEach((r,o)=>e.set(o,r));else if(z(s)||Array.isArray(s))for(let[r,o]of new URLSearchParams(s))e.set(r,o);else{let r=Object.keys(s);for(let o=0;o<r.length;o++){let i=r[o],a=s[i];a!==void 0&&e.set(i,typeof a=="string"?a:String(a))}}return e}#T(e,t){let s=e.headers,r=e.searchParams,o=e.body,i=t.headers,a=t.searchParams,d=t.method??e.method??this.#n.method??"GET",u=Se(d),l;!u&&s===void 0&&i===void 0?l=new Headers(this.#o):(l=new Headers(this.#n.headers),(s!==void 0||i!==void 0)&&n.#B(l,s,i));let c=this.#n.searchParams,f=c!==void 0&&c.size>0,R;!f&&r===void 0&&a===void 0?R=new URLSearchParams:(R=new URLSearchParams(c),(r!==void 0||a!==void 0)&&n.#b(R,r,a));let p=Object.assign({},this.#n,e,t);if(p.headers=l,p.searchParams=R,u)if(Pe(o))p.body=o,l.delete("content-type");else{let T=this.#n.body,S=m(T)&&m(o)?X(T,o):o!==void 0?o:T,P=l.get("content-type"),Ce=P!==null&&P.includes("json");p.body=Ce&&m(S)?Ae(S):S}else p.body instanceof URLSearchParams&&n.#b(R,p.body),p.body=void 0,(s!==void 0||i!==void 0)&&l.delete("content-type");let y=p.signal,x=p.timeout,k=p.global??!1,V=p.xsrf;if(V){let{cookieName:T,headerName:S}=typeof V=="object"?V:{},P=ve(T??ue);P&&l.set(S??de,P)}let re=new j({signal:y,timeout:x}).onAbort(T=>this.#r({name:g.ABORTED,event:T,global:k})).onTimeout(T=>this.#r({name:g.TIMEOUT,event:T,global:k}));return p.signal=re.signal,this.#r({name:g.CONFIGURED,data:p,global:k}),{signalController:re,requestOptions:p,global:k}}static#j(e){if(e instanceof URL)return e;if(!z(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static#J(e){if(e===null)return;let t=n.#g.get(e);return t!==void 0||(t=M.parse(e)??void 0,t!==void 0&&(n.#g.size>=100&&n.#g.delete(n.#g.keys().next().value),n.#g.set(e,t))),t}static#l(e,t,s){let r;if(e instanceof URL){let o=e.pathname,i=o.charCodeAt(o.length-1)===47?o.slice(0,-1):o;r=t?new URL(`${i}${t}`,e.origin):new URL(e)}else r=t?new URL(`${e.#s}${t}`,e.#t):new URL(e.#e);return s&&n.#b(r.searchParams,s),r}static#$(e,{status:t,statusText:s}=new Response){switch(e){case q.ABORT:return Re;case q.TIMEOUT:return he;default:return t>=400?new E(t,s):fe}}async#H(e,t,{cause:s,entity:r,url:o,method:i,timing:a}={},d){let u=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,l=new O(n.#$(s?.name,t),{message:u,cause:s,entity:r,url:o,method:i,timing:a});return l=await this.#D(l,d?.hooks?.beforeError),this.#r({name:g.ERROR,data:l}),l}#r({name:e,event:t,data:s,global:r=!0}){let o=r&&(n.#p[e]??0)>0,i=(this.#u[e]??0)>0;if(!o&&!i)return;let a=t??new CustomEvent(e);o&&n.#O.publish(e,a,s),i&&this.#h.publish(e,a,s)}#G(e){if(!e)return;let t=n.#d.get(e);if(t!==void 0)return t===null?void 0:t;let s=n.#J(e);if(!s){n.#d.set(e,null);return}let r=n.#w;for(let i=0,a=r.length;i<a;i++){let d=r[i];if(s.matches(d[0])){let u=d[1];return n.#d.set(e,u),u}}let o=s.subtype;if(o.endsWith("+json"))return n.#d.set(e,H),H;if(o.endsWith("+xml"))return n.#d.set(e,C),C;n.#d.set(e,null)}get[Symbol.toStringTag](){return"Transportr"}};export{He as Transportr};
|
|
6
|
+
`,!1)){if(!e)continue;let t=st(e);t&&(yield t)}}}),Ie=n=>({async*[Symbol.asyncIterator](){for await(let e of Le(n.body,`
|
|
7
|
+
`,!0)){let t=e.trim();t&&(yield JSON.parse(t))}}});var ie=(n,e)=>({preset:n?.sanitization?.preset??n?.sanitizePreset??e.sanitization?.preset??e.sanitizePreset??"strict",preserveTemplateScripts:n?.sanitization?.preserveTemplateScripts??e.sanitization?.preserveTemplateScripts,templateScriptTypes:n?.sanitization?.templateScriptTypes??e.sanitization?.templateScriptTypes}),Ue=class n{#e;#t;#s;#n;#o;#h;#a={beforeRequest:[],afterResponse:[],beforeError:[]};#f={beforeRequest:0,afterResponse:0,beforeError:0};#u=Object.create(null);static#O=new F;static#c={beforeRequest:[],afterResponse:[],beforeError:[]};static#R={beforeRequest:0,afterResponse:0,beforeError:0};static#p=Object.create(null);static#m=new Set;static#S=new Map;static#L={limit:0,statusCodes:[],methods:[],delay:J,backoffFactor:$};static#x=new WeakMap;static#g=new Map([[L.toString(),L]]);static#d=new Map;static#w=[[m.TEXT,Ae],[m.JSON,I],[m.BIN,re],[m.HTML,oe],[m.XML,U],[m.PNG,se],[m.JAVA_SCRIPT,te],[m.CSS,ne]];constructor(e=K,t={}){g(e)&&([e,t]=[K,e]),this.#e=n.#F(e),this.#t=this.#e.origin;let s=this.#e.pathname;this.#s=s.length>0&&s.charCodeAt(s.length-1)===47?s.slice(0,-1):s,this.#n=n.#z(t,n.#M),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type"),this.#h=new F}static CredentialsPolicy={INCLUDE:"include",OMIT:"omit",SAME_ORIGIN:"same-origin"};static RequestMode={CORS:"cors",NAVIGATE:"navigate",NO_CORS:"no-cors",SAME_ORIGIN:"same-origin"};static RequestPriority={HIGH:"high",LOW:"low",AUTO:"auto"};static RedirectPolicy={ERROR:"error",FOLLOW:"follow",MANUAL:"manual"};static ReferrerPolicy={NO_REFERRER:"no-referrer",NO_REFERRER_WHEN_DOWNGRADE:"no-referrer-when-downgrade",ORIGIN:"origin",ORIGIN_WHEN_CROSS_ORIGIN:"origin-when-cross-origin",SAME_ORIGIN:"same-origin",STRICT_ORIGIN:"strict-origin",STRICT_ORIGIN_WHEN_CROSS_ORIGIN:"strict-origin-when-cross-origin",UNSAFE_URL:"unsafe-url"};static RequestEvent=y;static#M={body:void 0,cache:pe.NO_STORE,credentials:n.CredentialsPolicy.SAME_ORIGIN,headers:new Headers({"content-type":L.toString(),accept:L.toString()}),searchParams:void 0,integrity:void 0,keepalive:void 0,method:"GET",mode:n.RequestMode.CORS,priority:n.RequestPriority.AUTO,redirect:n.RedirectPolicy.FOLLOW,referrer:"about:client",referrerPolicy:n.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,signal:void 0,timeout:3e4,global:!0};static register(e,t,s){let r=n.#O.subscribe(e,t,s);return n.#p[e]=(n.#p[e]??0)+1,r}static unregister(e){let t=n.#O.unsubscribe(e);if(t){let s=e.eventName,r=(n.#p[s]??1)-1;r<=0?delete n.#p[s]:n.#p[s]=r}return t}static abortAll(){for(let e of this.#m)e.abort(j());this.#m.clear()}static all(e){return Promise.all(e)}static async race(e){let t=[],s=new Array(e.length);for(let r=0;r<e.length;r++){let o=new AbortController;t.push(o),s[r]=e[r](o.signal)}try{return await Promise.race(s)}finally{for(let r of t)r.abort()}}static registerContentTypeHandler(e,t){n.#w.unshift([e,t]),n.#d.clear()}static unregisterContentTypeHandler(e){let t=n.#w.findIndex(([s])=>s===e);return t===-1?!1:(n.#w.splice(t,1),n.#d.clear(),!0)}static addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;t&&(n.#c.beforeRequest.push(...t),n.#R.beforeRequest+=t.length),s&&(n.#c.afterResponse.push(...s),n.#R.afterResponse+=s.length),r&&(n.#c.beforeError.push(...r),n.#R.beforeError+=r.length)}static clearHooks(){n.#c={beforeRequest:[],afterResponse:[],beforeError:[]},n.#R.beforeRequest=0,n.#R.afterResponse=0,n.#R.beforeError=0}static unregisterAll(){n.abortAll(),n.#O=new F,n.#p=Object.create(null),n.clearHooks(),n.#S.clear()}get baseUrl(){return this.#e}register(e,t,s){let r=this.#h.subscribe(e,t,s);return this.#u[e]=(this.#u[e]??0)+1,r}unregister(e){let t=this.#h.unsubscribe(e);if(t){let s=e.eventName,r=(this.#u[s]??1)-1;r<=0?delete this.#u[s]:this.#u[s]=r}return t}addHooks(e){let{beforeRequest:t,afterResponse:s,beforeError:r}=e;return t&&(this.#a.beforeRequest.push(...t),this.#f.beforeRequest+=t.length),s&&(this.#a.afterResponse.push(...s),this.#f.afterResponse+=s.length),r&&(this.#a.beforeError.push(...r),this.#f.beforeError+=r.length),this}clearHooks(){return this.#a.beforeRequest.length=0,this.#a.afterResponse.length=0,this.#a.beforeError.length=0,this.#f.beforeRequest=0,this.#f.afterResponse=0,this.#f.beforeError=0,this}configure({headers:e,searchParams:t,hooks:s,...r}){return e&&(n.#B(this.#n.headers,e),this.#o=new Headers(this.#n.headers),this.#o.delete("content-type")),t&&n.#T(this.#n.searchParams,t),Object.assign(this.#n,r),s&&this.addHooks(s),this}destroy(){this.clearHooks(),this.#h.destroy();for(let e in this.#u)delete this.#u[e]}async get(e,t){return this.#i(e,t)}async post(e,t,s){return this.#q("POST",e,t,s)}async put(e,t,s){return this.#q("PUT",e,t,s)}async patch(e,t,s){return this.#q("PATCH",e,t,s)}async delete(e,t,s){return this.#q("DELETE",e,t,s)}async head(e,t){return this.#A(e,t,{method:"HEAD"})}async options(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#b(t,{method:"OPTIONS"}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s);d=await this.#v(d,r,i?.afterResponse);let u=d.headers.get("allow"),l;if(u){let c=u.split(",");l=new Array(c.length);for(let p=0,f=c.length;p<f;p++)l[p]=c[p].trim()}return this.#r({name:y.SUCCESS,data:l,global:t.global}),o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async request(e,t={}){g(e)&&([e,t]=[void 0,e]);let s=this.#b(t,{}),r=s.requestOptions.unwrap!==!1;try{let o=await this.#y(e,s);return this.#r({name:y.SUCCESS,data:o,global:t.global}),r?o:[!0,o]}catch(o){if(!r)return[!1,o];throw o}}async getJson(e,t){return this.#i(e,t,{headers:{accept:`${m.JSON}`}},I)}async getXml(e,t){let s=g(e)&&!H(e)?e:t;return this.#i(e,t,{headers:{accept:`${m.XML}`}},Ce(ie(s,this.#n)))}async getHtml(e,t,s){let r=g(e)&&!H(e)?e:t,o=await this.#i(e,t,{headers:{accept:`${m.HTML}`}},xe(ie(r,this.#n)));return Array.isArray(o)?o:s&&o?o.querySelector(s):o}async getHtmlFragment(e,t,s){let r=g(e)&&!H(e)?e:t,o=await this.#i(e,t,{headers:{accept:`${m.HTML}`}},ke(ie(r,this.#n)));return Array.isArray(o)?o:s&&o?o.querySelector(s):o}async getScript(e,t){return this.#i(e,t,{headers:{accept:`${m.JAVA_SCRIPT}`}},te)}async getStylesheet(e,t){return this.#i(e,t,{headers:{accept:`${m.CSS}`}},ne)}async getBlob(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},Be)}async getImage(e,t){return this.#i(e,t,{headers:{accept:"image/*"}},se)}async getBuffer(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},He)}async getStream(e,t){return this.#i(e,t,{headers:{accept:"application/octet-stream"}},re)}async getEventStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#b(t??{},{method:t?.body?"POST":"GET",headers:{accept:`${m.EVENT_STREAM}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:y.SUCCESS,data:u,global:s.global});let l=Me(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async getJsonStream(e,t){g(e)&&([e,t]=[void 0,e]);let s=this.#b(t??{},{method:"GET",headers:{accept:`${m.NDJSON}`}}),{requestOptions:r}=s,o=r.unwrap!==!1,i=r.hooks;try{let a=n.#l(this,e,r.searchParams);await this.#P(r,a,e,i?.beforeRequest);let d=await this.#y(e,s),u=await this.#v(d,r,i?.afterResponse);this.#r({name:y.SUCCESS,data:u,global:s.global});let l=Ie(u);return o?l:[!0,l]}catch(a){if(!o)return[!1,a];throw a}}async#i(e,t,s={},r){return s.method="GET",s.body=void 0,this.#A(e,t,s,r)}async#y(e,t){let{signalController:s,requestOptions:r,global:o}=t;n.#m.add(s);let i=n.#N(r.retry),a=r.method??"GET",d=i.limit>0&&i.methods.includes(a),u=r.dedupe===!0&&(a==="GET"||a==="HEAD"),l=performance.now();try{let c=n.#l(this,e,r.searchParams),p;if(u){p=`${a}:${c.href}`;let w=n.#S.get(p);if(w)return(await w).clone()}let f=r.onUploadProgress,R=r.body;f&&R!=null&&(r.duplex="half");let h=this.#I(c,r,e,a,d,i,R,f,l,o);if(u){n.#S.set(p,h);try{return n.#C(await h,r)}finally{n.#S.delete(p)}}return n.#C(await h,r)}finally{if(n.#m.delete(s.destroy()),!r.signal?.aborted){let c=performance.now();this.#r({name:y.COMPLETE,data:{timing:{start:l,end:c,duration:c-l}},global:o}),n.#m.size===0&&this.#r({name:y.ALL_COMPLETE,global:o})}}}async#I(e,t,s,r,o,i,a,d,u,l){let c=0;for(;;)try{d&&await n.#U(t,a,d);let p=await fetch(e,t);if(!p.ok){if(o&&c<i.limit&&i.statusCodes.includes(p.status)){c++,this.#r({name:y.RETRY,data:{attempt:c,status:p.status,method:r,path:s,timing:n.#E(u)},global:l}),await n.#k(i,c);continue}let f;if(t.captureErrorBody!==!1)try{f=await p.text()}catch{}throw await this.#H(s,p,{entity:f,url:e,method:r,timing:n.#E(u)},t)}return p}catch(p){if(p instanceof q)throw p;if(o&&c<i.limit){c++,this.#r({name:y.RETRY,data:{attempt:c,error:p.message,method:r,path:s,timing:n.#E(u)},global:l}),await n.#k(i,c);continue}throw await this.#H(s,void 0,{cause:p,url:e,method:r,timing:n.#E(u)},t)}}static async#U(e,t,s){if(t==null)return;let r=null;if(typeof t=="string")r=new TextEncoder().encode(t);else if(t instanceof Blob)r=new Uint8Array(await t.arrayBuffer());else if(Se(t))r=new Uint8Array(t);else if(ArrayBuffer.isView(t))r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(!(t instanceof ReadableStream))return;let o=r?r.byteLength:null,i=r?new ReadableStream({start(u){u.enqueue(r),u.close()}}):t,a=0,d=new TransformStream({transform(u,l){a+=u.byteLength,s({loaded:a,total:o,percentage:o!==null&&o>0?Math.round(a/o*100):null}),l.enqueue(u)}});e.body=i.pipeThrough(d)}static#C(e,t){let s=t.onDownloadProgress;if(!s||!e.body)return e;let r=e.headers.get("content-length"),o=r?parseInt(r,10):null,i=0,a=new TransformStream({transform(d,u){i+=d.byteLength,s({loaded:i,total:o,percentage:o!==null&&o>0?Math.round(i/o*100):null}),u.enqueue(d)}});return new Response(e.body.pipeThrough(a),{status:e.status,statusText:e.statusText,headers:e.headers})}static#E(e){let t=performance.now();return{start:e,end:t,duration:t-e}}static#N(e){if(e===void 0)return n.#L;if(typeof e=="number")return{limit:e,statusCodes:Y,methods:Z,delay:J,backoffFactor:$};let t=n.#x.get(e);if(t!==void 0)return t;let s={limit:e.limit??0,statusCodes:e.statusCodes??Y,methods:e.methods??Z,delay:e.delay??J,backoffFactor:e.backoffFactor??$};return n.#x.set(e,s),s}static#k(e,t){let s=typeof e.delay=="function"?e.delay(t):e.delay*e.backoffFactor**(t-1);return new Promise(r=>setTimeout(r,s))}#q(e,t,s,r,o){let[i,a,d]=H(t)?[t,s,r]:[void 0,t,s],u=d!==void 0?Object.assign({},d,{body:a,method:e}):{body:a,method:e};return this.#A(i,u,{},o)}async#P(e,t,s,r){let o=n.#c.beforeRequest,i=this.#a.beforeRequest,a=r===void 0?0:r.length;if(o.length===0&&i.length===0&&a===0)return t;for(let d=0,u=o.length;d<u;d++){let l=await o[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0,u=i.length;d<u;d++){let l=await i[d](e,t);l&&(Object.assign(e,l),l.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}for(let d=0;d<a;d++){let u=await r[d](e,t);u&&(Object.assign(e,u),u.searchParams!==void 0&&(t=n.#l(this,s,e.searchParams)))}return t}async#v(e,t,s){let r=n.#c.afterResponse,o=this.#a.afterResponse,i=s===void 0?0:s.length;if(r.length===0&&o.length===0&&i===0)return e;for(let a=0,d=r.length;a<d;a++){let u=await r[a](e,t);u&&(e=u)}for(let a=0,d=o.length;a<d;a++){let u=await o[a](e,t);u&&(e=u)}for(let a=0;a<i;a++){let d=await s[a](e,t);d&&(e=d)}return e}async#D(e,t){let s=n.#c.beforeError,r=this.#a.beforeError,o=t===void 0?0:t.length;if(s.length===0&&r.length===0&&o===0)return e;for(let i=0,a=s.length;i<a;i++){let d=await s[i](e);d instanceof q&&(e=d)}for(let i=0,a=r.length;i<a;i++){let d=await r[i](e);d instanceof q&&(e=d)}for(let i=0;i<o;i++){let a=await t[i](e);a instanceof q&&(e=a)}return e}async#A(e,t={},s={},r){g(e)&&([e,t]=[void 0,e]);let o=this.#b(t,s),{requestOptions:i}=o,a=i.unwrap!==!1,d=i.hooks;try{let u=n.#l(this,e,i.searchParams);await this.#P(i,u,e,d?.beforeRequest);let l=await this.#y(e,o);l=await this.#v(l,i,d?.afterResponse);try{!r&&l.status!==204&&(r=this.#$(l.headers.get("content-type")));let c=await r?.(l);return this.#r({name:y.SUCCESS,data:c,global:o.global}),a?c:[!0,c]}catch(c){throw await this.#H(e,l,{cause:c},i)}}catch(u){if(!a)return[!1,u];throw u}}static#z({headers:e,searchParams:t,...s},{headers:r,searchParams:o,...i}){return r=n.#B(new Headers,e,r),o=n.#T(new URLSearchParams,t,o),{...W(i,s),headers:r,searchParams:o}}static#B(e,...t){for(let s of t)if(s!==void 0)if(s instanceof Headers)s.forEach((r,o)=>e.set(o,r));else if(Array.isArray(s))for(let[r,o]of s)e.set(r,o);else{let r=Object.keys(s);for(let o=0,i=r.length;o<i;o++){let a=r[o],d=s[a];d!==void 0&&e.set(a,d)}}return e}static#T(e,...t){for(let s of t)if(s!==void 0)if(s instanceof URLSearchParams)s.forEach((r,o)=>e.set(o,r));else if(H(s)||Array.isArray(s))for(let[r,o]of new URLSearchParams(s))e.set(r,o);else{let r=Object.keys(s);for(let o=0;o<r.length;o++){let i=r[o],a=s[i];a!==void 0&&e.set(i,typeof a=="string"?a:String(a))}}return e}#b(e,t){let s=e.headers,r=e.searchParams,o=e.body,i=t.headers,a=t.searchParams,d=t.method??e.method??this.#n.method??"GET",u=ye(d),l;!u&&s===void 0&&i===void 0?l=new Headers(this.#o):(l=new Headers(this.#n.headers),(s!==void 0||i!==void 0)&&n.#B(l,s,i));let c=this.#n.searchParams,p=c!==void 0&&c.size>0,f;!p&&r===void 0&&a===void 0?f=new URLSearchParams:(f=new URLSearchParams(c),(r!==void 0||a!==void 0)&&n.#T(f,r,a));let R=Object.assign({},this.#n,e,t);if(R.headers=l,R.searchParams=f,u)if(Te(o))R.body=o,l.delete("content-type");else{let b=this.#n.body,x=g(b)&&g(o)?W(b,o):o!==void 0?o:b,C=l.get("content-type"),Ne=C!==null&&C.includes("json");R.body=Ne&&g(x)?Oe(x):x}else R.body instanceof URLSearchParams&&n.#T(f,R.body),R.body=void 0,(s!==void 0||i!==void 0)&&l.delete("content-type");let h=R.signal,w=R.timeout,T=R.global??!1,v=R.xsrf;if(v){let{cookieName:b,headerName:x}=typeof v=="object"?v:{},C=be(b??le);C&&l.set(x??ce,C)}let E=new G({signal:h,timeout:w}).onAbort(b=>this.#r({name:y.ABORTED,event:b,global:T})).onTimeout(b=>this.#r({name:y.TIMEOUT,event:b,global:T}));return R.signal=E.signal,this.#r({name:y.CONFIGURED,data:R,global:T}),{signalController:E,requestOptions:R,global:T}}static#F(e){if(e instanceof URL)return e;if(!H(e))throw new TypeError("Invalid URL");return new URL(e,e.startsWith("/")?globalThis.location.origin:void 0)}static#j(e){if(e===null)return;let t=n.#g.get(e);return t!==void 0||(t=z.parse(e)??void 0,t!==void 0&&(n.#g.size>=100&&n.#g.delete(n.#g.keys().next().value),n.#g.set(e,t))),t}static#l(e,t,s){let r;if(e instanceof URL){let o=e.pathname,i=o.charCodeAt(o.length-1)===47?o.slice(0,-1):o;r=t?new URL(`${i}${t}`,e.origin):new URL(e)}else r=t?new URL(`${e.#s}${t}`,e.#t):new URL(e.#e);return s&&n.#T(r.searchParams,s),r}static#J(e,{status:t,statusText:s}=new Response){switch(e){case B.ABORT:return me;case B.TIMEOUT:return ge;default:return t>=400?new P(t,s):he}}async#H(e,t,{cause:s,entity:r,url:o,method:i,timing:a}={},d){let u=i&&o?`${i} ${o.href} failed${t?` with status ${t.status}`:""}`:`An error has occurred with your request to: '${e}'`,l=new q(n.#J(s?.name,t),{message:u,cause:s,entity:r,url:o,method:i,timing:a});return l=await this.#D(l,d?.hooks?.beforeError),this.#r({name:y.ERROR,data:l}),l}#r({name:e,event:t,data:s,global:r=!0}){let o=r&&(n.#p[e]??0)>0,i=(this.#u[e]??0)>0;if(!o&&!i)return;let a=t??new CustomEvent(e);o&&n.#O.publish(e,a,s),i&&this.#h.publish(e,a,s)}#$(e){if(!e)return;let t=n.#d.get(e);if(t!==void 0)return t===null?void 0:t;let s=n.#j(e);if(!s){n.#d.set(e,null);return}let r=n.#w;for(let i=0,a=r.length;i<a;i++){let d=r[i];if(s.matches(d[0])){let u=d[1];return n.#d.set(e,u),u}}let o=s.subtype;if(o.endsWith("+json"))return n.#d.set(e,I),I;if(o.endsWith("+xml"))return n.#d.set(e,U),U;n.#d.set(e,null)}get[Symbol.toStringTag](){return"Transportr"}};export{Ue as Transportr};
|
|
8
8
|
//# sourceMappingURL=transportr.js.map
|