kinetex 1.4.0 → 1.5.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.
Files changed (95) hide show
  1. package/README.md +170 -46
  2. package/dist/browser/kinetex.esm.js +29 -29
  3. package/dist/browser/kinetex.js +1143 -791
  4. package/dist/browser/kinetex.min.js +29 -29
  5. package/dist/cjs/aws-sigv4.js +7 -14
  6. package/dist/cjs/cache.js +9 -0
  7. package/dist/cjs/circuit-breaker.js +8 -1
  8. package/dist/cjs/client.js +350 -95
  9. package/dist/cjs/cookie-parser.js +28 -1
  10. package/dist/cjs/core.js +227 -5
  11. package/dist/cjs/dedup.js +93 -10
  12. package/dist/cjs/digest.js +36 -15
  13. package/dist/cjs/graphql.js +2 -11
  14. package/dist/cjs/headers.js +24 -1
  15. package/dist/cjs/interceptors.js +6 -17
  16. package/dist/cjs/lifecycle.js +3 -19
  17. package/dist/cjs/logging.js +12 -29
  18. package/dist/cjs/progress.js +1 -3
  19. package/dist/cjs/proxy.js +19 -2
  20. package/dist/cjs/response.js +202 -75
  21. package/dist/cjs/socks5.js +5 -0
  22. package/dist/cjs/utils.js +115 -27
  23. package/dist/cjs/ws.js +43 -2
  24. package/dist/esm/aws-sigv4.js +7 -14
  25. package/dist/esm/aws-sigv4.js.map +1 -1
  26. package/dist/esm/cache.js +9 -0
  27. package/dist/esm/cache.js.map +1 -1
  28. package/dist/esm/circuit-breaker.js +8 -1
  29. package/dist/esm/circuit-breaker.js.map +1 -1
  30. package/dist/esm/client.js +350 -95
  31. package/dist/esm/client.js.map +1 -1
  32. package/dist/esm/cookie-parser.js +28 -1
  33. package/dist/esm/cookie-parser.js.map +1 -1
  34. package/dist/esm/core.js +227 -5
  35. package/dist/esm/core.js.map +1 -1
  36. package/dist/esm/dedup.js +93 -10
  37. package/dist/esm/dedup.js.map +1 -1
  38. package/dist/esm/digest.js +36 -15
  39. package/dist/esm/digest.js.map +1 -1
  40. package/dist/esm/graphql.js +2 -11
  41. package/dist/esm/graphql.js.map +1 -1
  42. package/dist/esm/headers.js +24 -1
  43. package/dist/esm/headers.js.map +1 -1
  44. package/dist/esm/interceptors.js +6 -17
  45. package/dist/esm/interceptors.js.map +1 -1
  46. package/dist/esm/lifecycle.js +3 -19
  47. package/dist/esm/lifecycle.js.map +1 -1
  48. package/dist/esm/logging.js +12 -29
  49. package/dist/esm/logging.js.map +1 -1
  50. package/dist/esm/progress.js +1 -3
  51. package/dist/esm/progress.js.map +1 -1
  52. package/dist/esm/proxy.js +19 -2
  53. package/dist/esm/proxy.js.map +1 -1
  54. package/dist/esm/response.js +202 -75
  55. package/dist/esm/response.js.map +1 -1
  56. package/dist/esm/socks5.js +5 -0
  57. package/dist/esm/socks5.js.map +1 -1
  58. package/dist/esm/types.js.map +1 -1
  59. package/dist/esm/url.js.map +1 -1
  60. package/dist/esm/utils.js +115 -27
  61. package/dist/esm/utils.js.map +1 -1
  62. package/dist/esm/ws.js +43 -2
  63. package/dist/esm/ws.js.map +1 -1
  64. package/dist/types/aws-sigv4.d.ts.map +1 -1
  65. package/dist/types/cache.d.ts.map +1 -1
  66. package/dist/types/circuit-breaker.d.ts +1 -1
  67. package/dist/types/circuit-breaker.d.ts.map +1 -1
  68. package/dist/types/client.d.ts.map +1 -1
  69. package/dist/types/cookie-parser.d.ts.map +1 -1
  70. package/dist/types/core.d.ts +113 -0
  71. package/dist/types/core.d.ts.map +1 -1
  72. package/dist/types/dedup.d.ts +38 -3
  73. package/dist/types/dedup.d.ts.map +1 -1
  74. package/dist/types/digest.d.ts.map +1 -1
  75. package/dist/types/graphql.d.ts.map +1 -1
  76. package/dist/types/headers.d.ts +23 -4
  77. package/dist/types/headers.d.ts.map +1 -1
  78. package/dist/types/interceptors.d.ts +24 -38
  79. package/dist/types/interceptors.d.ts.map +1 -1
  80. package/dist/types/lifecycle.d.ts.map +1 -1
  81. package/dist/types/logging.d.ts.map +1 -1
  82. package/dist/types/progress.d.ts.map +1 -1
  83. package/dist/types/proxy.d.ts.map +1 -1
  84. package/dist/types/response.d.ts +42 -1
  85. package/dist/types/response.d.ts.map +1 -1
  86. package/dist/types/socks5.d.ts.map +1 -1
  87. package/dist/types/types.d.ts +105 -23
  88. package/dist/types/types.d.ts.map +1 -1
  89. package/dist/types/url.d.ts +0 -11
  90. package/dist/types/url.d.ts.map +1 -1
  91. package/dist/types/utils.d.ts +69 -1
  92. package/dist/types/utils.d.ts.map +1 -1
  93. package/dist/types/ws.d.ts +0 -1
  94. package/dist/types/ws.d.ts.map +1 -1
  95. package/package.json +10 -4
@@ -1,36 +1,36 @@
1
- /* kinetex v1.4.0 | MIT | https://github.com/kinetexjs/kinetex */
2
- "use strict";var kinetex=(()=>{var Wu=Object.create;var Vt=Object.defineProperty;var Ku=Object.getOwnPropertyDescriptor;var Vu=Object.getOwnPropertyNames;var Ju=Object.getPrototypeOf,Qu=Object.prototype.hasOwnProperty;var _i=r=>{throw TypeError(r)};var Gu=(r,e,t)=>e in r?Vt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ke=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var W=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var ae=(r,e)=>{for(var t in e)Vt(r,t,{get:e[t],enumerable:!0})},Si=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vu(e))!Qu.call(r,s)&&s!==t&&Vt(r,s,{get:()=>e[s],enumerable:!(n=Ku(e,s))||n.enumerable});return r};var Ce=(r,e,t)=>(t=r!=null?Wu(Ju(r)):{},Si(e||!r||!r.__esModule?Vt(t,"default",{value:r,enumerable:!0}):t,r)),Xu=r=>Si(Vt({},"__esModule",{value:!0}),r);var f=(r,e,t)=>Gu(r,typeof e!="symbol"?e+"":e,t),Yu=(r,e,t)=>e.has(r)||_i("Cannot "+t);var Ei=(r,e,t)=>e.has(r)?_i("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var ce=(r,e,t)=>(Yu(r,e,"access private method"),t);function Zu(){if(Cr)return Cr;let r=globalThis;if(r.process?.hrtime)return Cr=r.process,Cr}function el(){if(vr)return vr;let r=globalThis;if(r.Buffer&&typeof r.Buffer.isBuffer=="function")return vr=r.Buffer,vr}function ge(r,e={}){let t={...tl};for(let[i,a]of Object.entries(e))a!==void 0&&(t[i]=a);if(r.length>t.maxStringLength)return{success:!1,error:"STRING_TOO_LONG",message:`JSON string length exceeds limit of ${t.maxStringLength}`};let n=0,s=!1,o=!1;for(let i=0;i<r.length;i++){let a=r[i];if(o){o=!1;continue}if(a==="\\"){s&&(o=!0);continue}if(a==='"'){s=!s;continue}if(!s)if(a==="{"||a==="["){if(++n>t.maxDepth)return{success:!1,error:"DEPTH_EXCEEDED",message:`JSON depth exceeds limit of ${t.maxDepth}`}}else(a==="}"||a==="]")&&n--}try{let i=JSON.parse(r);return Fn(i,t,0)?!t.allowNonFinite&&Wn(i)?{success:!1,error:"NON_FINITE_NUMBER",message:"JSON contains NaN or Infinity values"}:{success:!0,value:i}:{success:!1,error:"VALIDATION_FAILED",message:"Parsed value exceeds size limits"}}catch{return{success:!1,error:"PARSE_ERROR",message:"Failed to parse JSON"}}}function Fn(r,e,t){if(t>e.maxDepth)return!1;if(r==null)return!0;if(typeof r=="string")return r.length<=e.maxStringLength;if(typeof r=="number"||typeof r=="boolean")return!0;if(Array.isArray(r))return r.length>e.maxArrayLength?!1:r.every(n=>Fn(n,e,t+1));if(typeof r=="object"){let n=Object.keys(r);if(n.length>e.maxObjectKeys||n.includes("__proto__"))return!1;if(n.includes("constructor")){let s=r.constructor;if(typeof s=="object"&&s!==null){let o=Object.keys(s);if(o.includes("prototype")||o.includes("__proto__"))return!1}}return n.every(s=>Fn(r[s],e,t+1))}return!0}function Wn(r){return typeof r=="number"&&!Number.isFinite(r)?!0:Array.isArray(r)?r.some(Wn):typeof r=="object"&&r!==null?Object.values(r).some(Wn):!1}function Ni(r){let e=ge(r);return e.success?e.value:r}function D(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r)){for(let t=0;t<r.length;t++)r[t]=D(r[t]);return r}let e=r;for(let t of Object.keys(e)){if(t==="__proto__"||t==="constructor"||t==="prototype"){delete e[t];continue}D(e[t])}return r}function $i(r){return ge(r,{maxDepth:16,maxStringLength:1*1024*1024,maxArrayLength:1e3,maxObjectKeys:100})}function lt(r,e,t,n){if(r===null||typeof r!="object")return!1;if(typeof e=="function")try{if(r instanceof e)return!0}catch{}if(Object.prototype.toString.call(r)!==`[object ${t}]`)return!1;let s=r;return n.every(o=>typeof s[o]=="function")}function Ui(r){return r instanceof Uint8Array}function Hi(r){return r instanceof ArrayBuffer}function ji(r){return lt(r,globalThis.ReadableStream,"ReadableStream",["getReader","cancel"])}function Bi(r){return lt(r,globalThis.Headers,"Headers",["get","set","append","forEach"])}function zi(r){return lt(r,globalThis.AbortSignal,"AbortSignal",["addEventListener","removeEventListener"])}function qi(r){if(r===null||typeof r!="object")return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function Fi(r){return lt(r,globalThis.FormData,"FormData",["append","get","getAll","set"])}function Wi(r){return lt(r,globalThis.Blob,"Blob",["arrayBuffer","slice","text","stream"])}function Ki(r){return lt(r,globalThis.URLSearchParams,"URLSearchParams",["append","get","getAll","sort"])}function Ve(r){return typeof r!="string"||r.length===0||r.length>4096?!1:rl.test(r)}function ve(r){if(typeof r!="string"||r.length>8192)return!1;for(let e=0;e<r.length;e++){let t=r.charCodeAt(e);if(t<32&&t!==9||t===127||t>255)return!1}return!0}function Gt(r){return sl.some(([e,t])=>r>=e&&r<=t)}function qn(r){return r===""?null:/^0[xX][0-9a-fA-F]+$/.test(r)?parseInt(r,16):/^0[0-7]+$/.test(r)?parseInt(r,8):/^\d+$/.test(r)?parseInt(r,10):null}function Vi(r){if(r.includes(":")||!/^[0-9a-fA-FxX.]+$/.test(r))return null;let e=r.endsWith(".")?r.slice(0,-1):r;if(e==="")return null;let t=e.split(".");if(t.length>4||t.length<1)return null;if(t.length===1){let i=qn(t[0]);return i===null||i>4294967295?null:i>>>0}let n=[];for(let i=0;i<t.length-1;i++){let a=qn(t[i]);if(a===null||a>255)return null;n.push(a)}let s=qn(t[t.length-1]),o=2**(8*(5-t.length));if(s===null||s>=o)return null;for(let i=8*(4-t.length);i>=0;i-=8)n.push(s>>>i&255);return(n[0]<<24|n[1]<<16|n[2]<<8|n[3])>>>0}function ol(r){if(!r.includes(":"))return null;let e=r.split("%")[0],t=e.split("::");if(t.length>2)return null;let n=o=>{if(o==="")return[];let i=o.split(":"),a=[];for(let c=0;c<i.length;c++){let u=i[c];if(u==="")return null;if(u.includes(".")){if(c!==i.length-1)return null;let l=Vi(u);if(l===null)return null;a.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255)}else{if(!/^[0-9a-fA-F]{1,4}$/.test(u))return null;let l=parseInt(u,16);a.push(l>>>8&255,l&255)}}return a},s;if(t.length===2){let o=n(t[0]),i=n(t[1]);if(!o||!i)return null;let a=16-o.length-i.length;if(a<0)return null;s=[...o,...new Array(a).fill(0),...i]}else{let o=n(e);if(!o||o.length!==16)return null;s=o}return s.length===16?new Uint8Array(s):null}function il(r){let e=n=>(r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3])>>>0;if(r.every(n=>n===0)||r.slice(0,15).every(n=>n===0)&&r[15]===1)return!0;let t=r[0];return(t&254)===252||t===254&&(r[1]&192)===128||t===255||r[0]===32&&r[1]===1&&r[2]===13&&r[3]===184?!0:r.slice(0,10).every(n=>n===0)&&r[10]===255&&r[11]===255||r.slice(0,12).every(n=>n===0)||r[0]===0&&r[1]===100&&r[2]===255&&r[3]===155&&r.slice(4,12).every(n=>n===0)?Gt(e(12)):r[0]===32&&r[1]===2?Gt(e(2)):!1}function te(r,e=["http","https"]){try{let t=typeof r=="string"?new URL(r):r,n=t.protocol.replace(/:$/,"").toLowerCase();if(!e.some(i=>i.toLowerCase()===n)||nl.has(n))return!1;let s=t.hostname.toLowerCase(),o=s.startsWith("[")&&s.endsWith("]");if(o&&(s=s.slice(1,-1)),s==="localhost"||s.endsWith(".localhost")||s==="0.0.0.0")return!1;if(o||s.includes(":")){let i=ol(s);if(i===null||il(i))return!1}else{let i=Vi(s);if(i!==null&&Gt(i))return!1}if(t.hostname.includes("..")||t.pathname.includes("..")||t.hostname.length>253||t.href.length>8192)return!1;if(t.port){let i=parseInt(t.port,10);if(isNaN(i)||i<1||i>65535)return!1}return!0}catch{return!1}}function ut(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(s=>ut(s));if(r instanceof Date)return new Date(r.getTime());if(r instanceof Uint8Array)return new Uint8Array(r);if(r instanceof Map){let s=new Map;return r.forEach((o,i)=>s.set(i,ut(o))),s}if(r instanceof Set){let s=new Set;return r.forEach(o=>s.add(ut(o))),s}let e=Object.getPrototypeOf(r),t=Object.prototype.toString.call(r)==="[object Object]",n=e===Object.prototype||e===null||!t?{}:Object.create(e);for(let s in r)s==="__proto__"||s==="constructor"||s==="prototype"||Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=ut(r[s]));return n}function Ji(r,e){let t=new Error(r);for(let n of Object.keys(e)){let s=e[n];if(n==="__proto__"){Object.defineProperty(t,n,{value:s,writable:!0,enumerable:!0,configurable:!0});continue}t[n]=s}return t}function Qi(r){if(r instanceof Error){let e={};for(let[n,s]of Object.entries(r))n!=="message"&&n!=="name"&&n!=="stack"&&(e[n]=s);let t=Object.keys(e).length>0?` | ${al(e)}`:"";return`${r.name}: ${r.message}${t}`}return String(r)}function al(r){let e=new Set;try{return JSON.stringify(r,(t,n)=>{if(typeof n=="bigint")return n.toString();if(typeof n=="object"&&n!==null){if(e.has(n))return"[Circular]";e.add(n)}return n})??String(r)}catch{return String(r)}}function Gi(r){if(typeof r!="string"||r.length>2048)return null;try{let e=new URL(r);return te(e)?(e.username="",e.password="",e.toString()):null}catch{return null}}function Xi(){let r=Zu();if(r?.hrtime){let[t,n]=r.hrtime();return t*1e3+n/1e6}return typeof globalThis.Bun<"u",Date.now()}function Yi(r,e){return e?.aborted?Promise.reject(Kn()):new Promise((t,n)=>{let s=()=>{clearTimeout(o),n(Kn())},o=setTimeout(()=>{e?.removeEventListener("abort",s),t()},r);e&&e.addEventListener("abort",s,{once:!0})})}function Xt(r){if(r.length===0)return new Uint8Array(0);let e=r.reduce((s,o)=>s+o.byteLength,0),t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function Zi(r){if(r instanceof Uint8Array)return r.slice();if(r instanceof ArrayBuffer)return new Uint8Array(r.slice(0));let e=el();return e&&e.isBuffer(r)?new Uint8Array(r):typeof r=="string"?new TextEncoder().encode(r):null}function re(r){if(r.byteLength<=24576){let n="";for(let s=0;s<r.byteLength;s++)n+=String.fromCharCode(r[s]);return btoa(n)}let t=[];for(let n=0;n<r.byteLength;n+=24576){let s=r.subarray(n,n+24576),o="";for(let i=0;i<s.byteLength;i++)o+=String.fromCharCode(s[i]);t.push(btoa(o))}return t.map((n,s)=>s<t.length-1?n.replace(/=+$/,""):n).join("")}function Pr(...r){let e=r.filter(i=>i!=null);if(e.length===0)return;if(e.length===1)return e[0];let t=e.find(i=>i.aborted);if(t){let i=new AbortController;return i.abort(t.reason),i.signal}let n=AbortSignal.any;if(typeof n=="function")return n.call(AbortSignal,e);let s=new AbortController,o=()=>{for(let i of e)i.removeEventListener("abort",o);s.abort(Kn())};for(let i of e)i.addEventListener("abort",o,{once:!0});return s.signal}function Lr(r){if(!(r instanceof Error))return!1;if(r.name==="AbortError")return!0;let e=r;return e.code==="ECONNRESET"||e.code==="ECONNABORTED"||r instanceof DOMException&&r.name==="AbortError"}function ye(r){if(!Number.isInteger(r)||r<0||r>65536)throw new Error(`randomBytes: invalid byteCount ${r}`);let e=new Uint8Array(r);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else throw new Error("randomBytes: no CSPRNG available in this runtime \u2014 crypto.getRandomValues is required");return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function Kn(){if(typeof DOMException<"u")return new DOMException("Aborted","AbortError");let r=new Error("Aborted");return r.name="AbortError",r}function Ir(){if(ue)return ue;try{if(globalThis.process?.versions?.node)return ue="node",ue}catch{}return typeof globalThis.Deno<"u"?ue="deno":typeof globalThis.Bun<"u"?ue="bun":typeof window<"u"?ue="browser":typeof globalThis<"u"&&typeof globalThis.fetch=="function"?ue="edge":ue="unknown",ue}function ea(){return Ir()==="node"}function ta(){return Ir()==="browser"}function ra(){return typeof globalThis?.fetch=="function"}function ht(r){let e={};return r.forEach((t,n)=>{let s=n.toLowerCase();if(s==="__proto__"){Object.defineProperty(e,s,{value:t,writable:!0,enumerable:!0,configurable:!0});return}if(s==="set-cookie"&&Object.hasOwn(e,s)){e[s]=`${e[s]}, ${t}`;return}e[s]=t}),e}var Cr,vr,tl,rl,nl,sl,ue,q=W(()=>{"use strict";tl={maxDepth:32,maxStringLength:10*1024*1024,maxArrayLength:1e4,maxObjectKeys:1e3,allowNonFinite:!1};rl=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;nl=new Set(["file","ftp","gopher","data","javascript","dict","ldap","ldaps","rlogin","telnet","tn3270","imap","pop","smtp","nntp","news","ssh","git","svn","webcal","urn"]),sl=[[0,16777215],[167772160,184549375],[1681915904,1686110207],[2130706432,2147483647],[2851995648,2852061183],[2886729728,2887778303],[3221225472,3221225727],[3221225984,3221226239],[3232235520,3232301055],[3323068416,3323199487],[3325256704,3325256959],[3405803776,3405804031],[3758096384,4026531839],[4026531840,4294967295]];ue=null});function Vn(r){return r}function sa(r){if(typeof r=="string"){for(let e of cl)if(e===r)return e}}var cl,x,dt,pt,mt,F,G,Mr,Dr,Pe,X,we=W(()=>{"use strict";cl=["ENETWORK","ETIMEOUT","EABORT","EHTTPSTATUS","ESIZELIMIT","EPARSE","EVALIDATION","EAUTH","EPROXY","EREDIRECT","EUNKNOWN"];x=class extends Error{constructor(t,n,s){super(t);f(this,"code");f(this,"request");f(this,"response");f(this,"cause");this.name="KinetexError",this.code=n,s?.request!==void 0&&(this.request=s.request),s?.response!==void 0&&(this.response=s.response),s?.cause!==void 0&&(this.cause=s.cause)}get isNetwork(){return this.code==="ENETWORK"}get isProxy(){return this.code==="EPROXY"}get isTimeout(){return this.code==="ETIMEOUT"}get isAbort(){return this.code==="EABORT"}get isHTTPError(){return this.code==="EHTTPSTATUS"}get status(){return this.response?.status??null}},dt=class extends x{constructor(t,n,s){super(`Response size limit exceeded: ${t} bytes read, limit is ${n} bytes`,"ESIZELIMIT",s!==void 0?{request:s}:{});f(this,"bytesRead");f(this,"limit");this.bytesRead=t,this.limit=n,this.name="SizeLimitError"}},pt=class extends x{constructor(e,t){super(`HTTP ${e.status} ${e.statusText} \u2014 ${e.url}`,"EHTTPSTATUS",{request:t,response:e}),this.name="HTTPStatusError"}get isClientError(){return(this.status??0)>=400&&(this.status??0)<500}get isServerError(){return(this.status??0)>=500}},mt=class extends x{constructor(e){super("Request was aborted","EABORT",e!==void 0?{request:e}:{}),this.name="AbortError"}},F=class extends x{constructor(e,t){super(e,"ENETWORK",t!==void 0?{request:t}:{}),this.name="NetworkError"}},G=class extends x{constructor(e,t){super(e,"EVALIDATION",t!==void 0?{request:t}:{}),this.name="ValidationError"}},Mr=class extends x{constructor(e,t){super(e,"EAUTH",t!==void 0?{request:t}:{}),this.name="AuthError"}},Dr=class extends x{constructor(e,t){super(e,"EPROXY",t!==void 0?{request:t}:{}),this.name="ProxyError"}},Pe=class extends x{constructor(e,t){super(e,"EREDIRECT",t!==void 0?{request:t}:{}),this.name="RedirectError"}},X=class extends x{constructor(t,n){super(`Request timed out after ${t}ms`,"ETIMEOUT",n!==void 0?{request:n}:{});f(this,"timeoutMs");this.timeoutMs=t,this.name="TimeoutError"}}});var ua={};ae(ua,{CREDENTIAL_HEADERS:()=>$r,CloudflareKVAdapter:()=>yt,HTTPCache:()=>le,MemoryStorageAdapter:()=>Le,TwoTierStorageAdapter:()=>wt,WebStorageAdapter:()=>Qe,createKVCache:()=>Zn,createLocalStorageCache:()=>Xn,createMemoryCache:()=>Gn,createSessionStorageCache:()=>Yn,createTwoTierCache:()=>es,getAuthFingerprint:()=>be});function aa(r){let e={noStore:!1,noCache:!1,mustRevalidate:!1,proxyRevalidate:!1,public:!1,private:!1,maxAge:null,sMaxAge:null,staleWhileRevalidate:null,staleIfError:null,immutable:!1};for(let t of r.split(",")){let n=t.trim(),s=n.indexOf("="),o=(s===-1?n:n.slice(0,s)).trim().toLowerCase(),i=s===-1?null:n.slice(s+1).trim().replace(/^"|"$/g,""),a=i!==null?parseInt(i,10):null;switch(o){case"no-store":e.noStore=!0;break;case"no-cache":e.noCache=!0;break;case"must-revalidate":e.mustRevalidate=!0;break;case"proxy-revalidate":e.proxyRevalidate=!0;break;case"public":e.public=!0;break;case"private":e.private=!0;break;case"immutable":e.immutable=!0;break;case"max-age":e.maxAge=a;break;case"s-maxage":e.sMaxAge=a;break;case"stale-while-revalidate":e.staleWhileRevalidate=a;break;case"stale-if-error":e.staleIfError=a;break;case"no-transform":break;case"only-if-cached":break;case"must-understand":break;default:break}}return e}function oa(r,e){return r?r.trim()==="*"?null:r.split(",").map(s=>s.trim().toLowerCase()).sort().map(s=>{let o=e[s]??e[s.toLowerCase()]??"";return`${s}=${o}`}).join(";"):""}function gt(r){return r.replaceAll(ul,"").replaceAll(/\s+/g," ").trim()}async function be(r){let e=new Map;for(let[i,a]of Object.entries(r))e.set(i.toLowerCase(),a);let t=[];for(let i of $r){let a=e.get(i);a&&t.push(`${i}=${a}`)}if(t.length===0)return"";let n=new TextEncoder().encode(t.join("|")),s=await crypto.subtle.digest("SHA-256",n);return`auth:${Array.from(new Uint8Array(s)).map(i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}`}async function ll(r){try{let e=new URL(r.url),t=gt(e.hostname),n=gt(e.pathname);e.searchParams.sort();let s=gt(e.search);e.hash="";let o=`${e.protocol}//${t}${e.port?":"+e.port:""}${n}${s}`,i=gt(r.method.toUpperCase()),a=await be(r.headers??{}),c=`${i}:${o}`;return a?`${c}:${a}`:c}catch{let e=gt(r.method.toUpperCase()),t=gt(r.url),n=await be(r.headers??{}),s=`${e}:${t}`;return n?`${s}:${n}`:s}}function hl(r){let e=r.headers["cache-control"]??r.headers["Cache-Control"]??"",t=aa(e);return t.noCache||t.mustRevalidate}function ia(r,e,t){let n=r.headers["cache-control"]??r.headers["Cache-Control"]??"",s=aa(n);if(t&&s.noStore)return{ttlMs:0,swrMs:0,staleOnError:0,shouldCache:!1};let o=s.sMaxAge??s.maxAge,i;if(o!==null){let u=parseInt(r.headers.age??r.headers.Age??"0",10)||0;i=Math.max(0,(o-u)*1e3)}else{let u=r.headers.expires??r.headers.Expires;if(u){let l=Date.parse(u);i=isNaN(l)?e:Math.max(0,l-Date.now())}else{let l=r.headers["last-modified"]??r.headers["Last-Modified"];if(l){let h=Date.parse(l);isNaN(h)?i=e:i=Math.min(Math.max((Date.now()-h)*.1,0),e)}else i=e}}s.immutable&&i>0&&(i=365*24*60*60*1e3);let a=s.staleWhileRevalidate!==null?s.staleWhileRevalidate*1e3:0,c=s.staleIfError!==null?s.staleIfError*1e3:0;return{ttlMs:i,swrMs:a,staleOnError:c,shouldCache:i>0||a>0||c>0}}function Nr(r){return{...r,response:ca(r.response),tags:[...r.tags]}}function ca(r){return{...r,headers:{...r.headers},body:r.body instanceof Uint8Array?new Uint8Array(r.body):r.body}}function fl(r){return r?typeof r=="string"?new TextEncoder().encode(r).byteLength:r.byteLength:0}function Gn(r){return new le({...r,storage:new Le})}function Xn(r,e){if(typeof localStorage>"u")throw new Error("localStorage is not available");return new le({...e,storage:new Qe(localStorage,r)})}function Yn(r,e){if(typeof sessionStorage>"u")throw new Error("sessionStorage is not available");return new le({...e,storage:new Qe(sessionStorage,r)})}function Zn(r,e){return new le({...e,storage:new yt(r)})}function es(r,e){return new le({...e,storage:new wt(r)})}var Le,Qe,yt,wt,ul,$r,Jn,Qn,le,bt=W(()=>{"use strict";q();Le=class{constructor(){f(this,"store",new Map)}get(e){return Promise.resolve(this.store.get(e)??null)}set(e,t){return this.store.set(e,t),Promise.resolve()}delete(e){return this.store.delete(e),Promise.resolve()}keys(){return Promise.resolve(Array.from(this.store.keys()))}clear(){return this.store.clear(),Promise.resolve()}get size(){return this.store.size}},Qe=class{constructor(e,t="hc:"){f(this,"storage");f(this,"prefix");this.storage=e,this.prefix=t}get(e){try{let t=this.storage.getItem(this.prefix+e);if(!t)return Promise.resolve(null);let n=ge(t,{maxDepth:32});return Promise.resolve(n.success&&n.value!==void 0?n.value:null)}catch{return Promise.resolve(null)}}set(e,t){try{return this.storage.setItem(this.prefix+e,JSON.stringify(t)),Promise.resolve(!0)}catch(n){return n instanceof Error&&(n.name==="QuotaExceededError"||n.name==="NS_ERROR_DOM_QUOTA_REACHED")&&console.warn("[kinetex] WebStorageAdapter: storage quota exceeded. Entry was NOT cached. Consider reducing maxBodySizeBytes or using a different storage adapter."),Promise.resolve(!1)}}delete(e){return this.storage.removeItem(this.prefix+e),Promise.resolve()}keys(){let e=[];for(let t=0;t<this.storage.length;t++){let n=this.storage.key(t);n?.startsWith(this.prefix)&&e.push(n.slice(this.prefix.length))}return Promise.resolve(e)}clear(){let e=[];for(let t=0;t<this.storage.length;t++){let n=this.storage.key(t);n?.startsWith(this.prefix)&&e.push(n)}for(let t of e)this.storage.removeItem(t);return Promise.resolve()}},yt=class{constructor(e,t="hc:"){f(this,"kv");f(this,"prefix");this.kv=e,this.prefix=t}async get(e){return await this.kv.get(this.prefix+e,"json")}async set(e,t){let n=t.expiresAt===1/0?void 0:Math.max(1,Math.ceil((t.expiresAt-Date.now())/1e3));await this.kv.put(this.prefix+e,JSON.stringify(t),{...n!==void 0?{expirationTtl:n}:{}})}async delete(e){await this.kv.delete(this.prefix+e)}async keys(){return(await this.kv.list({prefix:this.prefix})).keys.map(t=>t.name.slice(this.prefix.length))}async clear(){let e=await this.keys();await Promise.all(e.map(t=>this.kv.delete(this.prefix+t)))}},wt=class{constructor(e){f(this,"l2");f(this,"l1",new Le);this.l2=e}async get(e){let t=await this.l1.get(e);if(t)return t;let n=await this.l2.get(e);return n&&await this.l1.set(e,n),n}async set(e,t){await Promise.all([this.l1.set(e,t),this.l2.set(e,t)])}async delete(e){await Promise.all([this.l1.delete(e),this.l2.delete(e)])}async keys(){return await this.l2.keys()}async clear(){await Promise.all([this.l1.clear(),this.l2.clear()])}};ul=/[\u0000-\u001f\u007f-\u009f]/g;$r=["authorization","proxy-authorization","cookie","x-api-key","apikey","api-key","x-auth-token","x-access-token","x-refresh-token","x-session-id","x-session-token","x-secret","x-secret-key","x-private-key","x-csrf-token"];Jn=class{constructor(e,t=null,n=null){f(this,"key");f(this,"prev");f(this,"next");this.key=e,this.prev=t,this.next=n}},Qn=class{constructor(){f(this,"map",new Map);f(this,"head",null);f(this,"tail",null)}touch(e){let t=this.map.get(e);if(t)this._unlink(t),this._prepend(t);else{let n=new Jn(e);this.map.set(e,n),this._prepend(n)}}evict(){if(!this.tail)return null;let e=this.tail.key;return this._unlink(this.tail),this.map.delete(e),e}remove(e){let t=this.map.get(e);t&&(this._unlink(t),this.map.delete(e))}clear(){this.map.clear(),this.head=null,this.tail=null}get size(){return this.map.size}_prepend(e){e.prev=null,e.next=this.head,this.head&&(this.head.prev=e),this.head=e,this.tail||(this.tail=e)}_unlink(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=null,e.next=null}},le=class{constructor(e={}){f(this,"cfg");f(this,"storage");f(this,"lru",new Qn);f(this,"tagIndex",new Map);f(this,"swrInFlight",new Set);f(this,"stats",{hits:0,misses:0,staleHits:0,errors:0,evictions:0,totalEntries:0,totalSizeBytes:0,hitRate:0});this.cfg={maxEntries:e.maxEntries??500,maxSizeBytes:e.maxSizeBytes??50*1024*1024,maxBodySizeBytes:e.maxBodySizeBytes??5*1024*1024,defaultTtlMs:e.defaultTtlMs??6e4,maxAbsoluteAgeMs:e.maxAbsoluteAgeMs??10080*60*1e3,honorCacheControl:e.honorCacheControl??!0,cacheMethods:e.cacheMethods??["GET","HEAD"],cacheStatuses:e.cacheStatuses??[200,203,204,206,300,301,404,405,410,414,501],cacheKey:e.cacheKey??ll,storage:e.storage??new Le,namespace:e.namespace??""},(this.cfg.defaultTtlMs===1/0||this.cfg.defaultTtlMs>365*24*60*60*1e3)&&(console.warn(`[Kinetex Cache] Capping defaultTtlMs from ${this.cfg.defaultTtlMs}ms to 1 year (${365*24*60*60*1e3}ms)`),this.cfg.defaultTtlMs=365*24*60*60*1e3),this.storage=this.cfg.storage}async get(e){if(!this._isCacheable(e.method))return null;let t=await this._key(e),n=await this.storage.get(t);if(!n)return this.stats.misses++,this._updateHitRate(),null;if(n.varyKey!==null&&n.varyKey!==""){let i=oa(n.response.headers.vary??n.response.headers.Vary??"",e.headers);if(i===null||i!==n.varyKey)return this.stats.misses++,this._updateHitRate(),null}let s=Date.now();return s-n.createdAt>this.cfg.maxAbsoluteAgeMs?(await this._delete(t,n),this.stats.misses++,this._updateHitRate(),null):n.expiresAt===1/0||n.expiresAt>s?(this.stats.hits++,this.lru.touch(t),this._updateHitRate(),{entry:Nr(n),stale:n.mustRevalidate===!0}):n.staleUntil>s?(this.stats.staleHits++,this.lru.touch(t),this._updateHitRate(),{entry:Nr(n),stale:!0}):n.staleOnError>s?(this.stats.staleHits++,this._updateHitRate(),{entry:Nr(n),stale:!0}):(await this._delete(t,n),this.stats.misses++,this._updateHitRate(),null)}async set(e,t,n={}){if(!this._isCacheable(e.method)||!this.cfg.cacheStatuses.includes(t.status))return!1;let{ttlMs:s,swrMs:o,staleOnError:i,shouldCache:a}=n.ttlMs!==void 0?{ttlMs:n.ttlMs,swrMs:0,staleOnError:0,shouldCache:!0}:ia(t,this.cfg.defaultTtlMs,this.cfg.honorCacheControl);if(!a&&!n.force)return!1;let c=fl(t.body);if(c>this.cfg.maxBodySizeBytes)return!1;let u=Date.now(),l=this.cfg.maxAbsoluteAgeMs,h=Math.min(s===1/0?l:s,l);if(h<=0&&o<=0&&i<=0&&!n.force)return!1;let p=t.headers.vary??t.headers.Vary??null,d=p?oa(p,e.headers):"";if(d===null)return!1;let m=n.tags??[],g={response:ca(t),createdAt:u,expiresAt:h===1/0?1/0:u+h,staleUntil:u+h+o,staleOnError:u+h+i,etag:t.headers.etag??t.headers.ETag??null,lastModified:t.headers["last-modified"]??t.headers["Last-Modified"]??null,varyKey:d,mustRevalidate:hl(t),tags:m,size:c+256},y=await this._key(e);if(await this._ensureCapacity(g.size),await this.storage.set(y,g)===!1)return!1;this.lru.touch(y),this.stats.totalEntries++,this.stats.totalSizeBytes+=g.size;for(let _ of m){let b=this.tagIndex.get(_)??new Set;b.add(y),this.tagIndex.set(_,b)}return!0}buildConditionalHeaders(e){let t={};return e.etag&&(t["if-none-match"]=e.etag),e.lastModified&&(t["if-modified-since"]=e.lastModified),t}async revalidate(e,t){let n=await this._key(e),s=await this.storage.get(n);if(!s)return null;let o={...s.response.headers,...t.headers},i={...s.response,headers:o},{ttlMs:a,swrMs:c,staleOnError:u}=ia(i,this.cfg.defaultTtlMs,this.cfg.honorCacheControl),l=Date.now(),h=Math.min(a===1/0?this.cfg.maxAbsoluteAgeMs:a,this.cfg.maxAbsoluteAgeMs),p={...s,response:i,createdAt:l,expiresAt:h<=0?l:l+h,staleUntil:l+h+c,staleOnError:l+h+u,etag:o.etag??o.ETag??s.etag,lastModified:o["last-modified"]??o["Last-Modified"]??s.lastModified};return await this.storage.set(n,p),this.lru.touch(n),Nr(p)}async markSWRInFlight(e){let t=await this._key(e);return this.swrInFlight.has(t)?!1:(this.swrInFlight.add(t),!0)}async clearSWRInFlight(e){let t=await this._key(e);this.swrInFlight.delete(t)}async isSWRInFlight(e){let t=await this._key(e);return this.swrInFlight.has(t)}async delete(e){let t=await this._key(e),n=await this.storage.get(t);return n?(await this._delete(t,n),!0):!1}async invalidateByURL(e){let t=await this.storage.keys(),n=0;for(let s of t){let o=this.cfg.namespace?s.startsWith(this.cfg.namespace+":")?s.slice(this.cfg.namespace.length+1):null:s;if(o===null)continue;let i=o.indexOf(":");if(i===-1)continue;let a=o.slice(i+1),c=a.lastIndexOf(":auth:"),u=c!==-1?a.slice(0,c):a,l=e.endsWith("/")?e.slice(0,-1):e;if((u.endsWith("/")?u.slice(0,-1):u).startsWith(l)){let p=await this.storage.get(s);await this._delete(s,p??void 0),n++}}return n}async invalidateByTag(e){let t=this.tagIndex.get(e);if(!t||t.size===0)return 0;let n=0;for(let s of[...t]){let o=await this.storage.get(s);await this._delete(s,o??void 0),n++}return this.tagIndex.delete(e),n}async clear(){await this.storage.clear(),this.lru.clear(),this.tagIndex.clear(),this.swrInFlight.clear(),this.stats.totalEntries=0,this.stats.totalSizeBytes=0}async warm(e){for(let{req:t,res:n,tags:s}of e)await this.set(t,n,{...s!==void 0?{tags:s}:{},force:!0})}getStats(){return{...this.stats}}resetStats(){this.stats={...this.stats,hits:0,misses:0,staleHits:0,errors:0,evictions:0,hitRate:0}}async serialize(){let e=await this.storage.keys(),t=[],n=Date.now();for(let s of e){let o=await this.storage.get(s);o&&(o.expiresAt!==1/0&&o.expiresAt<n||t.push([s,o]))}return JSON.stringify({version:1,entries:t})}async deserialize(e){let t=ge(e,{maxDepth:32});if(!t.success)throw new Error("[kinetex] HTTPCache.deserialize: invalid JSON");let n=t.value;if(typeof n!="object"||n===null||!("version"in n)||!("entries"in n)||n.version!==1||!Array.isArray(n.entries))throw new Error("[kinetex] HTTPCache.deserialize: unexpected format (expected {version:1, entries:[\u2026]})");let{entries:s}=n,o=Date.now();for(let i of s){if(!Array.isArray(i)||i.length!==2)continue;let[a,c]=i;if(typeof a!="string"||a.length===0||a.length>2048)continue;let u=null;try{typeof c=="object"&&c!==null&&typeof c.createdAt=="number"&&typeof c.expiresAt=="number"&&typeof c.staleUntil=="number"&&typeof c.staleOnError=="number"&&typeof c.size=="number"&&Array.isArray(c.tags)&&c.tags.every(p=>typeof p=="string")&&(u=c)}catch{}if(!u)continue;let l=c;if(!(l.expiresAt!==1/0&&l.expiresAt<o)&&!(o-l.createdAt>this.cfg.maxAbsoluteAgeMs)&&!(l.size>this.cfg.maxBodySizeBytes+512)){await this.storage.set(a,l),this.lru.touch(a),this.stats.totalEntries++,this.stats.totalSizeBytes+=l.size;for(let h of l.tags){let p=this.tagIndex.get(h)??new Set;p.add(a),this.tagIndex.set(h,p)}}}}async _key(e){let t=await this.cfg.cacheKey(e);return this.cfg.namespace?`${this.cfg.namespace}:${t}`:t}_isCacheable(e){return this.cfg.cacheMethods.includes(e.toUpperCase())}async _delete(e,t){if(await this.storage.delete(e),this.lru.remove(e),t){this.stats.totalEntries=Math.max(0,this.stats.totalEntries-1),this.stats.totalSizeBytes=Math.max(0,this.stats.totalSizeBytes-t.size);for(let n of t.tags)this.tagIndex.get(n)?.delete(e)}else for(let n of this.tagIndex.values())n.delete(e)}async _ensureCapacity(e){for(;this.stats.totalEntries>=this.cfg.maxEntries;){let t=this.lru.evict();if(!t)break;let n=await this.storage.get(t);await this._delete(t,n??void 0),this.stats.evictions++}for(;this.stats.totalSizeBytes+e>this.cfg.maxSizeBytes;){let t=this.lru.evict();if(!t)break;let n=await this.storage.get(t);await this._delete(t,n??void 0),this.stats.evictions++}}_updateHitRate(){let e=this.stats.hits+this.stats.misses+this.stats.staleHits;this.stats.hitRate=e>0?(this.stats.hits+this.stats.staleHits)/e:0}}});function dl(r){if(typeof atob<"u")return atob(r);let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="";r=r.replace(/=+$/,"");for(let n=0;n<r.length;n+=4){let s=e.indexOf(r[n]),o=n+1<r.length?e.indexOf(r[n+1]):0,i=n+2<r.length?e.indexOf(r[n+2]):0,a=n+3<r.length?e.indexOf(r[n+3]):0;t+=String.fromCharCode(s<<2|o>>4),n+2<r.length&&(t+=String.fromCharCode((o&15)<<4|i>>2)),n+3<r.length&&(t+=String.fromCharCode((i&3)<<6|a))}return t}function ha(r){if(typeof btoa<"u")return btoa(r);let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="";for(let n=0;n<r.length;n+=3){let s=r.charCodeAt(n),o=n+1<r.length?r.charCodeAt(n+1):0,i=n+2<r.length?r.charCodeAt(n+2):0;t+=e[s>>2],t+=e[(s&3)<<4|o>>4],t+=n+1<r.length?e[(o&15)<<2|i>>6]:"=",t+=n+2<r.length?e[i&63]:"="}return t}function ml(r){let e=[],t="",n=!1;for(let s=0;s<r.length;s++){let o=r[s];if(n){if(o==="\\"&&s+1<r.length){t+=o+r[++s];continue}o==='"'&&(n=!1),t+=o;continue}if(o==='"'){n=!0,t+=o;continue}if(o===";"){e.push(t),t="";continue}t+=o}return e.push(t),e}function gl(r){return r.length>=2&&r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1).replace(/\\(.)/g,"$1"):r}function xe(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Y(r){let e=new Map;for(let t of ml(r)){let n=t.trim();if(!n)continue;let s=n.indexOf("=");if(s===-1)e.set(n.toLowerCase(),"");else{let o=n.slice(0,s).trim().toLowerCase();e.set(o,gl(n.slice(s+1).trim()))}}return e}function qr(r){return r.split(",").map(e=>{let t=e.trim().split(";"),n=(t[0]??"").trim(),s=1,o=new Map;for(let i=1;i<t.length;i++){let a=t[i].trim(),c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),l=a.slice(c+1).trim();if(u==="q"){let h=parseFloat(l);Number.isFinite(h)&&(s=Math.min(1,Math.max(0,h)))}else o.set(u,l)}return{value:n,quality:s,params:o}}).filter(e=>e.value!=="").sort((e,t)=>t.quality-e.quality)}function yl(r){let e=r.match(/^([A-Za-z0-9_-]+)'([A-Za-z0-9_-]*)'(.+)$/);if(!e)return null;try{return decodeURIComponent(e[3])}catch{return null}}function os(r){if(!r)return null;let e=r.indexOf(";"),t=e===-1?r.trim():r.slice(0,e).trim(),n=t.indexOf("/");if(n===-1)return null;let s=t.slice(0,n).toLowerCase(),o=t.slice(n+1).toLowerCase();if(!s||!o)return null;let i=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;if(!i.test(s)||!i.test(o))return null;let a=e===-1?new Map:Y(r.slice(e));return{mediaType:`${s}/${o}`,type:s,subtype:o,charset:a.get("charset")??null,boundary:a.get("boundary")??null,params:a}}function is(r){let e=r.mediaType;if(r.charset&&(e+=`; charset=${r.charset}`),r.boundary&&(e+=`; boundary=${r.boundary}`),r.params&&r.params instanceof Map)r.params.forEach((t,n)=>{n==="charset"||n==="boundary"||(e+=`; ${n}=${t.includes(" ")?`"${t}"`:t}`)});else if(r.params&&typeof r.params=="object")for(let[t,n]of Object.entries(r.params))t==="charset"||t==="boundary"||(e+=`; ${t}=${n.includes(" ")?`"${n}"`:n}`);return e}function as(r){if(!r)return null;let e=r.indexOf(";"),t=(e===-1?r:r.slice(0,e)).trim().toLowerCase(),n=e===-1?new Map:Y(r.slice(e)),s=null,o=n.get("filename*");o&&(s=yl(o)),s===null&&(s=n.get("filename")??null);let i=n.get("name")??null;return{type:t,filename:s,name:i,params:n}}function cs(r){let e=r.type;if(r.name&&(e+=`; name=${xe(r.name)}`),r.filename){e+=`; filename=${xe(r.filename)}`;let t=encodeURIComponent(r.filename);t!==r.filename&&(e+=`; filename*=UTF-8''${t}`)}return e}function wl(r){let e=[],t="",n=!1;for(let s of r){if(s==='"'&&(n=!n),s===","&&!n){e.push(t),t="";continue}t+=s}return e.push(t),e}function us(r){let e={noCache:!1,noStore:!1,noTransform:!1,onlyIfCached:!1,maxAge:null,maxStale:null,minFresh:null,staleIfError:null,public:!1,private:!1,mustRevalidate:!1,proxyRevalidate:!1,sMaxAge:null,immutable:!1,mustUnderstand:!1,staleWhileRevalidate:null,unknown:new Map};for(let t of wl(r)){let n=t.trim(),s=n.indexOf("="),o=(s===-1?n:n.slice(0,s)).trim().toLowerCase(),i=s===-1?null:n.slice(s+1).trim().replace(/^"|"$/g,""),a=i!==null?parseInt(i,10):null;switch(o){case"no-cache":e.noCache=!0;break;case"no-store":e.noStore=!0;break;case"no-transform":e.noTransform=!0;break;case"only-if-cached":e.onlyIfCached=!0;break;case"public":e.public=!0;break;case"must-revalidate":e.mustRevalidate=!0;break;case"proxy-revalidate":e.proxyRevalidate=!0;break;case"immutable":e.immutable=!0;break;case"must-understand":e.mustUnderstand=!0;break;case"max-age":e.maxAge=a;break;case"max-stale":e.maxStale=a??1/0;break;case"min-fresh":e.minFresh=a;break;case"s-maxage":e.sMaxAge=a;break;case"stale-if-error":e.staleIfError=a;break;case"stale-while-revalidate":e.staleWhileRevalidate=a;break;case"private":e.private=i?i.split(",").map(c=>c.trim()):!0;break;default:e.unknown.set(o,i??!0)}}return e}function ls(r){let e=[];if(r.noCache&&e.push("no-cache"),r.noStore&&e.push("no-store"),r.noTransform&&e.push("no-transform"),r.onlyIfCached&&e.push("only-if-cached"),r.public&&e.push("public"),r.mustRevalidate&&e.push("must-revalidate"),r.proxyRevalidate&&e.push("proxy-revalidate"),r.immutable&&e.push("immutable"),r.mustUnderstand&&e.push("must-understand"),r.maxAge!=null&&e.push(`max-age=${r.maxAge}`),r.maxStale!=null&&e.push(r.maxStale===1/0?"max-stale":`max-stale=${r.maxStale}`),r.minFresh!=null&&e.push(`min-fresh=${r.minFresh}`),r.sMaxAge!=null&&e.push(`s-maxage=${r.sMaxAge}`),r.staleIfError!=null&&e.push(`stale-if-error=${r.staleIfError}`),r.staleWhileRevalidate!=null&&e.push(`stale-while-revalidate=${r.staleWhileRevalidate}`),r.private&&e.push(Array.isArray(r.private)?`private=${r.private.join(", ")}`:"private"),r.unknown)for(let[t,n]of r.unknown)e.push(n===!0?t:`${t}=${n}`);return e.join(", ")}function Ur(r){if(!r)return null;let e=r.indexOf(" ");if(e===-1)return{scheme:r.toLowerCase(),token:null,params:new Map,basic:null};let t=r.slice(0,e).toLowerCase(),n=r.slice(e+1).trim(),s=new Map,o=null,i=null;if(t==="basic"){o=n;try{let a=dl(n),c=a.indexOf(":");c!==-1&&(i={username:a.slice(0,c),password:a.slice(c+1)})}catch{}}else if(t==="bearer"||t==="token")o=n;else if(n.includes("="))for(let a of n.split(",")){let c=a.trim(),u=c.indexOf("=");if(u===-1)continue;let l=c.slice(0,u).trim().toLowerCase(),h=c.slice(u+1).trim();h.startsWith('"')&&h.endsWith('"')&&(h=h.slice(1,-1)),s.set(l,h)}else o=n;return{scheme:t,token:o,params:s,basic:i}}function Hr(r){let e=[],t=[],n="",s=!1;for(let o=0;o<r.length;o++){let i=r[o];i==='"'&&(o===0||r[o-1]!=="\\")&&(s=!s),i===","&&!s?(t.push(n.trim()),n=""):n+=i}n.trim()&&t.push(n.trim());for(let o of t){if(!o)continue;let i=o.indexOf(" "),a=(i===-1?o:o.slice(0,i)).toLowerCase(),c=i===-1?"":o.slice(i+1),u=Y(c);e.push({scheme:a,realm:u.get("realm")??null,params:u})}return e}function ma(r){return`Bearer ${r}`}function ga(r,e){return`Basic ${ha(`${r}:${e}`)}`}function Fr(r){return qr(r)}function hs(r){return qr(r)}function fs(r){return qr(r)}function ya(r){return r.trim()?qr(r):[]}function wa(r,e){if(e.length===0)return null;if(!r.trim())return e[0];let t=i=>i.split(";")[0].trim().toLowerCase(),n=Fr(r).map(i=>({essence:t(i.value),quality:i.quality})).filter(i=>i.essence!==""),s=(i,a)=>i===a?2:i.endsWith("/*")&&a.startsWith(i.slice(0,i.length-1))?1:i==="*/*"?0:-1,o=null;for(let i=0;i<e.length;i++){let a=t(e[i]),c=null,u=-1;for(let l of n){let h=s(l.essence,a);h<0||h>u&&(u=h,c=l.quality)}c===null||c<=0||(o===null||c>o.quality||c===o.quality&&u>o.spec)&&(o={index:i,quality:c,spec:u})}return o===null?null:e[o.index]}function ds(r){let e=r.indexOf("=");if(e===-1)return null;let t=r.slice(0,e).trim().toLowerCase(),n=r.slice(e+1).split(",").map(s=>{let o=s.trim(),i=o.indexOf("-");if(i===-1)return null;let a=o.slice(0,i).trim(),c=o.slice(i+1).trim(),u=a===""?null:parseInt(a,10),l=c===""?null:parseInt(c,10);return u!==null&&!Number.isFinite(u)||l!==null&&!Number.isFinite(l)||u===null&&l===null||u!==null&&u<0||l!==null&&l<0||u!==null&&l!==null&&u>l?null:{start:u,end:l}}).filter(s=>s!==null);return n.length===0?null:{unit:t,ranges:n}}function ps(r){let e=r.match(/^(\S+)\s+(\*|\d+-\d+)\/(\*|\d+)$/);if(!e)return null;let t=e[1].toLowerCase(),n=e[2],s=e[3]==="*"?null:parseInt(e[3],10);if(n==="*")return{unit:t,start:null,end:null,total:s};let o=n.indexOf("-");return{unit:t,start:parseInt(n.slice(0,o),10),end:parseInt(n.slice(o+1),10),total:s}}function jr(r){let e=[],t=r.split(/,\s*(?=<)/);for(let n of t){let s=n.trim(),o=s.indexOf(">");if(!s.startsWith("<")||o===-1)continue;let i=s.slice(1,o),a=s.slice(o+1),c=Y(a);e.push({uri:i,rel:c.get("rel")??null,type:c.get("type")??null,hreflang:c.get("hreflang")??null,title:c.get("title")??null,media:c.get("media")??null,params:c})}return e}function ba(r){return r.map(e=>{let t=`<${e.uri}>`;e.rel&&(t+=`; rel=${xe(e.rel)}`),e.type&&(t+=`; type=${xe(e.type)}`),e.hreflang&&(t+=`; hreflang=${xe(e.hreflang)}`),e.title&&(t+=`; title=${xe(e.title)}`),e.media&&(t+=`; media=${xe(e.media)}`);let n=e.params instanceof Map?[...e.params.entries()]:Object.entries(e.params??{});for(let[s,o]of n)["rel","type","hreflang","title","media"].includes(s)||(t+=`; ${s}=${xe(String(o))}`);return t}).join(", ")}function ms(r){let e={by:null,for:[],host:null,proto:null};for(let t of r.split(",")){let n=Y(t.trim());n.has("by")&&(e.by=n.get("by")),n.has("for")&&e.for.push(n.get("for")),n.has("host")&&(e.host=n.get("host")),n.has("proto")&&(e.proto=n.get("proto"))}return e}function Wr(r){let e=r.get(S.Forwarded);if(e)return ms(e);let t=r.get(S.XForwardedFor),n=r.get(S.XForwardedHost),s=r.get(S.XForwardedProto);return{by:null,for:t?t.split(",").map(o=>o.trim()):[],host:n??null,proto:s??null}}function bl(r){return/^\d{1,3}(\.\d{1,3}){3}$/.test(r)?r.split(".").every(e=>Number(e)<=255&&(e==="0"||!e.startsWith("0"))):!r.includes(":")||!/^[0-9a-f:.]+$/i.test(r)?!1:(r.match(/::/g)??[]).length<=1}function ts(r){if(!r)return null;let e=xl(r);return e&&(/^_/.test(e)||bl(e))?e:null}function gs(r,e={}){let t=Math.max(0,Math.trunc(e.trustedHops??0)),n=Wr(r);if(n.for.length>0){let s=t===0?0:n.for.length-t;for(let o=s;o>=0;o--){let i=ts(n.for[o]);if(i)return i}for(let o of n.for){let i=ts(o);if(i)return i}return null}return ts(r.get(S.XRealIP))}function xl(r){let e=r.trim();if(e.startsWith('"')&&e.endsWith('"')&&e.length>=2&&(e=e.slice(1,-1)),e.startsWith("[")){let n=e.indexOf("]");if(n!==-1)return e.slice(1,n)}let t=/^(.*):\d+$/.exec(e);return t&&(t[1]??"").includes(".")?t[1]:e}function ys(r){let e=r.trim();if(!_l.test(e)&&!Sl.test(e)&&!El.test(e))return null;let t=Date.parse(e);return isNaN(t)?null:t}function Zt(r){let e=r.trim();if(/^\d+$/.test(e))return{date:null,delay:parseInt(e,10)};let t=ys(e);return t!==null?{date:new Date(t),delay:null}:{date:null,delay:null}}function xa(r){let e=[],t="",n=!1;for(let s=0;s<r.length;s++){let o=r[s];o==='"'&&(s===0||r[s-1]!=="\\")&&(n=!n),o===","&&!n?(t.trim()&&e.push(t.trim()),t=""):t+=o}return t.trim()&&e.push(t.trim()),e.map(s=>{let o=s.match(/^(\d{3})\s+(\S+)\s+["']?([^"']+)["']?\s*(.*)$/);if(!o)return null;let i=o[1],a=o[2],c=o[3],u=o[4]??"",l=parseInt(i,10),h=(()=>{let p=u.trim().replace(/^"|"$/g,"");if(p){let d=Date.parse(p);if(!isNaN(d))return new Date(d)}})();return{code:l,agent:a,text:c,...h!==void 0?{date:h}:{}}}).filter(s=>s!==null)}function ws(r){let e=Y(";"+r),t=e.get("max-age");if(t===void 0)return null;let n=parseInt(t,10);return isNaN(n)?null:{maxAge:n,includeSubDomains:e.has("includesubdomains"),preload:e.has("preload")}}function Kr(r){let e=`max-age=${r.maxAge}`;return r.includeSubDomains&&(e+="; includeSubDomains"),r.preload&&(e+="; preload"),e}function bs(r){let e=new Map;for(let t of r.split(";")){let n=t.trim().split(/\s+/);if(n.length===0||!n[0])continue;let s=n[0].toLowerCase(),o=n.slice(1);e.set(s,o)}return e}function Vr(r){let e=[];for(let[t,n]of r)e.push(n.length>0?`${t} ${n.join(" ")}`:t);return e.join("; ")}function xs(r){return r.split(",").map(e=>{let t=e.trim().split(";"),n=(t[0]??"").trim(),s=Y(t.slice(1).join(";")),o=s.get("dur");return{name:n,duration:o!==void 0?parseFloat(o):null,description:s.get("desc")??null}}).filter(e=>e.name!=="")}function _a(r){return r.map(e=>{let t=e.name;return e.duration!==null&&(t+=`;dur=${e.duration}`),e.description!==null&&(t+=`;desc=${xe(e.description)}`),t}).join(", ")}function _s(r){if(r.trim()==="clear")return[];let e=[];for(let t of r.split(",")){let n=t.trim(),s=n.indexOf("=");if(s===-1)continue;let o=n.slice(0,s).trim().replace(/^"|"$/g,""),i=n.slice(s+1).trim(),a=i.indexOf(";"),c=a!==-1?Y(";"+i.slice(a+1)):new Map,u=(a!==-1?i.slice(0,a):i).replace(/^"|"$/g,""),l,h;if(u.startsWith("[")){let p=u.indexOf("]");if(p===-1)l=u,h=443;else{l=u.slice(0,p+1);let d=u.slice(p+2);h=d?parseInt(d,10):443}}else{let p=u.lastIndexOf(":");l=p===-1?u:u.slice(0,p),h=p===-1?443:parseInt(u.slice(p+1),10)}e.push({protocol:o,host:l,port:h,maxAge:c.has("ma")?parseInt(c.get("ma"),10):null,persist:c.has("persist")&&c.get("persist")==="1"})}return e}function Sa(r){let e=new he;for(let[t,n]of Object.entries(r))if(n!==void 0)if(Array.isArray(n))for(let s of n)e.append(t,s);else e.append(t,n);return e}function Ea(r){let e={};return r.forEach((t,n)=>{let o=r.getAll(n);e[n]=o.length===1?o[0]:[...o]}),e}function Ta(r){return new he(r)}function Ra(r={}){let e=new he;if(r.hsts!==!1){let t=r.hsts===!0||r.hsts===void 0?{maxAge:31536e3,includeSubDomains:!0,preload:!1}:r.hsts;e.set(S.StrictTransportSecurity,Kr(t))}if(r.csp){let t=typeof r.csp=="string"?r.csp:Vr(r.csp);e.set(S.ContentSecurityPolicy,t)}return e.set(S.XFrameOptions,r.frameOptions??"DENY"),r.noSniff!==!1&&e.set(S.XContentTypeOptions,"nosniff"),e.set(S.ReferrerPolicy,r.referrer??"strict-origin-when-cross-origin"),r.permissions&&e.set(S.PermissionsPolicy,r.permissions),r.coep&&e.set(S.CrossOriginEmbedderPolicy,r.coep),r.coop&&e.set(S.CrossOriginOpenerPolicy,r.coop),r.corp&&e.set(S.CrossOriginResourcePolicy,r.corp),e}function Aa(r){let e=new he,t=Array.isArray(r.origin)?r.origin.join(", "):r.origin;return e.set(S.AccessControlAllowOrigin,t),r.methods?.length&&e.set(S.AccessControlAllowMethods,r.methods.join(", ")),r.allowHeaders?.length&&e.set(S.AccessControlAllowHeaders,r.allowHeaders.join(", ")),r.exposeHeaders?.length&&e.set(S.AccessControlExposeHeaders,r.exposeHeaders.join(", ")),r.credentials&&e.set(S.AccessControlAllowCredentials,"true"),r.maxAge!=null&&e.set(S.AccessControlMaxAge,String(r.maxAge)),e}function ka(r){return new Ie(r)}function Ca(r){return new Ie(r,"request")}function Jr(){if(typeof crypto>"u"||typeof crypto.getRandomValues!="function")throw new Error("generateIdempotencyKey: no CSPRNG available in this runtime \u2014 crypto.getRandomValues is required");let r=new Uint8Array(16);crypto.getRandomValues(r),r[6]=(r[6]??0)&15|64,r[8]=(r[8]??0)&63|128;let e=[];for(let t of r)e.push(t.toString(16).padStart(2,"0"));return[e.slice(0,4).join(""),e.slice(4,6).join(""),e.slice(6,8).join(""),e.slice(8,10).join(""),e.slice(10,16).join("")].join("-")}function Qr(r,e=255){return typeof r!="string"||r.length===0||r.length>e?!1:/^[\x21-\x7e]+$/.test(r)}function va(r){return new Ie(r,"response")}function Pa(r){return new Ie(r,"immutable")}var Ge,S,Br,zr,xt,la,pl,z,fa,rs,ns,ss,da,pa,he,_l,Sl,El,Ie,Oe=W(()=>{"use strict";q();S={ContentType:"content-type",ContentLength:"content-length",ContentEncoding:"content-encoding",ContentLanguage:"content-language",ContentLocation:"content-location",ContentDisposition:"content-disposition",ContentRange:"content-range",ContentMD5:"content-md5",TransferEncoding:"transfer-encoding",TrailingHeader:"trailer",CacheControl:"cache-control",Pragma:"pragma",Expires:"expires",Age:"age",ETag:"etag",LastModified:"last-modified",Vary:"vary",IfMatch:"if-match",IfNoneMatch:"if-none-match",IfModifiedSince:"if-modified-since",IfUnmodifiedSince:"if-unmodified-since",IfRange:"if-range",Host:"host",Origin:"origin",Referer:"referer",UserAgent:"user-agent",From:"from",TE:"te",Expect:"expect",IdempotencyKey:"idempotency-key",MaxForwards:"max-forwards",Accept:"accept",AcceptEncoding:"accept-encoding",AcceptLanguage:"accept-language",AcceptCharset:"accept-charset",AcceptRanges:"accept-ranges",AcceptPatch:"accept-patch",Authorization:"authorization",ProxyAuthorization:"proxy-authorization",WWWAuthenticate:"www-authenticate",ProxyAuthenticate:"proxy-authenticate",AuthenticationInfo:"authentication-info",Range:"range",Cookie:"cookie",SetCookie:"set-cookie",Location:"location",Via:"via",Forwarded:"forwarded",XForwardedFor:"x-forwarded-for",XForwardedHost:"x-forwarded-host",XForwardedProto:"x-forwarded-proto",XForwardedPort:"x-forwarded-port",XRealIP:"x-real-ip",Connection:"connection",KeepAlive:"keep-alive",Upgrade:"upgrade",AccessControlAllowOrigin:"access-control-allow-origin",AccessControlAllowMethods:"access-control-allow-methods",AccessControlAllowHeaders:"access-control-allow-headers",AccessControlExposeHeaders:"access-control-expose-headers",AccessControlMaxAge:"access-control-max-age",AccessControlAllowCredentials:"access-control-allow-credentials",AccessControlRequestMethod:"access-control-request-method",AccessControlRequestHeaders:"access-control-request-headers",Date:"date",RetryAfter:"retry-after",Allow:"allow",Server:"server",ServerTiming:"server-timing",TimingAllowOrigin:"timing-allow-origin",SecWebSocketKey:"sec-websocket-key",SecWebSocketAccept:"sec-websocket-accept",SecWebSocketProtocol:"sec-websocket-protocol",SecWebSocketVersion:"sec-websocket-version",SecWebSocketExtensions:"sec-websocket-extensions",SecFetchSite:"sec-fetch-site",SecFetchMode:"sec-fetch-mode",SecFetchUser:"sec-fetch-user",SecFetchDest:"sec-fetch-dest",StrictTransportSecurity:"strict-transport-security",ContentSecurityPolicy:"content-security-policy",ContentSecurityPolicyRO:"content-security-policy-report-only",XContentTypeOptions:"x-content-type-options",XFrameOptions:"x-frame-options",XXSSProtection:"x-xss-protection",ReferrerPolicy:"referrer-policy",PermissionsPolicy:"permissions-policy",CrossOriginOpenerPolicy:"cross-origin-opener-policy",CrossOriginEmbedderPolicy:"cross-origin-embedder-policy",CrossOriginResourcePolicy:"cross-origin-resource-policy",NEL:"nel",ReportTo:"report-to",ReportingEndpoints:"reporting-endpoints",Link:"link",AltSvc:"alt-svc",AltUsed:"alt-used",Priority:"priority",EarlyData:"early-data",PushPolicy:"push-policy",AcceptPushPolicy:"accept-push-policy",XRequestID:"x-request-id",XCorrelationID:"x-correlation-id",XRateLimitLimit:"x-ratelimit-limit",XRateLimitRemaining:"x-ratelimit-remaining",XRateLimitReset:"x-ratelimit-reset",XPoweredBy:"x-powered-by",XRequestedWith:"x-requested-with"};Br=Ve,zr=ve,xt=new Set(["set-cookie","www-authenticate","proxy-authenticate"]),la=new Set(["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]),pl=new Set(["set-cookie","set-cookie2"]),he=class{constructor(e,t="none"){Ei(this,z);f(this,"map",new Map);f(this,"guard");this.guard=t,e!=null&&ce(this,z,fa).call(this,e)}append(e,t){ce(this,z,ss).call(this,e);let n=ce(this,z,rs).call(this,e),s=ce(this,z,ns).call(this,t),o=this.map.get(n);o?o.values.push(s):this.map.set(n,{name:e,values:[s]})}delete(e){ce(this,z,pa).call(this,e),this.map.delete(e.toLowerCase())}get(e){let t=this.map.get(e.toLowerCase());return t?xt.has(e.toLowerCase())?t.values[0]??null:t.values.join(", "):null}getAll(e){return[...this.map.get(e.toLowerCase())?.values??[]]}has(e){return this.map.has(e.toLowerCase())}set(e,t){ce(this,z,da).call(this,e);let n=ce(this,z,rs).call(this,e),s=ce(this,z,ns).call(this,t);this.map.set(n,{name:e,values:[s]})}forEach(e,t){for(let[n,s]of this.map){let o=xt.has(n)?s.values:[s.values.join(", ")];for(let i of o)e.call(t,i,n,this)}}keys(){return this.map.keys()}*values(){for(let[e,t]of this.map)if(xt.has(e))for(let n of t.values)yield n;else yield t.values.join(", ")}*entries(){for(let[e,t]of this.map)if(xt.has(e))for(let n of t.values)yield[e,n];else yield[e,t.values.join(", ")]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"HttpHeaders"}toObject(){let e={};for(let[t,n]of this.map){let s=n.values;e[t]=s.length===1?s[0]:[...s]}return e}toFlatObject(){let e={};for(let[t,n]of this.map)e[t]=xt.has(t)?n.values[0]??"":n.values.join(", ");return e}toWebHeaders(){if(typeof Headers>"u")throw new Error("WHATWG Headers is not available in this runtime");let e=new Headers;for(let[t,n]of this.map)for(let s of n.values)e.append(t,s);return e}toHTTP1String(){let e=[];for(let[,t]of this.map)for(let n of t.values)e.push(`${t.name}: ${n}`);return e.join(`\r
3
- `)}clone(e){return new Ge(this,e??this.guard)}freeze(){return this.clone("immutable")}merge(e,t={}){let n=e instanceof Ge?e:new Ge(e);for(let[s,o]of n.map)if(t.append)for(let i of o.values)this.append(s,i);else this.map.set(s,{name:o.name,values:[...o.values]});return this}pick(...e){let t=new Ge;for(let n of e){let s=n.toLowerCase(),o=this.map.get(s);o&&t.map.set(s,{name:o.name,values:[...o.values]})}return t}omit(...e){let t=this.clone();for(let n of e)t.map.delete(n.toLowerCase());return t}redact(...e){let t=this.clone();for(let n of e){let s=n.toLowerCase(),o=t.map.get(s);o&&t.map.set(s,{name:o.name,values:o.values.map(()=>"**REDACTED**")})}return t}diff(e){let t=new Ge;for(let[n,s]of e.map){let o=this.get(n),i=xt.has(n)?s.values[0]??"":s.values.join(", ");o!==i&&t.map.set(n,{name:s.name,values:[...s.values]})}return t}get size(){return this.map.size}};z=new WeakSet,fa=function(e){if(e instanceof Ge){for(let[t,n]of e.map)this.map.set(t,{name:n.name,values:[...n.values]});return}if(typeof Headers<"u"&&e instanceof Headers){e.forEach((t,n)=>this.append(n,t));return}if(Array.isArray(e)){for(let t of e){if(!Array.isArray(t)||t.length<2)throw new TypeError("Headers init sequence must contain [name, value] pairs");this.append(String(t[0]),String(t[1]))}return}if(typeof e=="object")for(let[t,n]of Object.entries(e))if(Array.isArray(n))for(let s of n)this.append(t,s);else this.append(t,String(n))},rs=function(e){if(!Br(e))throw new TypeError(`Invalid header name: "${e}"`);return e.toLowerCase()},ns=function(e){let t=e.trim();if(!zr(t))throw new TypeError(`Invalid header value for: "${t}"`);return t},ss=function(e){if(this.guard==="immutable")throw new TypeError("Headers are immutable");if(this.guard==="request"&&la.has(e.toLowerCase()))throw new TypeError(`Header "${e}" is forbidden for request guard`);if(this.guard==="response"&&pl.has(e.toLowerCase()))throw new TypeError(`Header "${e}" is forbidden for response guard`)},da=function(e){ce(this,z,ss).call(this,e)},pa=function(e){if(this.guard==="immutable")throw new TypeError("Headers are immutable");if(this.guard==="request"&&la.has(e.toLowerCase()))throw new TypeError(`Header "${e}" is forbidden for request guard`)};Ge=he;_l=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/,Sl=/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2,4} \d{2}:\d{2}:\d{2} GMT$/,El=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]\d \d{2}:\d{2}:\d{2} \d{4}$/;Ie=class extends he{get contentType(){let e=this.get(S.ContentType);return e?os(e):null}set contentType(e){if(e===null){this.delete(S.ContentType);return}if(typeof e=="string"){this.set(S.ContentType,e);return}this.set(S.ContentType,is(e))}get contentLength(){let e=this.get(S.ContentLength);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}set contentLength(e){if(e===null){this.delete(S.ContentLength);return}this.set(S.ContentLength,String(e))}get contentDisposition(){let e=this.get(S.ContentDisposition);return e?as(e):null}set contentDisposition(e){if(e===null){this.delete(S.ContentDisposition);return}if(typeof e=="string"){this.set(S.ContentDisposition,e);return}this.set(S.ContentDisposition,cs(e))}get cacheControl(){let e=this.get(S.CacheControl);return e?us(e):null}set cacheControl(e){if(e===null){this.delete(S.CacheControl);return}if(typeof e=="string"){this.set(S.CacheControl,e);return}this.set(S.CacheControl,ls(e))}get authorization(){let e=this.get(S.Authorization);return e?Ur(e):null}set authorization(e){if(e===null){this.delete(S.Authorization);return}this.set(S.Authorization,e)}get accept(){return Fr(this.get(S.Accept)??"")}get acceptEncoding(){return hs(this.get(S.AcceptEncoding)??"")}get acceptLanguage(){return fs(this.get(S.AcceptLanguage)??"")}get range(){let e=this.get(S.Range);return e?ds(e):null}get contentRange(){let e=this.get(S.ContentRange);return e?ps(e):null}get etag(){return this.get(S.ETag)}set etag(e){if(e===null){this.delete(S.ETag);return}let t=e.startsWith('"')||e.startsWith('W/"')?e:`"${e}"`;this.set(S.ETag,t)}get links(){let e=this.get(S.Link);return e?jr(e):[]}get retryAfter(){let e=this.get(S.RetryAfter);return e?Zt(e):null}get hsts(){let e=this.get(S.StrictTransportSecurity);return e?ws(e):null}set hsts(e){if(e===null){this.delete(S.StrictTransportSecurity);return}this.set(S.StrictTransportSecurity,Kr(e))}get csp(){let e=this.get(S.ContentSecurityPolicy);return e?bs(e):null}set csp(e){if(e===null){this.delete(S.ContentSecurityPolicy);return}if(typeof e=="string"){this.set(S.ContentSecurityPolicy,e);return}this.set(S.ContentSecurityPolicy,Vr(e))}get serverTiming(){let e=this.get(S.ServerTiming);return e?xs(e):[]}get clientIP(){return gs(this)}get forwarded(){return Wr(this)}get host(){return this.get(S.Host)}get origin(){return this.get(S.Origin)}get userAgent(){return this.get(S.UserAgent)}get location(){return this.get(S.Location)}get date(){let e=this.get(S.Date);if(!e)return null;let t=Date.parse(e);return isNaN(t)?null:new Date(t)}get age(){let e=this.get(S.Age);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get vary(){let e=this.get(S.Vary);return e?e.split(",").map(t=>t.trim().toLowerCase()):[]}get xRequestID(){return this.get(S.XRequestID)}get xCorrelationID(){return this.get(S.XCorrelationID)}get xPoweredBy(){return this.get(S.XPoweredBy)}get xRequestedWith(){return this.get(S.XRequestedWith)}get xRateLimitLimit(){let e=this.get(S.XRateLimitLimit);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get xRateLimitRemaining(){let e=this.get(S.XRateLimitRemaining);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get xRateLimitReset(){let e=this.get(S.XRateLimitReset);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get secFetchSite(){return this.get(S.SecFetchSite)}get secFetchMode(){return this.get(S.SecFetchMode)}get secFetchUser(){return this.get(S.SecFetchUser)}get secFetchDest(){return this.get(S.SecFetchDest)}get earlyData(){let e=this.get(S.EarlyData);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get priority(){return this.get(S.Priority)}get allow(){return this.get(S.Allow)}get server(){return this.get(S.Server)}get acceptRanges(){return this.get("accept-ranges")}get lastModified(){let e=this.get("last-modified");if(!e)return null;let t=Date.parse(e);return isNaN(t)?null:new Date(t)}get expires(){let e=this.get("expires");if(!e)return null;let t=Date.parse(e);return isNaN(t)?null:new Date(t)}get contentEncoding(){return this.get("content-encoding")}get contentLanguage(){return this.get("content-language")}get contentLocation(){return this.get("content-location")}get link(){let e=this.get(S.Link);return e?jr(e)[0]??null:null}get altSvc(){let e=this.get(S.AltSvc);return e?_s(e):[]}get wwwAuthenticate(){let e=this.get("www-authenticate");return e?Hr(e):null}set wwwAuthenticate(e){if(e===null){this.delete("www-authenticate");return}let t=e.map(n=>{let o=[...n.params].filter(([a])=>a!=="realm").map(([a,c])=>`${a}=${c}`).join(", "),i=n.scheme;return n.realm&&(i+=` realm="${n.realm}"`),o&&(i+=`; ${o}`),i}).join(", ");this.set("www-authenticate",t)}get proxyAuthenticate(){let e=this.get(S.ProxyAuthenticate);return e?Hr(e):null}set proxyAuthenticate(e){if(e===null){this.delete(S.ProxyAuthenticate);return}let t=e.map(n=>{let o=[...n.params].filter(([a])=>a!=="realm").map(([a,c])=>`${a}=${c}`).join(", "),i=n.scheme;return n.realm&&(i+=` realm="${n.realm}"`),o&&(i+=`; ${o}`),i}).join(", ");this.set(S.ProxyAuthenticate,t)}get proxyAuthorization(){let e=this.get(S.ProxyAuthorization);return e?Ur(e):null}set proxyAuthorization(e){if(e===null){this.delete(S.ProxyAuthorization);return}if(typeof e=="string"){this.set(S.ProxyAuthorization,e);return}e.basic?this.set(S.ProxyAuthorization,`Basic ${ha(`${e.basic.username}:${e.basic.password}`)}`):e.token?this.set(S.ProxyAuthorization,`${e.scheme} ${e.token}`):this.set(S.ProxyAuthorization,e.scheme)}get setCookies(){return this.getAll(S.SetCookie)}get accessControlAllowOrigin(){return this.get(S.AccessControlAllowOrigin)}get accessControlAllowMethods(){return this.get(S.AccessControlAllowMethods)}get accessControlAllowHeaders(){return this.get(S.AccessControlAllowHeaders)}get accessControlMaxAge(){let e=this.get(S.AccessControlMaxAge);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get accessControlCredentials(){let e=this.get(S.AccessControlAllowCredentials);return e==="true"?!0:e==="false"?!1:null}}});var tc={};ae(tc,{connectThroughProxy:()=>Vl});function Fl(r){return/^socks5h?:/i.test(r)}function Wl(r){if(r.username===void 0)return;let e=`${r.username}:${r.password??""}`,t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return`Basic ${typeof globalThis.btoa=="function"?globalThis.btoa(n):Buffer.from(t).toString("base64")}`}function Kl(r){let e=r.split(`\r
4
- `,1)[0]??"",t=/^HTTP\/1\.[01] (\d{3})(?: (.*))?$/.exec(e);return t?{status:Number(t[1]),reason:t[2]??""}:null}async function Vl(r,e,t={}){let n=t.request!==void 0?{request:t.request}:{};if(Fl(r.url))throw new x(`proxy url "${r.url}" is a SOCKS proxy, which needs a different mechanism. Use createSocks5Tunnel() from kinetex/socks5 and supply your own fetch over the tunnel.`,"EVALIDATION",n);let s;try{s=new URL(r.url)}catch(y){throw new x(`proxy url "${r.url}" is not a valid URL`,"EVALIDATION",{...n,cause:y})}if(s.protocol!=="http:"&&s.protocol!=="https:")throw new x(`proxy url scheme "${s.protocol}" is not supported; use http:, https:, socks5: or socks5h:`,"EVALIDATION",n);let o=await import("node:net"),i=await import("node:tls"),a=s.port?Number(s.port):s.protocol==="https:"?443:80,c=e.port?Number(e.port):e.protocol==="https:"?443:80,u=`${e.hostname}:${c}`,l=t.connectTimeoutMs??zl,h=s.protocol==="https:"?await Ql(i,{host:s.hostname,port:a,servername:s.hostname,...t.ca!==void 0?{ca:t.ca}:{}},l,t.signal,n,`proxy ${s.host}`):await Jl(o,{host:s.hostname,port:a},l,t.signal,n,`proxy ${s.host}`),p=Wl(r),d=[`CONNECT ${u} HTTP/1.1`,`Host: ${u}`,"Proxy-Connection: Keep-Alive",...p!==void 0?[`Proxy-Authorization: ${p}`]:[],"",""];h.write(d.join(`\r
5
- `));let m="",g=await new Promise(y=>{let w=()=>{for(;;){let $=h.read();if($===null)return;m+=$.toString("latin1")}},_=()=>{w();let $=m.indexOf(`\r
1
+ /* kinetex v1.5.0 | MIT | https://github.com/kinetexjs/kinetex */
2
+ "use strict";var kinetex=(()=>{var ol=Object.create;var Yt=Object.defineProperty;var il=Object.getOwnPropertyDescriptor;var al=Object.getOwnPropertyNames;var cl=Object.getPrototypeOf,ul=Object.prototype.hasOwnProperty;var vi=r=>{throw TypeError(r)};var ll=(r,e,t)=>e in r?Yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ue=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var J=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var le=(r,e)=>{for(var t in e)Yt(r,t,{get:e[t],enumerable:!0})},Pi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of al(e))!ul.call(r,s)&&s!==t&&Yt(r,s,{get:()=>e[s],enumerable:!(n=il(e,s))||n.enumerable});return r};var Ie=(r,e,t)=>(t=r!=null?ol(cl(r)):{},Pi(e||!r||!r.__esModule?Yt(t,"default",{value:r,enumerable:!0}):t,r)),hl=r=>Pi(Yt({},"__esModule",{value:!0}),r);var f=(r,e,t)=>ll(r,typeof e!="symbol"?e+"":e,t),fl=(r,e,t)=>e.has(r)||vi("Cannot "+t);var Li=(r,e,t)=>e.has(r)?vi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var he=(r,e,t)=>(fl(r,e,"access private method"),t);function dl(){if(Mr)return Mr;let r=globalThis;if(r.process?.hrtime)return Mr=r.process,Mr}function pl(){if(Nr)return Nr;let r=globalThis;if(r.Buffer&&typeof r.Buffer.isBuffer=="function")return Nr=r.Buffer,Nr}function Se(r,e={}){let t={...ml};for(let[i,a]of Object.entries(e))a!==void 0&&(t[i]=a);if(r.length>t.maxStringLength)return{success:!1,error:"STRING_TOO_LONG",message:`JSON string length exceeds limit of ${t.maxStringLength}`};let n=0,s=!1,o=!1;for(let i=0;i<r.length;i++){let a=r[i];if(o){o=!1;continue}if(a==="\\"){s&&(o=!0);continue}if(a==='"'){s=!s;continue}if(!s)if(a==="{"||a==="["){if(++n>t.maxDepth)return{success:!1,error:"DEPTH_EXCEEDED",message:`JSON depth exceeds limit of ${t.maxDepth}`}}else(a==="}"||a==="]")&&n--}try{let i=JSON.parse(r);return Vn(i,t,0)?!t.allowNonFinite&&Jn(i)?{success:!1,error:"NON_FINITE_NUMBER",message:"JSON contains NaN or Infinity values"}:{success:!0,value:i}:{success:!1,error:"VALIDATION_FAILED",message:"Parsed value exceeds size limits"}}catch{return{success:!1,error:"PARSE_ERROR",message:"Failed to parse JSON"}}}function Vn(r,e,t){if(t>e.maxDepth)return!1;if(r==null)return!0;if(typeof r=="string")return r.length<=e.maxStringLength;if(typeof r=="number"||typeof r=="boolean")return!0;if(Array.isArray(r))return r.length>e.maxArrayLength?!1:r.every(n=>Vn(n,e,t+1));if(typeof r=="object"){let n=Object.keys(r);if(n.length>e.maxObjectKeys||n.includes("__proto__"))return!1;if(n.includes("constructor")){let s=r.constructor;if(typeof s=="object"&&s!==null){let o=Object.keys(s);if(o.includes("prototype")||o.includes("__proto__"))return!1}}return n.every(s=>Vn(r[s],e,t+1))}return!0}function Jn(r){return typeof r=="number"&&!Number.isFinite(r)?!0:Array.isArray(r)?r.some(Jn):typeof r=="object"&&r!==null?Object.values(r).some(Jn):!1}function Ii(r){let e=Se(r);return e.success?e.value:r}function D(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r)){for(let t=0;t<r.length;t++)r[t]=D(r[t]);return r}let e=r;for(let t of Object.keys(e)){if(t==="__proto__"||t==="constructor"||t==="prototype"){delete e[t];continue}D(e[t])}return r}function Oi(r){return Se(r,{maxDepth:16,maxStringLength:1*1024*1024,maxArrayLength:1e3,maxObjectKeys:100})}function dt(r,e,t,n){if(r===null||typeof r!="object")return!1;if(typeof e=="function")try{if(r instanceof e)return!0}catch{}if(Object.prototype.toString.call(r)!==`[object ${t}]`)return!1;let s=r;return n.every(o=>typeof s[o]=="function")}function Mi(r){return r instanceof Uint8Array}function Ni(r){return r instanceof ArrayBuffer}function Di(r){return dt(r,globalThis.ReadableStream,"ReadableStream",["getReader","cancel"])}function $i(r){return dt(r,globalThis.Headers,"Headers",["get","set","append","forEach"])}function Ui(r){return dt(r,globalThis.AbortSignal,"AbortSignal",["addEventListener","removeEventListener"])}function Hi(r){if(r===null||typeof r!="object")return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function ji(r){return dt(r,globalThis.FormData,"FormData",["append","get","getAll","set"])}function Bi(r){return dt(r,globalThis.Blob,"Blob",["arrayBuffer","slice","text","stream"])}function zi(r){return dt(r,globalThis.URLSearchParams,"URLSearchParams",["append","get","getAll","sort"])}function Te(r){return typeof r!="string"||r.length===0||r.length>4096?!1:gl.test(r)}function de(r){if(typeof r!="string"||r.length>8192)return!1;for(let e=0;e<r.length;e++){let t=r.charCodeAt(e);if(t<32&&t!==9||t===127||t>255)return!1}return!0}function ht(r){return wl.some(([e,t])=>r>=e&&r<=t)}function Kn(r){return r===""?null:/^0[xX][0-9a-fA-F]+$/.test(r)?parseInt(r,16):/^0[0-7]+$/.test(r)?parseInt(r,8):/^\d+$/.test(r)?parseInt(r,10):null}function Qn(r){if(r.includes(":")||!/^[0-9a-fA-FxX.]+$/.test(r))return null;let e=r.endsWith(".")?r.slice(0,-1):r;if(e==="")return null;let t=e.split(".");if(t.length>4||t.length<1)return null;if(t.length===1){let i=Kn(t[0]);return i===null||i>4294967295?null:i>>>0}let n=[];for(let i=0;i<t.length-1;i++){let a=Kn(t[i]);if(a===null||a>255)return null;n.push(a)}let s=Kn(t[t.length-1]),o=2**(8*(5-t.length));if(s===null||s>=o)return null;for(let i=8*(4-t.length);i>=0;i-=8)n.push(s>>>i&255);return(n[0]<<24|n[1]<<16|n[2]<<8|n[3])>>>0}function qi(r){if(!r.includes(":"))return null;let e=r.split("%")[0],t=e.split("::");if(t.length>2)return null;let n=o=>{if(o==="")return[];let i=o.split(":"),a=[];for(let c=0;c<i.length;c++){let u=i[c];if(u==="")return null;if(u.includes(".")){if(c!==i.length-1)return null;let l=Qn(u);if(l===null)return null;a.push(l>>>24&255,l>>>16&255,l>>>8&255,l&255)}else{if(!/^[0-9a-fA-F]{1,4}$/.test(u))return null;let l=parseInt(u,16);a.push(l>>>8&255,l&255)}}return a},s;if(t.length===2){let o=n(t[0]),i=n(t[1]);if(!o||!i)return null;let a=16-o.length-i.length;if(a<0)return null;s=[...o,...new Array(a).fill(0),...i]}else{let o=n(e);if(!o||o.length!==16)return null;s=o}return s.length===16?new Uint8Array(s):null}function Fi(r){let e=n=>(r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3])>>>0;if(r.every(n=>n===0)||r.slice(0,15).every(n=>n===0)&&r[15]===1)return!0;let t=r[0];return(t&254)===252||t===254&&(r[1]&192)===128||t===255||r[0]===32&&r[1]===1&&r[2]===13&&r[3]===184?!0:r.slice(0,10).every(n=>n===0)&&r[10]===255&&r[11]===255||r.slice(0,12).every(n=>n===0)||r[0]===0&&r[1]===100&&r[2]===255&&r[3]===155&&r.slice(4,12).every(n=>n===0)?ht(e(12)):r[0]===32&&r[1]===2?ht(e(2)):!1}function ne(r,e=["http","https"],t={}){try{let n=typeof r=="string"?new URL(r):r,s=n.protocol.replace(/:$/,"").toLowerCase();if(!e.some(o=>o.toLowerCase()===s)||yl.has(s))return!1;if(!t.allowPrivateNetwork){let o=n.hostname.toLowerCase(),i=o.startsWith("[")&&o.endsWith("]");if(i&&(o=o.slice(1,-1)),o==="localhost"||o.endsWith(".localhost")||o==="0.0.0.0")return!1;if(i||o.includes(":")){let a=qi(o);if(a===null||Fi(a))return!1}else{let a=Qn(o);if(a!==null&&ht(a))return!1}}if(n.hostname.includes("..")||n.pathname.includes("..")||n.hostname.length>253||n.href.length>8192)return!1;if(n.port){let o=parseInt(n.port,10);if(isNaN(o)||o<1||o>65535)return!1}return!0}catch{return!1}}function Wi(r){let e=r.trim().toLowerCase();if(e.startsWith("[")&&e.endsWith("]")||e===""||e==="localhost"||e.endsWith(".localhost"))return!0;if(e.includes(":")){let n=qi(e);return n===null||Fi(n)}let t=Qn(e);return t===null||ht(t)}function ft(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(s=>ft(s));if(r instanceof Date)return new Date(r.getTime());if(r instanceof Uint8Array)return new Uint8Array(r);if(r instanceof Map){let s=new Map;return r.forEach((o,i)=>s.set(i,ft(o))),s}if(r instanceof Set){let s=new Set;return r.forEach(o=>s.add(ft(o))),s}let e=Object.getPrototypeOf(r),t=Object.prototype.toString.call(r)==="[object Object]",n=e===Object.prototype||e===null||!t?{}:Object.create(e);for(let s in r)s==="__proto__"||s==="constructor"||s==="prototype"||Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=ft(r[s]));return n}function Ki(r,e){let t=new Error(r);for(let n of Object.keys(e)){let s=e[n];if(n==="__proto__"){Object.defineProperty(t,n,{value:s,writable:!0,enumerable:!0,configurable:!0});continue}t[n]=s}return t}function Vi(r){if(r instanceof Error){let e={};for(let[n,s]of Object.entries(r))n!=="message"&&n!=="name"&&n!=="stack"&&(e[n]=s);let t=Object.keys(e).length>0?` | ${Gn(e)}`:"";return`${r.name}: ${r.message}${t}`}return String(r)}function Gn(r,e="[Circular]"){let t=new Set;try{return JSON.stringify(r,(n,s)=>{if(typeof s=="bigint")return s.toString();if(typeof s=="object"&&s!==null){if(t.has(s))return e;t.add(s)}return s})??String(r)}catch{return String(r)}}function Ji(r){if(typeof r!="string"||r.length>2048)return null;try{let e=new URL(r);return ne(e)?(e.username="",e.password="",e.toString()):null}catch{return null}}function N(){let r=dl();if(r?.hrtime){let[t,n]=r.hrtime();return t*1e3+n/1e6}return typeof globalThis.Bun<"u",Date.now()}function Oe(r,e){return e?.aborted?Promise.reject(Zt()):new Promise((t,n)=>{let s=()=>{clearTimeout(o),n(Zt())},o=setTimeout(()=>{e?.removeEventListener("abort",s),t()},r);e&&e.addEventListener("abort",s,{once:!0})})}function er(r){if(r.length===0)return new Uint8Array(0);let e=r.reduce((s,o)=>s+o.byteLength,0),t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function Qi(r){if(r instanceof Uint8Array)return r.slice();if(r instanceof ArrayBuffer)return new Uint8Array(r.slice(0));let e=pl();return e&&e.isBuffer(r)?new Uint8Array(r):typeof r=="string"?new TextEncoder().encode(r):null}function Dr(r,e){return e.has(r.toLowerCase())}function pt(r,e,t){let n={};for(let[s,o]of Object.entries(r))n[s]=Dr(s,e)?t:o;return n}async function pe(r){let e=typeof r=="string"?new TextEncoder().encode(r):r,t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}function se(r){if(r.byteLength<=24576){let n="";for(let s=0;s<r.byteLength;s++)n+=String.fromCharCode(r[s]);return btoa(n)}let t=[];for(let n=0;n<r.byteLength;n+=24576){let s=r.subarray(n,n+24576),o="";for(let i=0;i<s.byteLength;i++)o+=String.fromCharCode(s[i]);t.push(btoa(o))}return t.map((n,s)=>s<t.length-1?n.replace(/=+$/,""):n).join("")}function $r(...r){let e=r.filter(i=>i!=null);if(e.length===0)return;if(e.length===1)return e[0];let t=e.find(i=>i.aborted);if(t){let i=new AbortController;return i.abort(t.reason),i.signal}let n=AbortSignal.any;if(typeof n=="function")return n.call(AbortSignal,e);let s=new AbortController,o=()=>{for(let i of e)i.removeEventListener("abort",o);s.abort(Zt())};for(let i of e)i.addEventListener("abort",o,{once:!0});return s.signal}function Ur(r){if(!(r instanceof Error))return!1;if(r.name==="AbortError")return!0;let e=r;return e.code==="ECONNRESET"||e.code==="ECONNABORTED"||r instanceof DOMException&&r.name==="AbortError"}function Ee(r){if(!Number.isInteger(r)||r<0||r>65536)throw new Error(`randomBytes: invalid byteCount ${r}`);let e=new Uint8Array(r);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else throw new Error("randomBytes: no CSPRNG available in this runtime \u2014 crypto.getRandomValues is required");return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function Zt(r="Aborted"){if(typeof DOMException<"u")return new DOMException(r,"AbortError");let e=new Error(r);return e.name="AbortError",e}function Hr(){if(fe)return fe;try{if(globalThis.process?.versions?.node)return fe="node",fe}catch{}return typeof globalThis.Deno<"u"?fe="deno":typeof globalThis.Bun<"u"?fe="bun":typeof window<"u"?fe="browser":typeof globalThis<"u"&&typeof globalThis.fetch=="function"?fe="edge":fe="unknown",fe}function Gi(){return Hr()==="node"}function Xi(){return Hr()==="browser"}function Yi(){return typeof globalThis?.fetch=="function"}function mt(r){let e={};return r.forEach((t,n)=>{let s=n.toLowerCase();if(s==="__proto__"){Object.defineProperty(e,s,{value:t,writable:!0,enumerable:!0,configurable:!0});return}if(s==="set-cookie"&&Object.hasOwn(e,s)){e[s]=`${e[s]}, ${t}`;return}e[s]=t}),e}var Mr,Nr,ml,gl,yl,wl,fe,U=J(()=>{"use strict";ml={maxDepth:32,maxStringLength:10*1024*1024,maxArrayLength:1e4,maxObjectKeys:1e3,allowNonFinite:!1};gl=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;yl=new Set(["file","ftp","gopher","data","javascript","dict","ldap","ldaps","rlogin","telnet","tn3270","imap","pop","smtp","nntp","news","ssh","git","svn","webcal","urn"]),wl=[[0,16777215],[167772160,184549375],[1681915904,1686110207],[2130706432,2147483647],[2851995648,2852061183],[2886729728,2887778303],[3221225472,3221225727],[3221225984,3221226239],[3232235520,3232301055],[3323068416,3323199487],[3325256704,3325256959],[3405803776,3405804031],[3758096384,4026531839],[4026531840,4294967295]];fe=null});function Zn(r){return r}function ma(r){if(typeof r=="string"){for(let e of _l)if(e===r)return e}}var _l,x,bt,xt,_t,V,X,zr,qr,Me,Y,Re=J(()=>{"use strict";_l=["ENETWORK","ETIMEOUT","EABORT","EHTTPSTATUS","ESIZELIMIT","EPARSE","EVALIDATION","EAUTH","EPROXY","EREDIRECT","EUNKNOWN"];x=class extends Error{constructor(t,n,s){super(t);f(this,"code");f(this,"request");f(this,"response");f(this,"cause");this.name="KinetexError",this.code=n,s?.request!==void 0&&(this.request=s.request),s?.response!==void 0&&(this.response=s.response),s?.cause!==void 0&&(this.cause=s.cause)}get isNetwork(){return this.code==="ENETWORK"}get isProxy(){return this.code==="EPROXY"}get isTimeout(){return this.code==="ETIMEOUT"}get isAbort(){return this.code==="EABORT"}get isHTTPError(){return this.code==="EHTTPSTATUS"}get status(){return this.response?.status??null}},bt=class extends x{constructor(t,n,s){super(`Response size limit exceeded: ${t} bytes read, limit is ${n} bytes`,"ESIZELIMIT",s!==void 0?{request:s}:{});f(this,"bytesRead");f(this,"limit");this.bytesRead=t,this.limit=n,this.name="SizeLimitError"}},xt=class extends x{constructor(e,t){super(`HTTP ${e.status} ${e.statusText} \u2014 ${e.url}`,"EHTTPSTATUS",{request:t,response:e}),this.name="HTTPStatusError"}get isClientError(){return(this.status??0)>=400&&(this.status??0)<500}get isServerError(){return(this.status??0)>=500}},_t=class extends x{constructor(e){super("Request was aborted","EABORT",e!==void 0?{request:e}:{}),this.name="AbortError"}},V=class extends x{constructor(e,t){super(e,"ENETWORK",t!==void 0?{request:t}:{}),this.name="NetworkError"}},X=class extends x{constructor(e,t){super(e,"EVALIDATION",t!==void 0?{request:t}:{}),this.name="ValidationError"}},zr=class extends x{constructor(e,t){super(e,"EAUTH",t!==void 0?{request:t}:{}),this.name="AuthError"}},qr=class extends x{constructor(e,t){super(e,"EPROXY",t!==void 0?{request:t}:{}),this.name="ProxyError"}},Me=class extends x{constructor(e,t){super(e,"EREDIRECT",t!==void 0?{request:t}:{}),this.name="RedirectError"}},Y=class extends x{constructor(t,n){super(`Request timed out after ${t}ms`,"ETIMEOUT",n!==void 0?{request:n}:{});f(this,"timeoutMs");this.timeoutMs=t,this.name="TimeoutError"}}});var xa={};le(xa,{CREDENTIAL_HEADERS:()=>Wr,CloudflareKVAdapter:()=>Tt,HTTPCache:()=>me,MemoryStorageAdapter:()=>Ne,TwoTierStorageAdapter:()=>Et,WebStorageAdapter:()=>Ye,createKVCache:()=>os,createLocalStorageCache:()=>ns,createMemoryCache:()=>rs,createSessionStorageCache:()=>ss,createTwoTierCache:()=>is,getAuthFingerprint:()=>Ze});function wa(r){let e={noStore:!1,noCache:!1,mustRevalidate:!1,proxyRevalidate:!1,public:!1,private:!1,maxAge:null,sMaxAge:null,staleWhileRevalidate:null,staleIfError:null,immutable:!1};for(let t of r.split(",")){let n=t.trim(),s=n.indexOf("="),o=(s===-1?n:n.slice(0,s)).trim().toLowerCase(),i=s===-1?null:n.slice(s+1).trim().replace(/^"|"$/g,""),a=i!==null?parseInt(i,10):null;switch(o){case"no-store":e.noStore=!0;break;case"no-cache":e.noCache=!0;break;case"must-revalidate":e.mustRevalidate=!0;break;case"proxy-revalidate":e.proxyRevalidate=!0;break;case"public":e.public=!0;break;case"private":e.private=!0;break;case"immutable":e.immutable=!0;break;case"max-age":e.maxAge=a;break;case"s-maxage":e.sMaxAge=a;break;case"stale-while-revalidate":e.staleWhileRevalidate=a;break;case"stale-if-error":e.staleIfError=a;break;case"no-transform":break;case"only-if-cached":break;case"must-understand":break;default:break}}return e}function ga(r,e){return r?r.trim()==="*"?null:r.split(",").map(s=>s.trim().toLowerCase()).sort().map(s=>{let o=e[s]??e[s.toLowerCase()]??"";return`${s}=${o}`}).join(";"):""}function St(r){return r.replaceAll(Sl,"").replaceAll(/\s+/g," ").trim()}async function Ze(r){let e=new Map;for(let[i,a]of Object.entries(r))e.set(i.toLowerCase(),a);let t=[];for(let i of Wr){let a=e.get(i);a&&t.push(`${i}=${a}`)}if(t.length===0)return"";let n=new TextEncoder().encode(t.join("|")),s=await crypto.subtle.digest("SHA-256",n);return`auth:${Array.from(new Uint8Array(s)).map(i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}`}async function Tl(r){try{let e=new URL(r.url),t=St(e.hostname),n=St(e.pathname);e.searchParams.sort();let s=St(e.search);e.hash="";let o=`${e.protocol}//${t}${e.port?":"+e.port:""}${n}${s}`,i=St(r.method.toUpperCase()),a=await Ze(r.headers??{}),c=`${i}:${o}`;return a?`${c}:${a}`:c}catch{let e=St(r.method.toUpperCase()),t=St(r.url),n=await Ze(r.headers??{}),s=`${e}:${t}`;return n?`${s}:${n}`:s}}function El(r){let e=r.headers["cache-control"]??r.headers["Cache-Control"]??"",t=wa(e);return t.noCache||t.mustRevalidate}function ya(r,e,t){let n=r.headers["cache-control"]??r.headers["Cache-Control"]??"",s=wa(n);if(t&&s.noStore)return{ttlMs:0,swrMs:0,staleOnError:0,shouldCache:!1};if(t&&s.private)return{ttlMs:0,swrMs:0,staleOnError:0,shouldCache:!1};let o=s.sMaxAge??s.maxAge,i;if(o!==null){let u=parseInt(r.headers.age??r.headers.Age??"0",10)||0;i=Math.max(0,(o-u)*1e3)}else{let u=r.headers.expires??r.headers.Expires;if(u){let l=Date.parse(u);i=isNaN(l)?e:Math.max(0,l-Date.now())}else{let l=r.headers["last-modified"]??r.headers["Last-Modified"];if(l){let h=Date.parse(l);isNaN(h)?i=e:i=Math.min(Math.max((Date.now()-h)*.1,0),e)}else i=e}}s.immutable&&i>0&&(i=365*24*60*60*1e3);let a=s.staleWhileRevalidate!==null?s.staleWhileRevalidate*1e3:0,c=s.staleIfError!==null?s.staleIfError*1e3:0;return{ttlMs:i,swrMs:a,staleOnError:c,shouldCache:i>0||a>0||c>0}}function Fr(r){return{...r,response:ba(r.response),tags:[...r.tags]}}function ba(r){return{...r,headers:{...r.headers},body:r.body instanceof Uint8Array?new Uint8Array(r.body):r.body}}function Rl(r){return r?typeof r=="string"?new TextEncoder().encode(r).byteLength:r.byteLength:0}function rs(r){return new me({...r,storage:new Ne})}function ns(r,e){if(typeof localStorage>"u")throw new Error("localStorage is not available");return new me({...e,storage:new Ye(localStorage,r)})}function ss(r,e){if(typeof sessionStorage>"u")throw new Error("sessionStorage is not available");return new me({...e,storage:new Ye(sessionStorage,r)})}function os(r,e){return new me({...e,storage:new Tt(r)})}function is(r,e){return new me({...e,storage:new Et(r)})}var Ne,Ye,Tt,Et,Sl,Wr,es,ts,me,Rt=J(()=>{"use strict";U();Ne=class{constructor(){f(this,"store",new Map)}get(e){return Promise.resolve(this.store.get(e)??null)}set(e,t){return this.store.set(e,t),Promise.resolve()}delete(e){return this.store.delete(e),Promise.resolve()}keys(){return Promise.resolve(Array.from(this.store.keys()))}clear(){return this.store.clear(),Promise.resolve()}get size(){return this.store.size}},Ye=class{constructor(e,t="hc:"){f(this,"storage");f(this,"prefix");this.storage=e,this.prefix=t}get(e){try{let t=this.storage.getItem(this.prefix+e);if(!t)return Promise.resolve(null);let n=Se(t,{maxDepth:32});return Promise.resolve(n.success&&n.value!==void 0?n.value:null)}catch{return Promise.resolve(null)}}set(e,t){try{return this.storage.setItem(this.prefix+e,JSON.stringify(t)),Promise.resolve(!0)}catch(n){return n instanceof Error&&(n.name==="QuotaExceededError"||n.name==="NS_ERROR_DOM_QUOTA_REACHED")&&console.warn("[kinetex] WebStorageAdapter: storage quota exceeded. Entry was NOT cached. Consider reducing maxBodySizeBytes or using a different storage adapter."),Promise.resolve(!1)}}delete(e){return this.storage.removeItem(this.prefix+e),Promise.resolve()}keys(){let e=[];for(let t=0;t<this.storage.length;t++){let n=this.storage.key(t);n?.startsWith(this.prefix)&&e.push(n.slice(this.prefix.length))}return Promise.resolve(e)}clear(){let e=[];for(let t=0;t<this.storage.length;t++){let n=this.storage.key(t);n?.startsWith(this.prefix)&&e.push(n)}for(let t of e)this.storage.removeItem(t);return Promise.resolve()}},Tt=class{constructor(e,t="hc:"){f(this,"kv");f(this,"prefix");this.kv=e,this.prefix=t}async get(e){return await this.kv.get(this.prefix+e,"json")}async set(e,t){let n=t.expiresAt===1/0?void 0:Math.max(1,Math.ceil((t.expiresAt-Date.now())/1e3));await this.kv.put(this.prefix+e,JSON.stringify(t),{...n!==void 0?{expirationTtl:n}:{}})}async delete(e){await this.kv.delete(this.prefix+e)}async keys(){return(await this.kv.list({prefix:this.prefix})).keys.map(t=>t.name.slice(this.prefix.length))}async clear(){let e=await this.keys();await Promise.all(e.map(t=>this.kv.delete(this.prefix+t)))}},Et=class{constructor(e){f(this,"l2");f(this,"l1",new Ne);this.l2=e}async get(e){let t=await this.l1.get(e);if(t)return t;let n=await this.l2.get(e);return n&&await this.l1.set(e,n),n}async set(e,t){await Promise.all([this.l1.set(e,t),this.l2.set(e,t)])}async delete(e){await Promise.all([this.l1.delete(e),this.l2.delete(e)])}async keys(){return await this.l2.keys()}async clear(){await Promise.all([this.l1.clear(),this.l2.clear()])}};Sl=/[\u0000-\u001f\u007f-\u009f]/g;Wr=["authorization","proxy-authorization","cookie","x-api-key","apikey","api-key","x-auth-token","x-access-token","x-refresh-token","x-session-id","x-session-token","x-secret","x-secret-key","x-private-key","x-csrf-token"];es=class{constructor(e,t=null,n=null){f(this,"key");f(this,"prev");f(this,"next");this.key=e,this.prev=t,this.next=n}},ts=class{constructor(){f(this,"map",new Map);f(this,"head",null);f(this,"tail",null)}touch(e){let t=this.map.get(e);if(t)this._unlink(t),this._prepend(t);else{let n=new es(e);this.map.set(e,n),this._prepend(n)}}evict(){if(!this.tail)return null;let e=this.tail.key;return this._unlink(this.tail),this.map.delete(e),e}remove(e){let t=this.map.get(e);t&&(this._unlink(t),this.map.delete(e))}clear(){this.map.clear(),this.head=null,this.tail=null}get size(){return this.map.size}_prepend(e){e.prev=null,e.next=this.head,this.head&&(this.head.prev=e),this.head=e,this.tail||(this.tail=e)}_unlink(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=null,e.next=null}},me=class{constructor(e={}){f(this,"cfg");f(this,"storage");f(this,"lru",new ts);f(this,"tagIndex",new Map);f(this,"swrInFlight",new Set);f(this,"stats",{hits:0,misses:0,staleHits:0,errors:0,evictions:0,totalEntries:0,totalSizeBytes:0,hitRate:0});this.cfg={maxEntries:e.maxEntries??500,maxSizeBytes:e.maxSizeBytes??50*1024*1024,maxBodySizeBytes:e.maxBodySizeBytes??5*1024*1024,defaultTtlMs:e.defaultTtlMs??6e4,maxAbsoluteAgeMs:e.maxAbsoluteAgeMs??10080*60*1e3,honorCacheControl:e.honorCacheControl??!0,cacheMethods:e.cacheMethods??["GET","HEAD"],cacheStatuses:e.cacheStatuses??[200,203,204,206,300,301,404,405,410,414,501],cacheKey:e.cacheKey??Tl,storage:e.storage??new Ne,namespace:e.namespace??""},(this.cfg.defaultTtlMs===1/0||this.cfg.defaultTtlMs>365*24*60*60*1e3)&&(console.warn(`[Kinetex Cache] Capping defaultTtlMs from ${this.cfg.defaultTtlMs}ms to 1 year (${365*24*60*60*1e3}ms)`),this.cfg.defaultTtlMs=365*24*60*60*1e3),this.storage=this.cfg.storage}async get(e){if(!this._isCacheable(e.method))return null;let t=await this._key(e),n=await this.storage.get(t);if(!n)return this.stats.misses++,this._updateHitRate(),null;if(n.varyKey!==null&&n.varyKey!==""){let i=ga(n.response.headers.vary??n.response.headers.Vary??"",e.headers);if(i===null||i!==n.varyKey)return this.stats.misses++,this._updateHitRate(),null}let s=Date.now();return s-n.createdAt>this.cfg.maxAbsoluteAgeMs?(await this._delete(t,n),this.stats.misses++,this._updateHitRate(),null):n.expiresAt===1/0||n.expiresAt>s?(this.stats.hits++,this.lru.touch(t),this._updateHitRate(),{entry:Fr(n),stale:n.mustRevalidate===!0}):n.staleUntil>s?(this.stats.staleHits++,this.lru.touch(t),this._updateHitRate(),{entry:Fr(n),stale:!0}):n.staleOnError>s?(this.stats.staleHits++,this._updateHitRate(),{entry:Fr(n),stale:!0}):(await this._delete(t,n),this.stats.misses++,this._updateHitRate(),null)}async set(e,t,n={}){if(!this._isCacheable(e.method)||!this.cfg.cacheStatuses.includes(t.status))return!1;let{ttlMs:s,swrMs:o,staleOnError:i,shouldCache:a}=n.ttlMs!==void 0?{ttlMs:n.ttlMs,swrMs:0,staleOnError:0,shouldCache:!0}:ya(t,this.cfg.defaultTtlMs,this.cfg.honorCacheControl);if(!a&&!n.force)return!1;let c=Rl(t.body);if(c>this.cfg.maxBodySizeBytes)return!1;let u=Date.now(),l=this.cfg.maxAbsoluteAgeMs,h=Math.min(s===1/0?l:s,l);if(h<=0&&o<=0&&i<=0&&!n.force)return!1;let d=t.headers.vary??t.headers.Vary??null,p=d?ga(d,e.headers):"";if(p===null)return!1;let m=n.tags??[],g={response:ba(t),createdAt:u,expiresAt:h===1/0?1/0:u+h,staleUntil:u+h+o,staleOnError:u+h+i,etag:t.headers.etag??t.headers.ETag??null,lastModified:t.headers["last-modified"]??t.headers["Last-Modified"]??null,varyKey:p,mustRevalidate:El(t),tags:m,size:c+256},w=await this._key(e);if(await this._ensureCapacity(g.size),await this.storage.set(w,g)===!1)return!1;this.lru.touch(w),this.stats.totalEntries++,this.stats.totalSizeBytes+=g.size;for(let S of m){let b=this.tagIndex.get(S)??new Set;b.add(w),this.tagIndex.set(S,b)}return!0}buildConditionalHeaders(e){let t={};return e.etag&&(t["if-none-match"]=e.etag),e.lastModified&&(t["if-modified-since"]=e.lastModified),t}async revalidate(e,t){let n=await this._key(e),s=await this.storage.get(n);if(!s)return null;let o={...s.response.headers,...t.headers},i={...s.response,headers:o},{ttlMs:a,swrMs:c,staleOnError:u}=ya(i,this.cfg.defaultTtlMs,this.cfg.honorCacheControl),l=Date.now(),h=Math.min(a===1/0?this.cfg.maxAbsoluteAgeMs:a,this.cfg.maxAbsoluteAgeMs),d={...s,response:i,createdAt:l,expiresAt:h<=0?l:l+h,staleUntil:l+h+c,staleOnError:l+h+u,etag:o.etag??o.ETag??s.etag,lastModified:o["last-modified"]??o["Last-Modified"]??s.lastModified};return await this.storage.set(n,d),this.lru.touch(n),Fr(d)}async markSWRInFlight(e){let t=await this._key(e);return this.swrInFlight.has(t)?!1:(this.swrInFlight.add(t),!0)}async clearSWRInFlight(e){let t=await this._key(e);this.swrInFlight.delete(t)}async isSWRInFlight(e){let t=await this._key(e);return this.swrInFlight.has(t)}async delete(e){let t=await this._key(e),n=await this.storage.get(t);return n?(await this._delete(t,n),!0):!1}async invalidateByURL(e){let t=await this.storage.keys(),n=0;for(let s of t){let o=this.cfg.namespace?s.startsWith(this.cfg.namespace+":")?s.slice(this.cfg.namespace.length+1):null:s;if(o===null)continue;let i=o.indexOf(":");if(i===-1)continue;let a=o.slice(i+1),c=a.lastIndexOf(":auth:"),u=c!==-1?a.slice(0,c):a,l=e.endsWith("/")?e.slice(0,-1):e;if((u.endsWith("/")?u.slice(0,-1):u).startsWith(l)){let d=await this.storage.get(s);await this._delete(s,d??void 0),n++}}return n}async invalidateByTag(e){let t=this.tagIndex.get(e);if(!t||t.size===0)return 0;let n=0;for(let s of[...t]){let o=await this.storage.get(s);await this._delete(s,o??void 0),n++}return this.tagIndex.delete(e),n}async clear(){await this.storage.clear(),this.lru.clear(),this.tagIndex.clear(),this.swrInFlight.clear(),this.stats.totalEntries=0,this.stats.totalSizeBytes=0}async warm(e){for(let{req:t,res:n,tags:s}of e)await this.set(t,n,{...s!==void 0?{tags:s}:{},force:!0})}getStats(){return{...this.stats}}resetStats(){this.stats={...this.stats,hits:0,misses:0,staleHits:0,errors:0,evictions:0,hitRate:0}}async serialize(){let e=await this.storage.keys(),t=[],n=Date.now();for(let s of e){let o=await this.storage.get(s);o&&(o.expiresAt!==1/0&&o.expiresAt<n||t.push([s,o]))}return JSON.stringify({version:1,entries:t})}async deserialize(e){let t=Se(e,{maxDepth:32});if(!t.success)throw new Error("[kinetex] HTTPCache.deserialize: invalid JSON");let n=t.value;if(typeof n!="object"||n===null||!("version"in n)||!("entries"in n)||n.version!==1||!Array.isArray(n.entries))throw new Error("[kinetex] HTTPCache.deserialize: unexpected format (expected {version:1, entries:[\u2026]})");let{entries:s}=n,o=Date.now();for(let i of s){if(!Array.isArray(i)||i.length!==2)continue;let[a,c]=i;if(typeof a!="string"||a.length===0||a.length>2048)continue;let u=null;try{typeof c=="object"&&c!==null&&typeof c.createdAt=="number"&&typeof c.expiresAt=="number"&&typeof c.staleUntil=="number"&&typeof c.staleOnError=="number"&&typeof c.size=="number"&&Array.isArray(c.tags)&&c.tags.every(d=>typeof d=="string")&&(u=c)}catch{}if(!u)continue;let l=c;if(!(l.expiresAt!==1/0&&l.expiresAt<o)&&!(o-l.createdAt>this.cfg.maxAbsoluteAgeMs)&&!(l.size>this.cfg.maxBodySizeBytes+512)){await this.storage.set(a,l),this.lru.touch(a),this.stats.totalEntries++,this.stats.totalSizeBytes+=l.size;for(let h of l.tags){let d=this.tagIndex.get(h)??new Set;d.add(a),this.tagIndex.set(h,d)}}}}async _key(e){let t=await this.cfg.cacheKey(e);return this.cfg.namespace?`${this.cfg.namespace}:${t}`:t}_isCacheable(e){return this.cfg.cacheMethods.includes(e.toUpperCase())}async _delete(e,t){if(await this.storage.delete(e),this.lru.remove(e),t){this.stats.totalEntries=Math.max(0,this.stats.totalEntries-1),this.stats.totalSizeBytes=Math.max(0,this.stats.totalSizeBytes-t.size);for(let n of t.tags)this.tagIndex.get(n)?.delete(e)}else for(let n of this.tagIndex.values())n.delete(e)}async _ensureCapacity(e){for(;this.stats.totalEntries>=this.cfg.maxEntries;){let t=this.lru.evict();if(!t)break;let n=await this.storage.get(t);await this._delete(t,n??void 0),this.stats.evictions++}for(;this.stats.totalSizeBytes+e>this.cfg.maxSizeBytes;){let t=this.lru.evict();if(!t)break;let n=await this.storage.get(t);await this._delete(t,n??void 0),this.stats.evictions++}}_updateHitRate(){let e=this.stats.hits+this.stats.misses+this.stats.staleHits;this.stats.hitRate=e>0?(this.stats.hits+this.stats.staleHits)/e:0}}});function kl(r){if(typeof atob<"u")return atob(r);let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="";r=r.replace(/=+$/,"");for(let n=0;n<r.length;n+=4){let s=e.indexOf(r[n]),o=n+1<r.length?e.indexOf(r[n+1]):0,i=n+2<r.length?e.indexOf(r[n+2]):0,a=n+3<r.length?e.indexOf(r[n+3]):0;t+=String.fromCharCode(s<<2|o>>4),n+2<r.length&&(t+=String.fromCharCode((o&15)<<4|i>>2)),n+3<r.length&&(t+=String.fromCharCode((i&3)<<6|a))}return t}function Sa(r){if(typeof btoa<"u")return btoa(r);let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="";for(let n=0;n<r.length;n+=3){let s=r.charCodeAt(n),o=n+1<r.length?r.charCodeAt(n+1):0,i=n+2<r.length?r.charCodeAt(n+2):0;t+=e[s>>2],t+=e[(s&3)<<4|o>>4],t+=n+1<r.length?e[(o&15)<<2|i>>6]:"=",t+=n+2<r.length?e[i&63]:"="}return t}function Cl(r){let e=[],t="",n=!1;for(let s=0;s<r.length;s++){let o=r[s];if(n){if(o==="\\"&&s+1<r.length){t+=o+r[++s];continue}o==='"'&&(n=!1),t+=o;continue}if(o==='"'){n=!0,t+=o;continue}if(o===";"){e.push(t),t="";continue}t+=o}return e.push(t),e}function vl(r){return r.length>=2&&r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1).replace(/\\(.)/g,"$1"):r}function ke(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Z(r){let e=new Map;for(let t of Cl(r)){let n=t.trim();if(!n)continue;let s=n.indexOf("=");if(s===-1)e.set(n.toLowerCase(),"");else{let o=n.slice(0,s).trim().toLowerCase();e.set(o,vl(n.slice(s+1).trim()))}}return e}function Xr(r){return r.split(",").map(e=>{let t=e.trim().split(";"),n=(t[0]??"").trim(),s=1,o=new Map;for(let i=1;i<t.length;i++){let a=t[i].trim(),c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),l=a.slice(c+1).trim();if(u==="q"){let h=parseFloat(l);Number.isFinite(h)&&(s=Math.min(1,Math.max(0,h)))}else o.set(u,l)}return{value:n,quality:s,params:o}}).filter(e=>e.value!=="").sort((e,t)=>t.quality-e.quality)}function Pl(r){let e=r.match(/^([A-Za-z0-9_-]+)'([A-Za-z0-9_-]*)'(.+)$/);if(!e)return null;try{return decodeURIComponent(e[3])}catch{return null}}function hs(r){if(!r)return null;let e=r.indexOf(";"),t=e===-1?r.trim():r.slice(0,e).trim(),n=t.indexOf("/");if(n===-1)return null;let s=t.slice(0,n).toLowerCase(),o=t.slice(n+1).toLowerCase();if(!s||!o)return null;let i=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;if(!i.test(s)||!i.test(o))return null;let a=e===-1?new Map:Z(r.slice(e));return{mediaType:`${s}/${o}`,type:s,subtype:o,charset:a.get("charset")??null,boundary:a.get("boundary")??null,params:a}}function fs(r){let e=r.mediaType;if(r.charset&&(e+=`; charset=${r.charset}`),r.boundary&&(e+=`; boundary=${r.boundary}`),r.params&&r.params instanceof Map)r.params.forEach((t,n)=>{n==="charset"||n==="boundary"||(e+=`; ${n}=${t.includes(" ")?`"${t}"`:t}`)});else if(r.params&&typeof r.params=="object")for(let[t,n]of Object.entries(r.params))t==="charset"||t==="boundary"||(e+=`; ${t}=${n.includes(" ")?`"${n}"`:n}`);return e}function ds(r){if(!r)return null;let e=r.indexOf(";"),t=(e===-1?r:r.slice(0,e)).trim().toLowerCase(),n=e===-1?new Map:Z(r.slice(e)),s=null,o=n.get("filename*");o&&(s=Pl(o)),s===null&&(s=n.get("filename")??null);let i=n.get("name")??null;return{type:t,filename:s,name:i,params:n}}function ps(r){let e=r.type;if(r.name&&(e+=`; name=${ke(r.name)}`),r.filename){e+=`; filename=${ke(r.filename)}`;let t=encodeURIComponent(r.filename);t!==r.filename&&(e+=`; filename*=UTF-8''${t}`)}return e}function Ll(r){let e=[],t="",n=!1;for(let s of r){if(s==='"'&&(n=!n),s===","&&!n){e.push(t),t="";continue}t+=s}return e.push(t),e}function ms(r){let e={noCache:!1,noStore:!1,noTransform:!1,onlyIfCached:!1,maxAge:null,maxStale:null,minFresh:null,staleIfError:null,public:!1,private:!1,mustRevalidate:!1,proxyRevalidate:!1,sMaxAge:null,immutable:!1,mustUnderstand:!1,staleWhileRevalidate:null,unknown:new Map};for(let t of Ll(r)){let n=t.trim(),s=n.indexOf("="),o=(s===-1?n:n.slice(0,s)).trim().toLowerCase(),i=s===-1?null:n.slice(s+1).trim().replace(/^"|"$/g,""),a=i!==null?parseInt(i,10):null;switch(o){case"no-cache":e.noCache=!0;break;case"no-store":e.noStore=!0;break;case"no-transform":e.noTransform=!0;break;case"only-if-cached":e.onlyIfCached=!0;break;case"public":e.public=!0;break;case"must-revalidate":e.mustRevalidate=!0;break;case"proxy-revalidate":e.proxyRevalidate=!0;break;case"immutable":e.immutable=!0;break;case"must-understand":e.mustUnderstand=!0;break;case"max-age":e.maxAge=a;break;case"max-stale":e.maxStale=a??1/0;break;case"min-fresh":e.minFresh=a;break;case"s-maxage":e.sMaxAge=a;break;case"stale-if-error":e.staleIfError=a;break;case"stale-while-revalidate":e.staleWhileRevalidate=a;break;case"private":e.private=i?i.split(",").map(c=>c.trim()):!0;break;default:e.unknown.set(o,i??!0)}}return e}function gs(r){let e=[];if(r.noCache&&e.push("no-cache"),r.noStore&&e.push("no-store"),r.noTransform&&e.push("no-transform"),r.onlyIfCached&&e.push("only-if-cached"),r.public&&e.push("public"),r.mustRevalidate&&e.push("must-revalidate"),r.proxyRevalidate&&e.push("proxy-revalidate"),r.immutable&&e.push("immutable"),r.mustUnderstand&&e.push("must-understand"),r.maxAge!=null&&e.push(`max-age=${r.maxAge}`),r.maxStale!=null&&e.push(r.maxStale===1/0?"max-stale":`max-stale=${r.maxStale}`),r.minFresh!=null&&e.push(`min-fresh=${r.minFresh}`),r.sMaxAge!=null&&e.push(`s-maxage=${r.sMaxAge}`),r.staleIfError!=null&&e.push(`stale-if-error=${r.staleIfError}`),r.staleWhileRevalidate!=null&&e.push(`stale-while-revalidate=${r.staleWhileRevalidate}`),r.private&&e.push(Array.isArray(r.private)?`private=${r.private.join(", ")}`:"private"),r.unknown)for(let[t,n]of r.unknown)e.push(n===!0?t:`${t}=${n}`);return e.join(", ")}function Kr(r){if(!r)return null;let e=r.indexOf(" ");if(e===-1)return{scheme:r.toLowerCase(),token:null,params:new Map,basic:null};let t=r.slice(0,e).toLowerCase(),n=r.slice(e+1).trim(),s=new Map,o=null,i=null;if(t==="basic"){o=n;try{let a=kl(n),c=a.indexOf(":");c!==-1&&(i={username:a.slice(0,c),password:a.slice(c+1)})}catch{}}else if(t==="bearer"||t==="token")o=n;else if(n.includes("="))for(let a of n.split(",")){let c=a.trim(),u=c.indexOf("=");if(u===-1)continue;let l=c.slice(0,u).trim().toLowerCase(),h=c.slice(u+1).trim();h.length>=2&&h.startsWith('"')&&h.endsWith('"')&&(h=h.slice(1,-1)),s.set(l,h)}else o=n;return{scheme:t,token:o,params:s,basic:i}}function Vr(r){let e=[],t=[],n="",s=!1;for(let o=0;o<r.length;o++){let i=r[o];i==='"'&&(o===0||r[o-1]!=="\\")&&(s=!s),i===","&&!s?(t.push(n.trim()),n=""):n+=i}n.trim()&&t.push(n.trim());for(let o of t){if(!o)continue;let i=o.indexOf(" "),a=(i===-1?o:o.slice(0,i)).toLowerCase(),c=i===-1?"":o.slice(i+1),u=Z(c);e.push({scheme:a,realm:u.get("realm")??null,params:u})}return e}function ka(r){return`Bearer ${r}`}function Aa(r,e){return`Basic ${Sa(`${r}:${e}`)}`}function Yr(r){return Xr(r)}function ys(r){return Xr(r)}function ws(r){return Xr(r)}function Ca(r){return r.trim()?Xr(r):[]}function va(r,e){if(e.length===0)return null;if(!r.trim())return e[0];let t=i=>i.split(";")[0].trim().toLowerCase(),n=Yr(r).map(i=>({essence:t(i.value),quality:i.quality})).filter(i=>i.essence!==""),s=(i,a)=>i===a?2:i.endsWith("/*")&&a.startsWith(i.slice(0,i.length-1))?1:i==="*/*"?0:-1,o=null;for(let i=0;i<e.length;i++){let a=t(e[i]),c=null,u=-1;for(let l of n){let h=s(l.essence,a);h<0||h>u&&(u=h,c=l.quality)}c===null||c<=0||(o===null||c>o.quality||c===o.quality&&u>o.spec)&&(o={index:i,quality:c,spec:u})}return o===null?null:e[o.index]}function bs(r){let e=r.indexOf("=");if(e===-1)return null;let t=r.slice(0,e).trim().toLowerCase(),n=r.slice(e+1).split(",").map(s=>{let o=s.trim(),i=o.indexOf("-");if(i===-1)return null;let a=o.slice(0,i).trim(),c=o.slice(i+1).trim(),u=a===""?null:parseInt(a,10),l=c===""?null:parseInt(c,10);return u!==null&&!Number.isFinite(u)||l!==null&&!Number.isFinite(l)||u===null&&l===null||u!==null&&u<0||l!==null&&l<0||u!==null&&l!==null&&u>l?null:{start:u,end:l}}).filter(s=>s!==null);return n.length===0?null:{unit:t,ranges:n}}function xs(r){let e=r.match(/^(\S+)\s+(\*|\d+-\d+)\/(\*|\d+)$/);if(!e)return null;let t=e[1].toLowerCase(),n=e[2],s=e[3]==="*"?null:parseInt(e[3],10);if(n==="*")return{unit:t,start:null,end:null,total:s};let o=n.indexOf("-");return{unit:t,start:parseInt(n.slice(0,o),10),end:parseInt(n.slice(o+1),10),total:s}}function Jr(r){let e=[],t=r.split(/,\s*(?=<)/);for(let n of t){let s=n.trim(),o=s.indexOf(">");if(!s.startsWith("<")||o===-1)continue;let i=s.slice(1,o),a=s.slice(o+1),c=Z(a);e.push({uri:i,rel:c.get("rel")??null,type:c.get("type")??null,hreflang:c.get("hreflang")??null,title:c.get("title")??null,media:c.get("media")??null,params:c})}return e}function Pa(r){return r.map(e=>{let t=`<${e.uri}>`;e.rel&&(t+=`; rel=${ke(e.rel)}`),e.type&&(t+=`; type=${ke(e.type)}`),e.hreflang&&(t+=`; hreflang=${ke(e.hreflang)}`),e.title&&(t+=`; title=${ke(e.title)}`),e.media&&(t+=`; media=${ke(e.media)}`);let n=e.params instanceof Map?[...e.params.entries()]:Object.entries(e.params??{});for(let[s,o]of n)["rel","type","hreflang","title","media"].includes(s)||(t+=`; ${s}=${ke(String(o))}`);return t}).join(", ")}function _s(r){let e={by:null,for:[],host:null,proto:null};for(let t of r.split(",")){let n=Z(t.trim());n.has("by")&&(e.by=n.get("by")),n.has("for")&&e.for.push(n.get("for")),n.has("host")&&(e.host=n.get("host")),n.has("proto")&&(e.proto=n.get("proto"))}return e}function Zr(r){let e=r.get(_.Forwarded);if(e)return _s(e);let t=r.get(_.XForwardedFor),n=r.get(_.XForwardedHost),s=r.get(_.XForwardedProto);return{by:null,for:t?t.split(",").map(o=>o.trim()):[],host:n??null,proto:s??null}}function Il(r){return/^\d{1,3}(\.\d{1,3}){3}$/.test(r)?r.split(".").every(e=>Number(e)<=255&&(e==="0"||!e.startsWith("0"))):!r.includes(":")||!/^[0-9a-f:.]+$/i.test(r)?!1:(r.match(/::/g)??[]).length<=1}function as(r){if(!r)return null;let e=Ol(r);return e&&(/^_/.test(e)||Il(e))?e:null}function Ss(r,e={}){let t=Math.max(0,Math.trunc(e.trustedHops??0)),n=Zr(r);if(n.for.length>0){let s=t===0?0:n.for.length-t;for(let o=s;o>=0;o--){let i=as(n.for[o]);if(i)return i}for(let o of n.for){let i=as(o);if(i)return i}return null}return as(r.get(_.XRealIP))}function Ol(r){let e=r.trim();if(e.startsWith('"')&&e.endsWith('"')&&e.length>=2&&(e=e.slice(1,-1)),e.startsWith("[")){let n=e.indexOf("]");if(n!==-1)return e.slice(1,n)}let t=/^(.*):\d+$/.exec(e);return t&&(t[1]??"").includes(".")?t[1]:e}function Ts(r){let e=r.trim();if(!Ml.test(e)&&!Nl.test(e)&&!Dl.test(e))return null;let t=Date.parse(e);return isNaN(t)?null:t}function sr(r){let e=r.trim();if(/^\d+$/.test(e))return{date:null,delay:parseInt(e,10)};let t=Ts(e);return t!==null?{date:new Date(t),delay:null}:{date:null,delay:null}}function La(r){let e=[],t="",n=!1;for(let s=0;s<r.length;s++){let o=r[s];o==='"'&&(s===0||r[s-1]!=="\\")&&(n=!n),o===","&&!n?(t.trim()&&e.push(t.trim()),t=""):t+=o}return t.trim()&&e.push(t.trim()),e.map(s=>{let o=s.match(/^(\d{3})\s+(\S+)\s+["']?([^"']+)["']?\s*(.*)$/);if(!o)return null;let i=o[1],a=o[2],c=o[3],u=o[4]??"",l=parseInt(i,10),h=(()=>{let d=u.trim().replace(/^"|"$/g,"");if(d){let p=Date.parse(d);if(!isNaN(p))return new Date(p)}})();return{code:l,agent:a,text:c,...h!==void 0?{date:h}:{}}}).filter(s=>s!==null)}function Es(r){let e=Z(";"+r),t=e.get("max-age");if(t===void 0)return null;let n=parseInt(t,10);return isNaN(n)?null:{maxAge:n,includeSubDomains:e.has("includesubdomains"),preload:e.has("preload")}}function en(r){let e=`max-age=${r.maxAge}`;return r.includeSubDomains&&(e+="; includeSubDomains"),r.preload&&(e+="; preload"),e}function Rs(r){let e=new Map;for(let t of r.split(";")){let n=t.trim().split(/\s+/);if(n.length===0||!n[0])continue;let s=n[0].toLowerCase(),o=n.slice(1);e.set(s,o)}return e}function tn(r){let e=[];for(let[t,n]of r)e.push(n.length>0?`${t} ${n.join(" ")}`:t);return e.join("; ")}function ks(r){return r.split(",").map(e=>{let t=e.trim().split(";"),n=(t[0]??"").trim(),s=Z(t.slice(1).join(";")),o=s.get("dur");return{name:n,duration:o!==void 0?parseFloat(o):null,description:s.get("desc")??null}}).filter(e=>e.name!=="")}function Ia(r){return r.map(e=>{let t=e.name;return e.duration!==null&&(t+=`;dur=${e.duration}`),e.description!==null&&(t+=`;desc=${ke(e.description)}`),t}).join(", ")}function As(r){if(r.trim()==="clear")return[];let e=[];for(let t of r.split(",")){let n=t.trim(),s=n.indexOf("=");if(s===-1)continue;let o=n.slice(0,s).trim().replace(/^"|"$/g,""),i=n.slice(s+1).trim(),a=i.indexOf(";"),c=a!==-1?Z(";"+i.slice(a+1)):new Map,u=(a!==-1?i.slice(0,a):i).replace(/^"|"$/g,""),l,h;if(u.startsWith("[")){let d=u.indexOf("]");if(d===-1)l=u,h=443;else{l=u.slice(0,d+1);let p=u.slice(d+2);h=p?parseInt(p,10):443}}else{let d=u.lastIndexOf(":");l=d===-1?u:u.slice(0,d),h=d===-1?443:parseInt(u.slice(d+1),10)}e.push({protocol:o,host:l,port:h,maxAge:c.has("ma")?parseInt(c.get("ma"),10):null,persist:c.has("persist")&&c.get("persist")==="1"})}return e}function Oa(r){let e=new ge;for(let[t,n]of Object.entries(r))if(n!==void 0)if(Array.isArray(n))for(let s of n)e.append(t,s);else e.append(t,n);return e}function Ma(r){let e={};return r.forEach((t,n)=>{let o=r.getAll(n);e[n]=o.length===1?o[0]:[...o]}),e}function Na(r){return new ge(r)}function Da(r={}){let e=new ge;if(r.hsts!==!1){let t=r.hsts===!0||r.hsts===void 0?{maxAge:31536e3,includeSubDomains:!0,preload:!1}:r.hsts;e.set(_.StrictTransportSecurity,en(t))}if(r.csp){let t=typeof r.csp=="string"?r.csp:tn(r.csp);e.set(_.ContentSecurityPolicy,t)}return e.set(_.XFrameOptions,r.frameOptions??"DENY"),r.noSniff!==!1&&e.set(_.XContentTypeOptions,"nosniff"),e.set(_.ReferrerPolicy,r.referrer??"strict-origin-when-cross-origin"),r.permissions&&e.set(_.PermissionsPolicy,r.permissions),r.coep&&e.set(_.CrossOriginEmbedderPolicy,r.coep),r.coop&&e.set(_.CrossOriginOpenerPolicy,r.coop),r.corp&&e.set(_.CrossOriginResourcePolicy,r.corp),e}function $a(r){let e=new ge,t=Array.isArray(r.origin)?r.origin.join(", "):r.origin;return e.set(_.AccessControlAllowOrigin,t),r.methods?.length&&e.set(_.AccessControlAllowMethods,r.methods.join(", ")),r.allowHeaders?.length&&e.set(_.AccessControlAllowHeaders,r.allowHeaders.join(", ")),r.exposeHeaders?.length&&e.set(_.AccessControlExposeHeaders,r.exposeHeaders.join(", ")),r.credentials&&e.set(_.AccessControlAllowCredentials,"true"),r.maxAge!=null&&e.set(_.AccessControlMaxAge,String(r.maxAge)),e}function Ua(r){return new De(r)}function Ha(r){return new De(r,"request")}function rn(){if(typeof crypto>"u"||typeof crypto.getRandomValues!="function")throw new Error("generateIdempotencyKey: no CSPRNG available in this runtime \u2014 crypto.getRandomValues is required");let r=new Uint8Array(16);crypto.getRandomValues(r),r[6]=(r[6]??0)&15|64,r[8]=(r[8]??0)&63|128;let e=[];for(let t of r)e.push(t.toString(16).padStart(2,"0"));return[e.slice(0,4).join(""),e.slice(4,6).join(""),e.slice(6,8).join(""),e.slice(8,10).join(""),e.slice(10,16).join("")].join("-")}function nn(r,e=255){return typeof r!="string"||r.length===0||r.length>e?!1:/^[\x21-\x7e]+$/.test(r)}function ja(r){return new De(r,"response")}function Ba(r){return new De(r,"immutable")}var et,_,Qr,Gr,kt,_a,Al,z,Ta,cs,us,ls,Ea,Ra,ge,Ml,Nl,Dl,De,$e=J(()=>{"use strict";U();_={ContentType:"content-type",ContentLength:"content-length",ContentEncoding:"content-encoding",ContentLanguage:"content-language",ContentLocation:"content-location",ContentDisposition:"content-disposition",ContentRange:"content-range",ContentMD5:"content-md5",TransferEncoding:"transfer-encoding",TrailingHeader:"trailer",CacheControl:"cache-control",Pragma:"pragma",Expires:"expires",Age:"age",ETag:"etag",LastModified:"last-modified",Vary:"vary",IfMatch:"if-match",IfNoneMatch:"if-none-match",IfModifiedSince:"if-modified-since",IfUnmodifiedSince:"if-unmodified-since",IfRange:"if-range",Host:"host",Origin:"origin",Referer:"referer",UserAgent:"user-agent",From:"from",TE:"te",Expect:"expect",IdempotencyKey:"idempotency-key",MaxForwards:"max-forwards",Accept:"accept",AcceptEncoding:"accept-encoding",AcceptLanguage:"accept-language",AcceptCharset:"accept-charset",AcceptRanges:"accept-ranges",AcceptPatch:"accept-patch",Authorization:"authorization",ProxyAuthorization:"proxy-authorization",WWWAuthenticate:"www-authenticate",ProxyAuthenticate:"proxy-authenticate",AuthenticationInfo:"authentication-info",Range:"range",Cookie:"cookie",SetCookie:"set-cookie",Location:"location",Via:"via",Forwarded:"forwarded",XForwardedFor:"x-forwarded-for",XForwardedHost:"x-forwarded-host",XForwardedProto:"x-forwarded-proto",XForwardedPort:"x-forwarded-port",XRealIP:"x-real-ip",Connection:"connection",KeepAlive:"keep-alive",Upgrade:"upgrade",AccessControlAllowOrigin:"access-control-allow-origin",AccessControlAllowMethods:"access-control-allow-methods",AccessControlAllowHeaders:"access-control-allow-headers",AccessControlExposeHeaders:"access-control-expose-headers",AccessControlMaxAge:"access-control-max-age",AccessControlAllowCredentials:"access-control-allow-credentials",AccessControlRequestMethod:"access-control-request-method",AccessControlRequestHeaders:"access-control-request-headers",Date:"date",RetryAfter:"retry-after",Allow:"allow",Server:"server",ServerTiming:"server-timing",TimingAllowOrigin:"timing-allow-origin",SecWebSocketKey:"sec-websocket-key",SecWebSocketAccept:"sec-websocket-accept",SecWebSocketProtocol:"sec-websocket-protocol",SecWebSocketVersion:"sec-websocket-version",SecWebSocketExtensions:"sec-websocket-extensions",SecFetchSite:"sec-fetch-site",SecFetchMode:"sec-fetch-mode",SecFetchUser:"sec-fetch-user",SecFetchDest:"sec-fetch-dest",StrictTransportSecurity:"strict-transport-security",ContentSecurityPolicy:"content-security-policy",ContentSecurityPolicyRO:"content-security-policy-report-only",XContentTypeOptions:"x-content-type-options",XFrameOptions:"x-frame-options",XXSSProtection:"x-xss-protection",ReferrerPolicy:"referrer-policy",PermissionsPolicy:"permissions-policy",CrossOriginOpenerPolicy:"cross-origin-opener-policy",CrossOriginEmbedderPolicy:"cross-origin-embedder-policy",CrossOriginResourcePolicy:"cross-origin-resource-policy",NEL:"nel",ReportTo:"report-to",ReportingEndpoints:"reporting-endpoints",Link:"link",AltSvc:"alt-svc",AltUsed:"alt-used",Priority:"priority",EarlyData:"early-data",PushPolicy:"push-policy",AcceptPushPolicy:"accept-push-policy",XRequestID:"x-request-id",XCorrelationID:"x-correlation-id",XRateLimitLimit:"x-ratelimit-limit",XRateLimitRemaining:"x-ratelimit-remaining",XRateLimitReset:"x-ratelimit-reset",XPoweredBy:"x-powered-by",XRequestedWith:"x-requested-with"};Qr=Te,Gr=de,kt=new Set(["set-cookie","www-authenticate","proxy-authenticate"]),_a=new Set(["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]),Al=new Set(["set-cookie","set-cookie2"]),ge=class{constructor(e,t="none"){Li(this,z);f(this,"map",new Map);f(this,"guard");this.guard=t,e!=null&&he(this,z,Ta).call(this,e)}append(e,t){he(this,z,ls).call(this,e);let n=he(this,z,cs).call(this,e),s=he(this,z,us).call(this,t),o=this.map.get(n);o?o.values.push(s):this.map.set(n,{name:e,values:[s]})}delete(e){he(this,z,Ra).call(this,e),this.map.delete(e.toLowerCase())}get(e){let t=this.map.get(e.toLowerCase());return t?kt.has(e.toLowerCase())?t.values[0]??null:t.values.join(", "):null}getAll(e){return[...this.map.get(e.toLowerCase())?.values??[]]}has(e){return this.map.has(e.toLowerCase())}set(e,t){he(this,z,Ea).call(this,e);let n=he(this,z,cs).call(this,e),s=he(this,z,us).call(this,t);this.map.set(n,{name:e,values:[s]})}forEach(e,t){for(let[n,s]of this.map){let o=kt.has(n)?s.values:[s.values.join(", ")];for(let i of o)e.call(t,i,n,this)}}keys(){return this.map.keys()}*values(){for(let[e,t]of this.map)if(kt.has(e))for(let n of t.values)yield n;else yield t.values.join(", ")}*entries(){for(let[e,t]of this.map)if(kt.has(e))for(let n of t.values)yield[e,n];else yield[e,t.values.join(", ")]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"HttpHeaders"}toObject(){let e={};for(let[t,n]of this.map){let s=n.values;e[t]=s.length===1?s[0]:[...s]}return e}toFlatObject(){let e={};for(let[t,n]of this.map)e[t]=kt.has(t)?n.values[0]??"":n.values.join(", ");return e}toWebHeaders(){if(typeof Headers>"u")throw new Error("WHATWG Headers is not available in this runtime");let e=new Headers;for(let[t,n]of this.map)for(let s of n.values)e.append(t,s);return e}toHTTP1String(){let e=[];for(let[,t]of this.map)for(let n of t.values)e.push(`${t.name}: ${n}`);return e.join(`\r
3
+ `)}clone(e){return new et(this,e??this.guard)}freeze(){return this.clone("immutable")}merge(e,t={}){let n=e instanceof et?e:new et(e);for(let[s,o]of n.map)if(t.append)for(let i of o.values)this.append(s,i);else this.map.set(s,{name:o.name,values:[...o.values]});return this}pick(...e){let t=new et;for(let n of e){let s=n.toLowerCase(),o=this.map.get(s);o&&t.map.set(s,{name:o.name,values:[...o.values]})}return t}omit(...e){let t=this.clone();for(let n of e)t.map.delete(n.toLowerCase());return t}redact(...e){let t=this.clone();for(let n of e){let s=n.toLowerCase(),o=t.map.get(s);o&&t.map.set(s,{name:o.name,values:o.values.map(()=>"**REDACTED**")})}return t}diff(e){let t=new et;for(let[n,s]of e.map){let o=this.get(n),i=kt.has(n)?s.values[0]??"":s.values.join(", ");o!==i&&t.map.set(n,{name:s.name,values:[...s.values]})}return t}get size(){return this.map.size}};z=new WeakSet,Ta=function(e){if(e instanceof et){for(let[t,n]of e.map)this.map.set(t,{name:n.name,values:[...n.values]});return}if(typeof Headers<"u"&&e instanceof Headers){e.forEach((t,n)=>this.append(n,t));return}if(Array.isArray(e)){for(let t of e){if(!Array.isArray(t)||t.length<2)throw new TypeError("Headers init sequence must contain [name, value] pairs");this.append(String(t[0]),String(t[1]))}return}if(typeof e=="object")for(let[t,n]of Object.entries(e))if(Array.isArray(n))for(let s of n)this.append(t,s);else this.append(t,String(n))},cs=function(e){if(!Qr(e))throw new TypeError(`Invalid header name: "${e}"`);return e.toLowerCase()},us=function(e){let t=e.trim();if(!Gr(t))throw new TypeError(`Invalid header value for: "${t}"`);return t},ls=function(e){if(this.guard==="immutable")throw new TypeError("Headers are immutable");if(this.guard==="request"&&_a.has(e.toLowerCase()))throw new TypeError(`Header "${e}" is forbidden for request guard`);if(this.guard==="response"&&Al.has(e.toLowerCase()))throw new TypeError(`Header "${e}" is forbidden for response guard`)},Ea=function(e){he(this,z,ls).call(this,e)},Ra=function(e){if(this.guard==="immutable")throw new TypeError("Headers are immutable");if(this.guard==="request"&&_a.has(e.toLowerCase()))throw new TypeError(`Header "${e}" is forbidden for request guard`)};et=ge;Ml=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/,Nl=/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2,4} \d{2}:\d{2}:\d{2} GMT$/,Dl=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ \d]\d \d{2}:\d{2}:\d{2} \d{4}$/;De=class extends ge{get contentType(){let e=this.get(_.ContentType);return e?hs(e):null}set contentType(e){if(e===null){this.delete(_.ContentType);return}if(typeof e=="string"){this.set(_.ContentType,e);return}this.set(_.ContentType,fs(e))}get contentLength(){let e=this.get(_.ContentLength);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}set contentLength(e){if(e===null){this.delete(_.ContentLength);return}this.set(_.ContentLength,String(e))}get contentDisposition(){let e=this.get(_.ContentDisposition);return e?ds(e):null}set contentDisposition(e){if(e===null){this.delete(_.ContentDisposition);return}if(typeof e=="string"){this.set(_.ContentDisposition,e);return}this.set(_.ContentDisposition,ps(e))}get cacheControl(){let e=this.get(_.CacheControl);return e?ms(e):null}set cacheControl(e){if(e===null){this.delete(_.CacheControl);return}if(typeof e=="string"){this.set(_.CacheControl,e);return}this.set(_.CacheControl,gs(e))}get authorization(){let e=this.get(_.Authorization);return e?Kr(e):null}set authorization(e){if(e===null){this.delete(_.Authorization);return}this.set(_.Authorization,e)}get accept(){return Yr(this.get(_.Accept)??"")}get acceptEncoding(){return ys(this.get(_.AcceptEncoding)??"")}get acceptLanguage(){return ws(this.get(_.AcceptLanguage)??"")}get range(){let e=this.get(_.Range);return e?bs(e):null}get contentRange(){let e=this.get(_.ContentRange);return e?xs(e):null}get etag(){return this.get(_.ETag)}set etag(e){if(e===null){this.delete(_.ETag);return}let t=e.startsWith('"')||e.startsWith('W/"')?e:`"${e}"`;this.set(_.ETag,t)}get links(){let e=this.get(_.Link);return e?Jr(e):[]}get retryAfter(){let e=this.get(_.RetryAfter);return e?sr(e):null}get hsts(){let e=this.get(_.StrictTransportSecurity);return e?Es(e):null}set hsts(e){if(e===null){this.delete(_.StrictTransportSecurity);return}this.set(_.StrictTransportSecurity,en(e))}get csp(){let e=this.get(_.ContentSecurityPolicy);return e?Rs(e):null}set csp(e){if(e===null){this.delete(_.ContentSecurityPolicy);return}if(typeof e=="string"){this.set(_.ContentSecurityPolicy,e);return}this.set(_.ContentSecurityPolicy,tn(e))}get serverTiming(){let e=this.get(_.ServerTiming);return e?ks(e):[]}get clientIP(){return Ss(this)}get forwarded(){return Zr(this)}get host(){return this.get(_.Host)}get origin(){return this.get(_.Origin)}get userAgent(){return this.get(_.UserAgent)}get location(){return this.get(_.Location)}get date(){let e=this.get(_.Date);if(!e)return null;let t=Date.parse(e);return isNaN(t)?null:new Date(t)}get age(){let e=this.get(_.Age);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get vary(){let e=this.get(_.Vary);return e?e.split(",").map(t=>t.trim().toLowerCase()):[]}get xRequestID(){return this.get(_.XRequestID)}get xCorrelationID(){return this.get(_.XCorrelationID)}get xPoweredBy(){return this.get(_.XPoweredBy)}get xRequestedWith(){return this.get(_.XRequestedWith)}get xRateLimitLimit(){let e=this.get(_.XRateLimitLimit);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get xRateLimitRemaining(){let e=this.get(_.XRateLimitRemaining);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get xRateLimitReset(){let e=this.get(_.XRateLimitReset);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get secFetchSite(){return this.get(_.SecFetchSite)}get secFetchMode(){return this.get(_.SecFetchMode)}get secFetchUser(){return this.get(_.SecFetchUser)}get secFetchDest(){return this.get(_.SecFetchDest)}get earlyData(){let e=this.get(_.EarlyData);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get priority(){return this.get(_.Priority)}get allow(){return this.get(_.Allow)}get server(){return this.get(_.Server)}get acceptRanges(){return this.get("accept-ranges")}get lastModified(){let e=this.get("last-modified");if(!e)return null;let t=Date.parse(e);return isNaN(t)?null:new Date(t)}get expires(){let e=this.get("expires");if(!e)return null;let t=Date.parse(e);return isNaN(t)?null:new Date(t)}get contentEncoding(){return this.get("content-encoding")}get contentLanguage(){return this.get("content-language")}get contentLocation(){return this.get("content-location")}get link(){let e=this.get(_.Link);return e?Jr(e)[0]??null:null}get altSvc(){let e=this.get(_.AltSvc);return e?As(e):[]}get wwwAuthenticate(){let e=this.get("www-authenticate");return e?Vr(e):null}set wwwAuthenticate(e){if(e===null){this.delete("www-authenticate");return}let t=e.map(n=>{let o=[...n.params].filter(([a])=>a!=="realm").map(([a,c])=>`${a}=${c}`).join(", "),i=n.scheme;return n.realm&&(i+=` realm="${n.realm}"`),o&&(i+=`; ${o}`),i}).join(", ");this.set("www-authenticate",t)}get proxyAuthenticate(){let e=this.get(_.ProxyAuthenticate);return e?Vr(e):null}set proxyAuthenticate(e){if(e===null){this.delete(_.ProxyAuthenticate);return}let t=e.map(n=>{let o=[...n.params].filter(([a])=>a!=="realm").map(([a,c])=>`${a}=${c}`).join(", "),i=n.scheme;return n.realm&&(i+=` realm="${n.realm}"`),o&&(i+=`; ${o}`),i}).join(", ");this.set(_.ProxyAuthenticate,t)}get proxyAuthorization(){let e=this.get(_.ProxyAuthorization);return e?Kr(e):null}set proxyAuthorization(e){if(e===null){this.delete(_.ProxyAuthorization);return}if(typeof e=="string"){this.set(_.ProxyAuthorization,e);return}e.basic?this.set(_.ProxyAuthorization,`Basic ${Sa(`${e.basic.username}:${e.basic.password}`)}`):e.token?this.set(_.ProxyAuthorization,`${e.scheme} ${e.token}`):this.set(_.ProxyAuthorization,e.scheme)}get setCookies(){return this.getAll(_.SetCookie)}get accessControlAllowOrigin(){return this.get(_.AccessControlAllowOrigin)}get accessControlAllowMethods(){return this.get(_.AccessControlAllowMethods)}get accessControlAllowHeaders(){return this.get(_.AccessControlAllowHeaders)}get accessControlMaxAge(){let e=this.get(_.AccessControlMaxAge);if(!e)return null;let t=parseInt(e,10);return isNaN(t)?null:t}get accessControlCredentials(){let e=this.get(_.AccessControlAllowCredentials);return e==="true"?!0:e==="false"?!1:null}}});var mc={};le(mc,{ContentTypeError:()=>je,HTTPResponseError:()=>rt,ResponseCache:()=>to,ResponseDecodeError:()=>nt,ResponseSizeLimitError:()=>He,applyDecompression:()=>dr,assertOk:()=>oo,assertOkJSON:()=>io,createLimitedReader:()=>ho,decodeBody:()=>fr,decompressStream:()=>mn,diffResponses:()=>ao,extractServerTiming:()=>uo,isBinary:()=>no,isJSON:()=>lr,isText:()=>dn,limitAction:()=>hr,normalizeHeaders:()=>we,normalizeResponse:()=>ro,parseContentType:()=>Be,parseMultipartResponse:()=>xn,readBlob:()=>wn,readBodyWithLimit:()=>ur,readBytes:()=>pr,readFormData:()=>co,readJSON:()=>gn,readJSONStream:()=>so,readNDJSON:()=>bn,readStream:()=>Lt,readText:()=>yn});function we(r){return mt(r)}function ro(r){return{status:r.status,statusText:r.statusText,headers:we(r.headers),url:r.url,redirected:r.redirected,ok:r.ok,bodyUsed:r.bodyUsed}}function Be(r){if(!r||r.length>rh)return null;let e=hs(r);return e?{mediaType:e.mediaType,type:e.type,subtype:e.subtype,charset:e.charset,boundary:e.boundary}:null}function lr(r){if(!r)return!1;let e=Be(r);return e?e.mediaType==="application/json"||e.subtype.endsWith("+json"):!1}function dn(r){return r?Be(r)?.type==="text":!1}function no(r){return!dn(r)&&!lr(r)}function pn(r,e){return e?e.aborted?Promise.resolve({done:!0,value:void 0}):new Promise((t,n)=>{let s=()=>{r.cancel("aborted").catch(()=>{}),t({done:!0,value:void 0})};e.addEventListener("abort",s,{once:!0}),r.read().then(t,n).finally(()=>{e.removeEventListener("abort",s)})}):r.read()}function hc(r){return r==="truncate"||r==="abort"?r:"throw"}function hr(r,e,t,n,s){let o=e+r.byteLength;if(o<=t.maxBytes)return{kind:"keep"};if(t.onExceedCallback?.(o,t.maxBytes),n==="throw")throw s(o,t.maxBytes);if(n==="truncate"){let i=t.maxBytes-e;return{kind:"truncate",chunk:r.slice(0,i)}}return{kind:"stop"}}async function ur(r,e,t,n){let s=hc(t.onExceed),o=r.getReader(),i=[],a=0;try{for(;;){if(n?.aborted)throw await o.cancel("aborted"),new DOMException("Response reading aborted","AbortError");let{done:c,value:u}=await pn(o,n);if(c){if(n?.aborted)throw new DOMException("Response reading aborted","AbortError");break}let l;try{l=hr(u,a,t,s,(h,d)=>new He(h,d,e))}catch(h){throw await o.cancel("size limit exceeded"),h}if(l.kind==="stop"){await o.cancel("size limit exceeded");break}if(l.kind==="truncate"){i.push(l.chunk),a+=l.chunk.byteLength;break}i.push(u),a+=u.byteLength}}finally{n?.aborted&&await o.cancel("aborted").catch(()=>{}),o.releaseLock()}return hh(i)}function nh(r){if(!r)return"utf-8";let e=r.toLowerCase().trim();return Object.prototype.hasOwnProperty.call(lc,e)?lc[e]:"utf-8"}function sh(r){return r[0]===239&&r[1]===187&&r[2]===191?"utf-8":r[0]===255&&r[1]===254?"utf-16le":r[0]===254&&r[1]===255?"utf-16be":null}function fr(r,e,t){let n=sh(r),s=n??nh(e),o=n?r.slice(n==="utf-8"?3:2):r;try{return new TextDecoder(s,{fatal:!0}).decode(o)}catch{try{return new TextDecoder(s,{fatal:!1}).decode(o)}catch(i){throw new nt(String(i),s,t??"<unknown url>")}}}function oh(r,e,t=1e8){let n=mn(r,e),s=0,o=new TransformStream({transform(i,a){if(s+=i.byteLength,s>t){a.error(new He(s,t,"decompression"));return}a.enqueue(i)}});return n.pipeThrough(o)}function mn(r,e){let t=e.trim().toLowerCase();if(t==="br")return ah(r);if(t==="zstd")return ch(r);if(typeof DecompressionStream>"u")return r;try{let n=t,s=new DecompressionStream(n);return ih(r,s)}catch{return r}}function ih(r,e){let t=r.getReader();return new ReadableStream({async start(n){let s=null;for(;;){let c=await t.read().catch(()=>({done:!0,value:void 0}));if(c.done||c.value.byteLength>0){s=c;break}}if(s.done){n.close();return}let a=new ReadableStream({start(c){c.enqueue(s.value)},async pull(c){let u=await t.read();u.done?c.close():c.enqueue(u.value)},cancel(c){t.cancel(c).catch(()=>{})}}).pipeThrough(e).getReader();(async()=>{try{for(;;){let c=await a.read();if(c.done){n.close();return}n.enqueue(c.value)}}catch(c){n.error(c)}})()},cancel(n){t.cancel(n).catch(()=>{})}})}function ah(r){return fc()?dc(r,e=>e.createBrotliDecompress()):r}function fc(){try{return typeof globalThis.process?.versions?.node=="string"}catch{return!1}}function dc(r,e){let t=!1,n=null,s=!1,o=!1;return new ReadableStream({async start(i){let a=await import("node:zlib"),c=e(a);if(n=r.getReader(),s){n.cancel().catch(()=>{}),n.releaseLock(),n=null;return}let u=l=>{t||(t=!0,i.error(l))};c.on("data",l=>{t||i.enqueue(new Uint8Array(l.buffer,l.byteOffset,l.byteLength))}),c.on("end",()=>{t||(t=!0,i.close())}),c.on("error",u);try{for(;;){let{done:l,value:h}=await n.read();if(l){if(!o){t||(t=!0,i.close()),c.destroy();break}c.end();break}h.byteLength>0&&(o=!0),c.write(h)}}catch(l){c.destroy(l instanceof Error?l:new Error(String(l))),u(l)}finally{n.releaseLock(),n=null}},cancel(){t=!0,s=!0,n?.cancel().catch(()=>{})}})}function ch(r){if(typeof DecompressionStream<"u")try{let e=DecompressionStream;return r.pipeThrough(new e("zstd"))}catch{}return fc()?dc(r,e=>{let t=e.createZstdDecompress;if(typeof t!="function")throw new Error("zstd decompression is not available in this Node.js version");return t()}):r}function dr(r,e){let t=e["content-encoding"]??e["Content-Encoding"];if(!t||t==="identity")return r;let n=t.split(",").map(o=>o.trim()).filter(Boolean).reverse(),s=r;for(let o of n)s=oh(s,o);return s}async function gn(r,e={}){let n=we(r.headers)["content-type"]??null,s=r.url;e.expectedContentType?pc(n,e.expectedContentType,s):lr(n);let o=await lo(r,s,e),i=e.charset??Be(n??"")?.charset??null,a=fr(o,i,s);try{return D(JSON.parse(a))}catch(c){throw new nt(`JSON parse failed: ${c}`,"json",s)}}async function yn(r,e={}){let n=we(r.headers)["content-type"]??null,s=r.url;e.expectedContentType&&pc(n,e.expectedContentType,s);let o=await lo(r,s,e),i=e.charset??Be(n??"")?.charset??null;return fr(o,i,s)}async function pr(r,e={}){let t=r.url;return await lo(r,t,e)}async function wn(r,e={}){let t=await pr(r,e),n=r.headers.get("content-type")??"application/octet-stream",s=new ArrayBuffer(t.byteLength);return new Uint8Array(s).set(t),new Blob([s],{type:n})}function Lt(r,e={}){if(!r.body)return new ReadableStream({start:s=>s.close()});let t=we(r.headers),n=r.body;return e.decompress!==!1&&(n=dr(n,t)),e.sizeLimit&&(n=lh(n,r.url,e.sizeLimit,e.signal)),n}async function*bn(r,e={}){let n=Lt(r,e).getReader(),s=new TextDecoder("utf-8"),o="";try{for(;!e.signal?.aborted;){let{done:i,value:a}=await pn(n,e.signal);if(i){let u=o.trim();if(u)try{yield D(JSON.parse(u))}catch(l){e.onParseError?.(l,u)}break}o+=s.decode(a,{stream:!0});let c=o.split(`
4
+ `);o=c.pop()??"";for(let u of c){let l=u.trim();if(!(!l||l.startsWith("#")))try{yield D(JSON.parse(l))}catch(h){e.onParseError?.(h,l)}}}}finally{n.releaseLock()}}async function*so(r,e={}){let n=Lt(r,e).getReader(),s=new TextDecoder("utf-8"),o=0,i="",a=-1,c=!1,u=!1,l=()=>{if(a===-1)return null;let h=i.slice(a);return a=-1,h};try{for(;!e.signal?.aborted;){let{done:h,value:d}=await pn(n,e.signal);if(h){let p=l();if(p)try{let m=D(JSON.parse(p));e.onObject?.(m),yield m}catch(m){e.onParseError?.(m,p)}break}i+=s.decode(d,{stream:!0});for(let p=0;p<i.length;p++){let m=i[p];if(c){u?u=!1:m==="\\"?u=!0:m==='"'&&(c=!1);continue}if(m==='"'){c=!0;continue}if(m==="{"||m==="[")o===0&&(a=p),o++;else if((m==="}"||m==="]")&&(o--,o===0&&a!==-1)){let g=i.slice(a,p+1);try{let w=D(JSON.parse(g));e.onObject?.(w),yield w}catch(w){e.onParseError?.(w,g)}i=i.slice(p+1),a=-1,c=!1,u=!1,p=-1}}if(i.length>1e7)throw new Error("JSON stream buffer exceeded 10MB limit")}}finally{n.releaseLock()}}async function oo(r,e={}){if(!(e.isError??(o=>o>=400))(r.status))return r;let n=we(r.headers),s=null;if(e.readBody!==!1&&r.body&&!r.bodyUsed)try{s=await r.clone().text()}catch{}throw new rt(r.status,r.statusText,r.url,n,s)}async function io(r){if(r.ok)return{response:r};let e=we(r.headers),t=null;if(r.body&&!r.bodyUsed)try{t=await r.clone().text()}catch{}throw new rt(r.status,r.statusText,r.url,e,t)}async function ao(r,e){let t=we(r.headers),n=we(e.headers),s={},o={},i={};for(let[c,u]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,c)?n[c]!==u&&(s[c]=[u,n[c]]):i[c]=u;for(let[c,u]of Object.entries(n))Object.prototype.hasOwnProperty.call(t,c)||(o[c]=u);let a=!1;try{let[c,u]=await Promise.all([r.clone().text(),e.clone().text()]);a=c!==u}catch{}return{statusChanged:r.status!==e.status,headersChanged:s,headersAdded:o,headersRemoved:i,bodyChanged:a}}async function xn(r){let e=r.headers.get("content-type")??"",t=Be(e);if(!t?.boundary)throw new je("multipart/*",e,r.url);let n=await r.arrayBuffer(),s=new Uint8Array(n),o=new TextEncoder().encode("--"+t.boundary),i=[],a=u=>{for(let l=u;l<=s.length-o.length;l++)if(s.subarray(l,l+o.length).every((h,d)=>h===o[d]))return l;return-1},c=a(0);if(c===-1)return[];if(c+=o.length,s[c]===13&&s[c+1]===10?c+=2:s[c]===10&&(c+=1),s[c]===45&&s[c+1]===45)return[];for(;c<s.length;){let u=a(c);if(u===-1)break;let l=u+o.length;l<s.length&&(s[l]===13&&s[l+1]===10||s[l]===10||s[l]===45&&s[l+1]);let h=u;h>=2&&s[h-2]===13&&s[h-1]===10?h-=2:h>=1&&s[h-1]===10&&(h-=1);let d=uh(s,c,h);if(!d){c=u+o.length;continue}let p=s.subarray(c,d.headerEnd),m=s.subarray(d.bodyStart,h),g=new TextDecoder().decode(p),w={};for(let y of g.split(/\r\n|\n/)){let S=y.indexOf(":");S!==-1&&(w[y.slice(0,S).trim().toLowerCase()]=y.slice(S+1).trim())}if(i.push({headers:w,body:m}),c=u+o.length,c<s.length-1&&s[c]===45&&s[c+1]===45)break}return i}function uh(r,e,t){for(let n=e;n<t;n++){if(r[n]===10&&r[n+1]===10)return{headerEnd:n,bodyStart:n+2};if(r[n]===13&&r[n+1]===10&&r[n+2]===13&&r[n+3]===10)return{headerEnd:n,bodyStart:n+4}}return null}async function co(r){let e=await xn(r),t=new FormData;for(let n of e){let s=n.headers["content-disposition"]??"",o=s.match(/name="([^"]+)"/),i=s.match(/filename="([^"]+)"/);if(!o)continue;let a=o[1],c=i?.[1];if(c){let u=n.headers["content-type"]??"application/octet-stream",l=new ArrayBuffer(n.body.byteLength);new Uint8Array(l).set(n.body);let h=new File([l],c,{type:u});t.append(a,h)}else{let u=new TextDecoder().decode(n.body);t.append(a,u)}}return t}function uo(r){let e=r["server-timing"]??r["Server-Timing"];return e?e.split(",").map(t=>{let n=t.trim().split(";"),s=(n[0]??"").trim(),o=th(n.slice(1).join(";")),i=o.get("dur"),a=i!==void 0?parseFloat(i):NaN;return{name:s,duration:Number.isFinite(a)?a:null,description:o.get("desc")??null}}).filter(t=>t.name):[]}function lo(r,e,t){if(!r.body)return Promise.resolve(new Uint8Array(0));let n=we(r.headers),s=r.body;if(t.decompress!==!1&&(s=dr(s,n)),t.signal?.aborted)throw new DOMException("Response reading aborted","AbortError");return t.sizeLimit?ur(s,e,t.sizeLimit,t.signal):ur(s,e,{maxBytes:1/0},t.signal)}function lh(r,e,t,n){let s=hc(t.onExceed),o=0;return new ReadableStream({async start(i){let a=r.getReader();try{for(;;){if(n?.aborted){await a.cancel("aborted"),i.error(new DOMException("Response reading aborted","AbortError"));return}let{done:c,value:u}=await pn(a,n);if(c){if(n?.aborted){await a.cancel("aborted").catch(()=>{}),i.error(new DOMException("Response reading aborted","AbortError"));return}i.close();break}let l;try{l=hr(u,o,t,s,(h,d)=>new He(h,d,e))}catch(h){await a.cancel("size limit exceeded"),i.error(h);return}if(l.kind!=="keep"){l.kind==="truncate"&&i.enqueue(l.chunk),i.close(),await a.cancel("size limit exceeded");return}o+=u.byteLength,i.enqueue(u)}}catch(c){i.error(c)}}})}function pc(r,e,t){if(!r)throw new je(e,"(none)",t);let n=r.split(";")[0]?.trim().toLowerCase()??"",s=e.split(";")[0]?.trim().toLowerCase()??"",o=n.split("/")[0]??"";if(!(n===s||s.indexOf("/")===-1&&o===s))throw new je(e,r,t)}function hh(r){let e=r.reduce((s,o)=>s+o.byteLength,0),t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function ho(r,e="throw"){let t={maxBytes:r,onExceed:e};return{json:(n,s)=>gn(n,{sizeLimit:t,...s}),text:(n,s)=>yn(n,{sizeLimit:t,...s}),bytes:(n,s)=>pr(n,{sizeLimit:t,...s}),blob:(n,s)=>wn(n,{sizeLimit:t,...s}),stream:(n,s)=>Lt(n,{sizeLimit:t,...s}),ndjson:(n,s)=>bn(n,{sizeLimit:t,...s})}}var th,rt,He,je,nt,rh,lc,to,mr=J(()=>{"use strict";$e();U();th=Z,rt=class extends Error{constructor(t,n,s,o,i){super(`HTTP ${t} ${n} \u2014 ${s}`);f(this,"code","EHTTPRESPONSE");f(this,"status");f(this,"statusText");f(this,"url");f(this,"headers");f(this,"body");this.name="HTTPResponseError",this.status=t,this.statusText=n,this.url=s,this.headers=o,this.body=i}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500&&this.status<600}get isNotFound(){return this.status===404}get isUnauthorized(){return this.status===401}get isForbidden(){return this.status===403}get isTooManyRequests(){return this.status===429}get isGone(){return this.status===410}get isConflict(){return this.status===409}},He=class extends Error{constructor(t,n,s){super(`Response size limit exceeded: read ${t} bytes, limit is ${n} bytes (${s})`);f(this,"code","ESIZELIMIT");f(this,"bytesRead");f(this,"limit");f(this,"url");this.name="ResponseSizeLimitError",this.bytesRead=t,this.limit=n,this.url=s}},je=class extends Error{constructor(t,n,s){super(`Expected content-type "${t}", got "${n}" (${s})`);f(this,"code","ECONTENTTYPE");f(this,"expected");f(this,"received");f(this,"url");this.name="ContentTypeError",this.expected=t,this.received=n,this.url=s}},nt=class extends Error{constructor(t,n,s){super(`Failed to decode response as ${n} (${s}): ${t}`);f(this,"code","EDECODE");f(this,"charset");f(this,"url");this.name="ResponseDecodeError",this.charset=n,this.url=s}};rh=8192;lc={"utf-8":"utf-8",utf8:"utf-8","latin-1":"latin1",latin1:"latin1","iso-8859-1":"latin1",ascii:"ascii","us-ascii":"ascii","utf-16le":"utf-16le","utf-16":"utf-16le","utf-16be":"utf-16be","windows-1252":"windows-1252",cp1252:"windows-1252"};to=class{constructor(e={ttlMs:6e4}){f(this,"cache",new Map);f(this,"ttlMs");this.ttlMs=e.ttlMs}hashRequest(e){let t=typeof e=="string"?e:e.url;return`${typeof e=="string"?"GET":e.method}:${t}`}async get(e){let t=this.hashRequest(e),n=this.cache.get(t);return n?Date.now()>=n.expiresAt?(this.cache.delete(t),null):await Promise.resolve(n.response.clone()):null}async set(e,t){let n=this.hashRequest(e);await Promise.resolve(this.cache.set(n,{response:t.clone(),expiresAt:Date.now()+this.ttlMs}))}delete(e){this.cache.delete(this.hashRequest(e))}clear(){this.cache.clear()}get size(){return this.cache.size}}});var yc={};le(yc,{connectThroughProxy:()=>yh});function gc(r){let e=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;return e.includes(":")||/^\d+(\.\d+)*$/.test(e)}function ph(r){return/^socks5h?:/i.test(r)}function mh(r){if(r.username===void 0)return;let e=`${r.username}:${r.password??""}`,t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return`Basic ${typeof globalThis.btoa=="function"?globalThis.btoa(n):Buffer.from(t).toString("base64")}`}function gh(r){let e=r.split(`\r
5
+ `,1)[0]??"",t=/^HTTP\/1\.[01] (\d{3})(?: (.*))?$/.exec(e);return t?{status:Number(t[1]),reason:t[2]??""}:null}async function yh(r,e,t={}){let n=t.request!==void 0?{request:t.request}:{};if(ph(r.url))throw new x(`proxy url "${r.url}" is a SOCKS proxy, which needs a different mechanism. Use createSocks5Tunnel() from kinetex/socks5 and supply your own fetch over the tunnel.`,"EVALIDATION",n);let s;try{s=new URL(r.url)}catch(w){throw new x(`proxy url "${r.url}" is not a valid URL`,"EVALIDATION",{...n,cause:w})}if(s.protocol!=="http:"&&s.protocol!=="https:")throw new x(`proxy url scheme "${s.protocol}" is not supported; use http:, https:, socks5: or socks5h:`,"EVALIDATION",n);let o=await import("node:net"),i=await import("node:tls"),a=s.port?Number(s.port):s.protocol==="https:"?443:80,c=e.port?Number(e.port):e.protocol==="https:"?443:80,u=`${e.hostname}:${c}`,l=t.connectTimeoutMs??fh,h=s.protocol==="https:"?await bh(i,{host:s.hostname,port:a,servername:s.hostname,...t.ca!==void 0?{ca:t.ca}:{}},l,t.signal,n,`proxy ${s.host}`):await wh(o,{host:s.hostname,port:a},l,t.signal,n,`proxy ${s.host}`),d=mh(r),p=[`CONNECT ${u} HTTP/1.1`,`Host: ${u}`,"Proxy-Connection: Keep-Alive",...d!==void 0?[`Proxy-Authorization: ${d}`]:[],"",""];h.write(p.join(`\r
6
+ `));let m="",g=await new Promise(w=>{let y=()=>{for(;;){let j=h.read();if(j===null)return;m+=j.toString("latin1")}},S=()=>{y();let j=m.indexOf(`\r
6
7
  \r
7
- `);if($===-1){m.length>ql&&(I(),y({ok:!1,err:new x("Proxy sent an oversized CONNECT response","EPROXY",n)}));return}I();let v=Kl(m.slice(0,$));if(!v){y({ok:!1,err:new x(`Proxy returned a malformed CONNECT response: ${JSON.stringify(m.slice(0,$).split(`\r
8
- `,1)[0]??"")}`,"EPROXY",n)});return}if(v.status>=200&&v.status<300){let P=m.slice($+4);P.length>0&&h.unshift(Buffer.from(P,"latin1")),y({ok:!0});return}if(v.status===407){y({ok:!1,err:new x("Proxy requires authentication (407). Set `username`/`password` on the proxy config, or embed them in the proxy URL.","EPROXY",n)});return}y({ok:!1,err:new x(`Proxy refused CONNECT to ${u}: ${v.status} ${v.reason}`.trim(),"EPROXY",n)})},b=$=>{I(),y({ok:!1,err:new x(`Proxy connection failed: ${$.message}`,"ENETWORK",{...n,cause:$})})},T=()=>{I(),y({ok:!1,err:new x(`Proxy closed the connection before answering CONNECT for ${u}`,"EPROXY",n)})},k=()=>{I(),h.destroy(),y({ok:!1,err:new x(`Proxy did not respond to CONNECT for ${u} within ${l}ms`,"ETIMEOUT",n)})},C=()=>{I(),h.destroy(),y({ok:!1,err:new x("Proxy connection aborted","EABORT",n)})},E=setTimeout(k,l);typeof E.unref=="function"&&E.unref();function I(){clearTimeout(E),h.off("readable",_),h.off("error",b),h.off("end",T),h.off("close",T),h.off("timeout",k),t.signal?.removeEventListener("abort",C)}h.on("readable",_),h.once("error",b),h.once("end",T),h.once("close",T),h.setTimeout(l,k),t.signal?.addEventListener("abort",C,{once:!0}),w()});if(!g.ok)throw h.destroy(),g.err;return e.protocol!=="https:"?(h.setTimeout(0),h):await new Promise((y,w)=>{let _=()=>{k(),h.destroy(),w(new x(`TLS handshake through proxy to ${e.hostname} did not complete within ${l}ms`,"ETIMEOUT",n))},b=()=>{k(),h.destroy(),w(new x("Proxy connection aborted","EABORT",n))},T=setTimeout(_,l);typeof T.unref=="function"&&T.unref(),t.signal?.addEventListener("abort",b,{once:!0});function k(){clearTimeout(T),t.signal?.removeEventListener("abort",b)}let C=i.connect({socket:h,servername:t.servername??e.hostname,...t.ca!==void 0?{ca:t.ca}:{}},()=>{k(),h.setTimeout(0),y(C)});C.once("error",E=>{k(),h.destroy(),w(new x(`TLS handshake through proxy failed for ${e.hostname}: ${E.message}`,"ENETWORK",{...n,cause:E}))})})}async function Jl(r,e,t,n,s,o){return await new Promise((i,a)=>{let c=r.connect({host:e.host,port:e.port}),u=d=>{p(),a(new x(`Cannot reach ${o}: ${d.message}`,"ENETWORK",{...s,cause:d}))},l=setTimeout(()=>{p(),c.destroy(),a(new x(`Connecting to ${o} timed out`,"ETIMEOUT",s))},t);typeof l.unref=="function"&&l.unref();let h=()=>{p(),c.destroy(),a(new x("Proxy connection aborted","EABORT",s))};function p(){clearTimeout(l),c.off("error",u),n?.removeEventListener("abort",h)}c.once("error",u),c.once("connect",()=>{p(),i(c)}),n?.aborted?h():n?.addEventListener("abort",h,{once:!0})})}async function Ql(r,e,t,n,s,o){return await new Promise((i,a)=>{let c=r.connect({host:e.host,port:e.port,servername:e.servername,...e.ca!==void 0?{ca:e.ca}:{}},()=>{p(),i(c)}),u=d=>{p(),a(new x(`Cannot reach ${o}: ${d.message}`,"ENETWORK",{...s,cause:d}))},l=setTimeout(()=>{p(),c.destroy(),a(new x(`Connecting to ${o} timed out`,"ETIMEOUT",s))},t);typeof l.unref=="function"&&l.unref();let h=()=>{p(),c.destroy(),a(new x("Proxy connection aborted","EABORT",s))};function p(){clearTimeout(l),c.off("error",u),n?.removeEventListener("abort",h)}c.once("error",u),n?.aborted?h():n?.addEventListener("abort",h,{once:!0})})}var zl,ql,rc=W(()=>{"use strict";we();zl=3e4,ql=64*1024});var uc={};ae(uc,{ContentTypeError:()=>Ne,HTTPResponseError:()=>Ye,ResponseCache:()=>Gs,ResponseDecodeError:()=>Ze,ResponseSizeLimitError:()=>De,applyDecompression:()=>ir,assertOk:()=>eo,assertOkJSON:()=>to,createLimitedReader:()=>io,decodeBody:()=>or,decompressStream:()=>an,diffResponses:()=>ro,extractServerTiming:()=>so,isBinary:()=>Ys,isJSON:()=>nr,isText:()=>sn,normalizeHeaders:()=>de,normalizeResponse:()=>Xs,parseContentType:()=>$e,parseMultipartResponse:()=>fn,readBlob:()=>ln,readBodyWithLimit:()=>on,readBytes:()=>ar,readFormData:()=>no,readJSON:()=>cn,readJSONStream:()=>Zs,readNDJSON:()=>hn,readStream:()=>At,readText:()=>un});function de(r){return ht(r)}function Xs(r){return{status:r.status,statusText:r.statusText,headers:de(r.headers),url:r.url,redirected:r.redirected,ok:r.ok,bodyUsed:r.bodyUsed}}function $e(r){if(!r||r.length>Xl)return null;let e=os(r);return e?{mediaType:e.mediaType,type:e.type,subtype:e.subtype,charset:e.charset,boundary:e.boundary}:null}function nr(r){if(!r)return!1;let e=$e(r);return e?e.mediaType==="application/json"||e.subtype.endsWith("+json"):!1}function sn(r){return r?$e(r)?.type==="text":!1}function Ys(r){return!sn(r)&&!nr(r)}function sr(r,e){return e?e.aborted?Promise.resolve({done:!0,value:void 0}):new Promise((t,n)=>{let s=()=>{r.cancel("aborted").catch(()=>{}),t({done:!0,value:void 0})};e.addEventListener("abort",s,{once:!0}),r.read().then(t,n).finally(()=>{e.removeEventListener("abort",s)})}):r.read()}function sc(r){return r==="truncate"||r==="abort"?r:"throw"}async function on(r,e,t,n){let s=sc(t.onExceed),o=r.getReader(),i=[],a=0;try{for(;;){if(n?.aborted)throw await o.cancel("aborted"),new DOMException("Response reading aborted","AbortError");let{done:c,value:u}=await sr(o,n);if(c){if(n?.aborted)throw new DOMException("Response reading aborted","AbortError");break}let l=a+u.byteLength;if(l>t.maxBytes){if(t.onExceedCallback?.(l,t.maxBytes),s==="throw")throw await o.cancel("size limit exceeded"),new De(l,t.maxBytes,e);if(s==="abort"){await o.cancel("size limit exceeded");break}if(s==="truncate"){let h=t.maxBytes-a;h>0&&(i.push(u.slice(0,h)),a+=h);break}}i.push(u),a+=u.byteLength}}finally{o.releaseLock()}return cc(i)}function Yl(r){if(!r)return"utf-8";let e=r.toLowerCase().trim();return Object.prototype.hasOwnProperty.call(nc,e)?nc[e]:"utf-8"}function Zl(r){return r[0]===239&&r[1]===187&&r[2]===191?"utf-8":r[0]===255&&r[1]===254?"utf-16le":r[0]===254&&r[1]===255?"utf-16be":null}function or(r,e,t){let n=Zl(r),s=n??Yl(e),o=n?r.slice(n==="utf-8"?3:2):r;try{return new TextDecoder(s,{fatal:!0}).decode(o)}catch{try{return new TextDecoder(s,{fatal:!1}).decode(o)}catch(i){throw new Ze(String(i),s,t)}}}function eh(r,e,t=1e8){let n=an(r,e),s=0,o=new TransformStream({transform(i,a){if(s+=i.byteLength,s>t){a.error(new De(s,t,"decompression"));return}a.enqueue(i)}});return n.pipeThrough(o)}function an(r,e){let t=e.trim().toLowerCase();if(t==="br")return th(r);if(t==="zstd")return rh(r);if(typeof DecompressionStream>"u")return r;try{let n=t,s=new DecompressionStream(n);return r.pipeThrough(s)}catch{return r}}function th(r){return oc()?ic(r,e=>e.createBrotliDecompress()):r}function oc(){try{return typeof globalThis.process?.versions?.node=="string"}catch{return!1}}function ic(r,e){let t=!1,n=null,s=!1;return new ReadableStream({async start(o){let i=await import("node:zlib"),a=e(i);if(n=r.getReader(),s){n.cancel().catch(()=>{}),n.releaseLock(),n=null;return}let c=u=>{t||(t=!0,o.error(u))};a.on("data",u=>{t||o.enqueue(new Uint8Array(u.buffer,u.byteOffset,u.byteLength))}),a.on("end",()=>{t||(t=!0,o.close())}),a.on("error",c);try{for(;;){let{done:u,value:l}=await n.read();if(u){a.end();break}a.write(l)}}catch(u){a.destroy(u instanceof Error?u:new Error(String(u))),c(u)}finally{n.releaseLock(),n=null}},cancel(){t=!0,s=!0,n?.cancel().catch(()=>{})}})}function rh(r){if(typeof DecompressionStream<"u")try{let e=DecompressionStream;return r.pipeThrough(new e("zstd"))}catch{}return oc()?ic(r,e=>{let t=e.createZstdDecompress;if(typeof t!="function")throw new Error("zstd decompression is not available in this Node.js version");return t()}):r}function ir(r,e){let t=e["content-encoding"]??e["Content-Encoding"];if(!t||t==="identity")return r;let n=t.split(",").map(o=>o.trim()).filter(Boolean).reverse(),s=r;for(let o of n)s=eh(s,o);return s}async function cn(r,e={}){let n=de(r.headers)["content-type"]??null,s=r.url;e.expectedContentType?ac(n,e.expectedContentType,s):nr(n);let o=await oo(r,s,e),i=e.charset??$e(n??"")?.charset??null,a=or(o,i,s);try{return D(JSON.parse(a))}catch(c){throw new Ze(`JSON parse failed: ${c}`,"json",s)}}async function un(r,e={}){let n=de(r.headers)["content-type"]??null,s=r.url;e.expectedContentType&&ac(n,e.expectedContentType,s);let o=await oo(r,s,e),i=e.charset??$e(n??"")?.charset??null;return or(o,i,s)}async function ar(r,e={}){let t=r.url;return await oo(r,t,e)}async function ln(r,e={}){let t=await ar(r,e),n=r.headers.get("content-type")??"application/octet-stream",s=new ArrayBuffer(t.byteLength);return new Uint8Array(s).set(t),new Blob([s],{type:n})}function At(r,e={}){if(!r.body)return new ReadableStream({start:s=>s.close()});let t=de(r.headers),n=r.body;return e.decompress!==!1&&(n=ir(n,t)),e.sizeLimit&&(n=sh(n,r.url,e.sizeLimit,e.signal)),n}async function*hn(r,e={}){let n=At(r,e).getReader(),s=new TextDecoder("utf-8"),o="";try{for(;!e.signal?.aborted;){let{done:i,value:a}=await sr(n,e.signal);if(i){let u=o.trim();if(u)try{yield D(JSON.parse(u))}catch(l){e.onParseError?.(l,u)}break}o+=s.decode(a,{stream:!0});let c=o.split(`
9
- `);o=c.pop()??"";for(let u of c){let l=u.trim();if(!(!l||l.startsWith("#")))try{yield D(JSON.parse(l))}catch(h){e.onParseError?.(h,l)}}}}finally{n.releaseLock()}}async function*Zs(r,e={}){let n=At(r,e).getReader(),s=new TextDecoder("utf-8"),o=0,i="",a=-1,c=!1,u=!1,l=()=>{if(a===-1)return null;let h=i.slice(a);return a=-1,h};try{for(;!e.signal?.aborted;){let{done:h,value:p}=await sr(n,e.signal);if(h){let d=l();if(d)try{let m=D(JSON.parse(d));e.onObject?.(m),yield m}catch(m){e.onParseError?.(m,d)}break}i+=s.decode(p,{stream:!0});for(let d=0;d<i.length;d++){let m=i[d];if(c){u?u=!1:m==="\\"?u=!0:m==='"'&&(c=!1);continue}if(m==='"'){c=!0;continue}if(m==="{"||m==="[")o===0&&(a=d),o++;else if((m==="}"||m==="]")&&(o--,o===0&&a!==-1)){let g=i.slice(a,d+1);try{let y=D(JSON.parse(g));e.onObject?.(y),yield y}catch(y){e.onParseError?.(y,g)}i=i.slice(d+1),a=-1,c=!1,u=!1,d=-1}}if(i.length>1e7)throw new Error("JSON stream buffer exceeded 10MB limit")}}finally{n.releaseLock()}}async function eo(r,e={}){if(!(e.isError??(o=>o>=400))(r.status))return r;let n=de(r.headers),s=null;if(e.readBody!==!1&&r.body&&!r.bodyUsed)try{s=await r.clone().text()}catch{}throw new Ye(r.status,r.statusText,r.url,n,s)}async function to(r){if(r.ok)return{response:r};let e=de(r.headers),t=null;if(r.body&&!r.bodyUsed)try{t=await r.clone().text()}catch{}throw new Ye(r.status,r.statusText,r.url,e,t)}async function ro(r,e){let t=de(r.headers),n=de(e.headers),s={},o={},i={};for(let[c,u]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,c)?n[c]!==u&&(s[c]=[u,n[c]]):i[c]=u;for(let[c,u]of Object.entries(n))Object.prototype.hasOwnProperty.call(t,c)||(o[c]=u);let a=!1;try{let[c,u]=await Promise.all([r.clone().text(),e.clone().text()]);a=c!==u}catch{}return{statusChanged:r.status!==e.status,headersChanged:s,headersAdded:o,headersRemoved:i,bodyChanged:a}}async function fn(r){let e=r.headers.get("content-type")??"",t=$e(e);if(!t?.boundary)throw new Ne("multipart/*",e,r.url);let n=await r.arrayBuffer(),s=new Uint8Array(n),o=new TextEncoder().encode("--"+t.boundary),i=[],a=u=>{for(let l=u;l<=s.length-o.length;l++)if(s.subarray(l,l+o.length).every((h,p)=>h===o[p]))return l;return-1},c=a(0);if(c===-1)return[];if(c+=o.length,s[c]===13&&s[c+1]===10?c+=2:s[c]===10&&(c+=1),s[c]===45&&s[c+1]===45)return[];for(;c<s.length;){let u=a(c);if(u===-1)break;let l=u+o.length;l<s.length&&(s[l]===13&&s[l+1]===10||s[l]===10||s[l]===45&&s[l+1]);let h=u;h>=2&&s[h-2]===13&&s[h-1]===10?h-=2:h>=1&&s[h-1]===10&&(h-=1);let p=nh(s,c,h);if(!p){c=u+o.length;continue}let d=s.subarray(c,p.headerEnd),m=s.subarray(p.bodyStart,h),g=new TextDecoder().decode(d),y={};for(let w of g.split(/\r\n|\n/)){let _=w.indexOf(":");_!==-1&&(y[w.slice(0,_).trim().toLowerCase()]=w.slice(_+1).trim())}if(i.push({headers:y,body:m}),c=u+o.length,c<s.length-1&&s[c]===45&&s[c+1]===45)break}return i}function nh(r,e,t){for(let n=e;n<t;n++){if(r[n]===10&&r[n+1]===10)return{headerEnd:n,bodyStart:n+2};if(r[n]===13&&r[n+1]===10&&r[n+2]===13&&r[n+3]===10)return{headerEnd:n,bodyStart:n+4}}return null}async function no(r){let e=await fn(r),t=new FormData;for(let n of e){let s=n.headers["content-disposition"]??"",o=s.match(/name="([^"]+)"/),i=s.match(/filename="([^"]+)"/);if(!o)continue;let a=o[1],c=i?.[1];if(c){let u=n.headers["content-type"]??"application/octet-stream",l=new ArrayBuffer(n.body.byteLength);new Uint8Array(l).set(n.body);let h=new File([l],c,{type:u});t.append(a,h)}else{let u=new TextDecoder().decode(n.body);t.append(a,u)}}return t}function so(r){let e=r["server-timing"]??r["Server-Timing"];return e?e.split(",").map(t=>{let n=t.trim().split(";"),s=(n[0]??"").trim(),o=Gl(n.slice(1).join(";")),i=o.get("dur"),a=i!==void 0?parseFloat(i):NaN;return{name:s,duration:Number.isFinite(a)?a:null,description:o.get("desc")??null}}).filter(t=>t.name):[]}async function oo(r,e,t){if(!r.body)return new Uint8Array(0);let n=de(r.headers),s=r.body;if(t.decompress!==!1&&(s=ir(s,n)),t.signal?.aborted)throw new DOMException("Response reading aborted","AbortError");if(t.sizeLimit)return on(s,e,t.sizeLimit,t.signal);let o=s.getReader(),i=[];try{for(;;){if(t.signal?.aborted)throw new DOMException("Response reading aborted","AbortError");let{done:a,value:c}=await sr(o,t.signal);if(a){if(t.signal?.aborted)throw new DOMException("Response reading aborted","AbortError");break}i.push(c)}}finally{t.signal?.aborted&&await o.cancel("aborted").catch(()=>{}),o.releaseLock()}return cc(i)}function sh(r,e,t,n){let s=sc(t.onExceed),o=0;return new ReadableStream({async start(i){let a=r.getReader();try{for(;;){if(n?.aborted){await a.cancel("aborted"),i.error(new DOMException("Response reading aborted","AbortError"));return}let{done:c,value:u}=await sr(a,n);if(c){if(n?.aborted){await a.cancel("aborted").catch(()=>{}),i.error(new DOMException("Response reading aborted","AbortError"));return}i.close();break}let l=o+u.byteLength;if(l>t.maxBytes){if(t.onExceedCallback?.(l,t.maxBytes),s==="throw"){await a.cancel("size limit"),i.error(new De(l,t.maxBytes,e));return}if(s==="abort"){await a.cancel("size limit"),i.close();return}if(s==="truncate"){let h=t.maxBytes-o;h>0&&i.enqueue(u.slice(0,h)),i.close(),await a.cancel("size limit");return}}o+=u.byteLength,i.enqueue(u)}}catch(c){i.error(c)}}})}function ac(r,e,t){if(!r)throw new Ne(e,"(none)",t);let n=r.split(";")[0]?.trim().toLowerCase()??"",s=e.split(";")[0]?.trim().toLowerCase()??"",o=n.split("/")[0]??"";if(!(n===s||s.indexOf("/")===-1&&o===s))throw new Ne(e,r,t)}function cc(r){let e=r.reduce((s,o)=>s+o.byteLength,0),t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function io(r,e="throw"){let t={maxBytes:r,onExceed:e};return{json:(n,s)=>cn(n,{sizeLimit:t,...s}),text:(n,s)=>un(n,{sizeLimit:t,...s}),bytes:(n,s)=>ar(n,{sizeLimit:t,...s}),blob:(n,s)=>ln(n,{sizeLimit:t,...s}),stream:(n,s)=>At(n,{sizeLimit:t,...s}),ndjson:(n,s)=>hn(n,{sizeLimit:t,...s})}}var Gl,Ye,De,Ne,Ze,Xl,nc,Gs,dn=W(()=>{"use strict";Oe();q();Gl=Y,Ye=class extends Error{constructor(t,n,s,o,i){super(`HTTP ${t} ${n} \u2014 ${s}`);f(this,"code","EHTTPRESPONSE");f(this,"status");f(this,"statusText");f(this,"url");f(this,"headers");f(this,"body");this.name="HTTPResponseError",this.status=t,this.statusText=n,this.url=s,this.headers=o,this.body=i}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500&&this.status<600}get isNotFound(){return this.status===404}get isUnauthorized(){return this.status===401}get isForbidden(){return this.status===403}get isTooManyRequests(){return this.status===429}get isGone(){return this.status===410}get isConflict(){return this.status===409}},De=class extends Error{constructor(t,n,s){super(`Response size limit exceeded: read ${t} bytes, limit is ${n} bytes (${s})`);f(this,"code","ESIZELIMIT");f(this,"bytesRead");f(this,"limit");f(this,"url");this.name="ResponseSizeLimitError",this.bytesRead=t,this.limit=n,this.url=s}},Ne=class extends Error{constructor(t,n,s){super(`Expected content-type "${t}", got "${n}" (${s})`);f(this,"code","ECONTENTTYPE");f(this,"expected");f(this,"received");f(this,"url");this.name="ContentTypeError",this.expected=t,this.received=n,this.url=s}},Ze=class extends Error{constructor(t,n,s){super(`Failed to decode response as ${n} (${s}): ${t}`);f(this,"code","EDECODE");f(this,"charset");f(this,"url");this.name="ResponseDecodeError",this.charset=n,this.url=s}};Xl=8192;nc={"utf-8":"utf-8",utf8:"utf-8","latin-1":"latin1",latin1:"latin1","iso-8859-1":"latin1",ascii:"ascii","us-ascii":"ascii","utf-16le":"utf-16le","utf-16":"utf-16le","utf-16be":"utf-16be","windows-1252":"windows-1252",cp1252:"windows-1252"};Gs=class{constructor(e={ttlMs:6e4}){f(this,"cache",new Map);f(this,"ttlMs");this.ttlMs=e.ttlMs}hashRequest(e){let t=typeof e=="string"?e:e.url;return`${typeof e=="string"?"GET":e.method}:${t}`}async get(e){let t=this.hashRequest(e),n=this.cache.get(t);return n?Date.now()>=n.expiresAt?(this.cache.delete(t),null):await Promise.resolve(n.response.clone()):null}async set(e,t){let n=this.hashRequest(e);await Promise.resolve(this.cache.set(n,{response:t.clone(),expiresAt:Date.now()+this.ttlMs}))}delete(e){this.cache.delete(this.hashRequest(e))}clear(){this.cache.clear()}get size(){return this.cache.size}}});var yc={};ae(yc,{DEFAULT_ACCEPT_ENCODING:()=>yn,FetchTransport:()=>et,HAS_NATIVE_FETCH:()=>lo,HTTP_STATUS_TEXTS:()=>gc,IS_NODE:()=>Ue,NodeHTTP2Transport:()=>kt,RUNTIME:()=>Se,createTransport:()=>cr,decompressBodyStream:()=>hr,detectRuntime:()=>gn,encodeMultipart:()=>lr,getEffectiveRuntime:()=>uo,normalizeHeaders:()=>dc,parseBody:()=>vt,readRawBody:()=>ur,sendWithTimeout:()=>Ct,setRuntime:()=>co});function gn(){let r=globalThis.Deno;return typeof r<"u"&&typeof r.version<"u"?"deno":typeof globalThis.Bun<"u"?"bun":typeof globalThis<"u"&&typeof globalThis.caches<"u"?"cloudflare-workers":typeof window<"u"&&typeof globalThis.document<"u"?"browser":mn.process?.versions?.node!==void 0?"node":typeof globalThis.fetch=="function"?"edge":"unknown"}function co(r){if(r!==null&&!lc.includes(r))throw new TypeError(`setRuntime: unknown runtime ${JSON.stringify(r)}. Expected one of: ${lc.join(", ")}`);hc=r}function uo(){return hc??Se}function fc(){try{return globalThis.process?.env?.NODE_ENV==="production"}catch{return!1}}function cr(r,e=!0,t,n){let s=r!==void 0||n?.dispatcher!==void 0;return Ue&&e&&s&&(fc()||console.warn(r!==void 0?'[kinetex] httpVersion: "HTTP/2" is ignored when a custom `fetch` is configured \u2014 NodeHTTP2Transport cannot use a custom fetch, so the request goes through FetchTransport (HTTP/1.1 semantics). Drop the `fetch` option to use HTTP/2.':'[kinetex] httpVersion: "HTTP/2" is ignored when a `dispatcher` is configured \u2014 NodeHTTP2Transport talks to node:http2 directly and cannot use a fetch dispatcher, so the request goes through FetchTransport (HTTP/1.1 semantics). Drop the `dispatcher` option to use HTTP/2.')),Ue&&e&&!s?new kt({...t?.sessionTTLMs!==void 0?{sessionTTLMs:t.sessionTTLMs}:{},...t?.pingIntervalMs!==void 0?{pingIntervalMs:t.pingIntervalMs}:{},...t?.maxSessions!==void 0?{maxSessions:t.maxSessions}:{},...t?.http1KeepAlive!==void 0?{http1KeepAlive:t.http1KeepAlive}:{},...t?.http1MaxSockets!==void 0?{http1MaxSockets:t.http1MaxSockets}:{},...t?.connectTimeoutMs!==void 0?{connectTimeoutMs:t.connectTimeoutMs}:{},...t?.requestTimeoutMs!==void 0?{requestTimeoutMs:t.requestTimeoutMs}:{},...n?.strict!==void 0?{strict:n.strict}:{},...n?.onDroppedHeader!==void 0?{onDroppedHeader:n.onDroppedHeader}:{},...n?.ca!==void 0?{ca:n.ca}:{},...n?.proxy!==void 0?{proxy:n.proxy}:{}}):new et({fetchFn:r??globalThis.fetch,...n?.strict!==void 0?{strict:n.strict}:{},...n?.onDroppedHeader!==void 0?{onDroppedHeader:n.onDroppedHeader}:{},...n?.dispatcher!==void 0?{dispatcher:n.dispatcher}:{}})}async function Ct(r,e,t){if(t<=0)return r.send(e);let n=new AbortController,s=setTimeout(()=>{n.abort(new X(t,e))},t),o=Pr(e.signal,n.signal)??null,i={...e,signal:o},a=new Promise((c,u)=>{n.signal.addEventListener("abort",()=>u(new X(t,e)),{once:!0})});try{let c=await Promise.race([r.send(i),a]);if(clearTimeout(s),n.signal.aborted)throw new X(t,e);return c}catch(c){throw clearTimeout(s),n.signal.aborted&&!(c instanceof X)?new X(t,e):c}}async function ur(r,e,t,n){if(!r)return new Uint8Array(0);let s=r.getReader(),o=[],i=0,a,c=new Promise((l,h)=>{a=h}),u=()=>{s.cancel("aborted").catch(()=>{}),a(new x("Response reading aborted","EABORT"))};if(n?.aborted)throw s.cancel("aborted").catch(()=>{}),new x("Response reading aborted","EABORT");n?.addEventListener("abort",u,{once:!0});try{for(;;){let l=await Promise.race([s.read().catch(d=>{throw s.cancel("read error").catch(()=>{}),d}),c]),{done:h,value:p}=l;if(h)break;if(e>0){let d=i+p.byteLength;if(d>e)throw await s.cancel("size limit exceeded"),new dt(d,e)}o.push(p),i+=p.byteLength}}catch(l){throw s.cancel("error during read").catch(()=>{}),l}finally{n?.removeEventListener("abort",u),s.releaseLock()}return Xt(o)}function vt(r,e,t,n,s,o){if(t)return t(r,s??{},o??"");if(!r.byteLength)return null;let i=e?.split(";")[0]?.trim().toLowerCase()??"";if(i==="application/json"||i.endsWith("+json")){let a=new TextDecoder("utf-8").decode(r),c,u;try{let l=ge(a,{maxStringLength:1e7,maxDepth:100,maxArrayLength:1e5});if(l.success&&l.value!==void 0)c=l.value;else if(!l.success){let h=new Error(`JSON body rejected: ${l.message??"parse failed"} \u2014 falling back to raw text`);Object.assign(h,{code:l.error??"EPARSE"}),u=h}}catch(l){u=l instanceof Error?l:new Error(String(l))}if(c!==void 0)return c;if(n)try{n(r,u??new Error("JSON parse failed \u2014 falling back to raw text"))}catch{}return a}return i.startsWith("text/")?new TextDecoder("utf-8").decode(r):r}function dc(r){return ht(r)}function oh(r){let e=r.trim().toLowerCase();return e==="2"||e==="2.0"||e==="h2"||e==="http/2"||e==="http/2.0"?"HTTP/2":e==="1"||e==="1.0"||e==="http/1"||e==="http/1.0"?"HTTP/1.0":e==="1.1"||e==="http/1.1"?"HTTP/1.1":null}function ih(r,e){let n=r.httpVersion;if(typeof n=="string"){let o=oh(n);if(o)return o}let s=r.headers.get("alt-svc");if(s){let o=s.includes('h3="')||s.includes("h3-29=")||s.includes("h3-32=");if(s.includes('h2="')||o)return"HTTP/2"}return"HTTP/1.1"}function ah(r){if(!(r instanceof Error))return!1;let e=r.message.toLowerCase();return e.includes("alpn")||e.includes("h2")||e.includes("http2")||r.code==="ERR_HTTP2_ERROR"}function pc(r){return new ReadableStream({start(e){let t=!1,n=!1;r.on("data",s=>{if(s instanceof Uint8Array)e.enqueue(s);else if(mn.Buffer?.isBuffer(s)){let o=s;e.enqueue(new Uint8Array(o.buffer,o.byteOffset,o.byteLength))}else e.enqueue(new Uint8Array(s))}),r.once("end",()=>{if(!(t||n)){t=!0;try{e.close()}catch{}}}),r.once("error",s=>{if(!(t||n)){t=!0,n=!0;try{e.error(s)}catch{}}}),r.once("close",()=>{if(t||n)return;t=!0;let s=Object.assign(new Error("Stream closed before end"),{code:"ECONNRESET"});try{e.error(s)}catch{}})},cancel(){r.destroy()}})}async function mc(r,e){r.write(e)||await new Promise(n=>r.once("drain",n))}async function uh(r,e){if(e instanceof ReadableStream){let t=e.getReader();for(;;){let{done:n,value:s}=await t.read();if(n){r.end();break}await mc(r,s)}}else if(e instanceof Uint8Array||e instanceof ArrayBuffer)r.end(mn.Buffer?new Uint8Array(e):e);else if(typeof e=="string")r.end(e);else{let{bytes:t}=await pn(e);r.end(t)}}async function lh(r,e){if(e instanceof ReadableStream){let t=e.getReader();for(;;){let{done:n,value:s}=await t.read();if(n){r.end();break}await mc(r,s)}}else if(e instanceof Uint8Array||e instanceof ArrayBuffer)r.end(mn.Buffer?new Uint8Array(e):e);else if(typeof e=="string")r.end(e);else{let{bytes:t}=await pn(e);r.end(t)}}async function pn(r){if(typeof URLSearchParams<"u"&&r instanceof URLSearchParams)return{bytes:new TextEncoder().encode(r.toString())};if(typeof Blob<"u"&&r instanceof Blob)return{bytes:new Uint8Array(await r.arrayBuffer())};if(typeof FormData<"u"&&r instanceof FormData){let{bytes:e,boundary:t}=await lr(r);return{bytes:e,contentType:`multipart/form-data; boundary=${t}`}}return{bytes:new Uint8Array(0)}}function ao(r){return r.replace(/[\r\n"\\]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}async function lr(r,e){let t=e??`----kinetexFormBoundary${ye(24)}`,n=new TextEncoder,s=[],o=i=>{s.push(n.encode(i))};for(let[i,a]of r.entries()){if(/[\r\n"]/.test(i))throw new x(`Cannot send a multipart field whose name contains CR, LF or a quote: ${JSON.stringify(i)}`,"EVALIDATION");if(o(`--${t}\r
10
- `),typeof a=="string"){o(`Content-Disposition: form-data; name="${ao(i)}"\r
8
+ `);if(j===-1){m.length>dh&&(P(),w({ok:!1,err:new x("Proxy sent an oversized CONNECT response","EPROXY",n)}));return}P();let v=gh(m.slice(0,j));if(!v){w({ok:!1,err:new x(`Proxy returned a malformed CONNECT response: ${JSON.stringify(m.slice(0,j).split(`\r
9
+ `,1)[0]??"")}`,"EPROXY",n)});return}if(v.status>=200&&v.status<300){let M=m.slice(j+4);M.length>0&&h.unshift(Buffer.from(M,"latin1")),w({ok:!0});return}if(v.status===407){w({ok:!1,err:new x("Proxy requires authentication (407). Set `username`/`password` on the proxy config, or embed them in the proxy URL.","EPROXY",n)});return}w({ok:!1,err:new x(`Proxy refused CONNECT to ${u}: ${v.status} ${v.reason}`.trim(),"EPROXY",n)})},b=j=>{P(),w({ok:!1,err:new x(`Proxy connection failed: ${j.message}`,"ENETWORK",{...n,cause:j})})},E=()=>{P(),w({ok:!1,err:new x(`Proxy closed the connection before answering CONNECT for ${u}`,"EPROXY",n)})},A=()=>{P(),h.destroy(),w({ok:!1,err:new x(`Proxy did not respond to CONNECT for ${u} within ${l}ms`,"ETIMEOUT",n)})},C=()=>{P(),h.destroy(),w({ok:!1,err:new x("Proxy connection aborted","EABORT",n)})},T=setTimeout(A,l);typeof T.unref=="function"&&T.unref();function P(){clearTimeout(T),h.off("readable",S),h.off("error",b),h.off("end",E),h.off("close",E),h.off("timeout",A),t.signal?.removeEventListener("abort",C)}h.on("readable",S),h.once("error",b),h.once("end",E),h.once("close",E),h.setTimeout(l,A),t.signal?.addEventListener("abort",C,{once:!0}),y()});if(!g.ok)throw h.destroy(),g.err;return e.protocol!=="https:"?(h.setTimeout(0),h):await new Promise((w,y)=>{let S=()=>{A(),h.destroy(),y(new x(`TLS handshake through proxy to ${e.hostname} did not complete within ${l}ms`,"ETIMEOUT",n))},b=()=>{A(),h.destroy(),y(new x("Proxy connection aborted","EABORT",n))},E=setTimeout(S,l);typeof E.unref=="function"&&E.unref(),t.signal?.addEventListener("abort",b,{once:!0});function A(){clearTimeout(E),t.signal?.removeEventListener("abort",b)}let C=t.servername??e.hostname,T=i.connect({socket:h,...C!==void 0&&!gc(C)?{servername:C}:{},...t.ca!==void 0?{ca:t.ca}:{}},()=>{A(),h.setTimeout(0),w(T)});T.once("error",P=>{A(),h.destroy(),y(new x(`TLS handshake through proxy failed for ${e.hostname}: ${P.message}`,"ENETWORK",{...n,cause:P}))})})}async function wh(r,e,t,n,s,o){return await new Promise((i,a)=>{let c=r.connect({host:e.host,port:e.port}),u=p=>{d(),a(new x(`Cannot reach ${o}: ${p.message}`,"ENETWORK",{...s,cause:p}))},l=setTimeout(()=>{d(),c.destroy(),a(new x(`Connecting to ${o} timed out`,"ETIMEOUT",s))},t);typeof l.unref=="function"&&l.unref();let h=()=>{d(),c.destroy(),a(new x("Proxy connection aborted","EABORT",s))};function d(){clearTimeout(l),c.off("error",u),n?.removeEventListener("abort",h)}c.once("error",u),c.once("connect",()=>{d(),i(c)}),n?.aborted?h():n?.addEventListener("abort",h,{once:!0})})}async function bh(r,e,t,n,s,o){return await new Promise((i,a)=>{let c=r.connect({host:e.host,port:e.port,...gc(e.servername)?{}:{servername:e.servername},...e.ca!==void 0?{ca:e.ca}:{}},()=>{d(),i(c)}),u=p=>{d(),a(new x(`Cannot reach ${o}: ${p.message}`,"ENETWORK",{...s,cause:p}))},l=setTimeout(()=>{d(),c.destroy(),a(new x(`Connecting to ${o} timed out`,"ETIMEOUT",s))},t);typeof l.unref=="function"&&l.unref();let h=()=>{d(),c.destroy(),a(new x("Proxy connection aborted","EABORT",s))};function d(){clearTimeout(l),c.off("error",u),n?.removeEventListener("abort",h)}c.once("error",u),n?.aborted?h():n?.addEventListener("abort",h,{once:!0})})}var fh,dh,wc=J(()=>{"use strict";Re();fh=3e4,dh=64*1024});var Pc={};le(Pc,{DEFAULT_ACCEPT_ENCODING:()=>En,FetchTransport:()=>st,HAS_NATIVE_FETCH:()=>go,HTTP_STATUS_TEXTS:()=>vc,IS_NODE:()=>ze,NodeHTTP2Transport:()=>It,RUNTIME:()=>Ce,blockedHostError:()=>Ec,createPinnedLookup:()=>Rc,createTransport:()=>gr,decompressBodyStream:()=>br,detectRuntime:()=>Tn,encodeMultipart:()=>wr,filterSafeAddresses:()=>wo,getEffectiveRuntime:()=>mo,normalizeHeaders:()=>kc,parseBody:()=>Mt,readRawBody:()=>yr,sendWithTimeout:()=>Ot,setRuntime:()=>po});function Tn(){let r=globalThis.Deno;return typeof r<"u"&&typeof r.version<"u"?"deno":typeof globalThis.Bun<"u"?"bun":typeof globalThis<"u"&&typeof globalThis.caches<"u"?"cloudflare-workers":typeof window<"u"&&typeof globalThis.document<"u"?"browser":Sn.process?.versions?.node!==void 0?"node":typeof globalThis.fetch=="function"?"edge":"unknown"}function po(r){if(r!==null&&!bc.includes(r))throw new TypeError(`setRuntime: unknown runtime ${JSON.stringify(r)}. Expected one of: ${bc.join(", ")}`);_c=r}function mo(){return _c??Ce}function Sc(){try{return globalThis.process?.env?.NODE_ENV==="production"}catch{return!1}}function gr(r,e=!0,t,n){let s=r!==void 0||n?.dispatcher!==void 0;return ze&&e&&s&&(Sc()||console.warn(r!==void 0?'[kinetex] httpVersion: "HTTP/2" is ignored when a custom `fetch` is configured \u2014 NodeHTTP2Transport cannot use a custom fetch, so the request goes through FetchTransport (HTTP/1.1 semantics). Drop the `fetch` option to use HTTP/2.':'[kinetex] httpVersion: "HTTP/2" is ignored when a `dispatcher` is configured \u2014 NodeHTTP2Transport talks to node:http2 directly and cannot use a fetch dispatcher, so the request goes through FetchTransport (HTTP/1.1 semantics). Drop the `dispatcher` option to use HTTP/2.')),ze&&e&&!s?new It({...t?.sessionTTLMs!==void 0?{sessionTTLMs:t.sessionTTLMs}:{},...t?.pingIntervalMs!==void 0?{pingIntervalMs:t.pingIntervalMs}:{},...t?.maxSessions!==void 0?{maxSessions:t.maxSessions}:{},...t?.http1KeepAlive!==void 0?{http1KeepAlive:t.http1KeepAlive}:{},...t?.http1MaxSockets!==void 0?{http1MaxSockets:t.http1MaxSockets}:{},...t?.connectTimeoutMs!==void 0?{connectTimeoutMs:t.connectTimeoutMs}:{},...t?.requestTimeoutMs!==void 0?{requestTimeoutMs:t.requestTimeoutMs}:{},...n?.strict!==void 0?{strict:n.strict}:{},...n?.allowPrivateNetwork!==void 0?{allowPrivateNetwork:n.allowPrivateNetwork}:{},...n?.onDroppedHeader!==void 0?{onDroppedHeader:n.onDroppedHeader}:{},...n?.ca!==void 0?{ca:n.ca}:{},...n?.proxy!==void 0?{proxy:n.proxy}:{}}):new st({fetchFn:r??globalThis.fetch,...n?.strict!==void 0?{strict:n.strict}:{},...n?.onDroppedHeader!==void 0?{onDroppedHeader:n.onDroppedHeader}:{},...n?.dispatcher!==void 0?{dispatcher:n.dispatcher}:{},...n?.allowPrivateNetwork!==void 0?{allowPrivateNetwork:n.allowPrivateNetwork}:{}})}async function Ot(r,e,t){if(t<=0)return r.send(e);let n=new AbortController,s=setTimeout(()=>{n.abort(new Y(t,e))},t),o=$r(e.signal,n.signal)??null,i={...e,signal:o},a=new Promise((c,u)=>{n.signal.addEventListener("abort",()=>u(new Y(t,e)),{once:!0})});try{let c=await Promise.race([r.send(i),a]);if(clearTimeout(s),n.signal.aborted)throw new Y(t,e);return c}catch(c){throw clearTimeout(s),n.signal.aborted&&!(c instanceof Y)?new Y(t,e):c}}async function yr(r,e,t,n){if(!r)return new Uint8Array(0);let s=r.getReader(),o=[],i=0,a,c=new Promise((l,h)=>{a=h}),u=()=>{s.cancel("aborted").catch(()=>{}),a(new x("Response reading aborted","EABORT"))};if(n?.aborted)throw s.cancel("aborted").catch(()=>{}),new x("Response reading aborted","EABORT");n?.addEventListener("abort",u,{once:!0});try{for(;;){let l=await Promise.race([s.read().catch(p=>{throw s.cancel("read error").catch(()=>{}),p}),c]),{done:h,value:d}=l;if(h)break;if(e>0)try{hr(d,i,{maxBytes:e},"throw",(p,m)=>new bt(p,m))}catch(p){throw await s.cancel("size limit exceeded"),p}o.push(d),i+=d.byteLength}}catch(l){throw s.cancel("error during read").catch(()=>{}),l}finally{n?.removeEventListener("abort",u),s.releaseLock()}return er(o)}function Mt(r,e,t,n,s,o){if(t)return t(r,s??{},o??"");if(!r.byteLength)return null;let i=e?.split(";")[0]?.trim().toLowerCase()??"";if(i==="application/json"||i.endsWith("+json")){let a=new TextDecoder("utf-8").decode(r),c,u;try{let l=Se(a,{maxStringLength:1e7,maxDepth:100,maxArrayLength:1e5});if(l.success&&l.value!==void 0)c=l.value;else if(!l.success){let h=new Error(`JSON body rejected: ${l.message??"parse failed"} \u2014 falling back to raw text`);Object.assign(h,{code:l.error??"EPARSE"}),u=h}}catch(l){u=l instanceof Error?l:new Error(String(l))}if(c!==void 0)return c;if(n)try{n(r,u??new Error("JSON parse failed \u2014 falling back to raw text"))}catch{}return a}return i.startsWith("text/")?new TextDecoder("utf-8").decode(r):r}function wo(r){return r.filter(e=>e.family!==0&&!Wi(e.address))}function Ec(r,e){return new x(`URL "${r}" resolved only to blocked addresses (${e.map(t=>t.address).join(", ")||"none"})`,"EBLOCKEDHOST")}function Rc(){return(r,e,t)=>{let n=i=>{t(i)},s=e.all===!0,o={...e,all:!0};(0,yo.lookup)(r,o,(i,a)=>{if(i){n(i);return}let c=wo(a??[]);if(c.length===0){let l=(a??[]).map(d=>d.address).join(", ")||"no addresses",h=new Error(`Refusing to connect to ${r}: it resolves only to a blocked address (${l})`);h.code="EBLOCKEDHOST",n(h);return}if(s){t(null,c);return}let u=c[0];t(null,u.address,u.family)})}}function kc(r){return mt(r)}function xh(r){let e=r.trim().toLowerCase();return e==="2"||e==="2.0"||e==="h2"||e==="http/2"||e==="http/2.0"?"HTTP/2":e==="1"||e==="1.0"||e==="http/1"||e==="http/1.0"?"HTTP/1.0":e==="1.1"||e==="http/1.1"?"HTTP/1.1":null}function _h(r,e){let n=r.httpVersion;if(typeof n=="string"){let o=xh(n);if(o)return o}let s=r.headers.get("alt-svc");if(s){let o=s.includes('h3="')||s.includes("h3-29=")||s.includes("h3-32=");if(s.includes('h2="')||o)return"HTTP/2"}return"HTTP/1.1"}function Sh(r){if(!(r instanceof Error))return!1;let e=r.message.toLowerCase();return e.includes("alpn")||e.includes("h2")||e.includes("http2")||r.code==="ERR_HTTP2_ERROR"}function Ac(r){return new ReadableStream({start(e){let t=!1,n=!1;r.on("data",s=>{if(s instanceof Uint8Array)e.enqueue(s);else if(Sn.Buffer?.isBuffer(s)){let o=s;e.enqueue(new Uint8Array(o.buffer,o.byteOffset,o.byteLength))}else e.enqueue(new Uint8Array(s))}),r.once("end",()=>{if(!(t||n)){t=!0;try{e.close()}catch{}}}),r.once("error",s=>{if(!(t||n)){t=!0,n=!0;try{e.error(s)}catch{}}}),r.once("close",()=>{if(t||n)return;t=!0;let s=Object.assign(new Error("Stream closed before end"),{code:"ECONNRESET"});try{e.error(s)}catch{}})},cancel(){r.destroy()}})}async function Cc(r,e){r.write(e)||await new Promise(n=>r.once("drain",n))}async function Eh(r,e){if(e instanceof ReadableStream){let t=e.getReader();for(;;){let{done:n,value:s}=await t.read();if(n){r.end();break}await Cc(r,s)}}else if(e instanceof Uint8Array||e instanceof ArrayBuffer)r.end(Sn.Buffer?new Uint8Array(e):e);else if(typeof e=="string")r.end(e);else{let{bytes:t}=await _n(e);r.end(t)}}async function Rh(r,e){if(e instanceof ReadableStream){let t=e.getReader();for(;;){let{done:n,value:s}=await t.read();if(n){r.end();break}await Cc(r,s)}}else if(e instanceof Uint8Array||e instanceof ArrayBuffer)r.end(Sn.Buffer?new Uint8Array(e):e);else if(typeof e=="string")r.end(e);else{let{bytes:t}=await _n(e);r.end(t)}}async function _n(r){if(typeof URLSearchParams<"u"&&r instanceof URLSearchParams)return{bytes:new TextEncoder().encode(r.toString())};if(typeof Blob<"u"&&r instanceof Blob)return{bytes:new Uint8Array(await r.arrayBuffer())};if(typeof FormData<"u"&&r instanceof FormData){let{bytes:e,boundary:t}=await wr(r);return{bytes:e,contentType:`multipart/form-data; boundary=${t}`}}return{bytes:new Uint8Array(0)}}function fo(r){return r.replace(/[\r\n"\\]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}async function wr(r,e){let t=e??`----kinetexFormBoundary${Ee(24)}`,n=new TextEncoder,s=[],o=i=>{s.push(n.encode(i))};for(let[i,a]of r.entries()){if(/[\r\n"]/.test(i))throw new x(`Cannot send a multipart field whose name contains CR, LF or a quote: ${JSON.stringify(i)}`,"EVALIDATION");if(o(`--${t}\r
10
+ `),typeof a=="string"){o(`Content-Disposition: form-data; name="${fo(i)}"\r
11
11
  \r
12
12
  `),o(a),o(`\r
13
- `);continue}o(`Content-Disposition: form-data; name="${ao(i)}"; filename="${ao(a.name||"blob")}"\r
13
+ `);continue}o(`Content-Disposition: form-data; name="${fo(i)}"; filename="${fo(a.name||"blob")}"\r
14
14
  Content-Type: ${a.type||"application/octet-stream"}\r
15
15
  \r
16
16
  `),s.push(new Uint8Array(await a.arrayBuffer())),o(`\r
17
17
  `)}return o(`--${t}--\r
18
- `),{bytes:Xt(s),boundary:t}}async function hr(r,e){if(!r)return null;let t=e["content-encoding"]??e["Content-Encoding"];if(!t)return r;let n=t.trim().toLowerCase(),s=n.split(",").map(a=>a.trim()).filter(Boolean),o=["gzip","deflate","br","zstd","identity"];for(let a of s)if(!o.includes(a))return console.warn(`[Kinetex] Unsupported Content-Encoding: ${a}. Supported: ${o.join(", ")}. Response body is passed through compressed.`),r;if(n==="identity")return delete e["content-encoding"],delete e["Content-Encoding"],r;let{applyDecompression:i}=await Promise.resolve().then(()=>(dn(),uc));return i(r,e)}var mn,Se,hc,lc,Ue,lo,yn,et,kt,ch,gc,Pt=W(()=>{"use strict";we();q();Oe();q();mn=globalThis;Se=gn(),hc=null,lc=["node","deno","bun","browser","cloudflare-workers","edge","unknown"];Ue=Se==="node",lo=Se!=="node"||typeof globalThis.fetch=="function";yn="gzip, deflate, br",et=class{constructor(e=globalThis.fetch){f(this,"fetchFn");f(this,"strict");f(this,"onDroppedHeader");f(this,"dispatcher");typeof e=="function"?(this.fetchFn=e,this.strict=!1,this.onDroppedHeader=void 0,this.dispatcher=void 0):(this.fetchFn=e.fetchFn??globalThis.fetch,this.strict=e.strict??!1,this.onDroppedHeader=e.onDroppedHeader,this.dispatcher=e.dispatcher)}async send(e){let t={};for(let[u,l]of Object.entries(e.headers??{}))if(!(typeof u!="string"||typeof l!="string")){if(!Br(u)||!zr(l)){if(this.strict)throw new x(`Invalid header dropped in strict mode: "${u}"`,"EVALIDATION",{request:e});this.onDroppedHeader?this.onDroppedHeader(u,l):fc()||console.warn(`[kinetex] Invalid header dropped: "${u}" \u2014 value may contain illegal characters. Pass strictHeaders: true to throw instead.`);continue}if(u==="__proto__"){Object.defineProperty(t,u,{value:l,writable:!0,enumerable:!0,configurable:!0});continue}t[u]=l}let n=t["accept-encoding"];n&&n.toLowerCase().replace(/\s+/g," ")===yn&&delete t["accept-encoding"];let s={method:e.method,headers:t,redirect:e.redirect??"follow",...e.signal!==null?{signal:e.signal}:{}};e.body!==null&&e.method!=="GET"&&e.method!=="HEAD"&&(s.body=e.body,Ue&&typeof s.body=="object"&&s.body!==null&&"getReader"in s.body&&(s.duplex="half")),this.dispatcher!==void 0&&(s.dispatcher=this.dispatcher);let o;try{o=await this.fetchFn(e.url,s)}catch(u){throw Lr(u)?new x("Request was aborted","EABORT",{request:e,cause:u}):new x(u instanceof Error?u.message:"Network request failed","ENETWORK",{request:e,cause:u})}let i=dc(o.headers),a=ih(o,i),c=!0;return Se==="deno"&&(o.headers.get("content-encoding")||"").toLowerCase().includes("deflate")&&(c=!1),{status:o.status,statusText:o.statusText,headers:i,body:o.body,url:o.url||e.url,redirected:o.redirected,httpVersion:a,alreadyDecompressed:c}}},kt=class{constructor(e={}){f(this,"sessions",new Map);f(this,"sessionTTLMs");f(this,"pingIntervalMs");f(this,"maxSessions");f(this,"pingTimers",new Map);f(this,"_sessionCreating",new Map);f(this,"sessionUsage",new Map);f(this,"_strict");f(this,"_onDroppedHeader");f(this,"_ca");f(this,"_connectTimeoutMs");f(this,"_requestTimeoutMs");f(this,"_http1Fallback",null);f(this,"_http1KeepAlive");f(this,"_http1MaxSockets");f(this,"_http1Agent",null);f(this,"_proxy");this.sessionTTLMs=e.sessionTTLMs??5*6e4,this.pingIntervalMs=e.pingIntervalMs??3e4,this.maxSessions=e.maxSessions??100,this._http1KeepAlive=e.http1KeepAlive??!0,this._http1MaxSockets=e.http1MaxSockets??16,this._proxy=e.proxy,this._strict=e.strict??!1,this._onDroppedHeader=e.onDroppedHeader,this._ca=e.ca,this._connectTimeoutMs=e.connectTimeoutMs??3e4,this._requestTimeoutMs=e.requestTimeoutMs??3e4}_getOrCreateSession(e,t,n){let s=this._sessionCreating.get(e);if(s)return s;let o=this._createSession(e,t,n);return this._sessionCreating.set(e,o),o.finally(()=>{this._sessionCreating.get(e)===o&&this._sessionCreating.delete(e)}).catch(()=>{}),o}async _createSession(e,t,n){let s=this.sessions.get(e);if(s&&!s.session.destroyed&&!s.session.closed&&!(Date.now()-s.createdAt>this.sessionTTLMs))return this.sessionUsage.set(e,Date.now()),s.session;if(s&&this._evictSession(e,s.session),this.sessions.size>=this.maxSessions){let a="",c=1/0;for(let[u,l]of this.sessionUsage.entries())l<c&&(c=l,a=u);if(a){let u=this.sessions.get(a);u&&this._evictSession(a,u.session)}}let o=null;this._proxy!==void 0&&(o=await this._createProxiedSocket(e,void 0,t));let i=await new Promise((a,c)=>{let u=n.connect(e,{rejectUnauthorized:!0,...this._ca!==void 0?{ca:this._ca}:{},...o!==null?{createConnection:(()=>o)}:{}}),l=setTimeout(()=>{u.destroy(),c(new x(`HTTP/2 connection to ${e} timed out`,"ETIMEOUT",{request:t}))},this._connectTimeoutMs);typeof l.unref=="function"&&l.unref();let h=()=>{clearTimeout(l),u.destroy(),c(new x("Connection aborted","EABORT",{request:t}))},p=()=>t.signal?.removeEventListener("abort",h);t.signal?.addEventListener("abort",h,{once:!0}),u.once("connect",()=>{p(),clearTimeout(l),a(u)}),u.once("error",d=>{p(),clearTimeout(l),c(d)})});if(i.on("goaway",()=>{this._evictSession(e,i)}),i.on("error",()=>{this._evictSession(e,i)}),this.sessions.set(e,{session:i,createdAt:Date.now()}),this.sessionUsage.set(e,Date.now()),this.pingIntervalMs>0){let a=this.pingTimers.get(e);a&&clearInterval(a);let c=setInterval(()=>{let u=this.sessions.get(e);if(!u||u.session.destroyed||u.session.closed){this._evictSession(e,u?.session);return}u.session.ping(l=>{l&&this._evictSession(e,u.session)})},this.pingIntervalMs);typeof c=="object"&&c!==null&&"unref"in c&&c.unref(),this.pingTimers.set(e,c)}return i}async send(e){let t=new URL(e.url);if(t.protocol!=="https:"||e.httpVersion==="HTTP/1.1")return this._sendHTTP1(e);try{return await this._sendHTTP2(e,t)}catch(n){if(ah(n))return this._sendHTTP1(e);throw n}}_rejectHeader(e,t,n,s){if(this._strict)throw new x(`Strict mode: header "${e}" ${n}`,"EVALIDATION",{request:s});this._onDroppedHeader?this._onDroppedHeader(e,t):typeof console<"u"&&console.warn(`[kinetex] Invalid header dropped (HTTP/2): "${e}" \u2014 ${n}. Pass strictHeaders: true to throw instead.`)}async _sendHTTP2(e,t){let n=await import("node:http2"),s=e,o=t,i=!1,a=10;for(let c=0;c<=a;c++){if(c===a)throw new x("Too many HTTP/2 redirects","ENETWORK",{request:e});let u=o.origin,l=this.sessions.get(u),h=l&&Date.now()-l.createdAt>this.sessionTTLMs,p;!l||l.session.destroyed||l.session.closed||h?p=await this._getOrCreateSession(u,s,n):(p=l.session,this.sessionUsage.set(u,Date.now()));let d=s.body,m;s.body instanceof FormData&&(m=await pn(s.body),d=m.bytes,m.contentType!==void 0&&!s.headers["content-type"]&&(s={...s,headers:{...s.headers,"content-type":m.contentType}}));let g={":method":s.method,":path":o.pathname+o.search,":scheme":"https",":authority":o.host};for(let[v,P]of Object.entries(s.headers)){if(v.startsWith(":")){this._rejectHeader(v,Array.isArray(P)?P.join(", "):String(P),"is not a valid header name",s);continue}if(v==="__proto__"){Object.defineProperty(g,v,{value:P,writable:!0,enumerable:!0,configurable:!0});continue}g[v]=P}for(let[v,P]of Object.entries(g)){if(v.startsWith(":"))continue;let Ae=Array.isArray(P)?P.join(", "):String(P),V=Br(v),Kt=zr(Ae);(!V||!Kt)&&(this._rejectHeader(v,Ae,V?"contains forbidden control characters":"is not a valid header name",s),delete g[v])}let y=!d||s.method==="GET"||s.method==="HEAD",w=p.request(g,{endStream:y});d&&!y&&uh(w,d).catch(v=>{w.destroy(v instanceof Error?v:new Error(String(v)))});let _=s.signal,b=await new Promise((v,P)=>{let Ae=this._requestTimeoutMs,V=setTimeout(()=>{A(),P(new x(`HTTP/2 request to ${o} timed out after ${Ae}ms`,"ETIMEOUT",{request:s})),w.destroy()},Ae),Kt=()=>{clearTimeout(V),P(new x("Request was aborted","EABORT",{request:s})),w.destroy()},A=()=>_?.removeEventListener("abort",Kt);_?.addEventListener("abort",Kt,{once:!0}),w.once("response",O=>{let L=Number(O[":status"]??200),H=gc[L]??"",B={};for(let[j,U]of Object.entries(O))j.startsWith(":")||(B[j]=Array.isArray(U)?U.join(", "):U??"");if(clearTimeout(V),A(),_?.aborted){P(new x("Request was aborted","EABORT",{request:s})),w.destroy();return}if(s.redirect==="error"&&L>=300&&L<400&&B.location){P(new x(`Redirect not allowed (redirect:"error") \u2014 received ${L} to ${B.location}`,"ENETWORK",{request:s})),w.destroy();return}v({status:L,statusText:H,headers:B,body:pc(w),url:s.url,redirected:i,httpVersion:"HTTP/2",alreadyDecompressed:!1})}),w.once("error",O=>{clearTimeout(V),A(),_?.aborted?P(new x("Request was aborted","EABORT",{request:s,cause:O})):P(new x(O.message,"ENETWORK",{request:s,cause:O})),w.destroy()})});if(!(b.status>=300&&b.status<400&&!!b.headers.location&&s.redirect!=="manual"))return b;try{if(b.body){let v=b.body.getReader();for(;;){let{done:P}=await v.read();if(P)break}v.releaseLock()}}catch{}let k=b.headers.location,C,E;try{let v=new URL(k,s.url);C=v.href,E=v.protocol.toLowerCase()}catch{throw new x(`Invalid redirect Location: ${k}`,"ENETWORK",{request:e})}if(E!=="https:")throw new x(`HTTP/2 redirect to a non-HTTPS target blocked: ${E}//\u2026`,"EVALIDATION",{request:e});if(!te(C))throw new x(`Unsafe redirect target blocked: ${C.replace(/:\/\/[^/@]*@/,"://\u2026@")}`,"EVALIDATION",{request:e});let I=b.status===301||b.status===302||b.status===303?"GET":s.method,$=I==="GET"||I==="HEAD"?null:s.body;s={...s,url:C,method:I,body:$},o=new URL(C),i=!0}throw new x("HTTP/2 redirect loop terminated unexpectedly","ENETWORK",{request:e})}_sendHTTP1(e){if(typeof globalThis.fetch=="function"){if(!this._http1Fallback){let t={fetchFn:globalThis.fetch,strict:this._strict};this._onDroppedHeader!==void 0&&(t.onDroppedHeader=this._onDroppedHeader),this._http1Fallback=new et(t)}return this._http1Fallback.send(e)}return this._sendHTTP1Legacy(e)}async _sendHTTP1Legacy(e){let t=await import("node:https"),n=new URL(e.url),s=e;if(e.body instanceof FormData){let i=await pn(e.body);s={...e,body:i.bytes},i.contentType!==void 0&&!s.headers["content-type"]&&(s={...s,headers:{...s.headers,"content-type":i.contentType}})}let o={hostname:n.hostname,port:n.port||"443",path:n.pathname+n.search,method:s.method,headers:s.headers,...this._http1KeepAlive?{agent:this._getHttp1Agent(t)}:{},...this._ca!==void 0?{ca:this._ca}:{}};return new Promise((i,a)=>{let c=t.request(o,h=>{let p={};for(let[m,g]of Object.entries(h.headers))g!==void 0&&(p[m]=Array.isArray(g)?g.join(", "):g);let d=ch(h);i({status:h.statusCode??200,statusText:h.statusMessage??"",headers:p,body:d,url:e.url,redirected:!1,httpVersion:"HTTP/1.1",alreadyDecompressed:!1})});c.once("error",h=>{a(h instanceof x?h:new x(h.message,"ENETWORK",{request:e,cause:h}))});let u=()=>{c.destroy(),a(new x("Request was aborted","EABORT",{request:e}))};e.signal?.addEventListener("abort",u,{once:!0});let l=()=>e.signal?.removeEventListener("abort",u);c.once("close",l),c.once("error",l),e.body&&e.method!=="GET"&&e.method!=="HEAD"?lh(c,s.body).catch(a):c.end()})}_getHttp1Agent(e){return this._http1Agent||(this._http1Agent=new e.Agent({keepAlive:!0,maxSockets:this._http1MaxSockets,maxFreeSockets:this._http1MaxSockets,...this._ca!==void 0?{ca:this._ca}:{}}),this._proxy!==void 0&&(this._http1Agent.createConnection=((t,n)=>{this._createProxiedSocket(`https://${String(t.host??t.servername??"localhost")}:${String(t.port??443)}`,void 0,void 0).then(s=>n(null,s),s=>n(s))}))),this._http1Agent}async _createProxiedSocket(e,t,n){let{connectThroughProxy:s}=await Promise.resolve().then(()=>(rc(),tc)),o=new URL(e);return await s(this._proxy,o,{...this._ca!==void 0?{ca:this._ca}:{},connectTimeoutMs:this._connectTimeoutMs,...n?.signal!=null?{signal:n.signal}:{},...n!==void 0?{request:n}:{}})}_evictSession(e,t){let n=this.pingTimers.get(e);n&&(clearInterval(n),this.pingTimers.delete(e)),this.sessions.delete(e),this.sessionUsage.delete(e),this._sessionCreating.delete(e),t&&!t.destroyed&&!t.closed&&t.destroy()}destroy(){for(let e of this.pingTimers.values())clearInterval(e);this.pingTimers.clear(),this._sessionCreating.clear();for(let[e,{session:t}]of this.sessions.entries())this._evictSession(e,t);this.sessions.clear(),this._http1Agent?.destroy(),this._http1Agent=null}};ch=pc;gc={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Content Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"}});function dh(r){return r.split(fh).filter(Boolean)}function ph(r){let e=r.match(/^(\d{1,2}):(\d{2}):(\d{2})(?:[+-]\d{2}:?\d{2}|Z|GMT|UTC)?$/i);if(!e)return null;let t=+e[1],n=+e[2],s=+e[3];return t>23||n>59||s>59?null:[t,n,s]}function mh(r){let e=r.slice(0,9).toLowerCase();return hh[e]??null}function gh(r){if(!/^\d{2,4}$/.test(r))return null;let e=+r;return e>=70&&e<=99&&(e+=1900),e>=0&&e<=69&&(e+=2e3),e}function fr(r){if(!r)return null;let e=dh(r),t={time:null,dayOfMonth:null,month:null,year:null};for(let a of e)if(a){if(t.time===null&&a.includes(":")){let c=ph(a);if(c!==null){t.time=c;continue}}if(t.month===null&&/[a-zA-Z]/.test(a)){let c=mh(a);if(c!==null){t.month=c;continue}}if(/^\d{1,4}(?:st|nd|rd|th)?$/i.test(a)){let c=a.replace(/[a-z]+$/i,""),u=+c;if(t.dayOfMonth===null&&c.length<=2&&u>=1&&u<=31){t.dayOfMonth=u;continue}if(t.year===null&&c.length>=2){let l=gh(c);if(l!==null){t.year=l;continue}}if(t.dayOfMonth===null&&u>=1&&u<=31){t.dayOfMonth=u;continue}}}if(t.time===null||t.dayOfMonth===null||t.month===null||t.year===null||t.year<1601||t.year>9999||t.dayOfMonth<1||t.dayOfMonth>31)return null;let[n,s,o]=t.time,i=Date.UTC(t.year,t.month,t.dayOfMonth,n,s,o);return isNaN(i)?null:i}function dr(r){let e=r.replace(/\.$/,"").toLowerCase(),t=e.split(".");if(t.length===0||t.length===1&&t[0]==="")return null;if(mo.has(e))return e;let n=null,s=0;for(let o=0;o<t.length;o++){let i=t.slice(o).join(".");if(fo.has(i)){let a=t.length-o;a>s&&(s=a,n=i)}}for(let o=0;o<t.length-1;o++){let i=t.slice(o+1).join(".");if(po.has(i)){let a=t.slice(o).join("."),c=t.length-o;c>s&&(s=c,n=a)}}return n||(t[t.length-1]??null)}function bn(r){let e=r.toLowerCase().replace(/\.$/,"");if(Ee(e))return e;let t=dr(e);if(!t)return null;let n=t.split(".").length,s=e.split(".");return s.length<=n?null:s.slice(-(n+1)).join(".")}function Te(r){let e=r.toLowerCase();if(mo.has(e)||fo.has(e))return!0;let t=e.split(".");if(t.length>=2){let n=t.slice(1).join(".");if(po.has(n))return!0}return!1}function wh(r){try{let c=r.lastIndexOf("-"),u=[],l=c>=0?r.slice(0,c):"";for(let b=0;b<l.length;b++){let T=l.charCodeAt(b);if(T>122||T>90&&T<97||T>57&&T<65||T<48)return r;u.push(T)}let h=c>=0?r.slice(c+1):r,p=128,d=0,m=72,g=b=>b>=65&&b<=90?b-65:b>=97&&b<=122?b-97:b>=48&&b<=57?b-48+26:-1,y=(b,T,k)=>{b=Math.floor(b/(k?700:2)),b+=Math.floor(b/T);let C=0;for(;b>910/2;)b=Math.floor(b/35),C+=36;return C+Math.floor(36*b/(b+38))},w=0;for(;w<h.length;){let b=d,T=1;for(let k=36;;k+=36){if(w>=h.length)return r;let C=g(h.charCodeAt(w++));if(C<0)return r;d+=C*T;let E=k<=m?1:k>=m+26?26:k-m;if(C<E)break;T*=36-E}m=y(d-b,u.length+1,b===0),p+=Math.floor(d/(u.length+1)),d%=u.length+1,u.splice(d,0,p),d++}return String.fromCodePoint(...u)||r}catch{return r}}function pr(r){if(!r.toLowerCase().startsWith("xn--"))return r;let e=Intl;if(typeof Intl<"u"&&e.IDN&&typeof e.IDN.toUnicode=="function")try{return e.IDN.toUnicode(r,{standard:"tr46"})}catch{return r}if(ho){let t=r+".invalid",n=ho(t);if(n&&n.length>8&&n.endsWith(".invalid")){let s=n.slice(0,-8);if(s!==r)return s}}if(r.startsWith("xn--"))try{let t=wh(r.slice(4));if(t&&t!==r.slice(4))return t}catch{}return r}function pe(r){return r.replace(/^\./,"").replace(/\.$/,"").toLowerCase().split(".").map(pr).join(".")}function xh(r){let e=r,t=e.lastIndexOf(":");if(t>=0&&e.slice(t+1).includes(".")){let s=e.slice(t+1);if(!bc.test(s))return!1;let o=s.split(".").map(Number);if(!o.every(i=>i>=0&&i<=255))return!1;e=e.slice(0,t+1)+((o[0]<<8|o[1]).toString(16)+":"+(o[2]<<8|o[3]).toString(16))}if(!bh.test(e)||e.split("::").length>2)return!1;let n=s=>(s??"").split(":").filter(Boolean).length;if(e.includes("::")){let[s,o]=e.split("::");return n(s)+n(o)<=7}return n(e)===8}function Ee(r){let e=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;return bc.test(e)?e.split(".").map(Number).every(n=>n>=0&&n<=255):xh(e)}function Lt(r,e){let t=r.toLowerCase(),n=e.toLowerCase().replace(/^\./,"");return t===n?!0:!(Ee(t)||!t.endsWith("."+n)||Ee(n)||Te(n))}function It(r){if(!r||r===""||r[0]!=="/")return"/";let e=r.lastIndexOf("/");return e===0?"/":r.slice(0,e)}function wn(r){if(!r.startsWith("/"))return"/"+r;let e=[],t=r.split("/");for(let n of t)n===""||n==="."||(n===".."?e.length>0&&e.pop():e.push(n));return"/"+e.join("/")}function Ot(r,e){let t=wn(r),n=wn(e);return!!(t===n||t.startsWith(n)&&(n.endsWith("/")||t[n.length]==="/"))}function Sh(r){return r===""?!0:_h.test(r)}function wc(r){for(let e=0;e<r.length;e++){let t=r.charCodeAt(e);if(t>=0&&t<=8||t>=10&&t<=31||t===127)return!1}return!0}function Mt(r){if(!r||r.trim()==="")return null;let e=r.indexOf(";"),t=e===-1?r:r.slice(0,e),n=e===-1?"":r.slice(e+1),s=t.indexOf("="),o,i;if(s===-1?(o="",i=t):(o=t.slice(0,s).trim(),i=t.slice(s+1)),!Sh(o)||!wc(i)||(i=i.trim(),i.length>=2&&i[0]==='"'&&i[i.length-1]==='"'&&(i=i.slice(1,-1)),!wc(i)))return null;let a=new Map,c=n.split(";");for(let E of c){let I=E.trim();if(!I)continue;let $=I.indexOf("=");if($===-1)a.set(I.toLowerCase(),"");else{let v=I.slice(0,$).trim().toLowerCase(),P=I.slice($+1).trim();a.has(v)||a.set(v,P)}}let u=a.has("domain")?a.get("domain"):null,l=a.has("path")?a.get("path"):null,h=a.has("expires")?a.get("expires"):null,p=a.has("max-age")?a.get("max-age"):null,d=a.has("secure"),m=a.has("httponly"),g="Unset";if(a.has("samesite")){let E=a.get("samesite").toLowerCase();E==="strict"?g="Strict":E==="lax"?g="Lax":E==="none"&&(g="None")}let y=a.has("sameparty"),w=null;if(a.has("priority")){let E=a.get("priority").toLowerCase();E==="low"?w="Low":E==="medium"?w="Medium":E==="high"&&(w="High")}let _=a.has("partitioned"),b=null;p!==null&&p.match(/^-?\d+$/)&&(b=parseInt(p,10));let T=null;b===null&&h!==null&&(T=fr(h));let k=null;u!==null&&u!==""&&(k=pe(u));let C=null;return l!==null&&l.startsWith("/")&&(C=l),{name:o,value:i,domain:k,path:C,expires:T,maxAge:b,secure:d,httpOnly:m,sameSite:g,sameParty:y,priority:w,partitioned:_}}function xc(r){let e=[];if(r.value.includes(";")||r.value.includes(",")||r.value.includes(" ")||r.value.includes('"')?e.push(`${r.name}="${r.value.replace(/"/g,'\\"')}"`):e.push(`${r.name}=${r.value}`),r.path&&e.push(`Path=${r.path}`),r.domain&&e.push(`Domain=${r.domain}`),r.expires!==null){let t=new Date(r.expires);e.push(`Expires=${t.toUTCString()}`)}return r.maxAge!==null&&e.push(`Max-Age=${r.maxAge}`),r.secure&&e.push("Secure"),r.httpOnly&&e.push("HttpOnly"),r.sameSite&&r.sameSite!=="Unset"&&e.push(`SameSite=${r.sameSite}`),r.sameParty&&e.push("SameParty"),r.priority&&e.push(`Priority=${r.priority}`),r.partitioned&&e.push("Partitioned"),e.join("; ")}function Eh(r,e){let t=e;for(;t<r.length&&(r[t]===" "||r[t]===" ");)t++;if(t>=r.length)return!0;for(;t<r.length;t++){let n=r[t];if(n===";"||n===",")return!1;if(n==="=")return!0}return!1}function tt(r){let e=[],t="",n=0,s=!1,o=!1,i=!1,a=!1,c=!1,u=()=>{i&&a&&t.trim()&&e.push(t.trim()),t="",i=!1,a=!1,c=!1};for(;n<r.length;){let l=r[n],h=r[n+1]??"";if(o){t+=l,o=!1,n++;continue}if(l==="\\"&&(s||h==='"'||h==="\\")){t+=l,o=!0,n++;continue}if(l==='"'){!s&&i?s=!0:s&&(s=!1,a=!0),t+=l,n++;continue}if(s){t+=l,n++;continue}if(l===","&&!s&&(c||a||i)){if(!Eh(r,n+1)){t+=l,n++;continue}for(u();n+1<r.length&&/\s/.test(r[n+1]);)n++;n++;continue}if(l===";"){i||(i=!0),a&&(c=!0),t+=l,n++;continue}if(l==="="&&!i){i=!0,a=!0,t+=l,n++;continue}if(i&&!a&&l!==";"&&l!==","&&(a=!0),l===" "||l===" "){t.length>0&&t.trim()!==""&&(t+=l),n++;continue}t+=l,n++}return i&&a&&t.trim()&&e.push(t.trim()),e}function Dt(r){if(typeof Headers<"u"&&r instanceof Headers){if(typeof r.getSetCookie=="function")return r.getSetCookie();let n=r.get("set-cookie");return n?tt(n):[]}let e=r,t=e["set-cookie"]??e["Set-Cookie"];return t?Array.isArray(t)?t.flatMap(n=>tt(n)):tt(t):[]}var hh,fh,yh,fo,po,mo,ho,bc,bh,_h,xn=W(()=>{"use strict";hh={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11},fh=/[\t\x20-\x2f\x3b-\x40\x5b-\x60\x7b-\x7e]+/;yh=["!www.ck","!city.kobe.jp","!city.nagoya.jp","!city.sapporo.jp","!city.sendai.jp","!city.yokohama.jp","*.ck","*.er","*.bd","*.fj","*.fk","*.gu","*.jm","*.kh","*.mm","*.np","*.pg","*.ss","*.tp","*.vi","*.ye","*.zm","*.kawasaki.jp","*.kitakyushu.jp","*.kobe.jp","*.nagoya.jp","*.osaka.jp","*.sapporo.jp","*.sendai.jp","*.yokohama.jp","com","net","org","edu","gov","mil","int","arpa","info","biz","name","mobi","tel","travel","museum","coop","aero","pro","jobs","cat","post","xxx","app","dev","io","ai","co","me","tv","fm","blog","shop","store","online","site","web","tech","cloud","digital","media","news","press","agency","solutions","services","systems","network","group","team","studio","design","art","photography","email","marketing","consulting","management","finance","money","bank","insurance","healthcare","medical","hospital","clinic","pharmacy","dental","legal","law","attorney","lawyer","accountant","pm","sh","ac","cc","cx","nu","ms","pw","sc","sx","tc","tk","ac","ad","ae","af","ag","ai","al","am","an","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","su","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","uk","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","za","zm","zw","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","info.au","conf.au","oz.au","act.au","nsw.au","nt.au","qld.au","sa.au","tas.au","vic.au","wa.au","com.br","net.br","org.br","edu.br","gov.br","mil.br","art.br","ind.br","adm.br","adv.br","agr.br","am.br","arq.br","ato.br","b.br","bio.br","blog.br","bmd.br","cim.br","cng.br","cnt.br","coop.br","ecn.br","eco.br","emp.br","eng.br","esp.br","etc.br","eti.br","far.br","flog.br","fm.br","fnd.br","fot.br","fst.br","g12.br","ggf.br","imb.br","inf.br","jor.br","jus.br","leg.br","lel.br","mat.br","med.br","mp.br","mus.br","not.br","ntr.br","odo.br","ppg.br","pro.br","psc.br","psi.br","qsl.br","radio.br","rec.br","slg.br","srv.br","taxi.br","teo.br","tmp.br","trd.br","tur.br","tv.br","vet.br","vlog.br","wiki.br","zlg.br","ab.ca","bc.ca","mb.ca","nb.ca","nf.ca","nl.ca","ns.ca","nt.ca","nu.ca","on.ca","pe.ca","qc.ca","sk.ca","yk.ca","com.cn","net.cn","org.cn","edu.cn","gov.cn","mil.cn","ac.cn","ah.cn","bj.cn","cq.cn","fj.cn","gd.cn","gs.cn","gz.cn","gx.cn","ha.cn","hb.cn","he.cn","hi.cn","hl.cn","hn.cn","jl.cn","js.cn","jx.cn","ln.cn","nm.cn","nx.cn","qh.cn","sc.cn","sd.cn","sh.cn","sn.cn","sx.cn","tj.cn","xj.cn","xz.cn","yn.cn","zj.cn","co.uk","me.uk","org.uk","ltd.uk","plc.uk","net.uk","sch.uk","gov.uk","nhs.uk","police.uk","mod.uk","ac.uk","judiciary.uk","parliament.uk","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","aichi.jp","akita.jp","aomori.jp","chiba.jp","ehime.jp","fukui.jp","fukuoka.jp","fukushima.jp","gifu.jp","gunma.jp","hiroshima.jp","hokkaido.jp","hyogo.jp","ibaraki.jp","ishikawa.jp","iwate.jp","kagawa.jp","kagoshima.jp","kanagawa.jp","kochi.jp","kumamoto.jp","kyoto.jp","mie.jp","miyagi.jp","miyazaki.jp","nagano.jp","nagasaki.jp","nara.jp","niigata.jp","oita.jp","okayama.jp","okinawa.jp","osaka.jp","saga.jp","saitama.jp","shiga.jp","shimane.jp","shizuoka.jp","tochigi.jp","tokushima.jp","tokyo.jp","tottori.jp","toyama.jp","wakayama.jp","yamagata.jp","yamaguchi.jp","yamanashi.jp","co.nz","net.nz","org.nz","edu.nz","govt.nz","school.nz","geek.nz","maori.nz","iwi.nz","mil.nz","parliament.nz","ac.nz","co.za","net.za","org.za","edu.za","gov.za","mil.za","ac.za","alt.za","agric.za","cybernet.za","db.za","grondar.za","nis.za","nom.za","ngo.za","pty.za","school.za","tm.za","web.za","co.in","net.in","org.in","edu.in","gov.in","mil.in","ac.in","res.in","firm.in","gen.in","ind.in","int.in","nic.in","com.ar","net.ar","org.ar","edu.ar","gov.ar","mil.ar","int.ar","tur.ar","com.mx","net.mx","org.mx","edu.mx","gob.mx","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","mil.tw","idv.tw","game.tw","ebiz.tw","club.tw","com.my","net.my","org.my","edu.my","gov.my","mil.my","name.my","sch.my","com.ph","net.ph","org.ph","edu.ph","gov.ph","mil.ph","ngo.ph","i.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","mil.pk","ac.pk","res.pk","biz.pk","fam.pk","gob.pk","gok.pk","gon.pk","gop.pk","gos.pk","info.pk","com.eg","net.eg","org.eg","edu.eg","gov.eg","mil.eg","sci.eg","eun.eg","info.eg","name.eg","com.sa","net.sa","org.sa","edu.sa","gov.sa","med.sa","pub.sa","sch.sa","com.ae","net.ae","org.ae","edu.ae","gov.ae","mil.ae","sch.ae","ac.ae","pro.ae","name.ae","com.tr","net.tr","org.tr","edu.tr","gov.tr","mil.tr","bel.tr","k12.tr","av.tr","bbs.tr","dr.tr","gen.tr","info.tr","name.tr","pol.tr","tel.tr","web.tr","com.ua","net.ua","org.ua","edu.ua","gov.ua","mil.ua","in.ua","co.ua","cherkassy.ua","chernigov.ua","chernovtsy.ua","dn.ua","dnepropetrovsk.ua","donetsk.ua","dp.ua","if.ua","kh.ua","kharkov.ua","kherson.ua","khmelnitskiy.ua","kiev.ua","kirovograd.ua","km.ua","kr.ua","lg.ua","lugansk.ua","lutsk.ua","lviv.ua","mk.ua","mykolaiv.ua","nikolaev.ua","od.ua","odessa.ua","pl.ua","poltava.ua","rivne.ua","rovno.ua","rv.ua","sebastopol.ua","sumy.ua","te.ua","ternopil.ua","uzhgorod.ua","vinnica.ua","vn.ua","volyn.ua","yalta.ua","zp.ua","zaporizhzhe.ua","zt.ua","zhitomir.ua","com.ru","net.ru","org.ru","edu.ru","gov.ru","mil.ru","pp.ru","int.ru","ac.ru","msk.ru","spb.ru","com.pl","net.pl","org.pl","edu.pl","gov.pl","mil.pl","co.pl","info.pl","biz.pl","nom.pl","waw.pl","poznan.pl","lodz.pl","krakow.pl","wroclaw.pl","com.de","co.de","com.fr","co.fr","asso.fr","nom.fr","prd.fr","presse.fr","tm.fr","aeroport.fr","assedic.fr","avocat.fr","avoues.fr","cci.fr","chambagri.fr","chirurgiens-dentistes.fr","experts-comptables.fr","geometre-expert.fr","gouv.fr","greta.fr","huissier-justice.fr","medecin.fr","notaires.fr","pharmacien.fr","port.fr","veterinaire.fr","com.it","co.it","com.es","co.es","nom.es","org.es","edu.es","gob.es","com.nl","co.nl","com.be","co.be","ac.be","org.be","net.be","com.ch","co.ch","com.at","co.at","ac.at","gv.at","or.at","priv.at","com.se","co.se","ac.se","bd.se","brand.se","fh.se","fhsk.se","fhv.se","tm.se","pp.se","press.se","parti.se","komforb.se","kommunalforbund.se","komvux.se","lanarb.se","lanbib.se","naturbruksgymn.se","sshn.se","com.no","co.no","stat.no","fylkesbibl.no","folkebibl.no","museum.no","idrett.no","priv.no","mil.no","vgs.no","videregaaende.no","kommune.no","herad.no","aa.no","ah.no","bu.no","fm.no","hl.no","hm.no","jan-mayen.no","mr.no","nl.no","nt.no","of.no","ol.no","oslo.no","rl.no","sf.no","st.no","svalbard.no","tm.no","tr.no","va.no","vf.no","com.dk","co.dk","ac.dk","com.fi","co.fi","ac.fi","iki.fi","aland.fi","www.fi","com.pt","co.pt","edu.pt","gov.pt","int.pt","net.pt","nome.pt","org.pt","publ.pt","dyndns.pt","com.gr","co.gr","edu.gr","gov.gr","net.gr","org.gr","store.gr","com.ie","co.ie","gov.ie","net.ie","org.ie","teagasc.ie","com.cz","co.cz","edu.cz","net.cz","org.cz","info.cz","com.sk","co.sk","edu.sk","net.sk","org.sk","com.hu","co.hu","edu.hu","film.hu","gov.hu","info.hu","net.hu","org.hu","priv.hu","sport.hu","tm.hu","2000.hu","agrar.hu","bolt.hu","casino.hu","city.hu","erotica.hu","erotika.hu","forum.hu","games.hu","hotel.hu","ingatlan.hu","jogasz.hu","konyvelo.hu","lakas.hu","media.hu","news.hu","reklam.hu","sex.hu","shop.hu","suli.hu","szex.hu","tozsde.hu","utazas.hu","video.hu","com.ro","co.ro","edu.ro","gov.ro","info.ro","net.ro","nom.ro","org.ro","rec.ro","store.ro","tm.ro","www.ro","arts.ro","firm.ro","nt.ro","shop.ro","com.bg","co.bg","edu.bg","gov.bg","net.bg","org.bg","tel.bg","biz.bg","com.hr","co.hr","from.hr","iz.hr","name.hr","net.hr","com.rs","co.rs","edu.rs","gov.rs","in.rs","net.rs","org.rs","com.ba","co.ba","edu.ba","gov.ba","mil.ba","net.ba","org.ba","rs.ba","unbi.ba","unmo.ba","unsa.ba","untz.ba","unze.ba","com.co","net.co","org.co","edu.co","gov.co","mil.co","nom.co","com.ve","net.ve","org.ve","edu.ve","gov.ve","mil.ve","int.ve","co.ve","arts.ve","bib.ve","firm.ve","info.ve","nom.ve","rec.ve","store.ve","tec.ve","web.ve","com.pe","net.pe","org.pe","edu.pe","gov.pe","mil.pe","nom.pe","sld.pe","com.cl","co.cl","gob.cl","gov.cl","net.cl","org.cl","mil.cl","edu.cl","co.kr","ne.kr","or.kr","re.kr","pe.kr","go.kr","mil.kr","ac.kr","hs.kr","ms.kr","es.kr","sc.kr","kg.kr","seoul.kr","busan.kr","daegu.kr","incheon.kr","gwangju.kr","daejeon.kr","ulsan.kr","gyeonggi.kr","gangwon.kr","chungbuk.kr","chungnam.kr","jeonbuk.kr","jeonnam.kr","gyeongbuk.kr","gyeongnam.kr","jeju.kr","co.id","net.id","or.id","ac.id","web.id","sch.id","go.id","mil.id","my.id","co.th","net.th","org.th","ac.th","go.th","in.th","mi.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","int.vn","ac.vn","biz.vn","info.vn","name.vn","pro.vn","health.vn","com.ng","net.ng","org.ng","edu.ng","gov.ng","mil.ng","mobi.ng","name.ng","sch.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","me.ke","mobi.ke","co.il","net.il","org.il","edu.il","gov.il","muni.il","ac.il","idf.il","com.ir","net.ir","org.ir","edu.ir","gov.ir","ac.ir","id.ir"],fo=new Set,po=new Set,mo=new Set;for(let r of yh)r.startsWith("!")?mo.add(r.slice(1).toLowerCase()):r.startsWith("*.")?po.add(r.slice(2).toLowerCase()):fo.add(r.toLowerCase());(async()=>{try{let r=await import("node:url");typeof r.domainToUnicode=="function"&&(ho=r.domainToUnicode)}catch{}})();bc=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,bh=/^[\da-f:]+$/i;_h=/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/});function kh(r,e){let t=r.name;return!(t.startsWith("__Secure-")&&(!r.secure||e.protocol!=="https:")||t.startsWith("__Host-")&&(!r.secure||e.protocol!=="https:"||r.path!=="/"||!r.hostOnly))}function Ch(r){if(typeof r!="string")return"Unset";switch(r.trim().toLowerCase()){case"strict":return"Strict";case"lax":return"Lax";case"none":return"None";default:return"Unset"}}function vh(r,e){switch(r){case"Strict":return e==="strict";case"Lax":return e==="strict"||e==="lax";case"Unset":return e!=="cross-site";case"None":return!0}}function go(r){try{return new URL(r)}catch{return null}}function _n(){return new He}function Sn(r){return He.fromJSON(r)}var Th,Rh,Ah,_c,He,Sc=W(()=>{"use strict";xn();Th=4096,Rh=50,Ah=3e3,_c=400*24*60*60*1e3;He=class r{constructor(e={}){f(this,"dm",new Map);f(this,"total",0);f(this,"cleanupTimer",null);f(this,"maxTotal");f(this,"maxPerDomain");f(this,"domainMatcherFn");this.maxTotal=e.maxTotal??Ah,this.maxPerDomain=e.maxPerDomain??Rh,this.domainMatcherFn=e.domainMatcher??null,this.cleanupTimer=setInterval(()=>{this.clearExpired()},300*1e3),typeof this.cleanupTimer=="object"&&this.cleanupTimer!==null&&"unref"in this.cleanupTimer&&this.cleanupTimer.unref()}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null)}setCookie(e,t){let n=go(t.url);if(!n)return!1;let s=Mt(e);if(!s)return!1;let o=Date.now(),i=n.hostname.toLowerCase(),a=i.replace(/^\[|\]$/g,""),c=n.protocol==="https:"||a==="localhost"||a==="127.0.0.1"||a==="::1";if(s.name.length+1+s.value.length>Th)return!1;let l,h;if(s.domain!==null&&s.domain!==""){let w=s.domain.toLowerCase();if(!(this.domainMatcherFn??Lt)(i,w)||Te(w))return!1;l=w,h=!1}else l=i,h=!0;let p=s.path??It(n.pathname),d=s.secure;if(d&&!c)return!1;let m=s.sameSite;if(m==="None"&&!d)return!1;let g;if(s.maxAge!==null){if(s.maxAge<=0)return this.removeCookie(l,p,s.name),!0;let w=Math.min(s.maxAge*1e3,_c);g=o+w}else if(s.expires!==null){if(g=s.expires,g<=o)return this.removeCookie(l,p,s.name),!0;g=Math.min(g,o+_c)}else g=1/0;let y={name:s.name,value:s.value,domain:l,path:p,expires:g,maxAge:s.maxAge,secure:d,httpOnly:s.httpOnly,sameSite:m,createdAt:o,lastAccessed:o,hostOnly:h};return kh(y,n)?(this.putCookie(y),!0):!1}getCookies(e){let t=go(e.url);if(!t)return[];let n=t.hostname.toLowerCase(),s=n.replace(/^\[|\]$/g,""),o=t.pathname||"/",i=t.protocol==="https:"||s==="localhost"||s==="127.0.0.1"||s==="::1",a=e.http!==!1,c=e.sameSiteContext??"none",u=Date.now(),l=[];for(let[p,d]of this.dm)if(this.matchDomain(n,p))for(let[,m]of d)for(let[,g]of m)g.hostOnly&&n!==g.domain||g.expires!==1/0&&g.expires<u||Ot(o,g.path)&&(g.secure&&!i||g.httpOnly&&!a||vh(g.sameSite,c)&&(g.name.startsWith("__Secure-")&&!(g.secure&&i)||g.name.startsWith("__Host-")&&!(g.secure&&i&&g.path==="/"&&g.hostOnly)||Te(g.domain)||l.push(g)));l.sort((p,d)=>{let m=d.path.length-p.path.length;return m!==0?m:p.createdAt-d.createdAt});let h=Date.now();return l.map(p=>{let d={...p};return p.lastAccessed=h,d})}getCookieHeader(e){return this.getCookies(e).map(t=>t.name?`${t.name}=${t.value}`:t.value).join("; ")}getCookiesForDomain(e){let t=pe(e),n=[],s=Date.now();for(let[o,i]of this.dm)if(o===t||o.endsWith("."+t)||t.endsWith("."+o))for(let[,a]of i)for(let[,c]of a)c.expires!==1/0&&c.expires<s||c.hostOnly&&c.domain!==t||Te(c.domain)||n.push({...c});return n}processResponseHeaders(e,t){for(let n of Dt(e))this.setCookie(n,t)}removeCookie(e,t,n){let s=pe(e),o=this.dm.get(s);if(!o)return!1;let i=o.get(t);if(!i)return!1;let a=i.delete(n);return a&&(this.total--,i.size===0&&o.delete(t),o.size===0&&this.dm.delete(s)),a}clear(){this.dm.clear(),this.total=0}clearExpired(){let e=Date.now(),t=0;for(let[n,s]of this.dm){for(let[o,i]of s){for(let[a,c]of i)c.expires!==1/0&&c.expires<e&&(i.delete(a),this.total--,t++);i.size===0&&s.delete(o)}s.size===0&&this.dm.delete(n)}return t}clearSession(){let e=0;for(let[t,n]of this.dm){for(let[s,o]of n){for(let[i,a]of o)a.expires===1/0&&(o.delete(i),this.total--,e++);o.size===0&&n.delete(s)}n.size===0&&this.dm.delete(t)}return e}clearForDomain(e){let t=pe(e),n=0;for(let[s,o]of this.dm)if(s===t||s.endsWith("."+t)){let i=0;for(let a of o.values())i+=a.size;this.dm.delete(s),this.total-=i,n+=i}return n}clearForUrl(e){let t=go(e);return t?this.clearForDomain(t.hostname):0}toJSON(){let e=Date.now(),t=[];for(let[,n]of this.dm)for(let[,s]of n)for(let[,o]of s)o.expires!==1/0&&o.expires<e||t.push({name:o.name,value:o.value,domain:o.domain,path:o.path,expires:o.expires===1/0?null:o.expires,maxAge:o.maxAge,secure:o.secure,httpOnly:o.httpOnly,sameSite:o.sameSite,createdAt:o.createdAt,lastAccessed:o.lastAccessed,hostOnly:o.hostOnly});return t}toString(){return JSON.stringify(this.toJSON(),null,2)}static fromJSON(e){let t=new r,n=typeof e=="string"?JSON.parse(e):e,s=Date.now();for(let o of n){let i=o.expires===null?1/0:o.expires;if(i!==1/0&&i<s)continue;let a={name:o.name,value:o.value,domain:o.domain,path:o.path,expires:i,maxAge:o.maxAge,secure:o.secure,httpOnly:o.httpOnly,sameSite:Ch(o.sameSite),createdAt:o.createdAt,lastAccessed:o.lastAccessed,hostOnly:o.hostOnly};t.putCookie(a)}return t}get count(){return this.total}getAll(){let e=[];for(let[,t]of this.dm)for(let[,n]of t)for(let[,s]of n)e.push({...s});return e}getForDomain(e){let t=pe(e),n=[];for(let[s,o]of this.dm)if(s===t||s.endsWith("."+t))for(let[,i]of o)for(let[,a]of i)n.push({...a});return n}putCookie(e){let{domain:t,path:n,name:s}=e,o=this.dm.get(t)?.get(n)?.get(s);if(o){this.dm.get(t).get(n).set(s,{...e,createdAt:o.createdAt});return}this.evictForDomain(t),this.evictGlobal();let i=this.dm.get(t);i||(i=new Map,this.dm.set(t,i));let a=i.get(n);a||(a=new Map,i.set(n,a)),a.set(s,e),this.total++}evictForDomain(e){let t=this.dm.get(e);if(!t)return;let n=0;for(let i of t.values())n+=i.size;if(n<this.maxPerDomain)return;let s=[];for(let[i,a]of t)for(let[c,u]of a)s.push([i,c,u]);s.sort((i,a)=>i[2].lastAccessed-a[2].lastAccessed);let o=0;for(;n>=this.maxPerDomain&&o<s.length;){let[i,a]=s[o++];t.get(i)?.delete(a)&&(this.total--,n--)}for(let[i,a]of t)a.size===0&&t.delete(i)}evictGlobal(){if(this.total<this.maxTotal)return;let e=[];for(let[n,s]of this.dm)for(let[o,i]of s)for(let[a,c]of i)e.push([n,o,a,c]);e.sort((n,s)=>n[3].lastAccessed-s[3].lastAccessed);let t=0;for(;this.total>=this.maxTotal&&t<e.length;){let[n,s,o]=e[t++],i=this.dm.get(n),a=i?.get(s);a?.delete(o)&&(this.total--,a.size===0&&i.delete(s),i.size===0&&this.dm.delete(n))}}matchDomain(e,t){if(this.domainMatcherFn)return this.domainMatcherFn(e,t);let n=e.toLowerCase(),s=t.toLowerCase();return n===s?!0:Ee(n)?!1:n.endsWith("."+s)}}});var Ec={};ae(Ec,{CookieJar:()=>He,canonicalizeDomainFull:()=>pe,createCookieJar:()=>_n,decodeIDNLabel:()=>pr,defaultPath:()=>It,domainMatch:()=>Lt,extractSetCookieHeaders:()=>Dt,formatSetCookieHeader:()=>xc,getPublicSuffix:()=>dr,getRegistrableDomain:()=>bn,isIPAddress:()=>Ee,isPublicSuffix:()=>Te,loadCookieJar:()=>Sn,normalizePath:()=>wn,parseCookieDate:()=>fr,parseSetCookieHeader:()=>Mt,pathMatch:()=>Ot,splitSetCookieHeaders:()=>tt});var yo=W(()=>{"use strict";Sc();xn()});var Tc={};ae(Tc,{BatchingTransport:()=>Ut,ConsoleTransport:()=>rt,HTTPLogger:()=>Be,JSONTransport:()=>$t,LogLevel:()=>Nt,MultiTransport:()=>jt,Redactor:()=>Bt,RemoteTransport:()=>Ht,createDevelopmentLogger:()=>So,createLogger:()=>xo,createProductionLogger:()=>_o,toOTelSpan:()=>bo});function Oh(r){let e=r.split(";",1)[0].trim().toLowerCase();return e==="application/json"||e==="text/json"||e.endsWith("+json")}function $h(){let r=Date.now().toString(36),e=(++Nh).toString(36).padStart(4,"0"),t=Math.random().toString(36).slice(2,6);return`${r}-${e}-${t}`}function wo(r,e){if(!r||typeof r!="object"||e.length===0)return;if(Array.isArray(r)){for(let o of r)wo(o,e);return}let[t,...n]=e;if(t===void 0||t==="__proto__"||t==="constructor"||t==="prototype")return;let s=r;if(n.length===0){Object.prototype.hasOwnProperty.call(s,t)&&(s[t]="***");return}typeof s[t]=="object"&&wo(s[t],n)}function En(r){return typeof r=="string"?new TextEncoder().encode(r).byteLength:r.byteLength}function bo(r){let e={"http.request.id":r.requestId,"http.request.method":r.method,"url.full":r.url};return r.type==="response"&&(e["http.response.status_code"]=r.status,e["http.response.body.size"]=r.bodySize,e["http.time_to_first_byte"]=r.durationMs),r.type==="error"&&(e.error=!0,e["error.type"]=r.error.name,e["error.message"]=r.error.message,e["http.status_code"]=r.status),e}function Uh(r){if(r instanceof Error){let e=r.code,t=r.stack;return{name:r.name,message:r.message,...e!==void 0?{code:e}:{},...t!==void 0?{stack:t}:{}}}if(r!==null&&typeof r=="object"){let e=r,t={name:typeof e.name=="string"&&e.name!==""?e.name:"Error",message:typeof e.message=="string"?e.message:Hh(r)};return(typeof e.code=="string"||typeof e.code=="number")&&(t.code=String(e.code)),typeof e.stack=="string"&&(t.stack=e.stack),t}return{name:"Error",message:String(r)}}function Hh(r){try{let e=new WeakSet;return JSON.stringify(r,(t,n)=>{if(n!==null&&typeof n=="object"){if(e.has(n))return"[circular]";e.add(n)}return n})??String(r)}catch{return String(r)}}function jh(r,e){let t=new TextEncoder,n=t.encode(r).byteLength;if(n<=e)return{text:r,removed:0};let s=0,o=0;for(let i of r){let a=t.encode(i).byteLength;if(s+a>e)break;s+=a,o+=i.length}return{text:r.slice(0,o),removed:n-s}}function Tn(){return typeof performance<"u"?performance.now():Date.now()}function xo(r){return new Be(r)}function _o(r){let e=[new $t];return r.endpoint&&e.push(new Ut(new Ht(r.endpoint))),new Be({level:r.level??"INFO",transports:[new jt(e)],...r.context!==void 0?{context:r.context}:{}})}function So(r={}){return new Be({level:r.level??"DEBUG",transports:[new rt({pretty:!0,useColors:!0,onWrite:e=>console.log(e)})],redaction:{logRequestBody:r.logBodies??!0,logResponseBody:r.logBodies??!0,maxBodyLength:2048}})}var Ph,Nt,Lh,Ih,Mh,rt,Dh,$t,Ut,Ht,jt,Nh,Bt,je,Be,Rn=W(()=>{"use strict";q();Ph=()=>{try{return globalThis.process?.env?.NODE_ENV}catch{return}},Nt={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Lh=["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-access-token","x-refresh-token","x-csrf-token","x-session-id","x-session-token","x-secret","x-secret-key","x-private-key","api-key","apikey","bearer","token","authentication","credentials","password","passwd","secret"],Ih=["token","api_key","apikey","access_token","refresh_token","secret","password","pass","pwd","key","auth"];Mh=["application/json","application/x-www-form-urlencoded","text/"],rt=class{constructor(e={}){f(this,"pretty");f(this,"onWrite");this.pretty=e.pretty??Ph()!=="production",this.onWrite=e.onWrite??(t=>console.log(t)),e.useColors}write(e){let t=this.pretty?this._prettyFormat(e):JSON.stringify(e);this.onWrite(t)}_prettyFormat(e){let t=new Date(e.timestampMs).toISOString().slice(11,23),n=e.level.padEnd(5),s=e.requestId.slice(-8);if(e.type==="request")return`[${t}] ${n} \u2190 ${e.method} ${e.url} [${s}]`;if(e.type==="response"){let o=`${e.durationMs.toFixed(0)}ms`,i=e.cached?" (cached)":"";return`[${t}] ${n} \u2192 ${e.status} ${e.method} ${e.url} ${o}${i} [${s}]`}return`[${t}] ${n} \u2717 ${e.method} ${e.url} ${e.error.message} [${s}]`}},Dh=()=>{try{return typeof globalThis.process?.stdout?.write=="function"}catch{return!1}},$t=class{constructor(e=t=>{Dh()?globalThis.process.stdout.write(t+`
19
- `):console.log(t)}){f(this,"writeLine");this.writeLine=e}write(e){this.writeLine(JSON.stringify(e))}},Ut=class{constructor(e,t={}){f(this,"inner");f(this,"options");f(this,"buffer",[]);f(this,"timer",null);this.inner=e,this.options=t}write(e){if(this.buffer.push(e),this.buffer.length>=(this.options.maxBatch??100)){this._flush();return}this.timer||(this.timer=setTimeout(()=>this._flush(),this.options.flushMs??5e3))}async flush(){this.timer&&(clearTimeout(this.timer),this.timer=null),this._flush(),this.inner.flush&&await this.inner.flush()}_flush(){if(this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.buffer.length===0)return;let e=this.buffer.splice(0);for(let t of e)this.inner.write(t)}},Ht=class{constructor(e,t={}){f(this,"endpoint");f(this,"options");f(this,"buffer",[]);f(this,"timer",null);this.endpoint=e,this.options=t}write(e){if(this.buffer.push(e),this.buffer.length>=(this.options.batchSize??50)){this._flush();return}this.timer||(this.timer=setTimeout(()=>this._flush(),this.options.flushMs??3e3))}async flush(){this.timer&&(clearTimeout(this.timer),this.timer=null),await this._flushAsync()}_flush(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this._flushAsync().catch(this.options.onError??(e=>console.error("[logging] Flush error:",e)))}async _flushAsync(){if(this.buffer.length===0)return;let e=this.buffer.splice(0),t=this.options.fetch??globalThis.fetch;if(e.length<=10)await t(this.endpoint,{method:"POST",headers:{"content-type":"application/json",...this.options.headers},body:JSON.stringify(e)});else try{let{Readable:n}=await import("node:stream"),s=n.from([JSON.stringify(e)]);await t(this.endpoint,{method:"POST",headers:{"content-type":"application/json",...this.options.headers},body:s,duplex:"half"})}catch{await t(this.endpoint,{method:"POST",headers:{"content-type":"application/json",...this.options.headers},body:JSON.stringify(e)})}}},jt=class{constructor(e){f(this,"transports");this.transports=e}write(e){for(let t of this.transports)try{t.write(e)}catch{}}async flush(){await Promise.allSettled(this.transports.map(e=>e.flush?.()))}},Nh=0;Bt=class{constructor(e={}){f(this,"headerSet");f(this,"paramSet");f(this,"bodyFields");f(this,"patterns");f(this,"maxBody");f(this,"logReqBody");f(this,"logResBody");f(this,"allowedTypes");let t=e.headers??Lh,n=e.queryParams??Ih;this.headerSet=new Set(t.map(s=>s.toLowerCase())),this.paramSet=new Set(n.map(s=>s.toLowerCase())),this.bodyFields=e.bodyFields??[],this.patterns=e.bodyPatterns??[],this.maxBody=e.maxBodyLength??4096,this.logReqBody=e.logRequestBody??!1,this.logResBody=e.logResponseBody??!1,this.allowedTypes=e.allowedBodyTypes??Mh}redactHeaders(e){let t={};for(let[n,s]of Object.entries(e))t[n]=this.headerSet.has(n.toLowerCase())?"***":s;return t}redactURL(e){try{let t=new URL(e);for(let n of[...t.searchParams.keys()])this.paramSet.has(n.toLowerCase())&&t.searchParams.set(n,"***");return t.toString()}catch{return this._redactRelativeQuery(e)}}_redactRelativeQuery(e){let t=e.indexOf("?");if(t===-1)return e;let n=e.slice(0,t),s=e.slice(t+1),o=s.indexOf("#"),i=o===-1?"":s.slice(o),c=(o===-1?s:s.slice(0,o)).split("&").map(u=>{if(u==="")return u;let l=u.indexOf("="),h=l===-1?u:u.slice(0,l),p=h;try{p=decodeURIComponent(h)}catch{}return this.paramSet.has(p.toLowerCase())?l===-1?`${h}=***`:`${h}=***`:u});return`${n}?${c.join("&")}${i}`}redactBody(e,t,n){if(!(n?this.logResBody:this.logReqBody)||!e)return{body:null,size:e?En(e):null};let o=t??"";if(!this.allowedTypes.some(l=>o.startsWith(l)))return{body:`[${o||"binary"}]`,size:e?En(e):null};let a=En(e),c;if(e instanceof Uint8Array)try{c=new TextDecoder().decode(e)}catch{return{body:"[binary]",size:e.byteLength}}else c=e;if(Oh(o)&&this.bodyFields.length>0)try{let l=D(JSON.parse(c));for(let h of this.bodyFields)wo(l,h.split("."));c=JSON.stringify(l)}catch{}for(let l of this.patterns)c=c.replace(l,"***");if(En(c)>this.maxBody){let l=jh(c,this.maxBody);c=`${l.text}... [truncated ${l.removed} bytes]`}return{body:c,size:a}}};je=class je{constructor(e={}){f(this,"cfg");f(this,"redactor");f(this,"level");f(this,"activeIds",new Map);this.cfg={level:e.level??"INFO",transports:e.transports??[new rt],redaction:e.redaction??{},sampleRate:e.sampleRate??1,methods:e.methods??[],statuses:e.statuses??[],excludeURLs:e.excludeURLs??[],context:e.context??{},generateId:e.generateId??$h},this.redactor=new Bt(this.cfg.redaction),this.level=Nt[this.cfg.level]}_cleanupActiveIds(){let e=Tn();if(this.activeIds.size>je.MAX_ACTIVE_IDS){let t=Array.from(this.activeIds.entries()),n=t.slice(0,t.length-Math.floor(je.MAX_ACTIVE_IDS*.8));for(let[s]of n)this.activeIds.delete(s)}for(let[t,n]of this.activeIds)e-n.startMs>je.IDLE_TIMEOUT_MS&&this.activeIds.delete(t)}logRequest(e,t,n,s,o,i,a={}){if(!this._shouldLog("INFO",t,n))return;this.activeIds.size>500&&this._cleanupActiveIds(),this.activeIds.set(e,{startMs:Tn(),method:t,url:n});let c=s["content-type"]??s["Content-Type"]??null,u=this.redactor.redactBody(o,c,!1),l={type:"request",requestId:e,timestamp:new Date().toISOString(),timestampMs:Date.now(),level:"INFO",method:t.toUpperCase(),url:this.redactor.redactURL(n),headers:this.redactor.redactHeaders(s),bodySize:u.size,body:u.body,attempt:i,meta:{...this.cfg.context,...a}};this._write(l)}logResponse(e,t,n,s,o,i,a,c={}){let u=this.activeIds.get(e),l=u?Tn()-u.startMs:0,h=u?.method??"GET",p=u?.url??"";if(this.activeIds.delete(e),!this._shouldLog("INFO",h,p,t))return;let d=s["content-type"]??s["Content-Type"]??null,m=this.redactor.redactBody(o,d,!0),g=t>=500?"ERROR":t>=400?"WARN":"INFO",y={type:"response",requestId:e,timestamp:new Date().toISOString(),timestampMs:Date.now(),level:g,method:h.toUpperCase(),url:this.redactor.redactURL(p),status:t,statusText:n,headers:this.redactor.redactHeaders(s),bodySize:m.size,body:m.body,durationMs:Math.round(l),attempt:i,cached:a,meta:{...this.cfg.context,...c}};this._write(y)}logError(e,t,n,s,o={}){let i=this.activeIds.get(e),a=i?Tn()-i.startMs:0,c=i?.method??"GET",u=i?.url??"";if(this.activeIds.delete(e),!this._shouldLog("ERROR",c,u))return;let l={type:"error",requestId:e,timestamp:new Date().toISOString(),timestampMs:Date.now(),level:"ERROR",method:c.toUpperCase(),url:this.redactor.redactURL(u),error:Uh(t),status:n,durationMs:Math.round(a),attempt:s,meta:{...this.cfg.context,...o}};this._write(l)}generateRequestId(){return this.cfg.generateId()}child(e){return new je({...this.cfg,context:{...this.cfg.context,...e}})}async flush(){await Promise.allSettled(this.cfg.transports.map(e=>e.flush?.()))}_write(e){if(!(Nt[e.level]<this.level))for(let n of this.cfg.transports)try{let s=n.write(e);s&&typeof s.then=="function"&&s.catch(()=>{})}catch{}}_shouldLog(e,t,n,s){if(Nt[e]<this.level||this.cfg.sampleRate<1&&Math.random()>this.cfg.sampleRate||this.cfg.methods.length>0&&!this.cfg.methods.includes(t.toUpperCase())||s!==void 0&&this.cfg.statuses.length>0&&!this.cfg.statuses.includes(s))return!1;for(let o of this.cfg.excludeURLs)if(o.test(n))return!1;return!0}};f(je,"MAX_ACTIVE_IDS",1e4),f(je,"IDLE_TIMEOUT_MS",6e4);Be=je});var Co={};ae(Co,{SSEClient:()=>nt,SSEError:()=>me,SSEMaxReconnectsError:()=>st,SSEParser:()=>ze,SSERouter:()=>gr,SSEServerResponse:()=>zt,SSETransformStream:()=>mr,createJSONSSEStream:()=>Ro,createSSEResponse:()=>Ao,createSSEStream:()=>To,jsonSSE:()=>An,parseSSEText:()=>ko});async function*An(r,e={}){for await(let t of r)if(!(!t.data&&t.data!==""))try{let n=D(JSON.parse(t.data,e.reviver));yield{event:t.event,data:n,id:t.id}}catch(n){e.onError?.(n,t)}}function Eo(r){return r.replace(/[\r\n\u0000]/g,"")}function To(r){return new nt(r)}function Ro(r,e={}){return An(new nt(r),e)}function Ao(r,e={}){let t=new zt;return(async()=>{try{await r(t)}catch(n){console.error("[sse] Generator error:",n)}t.close()})(),t.toResponse(e)}function ko(r){let e=new ze,t=e.feed(r),n=e.flush();return n&&t.push(n),t}function Bh(r,...e){let t=e.filter(n=>!!n);return t.some(n=>n.aborted)?(r.then(void 0,()=>{}),Promise.resolve(null)):new Promise((n,s)=>{let o=()=>{i(),r.then(void 0,()=>{}),n(null)},i=()=>{for(let a of t)a.removeEventListener("abort",o)};for(let a of t)a.addEventListener("abort",o,{once:!0});r.then(a=>{i(),n(a)},a=>{i(),s(a)})})}function Rc(r,...e){let t=e.filter(n=>!!n);return t.some(n=>n.aborted)?Promise.resolve():new Promise(n=>{let s=[],i=setTimeout(()=>{clearTimeout(i);for(let a of s)a();n()},r);for(let a of t){let c=()=>{clearTimeout(i),a.removeEventListener("abort",c),n()};s.push(()=>a.removeEventListener("abort",c)),a.addEventListener("abort",c,{once:!0})}})}var ze,mr,nt,gr,zt,me,st,yr=W(()=>{"use strict";q();ze=class{constructor(){f(this,"lines",[]);f(this,"id",null);f(this,"event","message");f(this,"data",[]);f(this,"retry",null);f(this,"buffer","")}feed(e){let t=[];this.buffer+=e;let n=this.buffer.split(/\r\n|\r|\n/);this.buffer=n.pop()??"";for(let s of n){let o=this._processLine(s);o&&t.push(o)}return t}flush(){return this.buffer&&(this._processLine(this.buffer),this.buffer=""),this.data.length>0?this._dispatch():null}_processLine(e){if(this.lines.push(e),e==="")return this.data.length===0?(this.lines=[],null):this._dispatch();if(e.startsWith(":"))return null;let t=e.indexOf(":"),n,s;switch(t===-1?(n=e,s=""):(n=e.slice(0,t),s=e.slice(t+1).replace(/^ /,"")),n){case"id":if(s.includes("\0"))break;this.id=s||null;break;case"event":this.event=s;break;case"data":this.data.push(s);break;case"retry":{/^[0-9]+$/.test(s)&&(this.retry=Number(s));break}}return null}_dispatch(){let e={id:this.id,event:this.event,data:this.data.join(`
20
- `),retry:this.retry,raw:[...this.lines]};return this.lines=[],this.event="message",this.data=[],this.retry=null,e}reset(){this.lines=[],this.id=null,this.event="message",this.data=[],this.retry=null,this.buffer=""}get lastId(){return this.id}},mr=class extends TransformStream{constructor(t={}){super({transform:(n,s)=>{try{let o=typeof n=="string"?n:this.decoder.decode(n,{stream:!0}),i=this.parser.feed(o);for(let a of i)s.enqueue(a)}catch(o){t.onParseError?.(o,String(n))}},flush:n=>{let s=this.parser.flush();s&&n.enqueue(s)}});f(this,"parser",new ze);f(this,"decoder",new TextDecoder("utf-8"))}},nt=class{constructor(e){f(this,"config");f(this,"health");f(this,"_closed",!1);f(this,"_streamController",null);this.config={fetch:globalThis.fetch,headers:{},signal:e.signal??void 0,lastEventId:"",reconnect:!0,reconnectDelayMs:3e3,maxReconnectDelayMs:3e4,reconnectJitter:.3,maxReconnects:0,onReconnect:()=>{},onParseError:t=>{},heartbeatTimeoutMs:0,method:"GET",body:null,validateResponse:()=>!0,...e},this.health={connected:!1,totalEvents:0,totalReconnects:0,lastEventAt:null,lastEventId:this.config.lastEventId||null,reconnectAttempt:0}}get url(){return this.config.url}get closed(){return this._closed}async*[Symbol.asyncIterator](){yield*this._stream()}async*stream(){yield*this._stream()}async*on(e){for await(let t of this._stream())t.event===e&&(yield t)}async collect(e={}){let t=[],n=0,s=e.signal;if(s?.aborted)return[];let o=()=>{this._streamController?.abort()};s?.addEventListener("abort",o);try{for await(let i of this._stream())if(t.push(i),n++,e.limit&&n>=e.limit||e.signal?.aborted)break}finally{s?.removeEventListener("abort",o)}return t}close(){this._closed=!0,this._streamController&&(this._streamController.abort(),this._streamController=null),this.health.connected=!1}destroy(){this.close(),this.health={connected:!1,totalEvents:this.health.totalEvents,totalReconnects:this.health.totalReconnects,lastEventAt:this.health.lastEventAt,lastEventId:this.health.lastEventId,reconnectAttempt:0}}get streamHealth(){return{...this.health}}async*_stream(){let e=this.config,t=e.reconnectDelayMs,n=0;this._streamController=new AbortController;let s=this._streamController.signal;for(;!this._closed&&!s.aborted;){let o=this._closed;if(o||e.signal?.aborted||this._streamController?.signal.aborted)break;let i=new ze,a=null;try{let u={accept:"text/event-stream","cache-control":"no-cache",...e.headers};this.health.lastEventId&&(u["last-event-id"]=this.health.lastEventId);let l={method:e.method,headers:u,body:e.body??null,signal:e.signal??null};e.body!==null&&e.body!==void 0&&(l.duplex="half");let h=await e.fetch(e.url,l),p=e.validateResponse(h);if(p!==!0){let _=typeof p=="string"?p:`SSE server returned ${h.status}`;throw new me(_,h.status,h)}if(!h.ok)throw new me(`SSE server error: ${h.status}`,h.status,h);if(!h.body)throw new me("SSE response has no body",h.status,h);let d=h.headers.get("content-type")??"";if(!d.startsWith("text/event-stream"))throw new me(`Expected text/event-stream, got: ${d}`,h.status,h);this.health.connected=!0,n=0,t=e.reconnectDelayMs;let m=h.body.getReader(),g=new TextDecoder("utf-8"),y=()=>{a&&clearTimeout(a),e.heartbeatTimeoutMs>0&&(a=setTimeout(()=>{m.cancel("heartbeat timeout")},e.heartbeatTimeoutMs))};y();try{for(;!o&&!e.signal?.aborted;){let _=await Bh(m.read(),e.signal,s);if(_===null)break;let{done:b,value:T}=_;if(b)break;let k=g.decode(T,{stream:!0}),C=i.feed(k);for(let E of C)y(),E.retry!==null&&(t=Math.min(E.retry,e.maxReconnectDelayMs)),E.id!==null&&(this.health.lastEventId=E.id),this.health.totalEvents++,this.health.lastEventAt=Date.now(),yield E}}finally{a&&clearTimeout(a);try{m.cancel().catch(()=>{})}catch{}}let w=s.aborted||e.signal?.aborted?null:i.flush();w&&(this.health.totalEvents++,this.health.lastEventAt=Date.now(),yield w)}catch(u){if(this.health.connected=!1,o||u instanceof Error&&u.name==="AbortError"||e.signal?.aborted)break;if(u instanceof me&&u.status&&[401,403,404].includes(u.status)||!e.reconnect)throw u;if(e.maxReconnects>0&&this.health.totalReconnects>=e.maxReconnects)throw new st(this.health.totalReconnects,e.url);n++,this.health.totalReconnects++,this.health.reconnectAttempt=n;let l=t*e.reconnectJitter*Math.random(),h=Math.min(t+l,e.maxReconnectDelayMs);if(t=Math.min(t*2,e.maxReconnectDelayMs),e.onReconnect(n,h),a&&(clearTimeout(a),a=null),await Rc(h,e.signal,s),e.signal?.aborted||s.aborted)break;i.reset();continue}if(this.health.connected=!1,!e.reconnect)break;if(e.maxReconnects>0&&this.health.totalReconnects>=e.maxReconnects)throw new st(this.health.totalReconnects,e.url);n++,this.health.totalReconnects++,this.health.reconnectAttempt=n;let c=Math.min(t+t*e.reconnectJitter*Math.random(),e.maxReconnectDelayMs);if(t=Math.min(t*2,e.maxReconnectDelayMs),e.onReconnect(n,c),a&&(clearTimeout(a),a=null),await Rc(c,e.signal,s),e.signal?.aborted||s.aborted)break}this.health.connected=!1}};gr=class{constructor(){f(this,"handlers",new Map);f(this,"fallback",null)}on(e,t){let n=this.handlers.get(e)??[];return n.push(t),this.handlers.set(e,n),this}onJSON(e,t){return this.on(e,async(n,s)=>{let o;try{o=D(JSON.parse(n))}catch{return}await t(o,s)})}onMessage(e){return this.on("message",e)}onAny(e){return this.fallback=e,this}async dispatch(e){let t=this.handlers.get(e.event);if(t&&t.length>0)for(let n of t)await n(e.data,e);else this.fallback&&await this.fallback(e.data,e)}async consume(e){for await(let t of e)await this.dispatch(t)}};zt=class{constructor(){f(this,"controller");f(this,"stream");f(this,"_closed",!1);let e;this.stream=new ReadableStream({start:t=>{e=t},cancel:()=>{this._closed=!0}}),this.controller=e}comment(e=""){return this._closed||this.controller.enqueue(`: ${Eo(e)}
18
+ `),{bytes:er(s),boundary:t}}async function br(r,e){if(!r)return null;let t=e["content-encoding"]??e["Content-Encoding"];if(!t)return r;let n=t.trim().toLowerCase(),s=n.split(",").map(a=>a.trim()).filter(Boolean),o=["gzip","deflate","br","zstd","identity"];for(let a of s)if(!o.includes(a))return console.warn(`[Kinetex] Unsupported Content-Encoding: ${a}. Supported: ${o.join(", ")}. Response body is passed through compressed.`),r;if(n==="identity")return delete e["content-encoding"],delete e["Content-Encoding"],r;let{applyDecompression:i}=await Promise.resolve().then(()=>(mr(),mc));return i(r,e)}var yo,Tc,Sn,Ce,_c,bc,ze,go,En,st,It,xc,Th,vc,Nt=J(()=>{"use strict";Re();U();$e();yo=ue("node:dns"),Tc=ue("node:net");U();mr();Sn=globalThis;Ce=Tn(),_c=null,bc=["node","deno","bun","browser","cloudflare-workers","edge","unknown"];ze=Ce==="node",go=Ce!=="node"||typeof globalThis.fetch=="function";En="gzip, deflate, br",st=class{constructor(e=globalThis.fetch){f(this,"fetchFn");f(this,"strict");f(this,"onDroppedHeader");f(this,"dispatcher");f(this,"requestTimeoutMs");f(this,"_allowPrivateNetwork");typeof e=="function"?(this.fetchFn=e,this.strict=!1,this.onDroppedHeader=void 0,this.dispatcher=void 0,this.requestTimeoutMs=void 0,this._allowPrivateNetwork=!1):(this.fetchFn=e.fetchFn??globalThis.fetch,this.strict=e.strict??!1,this.onDroppedHeader=e.onDroppedHeader,this.dispatcher=e.dispatcher,this.requestTimeoutMs=e.requestTimeoutMs,this._allowPrivateNetwork=e.allowPrivateNetwork??!1)}async assertReachableHost(e){if(this._allowPrivateNetwork||this.fetchFn!==globalThis.fetch)return;let t;try{t=new URL(e)}catch{return}if(!t.hostname||(0,Tc.isIP)(t.hostname))return;let n;try{n=await new Promise((o,i)=>{(0,yo.lookup)(t.hostname,{all:!0},(a,c)=>a?i(a):o(c))})}catch{return}if(!(wo(n).length>0))throw Ec(e,n)}async send(e){await this.assertReachableHost(e.url);let t={};for(let[g,w]of Object.entries(e.headers??{}))if(!(typeof g!="string"||typeof w!="string")){if(!Qr(g)||!Gr(w)){if(this.strict)throw new x(`Invalid header dropped in strict mode: "${g}"`,"EVALIDATION",{request:e});this.onDroppedHeader?this.onDroppedHeader(g,w):Sc()||console.warn(`[kinetex] Invalid header dropped: "${g}" \u2014 value may contain illegal characters. Pass strictHeaders: true to throw instead.`);continue}if(g==="__proto__"){Object.defineProperty(t,g,{value:w,writable:!0,enumerable:!0,configurable:!0});continue}t[g]=w}let n=t["accept-encoding"];n&&n.toLowerCase().replace(/\s+/g," ")===En&&delete t["accept-encoding"];let s={method:e.method,headers:t,redirect:e.redirect??"follow",...e.signal!==null?{signal:e.signal}:{}};e.body!==null&&e.method!=="GET"&&e.method!=="HEAD"&&(s.body=e.body,ze&&typeof s.body=="object"&&s.body!==null&&"getReader"in s.body&&(s.duplex="half")),this.dispatcher!==void 0&&(s.dispatcher=this.dispatcher);let o=this.requestTimeoutMs,i=o===void 0?void 0:new AbortController,a=!1,c=()=>i?.abort();i&&e.signal&&(e.signal.aborted?i.abort():e.signal.addEventListener("abort",c,{once:!0}));let u=i&&o!==void 0?setTimeout(()=>{a=!0,i.abort()},o):void 0,l=i&&!s.signal?{...s,signal:i.signal}:s,h;try{h=await this.fetchFn(e.url,l)}catch(g){throw u!==void 0&&clearTimeout(u),i&&e.signal&&e.signal.removeEventListener("abort",c),a?new x(`HTTP/1.1 request to ${e.url} timed out after ${o}ms`,"ETIMEOUT",{request:e,cause:g}):Ur(g)?new x("Request was aborted","EABORT",{request:e,cause:g}):new x(g instanceof Error?g.message:"Network request failed","ENETWORK",{request:e,cause:g})}u!==void 0&&clearTimeout(u),i&&e.signal&&e.signal.removeEventListener("abort",c);let d=kc(h.headers),p=_h(h,d),m=!0;return Ce==="deno"&&(h.headers.get("content-encoding")||"").toLowerCase().includes("deflate")&&(m=!1),{status:h.status,statusText:h.statusText,headers:d,body:h.body,url:h.url||e.url,redirected:h.redirected,httpVersion:p,alreadyDecompressed:m}}},It=class{constructor(e={}){f(this,"sessions",new Map);f(this,"sessionTTLMs");f(this,"pingIntervalMs");f(this,"maxSessions");f(this,"pingTimers",new Map);f(this,"_sessionCreating",new Map);f(this,"sessionUsage",new Map);f(this,"_strict");f(this,"_onDroppedHeader");f(this,"_ca");f(this,"_connectTimeoutMs");f(this,"_requestTimeoutMs");f(this,"_http1Fallback",null);f(this,"_allowPrivateNetwork");f(this,"_http1KeepAlive");f(this,"_http1MaxSockets");f(this,"_http1Agent",null);f(this,"_proxy");this.sessionTTLMs=e.sessionTTLMs??5*6e4,this.pingIntervalMs=e.pingIntervalMs??3e4,this.maxSessions=e.maxSessions??100,this._allowPrivateNetwork=e.allowPrivateNetwork??!1,this._http1KeepAlive=e.http1KeepAlive??!0,this._http1MaxSockets=e.http1MaxSockets??16,this._proxy=e.proxy,this._strict=e.strict??!1,this._onDroppedHeader=e.onDroppedHeader,this._ca=e.ca,this._connectTimeoutMs=e.connectTimeoutMs??3e4,this._requestTimeoutMs=e.requestTimeoutMs??3e4}_getOrCreateSession(e,t,n){let s=this._sessionCreating.get(e);if(s)return s;let o=this._createSession(e,t,n);return this._sessionCreating.set(e,o),o.finally(()=>{this._sessionCreating.get(e)===o&&this._sessionCreating.delete(e)}).catch(()=>{}),o}async _createSession(e,t,n){let s=this.sessions.get(e);if(s&&!s.session.destroyed&&!s.session.closed&&!(Date.now()-s.createdAt>this.sessionTTLMs))return this.sessionUsage.set(e,Date.now()),s.session;if(s&&this._evictSession(e,s.session),this.sessions.size>=this.maxSessions){let a="",c=1/0;for(let[u,l]of this.sessionUsage.entries())l<c&&(c=l,a=u);if(a){let u=this.sessions.get(a);u&&this._evictSession(a,u.session)}}let o=null;this._proxy!==void 0&&(o=await this._createProxiedSocket(e,void 0,t));let i=await new Promise((a,c)=>{let u=n.connect(e,{rejectUnauthorized:!0,...this._allowPrivateNetwork?{}:{lookup:xc},...this._ca!==void 0?{ca:this._ca}:{},...o!==null?{createConnection:(()=>o)}:{}}),l=setTimeout(()=>{u.destroy(),c(new x(`HTTP/2 connection to ${e} timed out`,"ETIMEOUT",{request:t}))},this._connectTimeoutMs);typeof l.unref=="function"&&l.unref();let h=()=>{clearTimeout(l),u.destroy(),c(new x("Connection aborted","EABORT",{request:t}))},d=()=>t.signal?.removeEventListener("abort",h);t.signal?.addEventListener("abort",h,{once:!0}),u.once("connect",()=>{d(),clearTimeout(l),a(u)}),u.once("error",p=>{d(),clearTimeout(l),c(p)})});if(i.on("goaway",()=>{this._evictSession(e,i)}),i.on("error",()=>{this._evictSession(e,i)}),this.sessions.set(e,{session:i,createdAt:Date.now()}),this.sessionUsage.set(e,Date.now()),this.pingIntervalMs>0){let a=this.pingTimers.get(e);a&&clearInterval(a);let c=setInterval(()=>{let u=this.sessions.get(e);if(!u||u.session.destroyed||u.session.closed){this._evictSession(e,u?.session);return}u.session.ping(l=>{l&&this._evictSession(e,u.session)})},this.pingIntervalMs);typeof c=="object"&&c!==null&&"unref"in c&&c.unref(),this.pingTimers.set(e,c)}return i}async send(e){let t=new URL(e.url);if(t.protocol!=="https:"||e.httpVersion==="HTTP/1.1")return this._sendHTTP1(e);try{return await this._sendHTTP2(e,t)}catch(n){if(Sh(n))return this._sendHTTP1(e);throw n}}_rejectHeader(e,t,n,s){if(this._strict)throw new x(`Strict mode: header "${e}" ${n}`,"EVALIDATION",{request:s});this._onDroppedHeader?this._onDroppedHeader(e,t):typeof console<"u"&&console.warn(`[kinetex] Invalid header dropped (HTTP/2): "${e}" \u2014 ${n}. Pass strictHeaders: true to throw instead.`)}async _sendHTTP2(e,t){let n=await import("node:http2"),s=e,o=t,i=!1,a=10;for(let c=0;c<=a;c++){if(c===a)throw new x("Too many HTTP/2 redirects","ENETWORK",{request:e});let u=o.origin,l=this.sessions.get(u),h=l&&Date.now()-l.createdAt>this.sessionTTLMs,d;!l||l.session.destroyed||l.session.closed||h?d=await this._getOrCreateSession(u,s,n):(d=l.session,this.sessionUsage.set(u,Date.now()));let p=s.body,m;s.body instanceof FormData&&(m=await _n(s.body),p=m.bytes,m.contentType!==void 0&&!s.headers["content-type"]&&(s={...s,headers:{...s.headers,"content-type":m.contentType}}));let g={":method":s.method,":path":o.pathname+o.search,":scheme":"https",":authority":o.host};for(let[v,M]of Object.entries(s.headers)){if(v.startsWith(":")){this._rejectHeader(v,Array.isArray(M)?M.join(", "):String(M),"is not a valid header name",s);continue}if(v==="__proto__"){Object.defineProperty(g,v,{value:M,writable:!0,enumerable:!0,configurable:!0});continue}g[v]=M}for(let[v,M]of Object.entries(g)){if(v.startsWith(":"))continue;let q=Array.isArray(M)?M.join(", "):String(M),_e=Qr(v),re=Gr(q);(!_e||!re)&&(this._rejectHeader(v,q,_e?"contains forbidden control characters":"is not a valid header name",s),delete g[v])}let w=!p||s.method==="GET"||s.method==="HEAD",y=d.request(g,{endStream:w});p&&!w&&Eh(y,p).catch(v=>{y.destroy(v instanceof Error?v:new Error(String(v)))});let S=s.signal,b=await new Promise((v,M)=>{let q=this._requestTimeoutMs,_e=setTimeout(()=>{Or(),M(new x(`HTTP/2 request to ${o} timed out after ${q}ms`,"ETIMEOUT",{request:s})),y.destroy()},q),re=()=>{clearTimeout(_e),M(new x("Request was aborted","EABORT",{request:s})),y.destroy()},Or=()=>S?.removeEventListener("abort",re);S?.addEventListener("abort",re,{once:!0}),y.once("response",k=>{let O=Number(k[":status"]??200),L=vc[O]??"",$={};for(let[K,B]of Object.entries(k))K.startsWith(":")||($[K]=Array.isArray(B)?B.join(", "):B??"");if(clearTimeout(_e),Or(),S?.aborted){M(new x("Request was aborted","EABORT",{request:s})),y.destroy();return}if(s.redirect==="error"&&O>=300&&O<400&&$.location){M(new x(`Redirect not allowed (redirect:"error") \u2014 received ${O} to ${$.location}`,"ENETWORK",{request:s})),y.destroy();return}v({status:O,statusText:L,headers:$,body:Ac(y),url:s.url,redirected:i,httpVersion:"HTTP/2",alreadyDecompressed:!1})}),y.once("error",k=>{clearTimeout(_e),Or(),S?.aborted?M(new x("Request was aborted","EABORT",{request:s,cause:k})):M(new x(k.message,"ENETWORK",{request:s,cause:k})),y.destroy()})});if(!(b.status>=300&&b.status<400&&!!b.headers.location&&s.redirect!=="manual"))return b;try{if(b.body){let v=b.body.getReader();for(;;){let{done:M}=await v.read();if(M)break}v.releaseLock()}}catch{}let A=b.headers.location,C,T;try{let v=new URL(A,s.url);C=v.href,T=v.protocol.toLowerCase()}catch{throw new x(`Invalid redirect Location: ${A}`,"ENETWORK",{request:e})}if(T!=="https:")throw new x(`HTTP/2 redirect to a non-HTTPS target blocked: ${T}//\u2026`,"EVALIDATION",{request:e});if(!ne(C))throw new x(`Unsafe redirect target blocked: ${C.replace(/:\/\/[^/@]*@/,"://\u2026@")}`,"EVALIDATION",{request:e});let P=b.status===301||b.status===302||b.status===303?"GET":s.method,j=P==="GET"||P==="HEAD"?null:s.body;s={...s,url:C,method:P,body:j},o=new URL(C),i=!0}throw new x("HTTP/2 redirect loop terminated unexpectedly","ENETWORK",{request:e})}_sendHTTP1(e){if(typeof globalThis.fetch=="function"){if(!this._http1Fallback){let t={fetchFn:globalThis.fetch,strict:this._strict,requestTimeoutMs:this._requestTimeoutMs};this._onDroppedHeader!==void 0&&(t.onDroppedHeader=this._onDroppedHeader),this._http1Fallback=new st(t)}return this._http1Fallback.send(e)}return this._sendHTTP1Legacy(e)}async _sendHTTP1Legacy(e){let t=await import("node:https"),n=new URL(e.url),s=e;if(e.body instanceof FormData){let i=await _n(e.body);s={...e,body:i.bytes},i.contentType!==void 0&&!s.headers["content-type"]&&(s={...s,headers:{...s.headers,"content-type":i.contentType}})}let o={hostname:n.hostname,port:n.port||"443",path:n.pathname+n.search,method:s.method,headers:s.headers,...this._http1KeepAlive?{agent:this._getHttp1Agent(t)}:{},...this._ca!==void 0?{ca:this._ca}:{},...this._allowPrivateNetwork?{}:{lookup:xc}};return new Promise((i,a)=>{let c=t.request(o,h=>{let d={};for(let[m,g]of Object.entries(h.headers))g!==void 0&&(d[m]=Array.isArray(g)?g.join(", "):g);let p=Th(h);i({status:h.statusCode??200,statusText:h.statusMessage??"",headers:d,body:p,url:e.url,redirected:!1,httpVersion:"HTTP/1.1",alreadyDecompressed:!1})});c.once("error",h=>{a(h instanceof x?h:new x(h.message,"ENETWORK",{request:e,cause:h}))});let u=()=>{c.destroy(),a(new x("Request was aborted","EABORT",{request:e}))};e.signal?.addEventListener("abort",u,{once:!0});let l=()=>e.signal?.removeEventListener("abort",u);c.once("close",l),c.once("error",l),e.body&&e.method!=="GET"&&e.method!=="HEAD"?Rh(c,s.body).catch(a):c.end()})}_getHttp1Agent(e){return this._http1Agent||(this._http1Agent=new e.Agent({keepAlive:!0,maxSockets:this._http1MaxSockets,maxFreeSockets:this._http1MaxSockets,...this._ca!==void 0?{ca:this._ca}:{}}),this._proxy!==void 0&&(this._http1Agent.createConnection=((t,n)=>{this._createProxiedSocket(`https://${String(t.host??t.servername??"localhost")}:${String(t.port??443)}`,void 0,void 0).then(s=>n(null,s),s=>n(s))}))),this._http1Agent}async _createProxiedSocket(e,t,n){let{connectThroughProxy:s}=await Promise.resolve().then(()=>(wc(),yc)),o=new URL(e);return await s(this._proxy,o,{...this._ca!==void 0?{ca:this._ca}:{},connectTimeoutMs:this._connectTimeoutMs,...n?.signal!=null?{signal:n.signal}:{},...n!==void 0?{request:n}:{}})}_evictSession(e,t){let n=this.pingTimers.get(e);n&&(clearInterval(n),this.pingTimers.delete(e)),this.sessions.delete(e),this.sessionUsage.delete(e),this._sessionCreating.delete(e),t&&!t.destroyed&&!t.closed&&t.destroy()}destroy(){for(let e of this.pingTimers.values())clearInterval(e);this.pingTimers.clear(),this._sessionCreating.clear();for(let[e,{session:t}]of this.sessions.entries())this._evictSession(e,t);this.sessions.clear(),this._http1Agent?.destroy(),this._http1Agent=null}};xc=Rc();Th=Ac;vc={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Content Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"}});function Ch(r){return r.split(Ah).filter(Boolean)}function vh(r){let e=r.match(/^(\d{1,2}):(\d{2}):(\d{2})(?:[+-]\d{2}:?\d{2}|Z|GMT|UTC)?$/i);if(!e)return null;let t=+e[1],n=+e[2],s=+e[3];return t>23||n>59||s>59?null:[t,n,s]}function Ph(r){let e=r.slice(0,9).toLowerCase();return kh[e]??null}function Lh(r){if(!/^\d{2,4}$/.test(r))return null;let e=+r;return e>=70&&e<=99&&(e+=1900),e>=0&&e<=69&&(e+=2e3),e}function xr(r){if(!r)return null;let e=Ch(r),t={time:null,dayOfMonth:null,month:null,year:null};for(let a of e)if(a){if(t.time===null&&a.includes(":")){let c=vh(a);if(c!==null){t.time=c;continue}}if(t.month===null&&/[a-zA-Z]/.test(a)){let c=Ph(a);if(c!==null){t.month=c;continue}}if(/^\d{1,4}(?:st|nd|rd|th)?$/i.test(a)){let c=a.replace(/[a-z]+$/i,""),u=+c;if(t.dayOfMonth===null&&c.length<=2&&u>=1&&u<=31){t.dayOfMonth=u;continue}if(t.year===null&&c.length>=2){let l=Lh(c);if(l!==null){t.year=l;continue}}if(t.dayOfMonth===null&&u>=1&&u<=31){t.dayOfMonth=u;continue}}}if(t.time===null||t.dayOfMonth===null||t.month===null||t.year===null||t.year<1601||t.year>9999||t.dayOfMonth<1||t.dayOfMonth>31)return null;let[n,s,o]=t.time,i=Date.UTC(t.year,t.month,t.dayOfMonth,n,s,o);return isNaN(i)?null:i}function _r(r){let e=r.replace(/\.$/,"").toLowerCase(),t=e.split(".");if(t.length===0||t.length===1&&t[0]==="")return null;if(So.has(e))return e;let n=null,s=0;for(let o=0;o<t.length;o++){let i=t.slice(o).join(".");if(xo.has(i)){let a=t.length-o;a>s&&(s=a,n=i)}}for(let o=0;o<t.length-1;o++){let i=t.slice(o+1).join(".");if(_o.has(i)){let a=t.slice(o).join("."),c=t.length-o;c>s&&(s=c,n=a)}}return n||(t[t.length-1]??null)}function kn(r){let e=r.toLowerCase().replace(/\.$/,"");if(ve(e))return e;let t=_r(e);if(!t)return null;let n=t.split(".").length,s=e.split(".");return s.length<=n?null:s.slice(-(n+1)).join(".")}function Pe(r){let e=r.toLowerCase();if(So.has(e)||xo.has(e))return!0;let t=e.split(".");if(t.length>=2){let n=t.slice(1).join(".");if(_o.has(n))return!0}return!1}function Oh(r){try{let c=r.lastIndexOf("-"),u=[],l=c>=0?r.slice(0,c):"";for(let b=0;b<l.length;b++){let E=l.charCodeAt(b);if(E>=128||E<32||E===127)return r;u.push(E)}let h=c>=0?r.slice(c+1):r,d=128,p=0,m=72,g=b=>b>=65&&b<=90?b-65:b>=97&&b<=122?b-97:b>=48&&b<=57?b-48+26:-1,w=(b,E,A)=>{b=Math.floor(b/(A?700:2)),b+=Math.floor(b/E);let C=0;for(;b>910/2;)b=Math.floor(b/35),C+=36;return C+Math.floor(36*b/(b+38))},y=0;for(;y<h.length;){let b=p,E=1;for(let A=36;;A+=36){if(y>=h.length)return r;let C=g(h.charCodeAt(y++));if(C<0)return r;p+=C*E;let T=A<=m?1:A>=m+26?26:A-m;if(C<T)break;E*=36-T}m=w(p-b,u.length+1,b===0),d+=Math.floor(p/(u.length+1)),p%=u.length+1,u.splice(p,0,d),p++}return String.fromCodePoint(...u)||r}catch{return r}}function Dt(r){if(r.includes("."))return r.split(".").map(t=>Dt(t)).join(".");if(!r.toLowerCase().startsWith("xn--"))return r;let e=Intl;if(typeof Intl<"u"&&e.IDN&&typeof e.IDN.toUnicode=="function")try{return e.IDN.toUnicode(r,{standard:"tr46"})}catch{return r}if(bo){let t=r+".invalid",n=bo(t);if(n&&n.length>8&&n.endsWith(".invalid")){let s=n.slice(0,-8);if(s!==r)return s}}if(r.startsWith("xn--"))try{let t=Oh(r.slice(4));if(t&&t!==r.slice(4))return t}catch{}return r}function be(r){return r.replace(/^\./,"").replace(/\.$/,"").toLowerCase().split(".").map(Dt).join(".")}function Nh(r){let e=r,t=e.lastIndexOf(":");if(t>=0&&e.slice(t+1).includes(".")){let s=e.slice(t+1);if(!Ic.test(s))return!1;let o=s.split(".").map(Number);if(!o.every(i=>i>=0&&i<=255))return!1;e=e.slice(0,t+1)+((o[0]<<8|o[1]).toString(16)+":"+(o[2]<<8|o[3]).toString(16))}if(!Mh.test(e)||e.split("::").length>2)return!1;let n=s=>(s??"").split(":").filter(Boolean).length;if(e.includes("::")){let[s,o]=e.split("::");return n(s)+n(o)<=7}return n(e)===8}function ve(r){let e=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;return Ic.test(e)?e.split(".").map(Number).every(n=>n>=0&&n<=255):Nh(e)}function $t(r,e){let t=r.toLowerCase(),n=e.toLowerCase().replace(/^\./,"");return t===n?!0:!(ve(t)||!t.endsWith("."+n)||ve(n)||Pe(n))}function Ut(r){if(!r||r===""||r[0]!=="/")return"/";let e=r.lastIndexOf("/");return e===0?"/":r.slice(0,e)}function Rn(r){if(!r.startsWith("/"))return"/"+r;let e=[],t=r.split("/");for(let n of t)n===""||n==="."||(n===".."?e.length>0&&e.pop():e.push(n));return"/"+e.join("/")}function Ht(r,e){let t=Rn(r),n=Rn(e);return!!(t===n||t.startsWith(n)&&(n.endsWith("/")||t[n.length]==="/"))}function $h(r){return r===""?!0:Dh.test(r)}function Lc(r){for(let e=0;e<r.length;e++){let t=r.charCodeAt(e);if(t>=0&&t<=8||t>=10&&t<=31||t===127)return!1}return!0}function jt(r){if(!r||r.trim()==="")return null;let e=r.indexOf(";"),t=e===-1?r:r.slice(0,e),n=e===-1?"":r.slice(e+1),s=t.indexOf("="),o,i;if(s===-1?(o="",i=t):(o=t.slice(0,s).trim(),i=t.slice(s+1)),!$h(o)||!Lc(i)||(i=i.trim(),i.length>=2&&i[0]==='"'&&i[i.length-1]==='"'&&(i=i.slice(1,-1)),!Lc(i)))return null;let a=new Map,c=n.split(";");for(let T of c){let P=T.trim();if(!P)continue;let j=P.indexOf("=");if(j===-1)a.set(P.toLowerCase(),"");else{let v=P.slice(0,j).trim().toLowerCase(),M=P.slice(j+1).trim();a.has(v)||a.set(v,M)}}let u=a.has("domain")?a.get("domain"):null,l=a.has("path")?a.get("path"):null,h=a.has("expires")?a.get("expires"):null,d=a.has("max-age")?a.get("max-age"):null,p=a.has("secure"),m=a.has("httponly"),g="Unset";if(a.has("samesite")){let T=a.get("samesite").toLowerCase();T==="strict"?g="Strict":T==="lax"?g="Lax":T==="none"&&(g="None")}let w=a.has("sameparty"),y=null;if(a.has("priority")){let T=a.get("priority").toLowerCase();T==="low"?y="Low":T==="medium"?y="Medium":T==="high"&&(y="High")}let S=a.has("partitioned"),b=null;d!==null&&d.match(/^-?\d+$/)&&(b=parseInt(d,10));let E=null;b===null&&h!==null&&(E=xr(h));let A=null;u!==null&&u!==""&&(A=be(u));let C=null;return l!==null&&l.startsWith("/")&&(C=l),{name:o,value:i,domain:A,path:C,expires:E,maxAge:b,secure:p,httpOnly:m,sameSite:g,sameParty:w,priority:y,partitioned:S}}function Oc(r){let e=[];if(r.value.includes(";")||r.value.includes(",")||r.value.includes(" ")||r.value.includes('"')?e.push(`${r.name}="${r.value.replace(/"/g,'\\"')}"`):e.push(`${r.name}=${r.value}`),r.path&&e.push(`Path=${r.path}`),r.domain&&e.push(`Domain=${r.domain}`),r.expires!==null){let t=new Date(r.expires);e.push(`Expires=${t.toUTCString()}`)}return r.maxAge!==null&&e.push(`Max-Age=${r.maxAge}`),r.secure&&e.push("Secure"),r.httpOnly&&e.push("HttpOnly"),r.sameSite&&r.sameSite!=="Unset"&&e.push(`SameSite=${r.sameSite}`),r.sameParty&&e.push("SameParty"),r.priority&&e.push(`Priority=${r.priority}`),r.partitioned&&e.push("Partitioned"),e.join("; ")}function Uh(r,e){let t=e;for(;t<r.length&&(r[t]===" "||r[t]===" ");)t++;if(t>=r.length)return!0;for(;t<r.length;t++){let n=r[t];if(n===";"||n===",")return!1;if(n==="=")return!0}return!1}function ot(r){let e=[],t="",n=0,s=!1,o=!1,i=!1,a=!1,c=!1,u=()=>{i&&a&&t.trim()&&e.push(t.trim()),t="",i=!1,a=!1,c=!1};for(;n<r.length;){let l=r[n],h=r[n+1]??"";if(o){t+=l,o=!1,n++;continue}if(l==="\\"&&(s||h==='"'||h==="\\")){t+=l,o=!0,n++;continue}if(l==='"'){!s&&i?s=!0:s&&(s=!1,a=!0),t+=l,n++;continue}if(s){t+=l,n++;continue}if(l===","&&!s&&(c||a||i)){if(!Uh(r,n+1)){t+=l,n++;continue}for(u();n+1<r.length&&/\s/.test(r[n+1]);)n++;n++;continue}if(l===";"){i||(i=!0),a&&(c=!0),t+=l,n++;continue}if(l==="="&&!i){i=!0,a=!0,t+=l,n++;continue}if(i&&!a&&l!==";"&&l!==","&&(a=!0),l===" "||l===" "){t.length>0&&t.trim()!==""&&(t+=l),n++;continue}t+=l,n++}return i&&a&&t.trim()&&e.push(t.trim()),e}function Bt(r){if(typeof Headers<"u"&&r instanceof Headers){if(typeof r.getSetCookie=="function")return r.getSetCookie();let n=r.get("set-cookie");return n?ot(n):[]}let e=r,t=e["set-cookie"]??e["Set-Cookie"];return t?Array.isArray(t)?t.flatMap(n=>ot(n)):ot(t):[]}var kh,Ah,Ih,xo,_o,So,bo,Ic,Mh,Dh,An=J(()=>{"use strict";kh={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11},Ah=/[\t\x20-\x2f\x3b-\x40\x5b-\x60\x7b-\x7e]+/;Ih=["!www.ck","!city.kobe.jp","!city.nagoya.jp","!city.sapporo.jp","!city.sendai.jp","!city.yokohama.jp","*.ck","*.er","*.bd","*.fj","*.fk","*.gu","*.jm","*.kh","*.mm","*.np","*.pg","*.ss","*.tp","*.vi","*.ye","*.zm","*.kawasaki.jp","*.kitakyushu.jp","*.kobe.jp","*.nagoya.jp","*.osaka.jp","*.sapporo.jp","*.sendai.jp","*.yokohama.jp","com","net","org","edu","gov","mil","int","arpa","info","biz","name","mobi","tel","travel","museum","coop","aero","pro","jobs","cat","post","xxx","app","dev","io","ai","co","me","tv","fm","blog","shop","store","online","site","web","tech","cloud","digital","media","news","press","agency","solutions","services","systems","network","group","team","studio","design","art","photography","email","marketing","consulting","management","finance","money","bank","insurance","healthcare","medical","hospital","clinic","pharmacy","dental","legal","law","attorney","lawyer","accountant","pm","sh","ac","cc","cx","nu","ms","pw","sc","sx","tc","tk","ac","ad","ae","af","ag","ai","al","am","an","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","su","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","uk","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","za","zm","zw","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","info.au","conf.au","oz.au","act.au","nsw.au","nt.au","qld.au","sa.au","tas.au","vic.au","wa.au","com.br","net.br","org.br","edu.br","gov.br","mil.br","art.br","ind.br","adm.br","adv.br","agr.br","am.br","arq.br","ato.br","b.br","bio.br","blog.br","bmd.br","cim.br","cng.br","cnt.br","coop.br","ecn.br","eco.br","emp.br","eng.br","esp.br","etc.br","eti.br","far.br","flog.br","fm.br","fnd.br","fot.br","fst.br","g12.br","ggf.br","imb.br","inf.br","jor.br","jus.br","leg.br","lel.br","mat.br","med.br","mp.br","mus.br","not.br","ntr.br","odo.br","ppg.br","pro.br","psc.br","psi.br","qsl.br","radio.br","rec.br","slg.br","srv.br","taxi.br","teo.br","tmp.br","trd.br","tur.br","tv.br","vet.br","vlog.br","wiki.br","zlg.br","ab.ca","bc.ca","mb.ca","nb.ca","nf.ca","nl.ca","ns.ca","nt.ca","nu.ca","on.ca","pe.ca","qc.ca","sk.ca","yk.ca","com.cn","net.cn","org.cn","edu.cn","gov.cn","mil.cn","ac.cn","ah.cn","bj.cn","cq.cn","fj.cn","gd.cn","gs.cn","gz.cn","gx.cn","ha.cn","hb.cn","he.cn","hi.cn","hl.cn","hn.cn","jl.cn","js.cn","jx.cn","ln.cn","nm.cn","nx.cn","qh.cn","sc.cn","sd.cn","sh.cn","sn.cn","sx.cn","tj.cn","xj.cn","xz.cn","yn.cn","zj.cn","co.uk","me.uk","org.uk","ltd.uk","plc.uk","net.uk","sch.uk","gov.uk","nhs.uk","police.uk","mod.uk","ac.uk","judiciary.uk","parliament.uk","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","aichi.jp","akita.jp","aomori.jp","chiba.jp","ehime.jp","fukui.jp","fukuoka.jp","fukushima.jp","gifu.jp","gunma.jp","hiroshima.jp","hokkaido.jp","hyogo.jp","ibaraki.jp","ishikawa.jp","iwate.jp","kagawa.jp","kagoshima.jp","kanagawa.jp","kochi.jp","kumamoto.jp","kyoto.jp","mie.jp","miyagi.jp","miyazaki.jp","nagano.jp","nagasaki.jp","nara.jp","niigata.jp","oita.jp","okayama.jp","okinawa.jp","osaka.jp","saga.jp","saitama.jp","shiga.jp","shimane.jp","shizuoka.jp","tochigi.jp","tokushima.jp","tokyo.jp","tottori.jp","toyama.jp","wakayama.jp","yamagata.jp","yamaguchi.jp","yamanashi.jp","co.nz","net.nz","org.nz","edu.nz","govt.nz","school.nz","geek.nz","maori.nz","iwi.nz","mil.nz","parliament.nz","ac.nz","co.za","net.za","org.za","edu.za","gov.za","mil.za","ac.za","alt.za","agric.za","cybernet.za","db.za","grondar.za","nis.za","nom.za","ngo.za","pty.za","school.za","tm.za","web.za","co.in","net.in","org.in","edu.in","gov.in","mil.in","ac.in","res.in","firm.in","gen.in","ind.in","int.in","nic.in","com.ar","net.ar","org.ar","edu.ar","gov.ar","mil.ar","int.ar","tur.ar","com.mx","net.mx","org.mx","edu.mx","gob.mx","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","mil.tw","idv.tw","game.tw","ebiz.tw","club.tw","com.my","net.my","org.my","edu.my","gov.my","mil.my","name.my","sch.my","com.ph","net.ph","org.ph","edu.ph","gov.ph","mil.ph","ngo.ph","i.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","mil.pk","ac.pk","res.pk","biz.pk","fam.pk","gob.pk","gok.pk","gon.pk","gop.pk","gos.pk","info.pk","com.eg","net.eg","org.eg","edu.eg","gov.eg","mil.eg","sci.eg","eun.eg","info.eg","name.eg","com.sa","net.sa","org.sa","edu.sa","gov.sa","med.sa","pub.sa","sch.sa","com.ae","net.ae","org.ae","edu.ae","gov.ae","mil.ae","sch.ae","ac.ae","pro.ae","name.ae","com.tr","net.tr","org.tr","edu.tr","gov.tr","mil.tr","bel.tr","k12.tr","av.tr","bbs.tr","dr.tr","gen.tr","info.tr","name.tr","pol.tr","tel.tr","web.tr","com.ua","net.ua","org.ua","edu.ua","gov.ua","mil.ua","in.ua","co.ua","cherkassy.ua","chernigov.ua","chernovtsy.ua","dn.ua","dnepropetrovsk.ua","donetsk.ua","dp.ua","if.ua","kh.ua","kharkov.ua","kherson.ua","khmelnitskiy.ua","kiev.ua","kirovograd.ua","km.ua","kr.ua","lg.ua","lugansk.ua","lutsk.ua","lviv.ua","mk.ua","mykolaiv.ua","nikolaev.ua","od.ua","odessa.ua","pl.ua","poltava.ua","rivne.ua","rovno.ua","rv.ua","sebastopol.ua","sumy.ua","te.ua","ternopil.ua","uzhgorod.ua","vinnica.ua","vn.ua","volyn.ua","yalta.ua","zp.ua","zaporizhzhe.ua","zt.ua","zhitomir.ua","com.ru","net.ru","org.ru","edu.ru","gov.ru","mil.ru","pp.ru","int.ru","ac.ru","msk.ru","spb.ru","com.pl","net.pl","org.pl","edu.pl","gov.pl","mil.pl","co.pl","info.pl","biz.pl","nom.pl","waw.pl","poznan.pl","lodz.pl","krakow.pl","wroclaw.pl","com.de","co.de","com.fr","co.fr","asso.fr","nom.fr","prd.fr","presse.fr","tm.fr","aeroport.fr","assedic.fr","avocat.fr","avoues.fr","cci.fr","chambagri.fr","chirurgiens-dentistes.fr","experts-comptables.fr","geometre-expert.fr","gouv.fr","greta.fr","huissier-justice.fr","medecin.fr","notaires.fr","pharmacien.fr","port.fr","veterinaire.fr","com.it","co.it","com.es","co.es","nom.es","org.es","edu.es","gob.es","com.nl","co.nl","com.be","co.be","ac.be","org.be","net.be","com.ch","co.ch","com.at","co.at","ac.at","gv.at","or.at","priv.at","com.se","co.se","ac.se","bd.se","brand.se","fh.se","fhsk.se","fhv.se","tm.se","pp.se","press.se","parti.se","komforb.se","kommunalforbund.se","komvux.se","lanarb.se","lanbib.se","naturbruksgymn.se","sshn.se","com.no","co.no","stat.no","fylkesbibl.no","folkebibl.no","museum.no","idrett.no","priv.no","mil.no","vgs.no","videregaaende.no","kommune.no","herad.no","aa.no","ah.no","bu.no","fm.no","hl.no","hm.no","jan-mayen.no","mr.no","nl.no","nt.no","of.no","ol.no","oslo.no","rl.no","sf.no","st.no","svalbard.no","tm.no","tr.no","va.no","vf.no","com.dk","co.dk","ac.dk","com.fi","co.fi","ac.fi","iki.fi","aland.fi","www.fi","com.pt","co.pt","edu.pt","gov.pt","int.pt","net.pt","nome.pt","org.pt","publ.pt","dyndns.pt","com.gr","co.gr","edu.gr","gov.gr","net.gr","org.gr","store.gr","com.ie","co.ie","gov.ie","net.ie","org.ie","teagasc.ie","com.cz","co.cz","edu.cz","net.cz","org.cz","info.cz","com.sk","co.sk","edu.sk","net.sk","org.sk","com.hu","co.hu","edu.hu","film.hu","gov.hu","info.hu","net.hu","org.hu","priv.hu","sport.hu","tm.hu","2000.hu","agrar.hu","bolt.hu","casino.hu","city.hu","erotica.hu","erotika.hu","forum.hu","games.hu","hotel.hu","ingatlan.hu","jogasz.hu","konyvelo.hu","lakas.hu","media.hu","news.hu","reklam.hu","sex.hu","shop.hu","suli.hu","szex.hu","tozsde.hu","utazas.hu","video.hu","com.ro","co.ro","edu.ro","gov.ro","info.ro","net.ro","nom.ro","org.ro","rec.ro","store.ro","tm.ro","www.ro","arts.ro","firm.ro","nt.ro","shop.ro","com.bg","co.bg","edu.bg","gov.bg","net.bg","org.bg","tel.bg","biz.bg","com.hr","co.hr","from.hr","iz.hr","name.hr","net.hr","com.rs","co.rs","edu.rs","gov.rs","in.rs","net.rs","org.rs","com.ba","co.ba","edu.ba","gov.ba","mil.ba","net.ba","org.ba","rs.ba","unbi.ba","unmo.ba","unsa.ba","untz.ba","unze.ba","com.co","net.co","org.co","edu.co","gov.co","mil.co","nom.co","com.ve","net.ve","org.ve","edu.ve","gov.ve","mil.ve","int.ve","co.ve","arts.ve","bib.ve","firm.ve","info.ve","nom.ve","rec.ve","store.ve","tec.ve","web.ve","com.pe","net.pe","org.pe","edu.pe","gov.pe","mil.pe","nom.pe","sld.pe","com.cl","co.cl","gob.cl","gov.cl","net.cl","org.cl","mil.cl","edu.cl","co.kr","ne.kr","or.kr","re.kr","pe.kr","go.kr","mil.kr","ac.kr","hs.kr","ms.kr","es.kr","sc.kr","kg.kr","seoul.kr","busan.kr","daegu.kr","incheon.kr","gwangju.kr","daejeon.kr","ulsan.kr","gyeonggi.kr","gangwon.kr","chungbuk.kr","chungnam.kr","jeonbuk.kr","jeonnam.kr","gyeongbuk.kr","gyeongnam.kr","jeju.kr","co.id","net.id","or.id","ac.id","web.id","sch.id","go.id","mil.id","my.id","co.th","net.th","org.th","ac.th","go.th","in.th","mi.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","int.vn","ac.vn","biz.vn","info.vn","name.vn","pro.vn","health.vn","com.ng","net.ng","org.ng","edu.ng","gov.ng","mil.ng","mobi.ng","name.ng","sch.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","me.ke","mobi.ke","co.il","net.il","org.il","edu.il","gov.il","muni.il","ac.il","idf.il","com.ir","net.ir","org.ir","edu.ir","gov.ir","ac.ir","id.ir"],xo=new Set,_o=new Set,So=new Set;for(let r of Ih)r.startsWith("!")?So.add(r.slice(1).toLowerCase()):r.startsWith("*.")?_o.add(r.slice(2).toLowerCase()):xo.add(r.toLowerCase());(async()=>{try{let r=await import("node:url");typeof r.domainToUnicode=="function"&&(bo=r.domainToUnicode)}catch{}})();Ic=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,Mh=/^[\da-f:]+$/i;Dh=/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/});function zh(r,e){let t=r.name;return!(t.startsWith("__Secure-")&&(!r.secure||e.protocol!=="https:")||t.startsWith("__Host-")&&(!r.secure||e.protocol!=="https:"||r.path!=="/"||!r.hostOnly))}function qh(r){if(typeof r!="string")return"Unset";switch(r.trim().toLowerCase()){case"strict":return"Strict";case"lax":return"Lax";case"none":return"None";default:return"Unset"}}function Fh(r,e){switch(r){case"Strict":return e==="strict";case"Lax":return e==="strict"||e==="lax";case"Unset":return e!=="cross-site";case"None":return!0}}function To(r){try{return new URL(r)}catch{return null}}function Cn(){return new qe}function vn(r){return qe.fromJSON(r)}var Hh,jh,Bh,Mc,qe,Nc=J(()=>{"use strict";An();Hh=4096,jh=50,Bh=3e3,Mc=400*24*60*60*1e3;qe=class r{constructor(e={}){f(this,"dm",new Map);f(this,"total",0);f(this,"cleanupTimer",null);f(this,"maxTotal");f(this,"maxPerDomain");f(this,"domainMatcherFn");this.maxTotal=e.maxTotal??Bh,this.maxPerDomain=e.maxPerDomain??jh,this.domainMatcherFn=e.domainMatcher??null,this.cleanupTimer=setInterval(()=>{this.clearExpired()},300*1e3),typeof this.cleanupTimer=="object"&&this.cleanupTimer!==null&&"unref"in this.cleanupTimer&&this.cleanupTimer.unref()}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null)}setCookie(e,t){let n=To(t.url);if(!n)return!1;let s=jt(e);if(!s)return!1;let o=Date.now(),i=n.hostname.toLowerCase(),a=i.replace(/^\[|\]$/g,""),c=n.protocol==="https:"||a==="localhost"||a==="127.0.0.1"||a==="::1";if(s.name.length+1+s.value.length>Hh)return!1;let l,h;if(s.domain!==null&&s.domain!==""){let y=s.domain.toLowerCase();if(!(this.domainMatcherFn??$t)(i,y)||Pe(y))return!1;l=y,h=!1}else l=i,h=!0;let d=s.path??Ut(n.pathname),p=s.secure;if(p&&!c)return!1;let m=s.sameSite;if(m==="None"&&!p)return!1;let g;if(s.maxAge!==null){if(s.maxAge<=0)return this.removeCookie(l,d,s.name),!0;let y=Math.min(s.maxAge*1e3,Mc);g=o+y}else if(s.expires!==null){if(g=s.expires,g<=o)return this.removeCookie(l,d,s.name),!0;g=Math.min(g,o+Mc)}else g=1/0;let w={name:s.name,value:s.value,domain:l,path:d,expires:g,maxAge:s.maxAge,secure:p,httpOnly:s.httpOnly,sameSite:m,createdAt:o,lastAccessed:o,hostOnly:h};return zh(w,n)?(this.putCookie(w),!0):!1}getCookies(e){let t=To(e.url);if(!t)return[];let n=t.hostname.toLowerCase(),s=n.replace(/^\[|\]$/g,""),o=t.pathname||"/",i=t.protocol==="https:"||s==="localhost"||s==="127.0.0.1"||s==="::1",a=e.http!==!1,c=e.sameSiteContext??"none",u=Date.now(),l=[];for(let[d,p]of this.dm)if(this.matchDomain(n,d))for(let[,m]of p)for(let[,g]of m)g.hostOnly&&n!==g.domain||g.expires!==1/0&&g.expires<u||Ht(o,g.path)&&(g.secure&&!i||g.httpOnly&&!a||Fh(g.sameSite,c)&&(g.name.startsWith("__Secure-")&&!(g.secure&&i)||g.name.startsWith("__Host-")&&!(g.secure&&i&&g.path==="/"&&g.hostOnly)||Pe(g.domain)||l.push(g)));l.sort((d,p)=>{let m=p.path.length-d.path.length;return m!==0?m:d.createdAt-p.createdAt});let h=Date.now();return l.map(d=>{let p={...d};return d.lastAccessed=h,p})}getCookieHeader(e){return this.getCookies(e).map(t=>t.name?`${t.name}=${t.value}`:t.value).join("; ")}getCookiesForDomain(e){let t=be(e),n=[],s=Date.now();for(let[o,i]of this.dm)if(o===t||o.endsWith("."+t)||t.endsWith("."+o))for(let[,a]of i)for(let[,c]of a)c.expires!==1/0&&c.expires<s||c.hostOnly&&c.domain!==t||Pe(c.domain)||n.push({...c});return n}processResponseHeaders(e,t){for(let n of Bt(e))this.setCookie(n,t)}removeCookie(e,t,n){let s=be(e),o=this.dm.get(s);if(!o)return!1;let i=o.get(t);if(!i)return!1;let a=i.delete(n);return a&&(this.total--,i.size===0&&o.delete(t),o.size===0&&this.dm.delete(s)),a}clear(){this.dm.clear(),this.total=0}clearExpired(){let e=Date.now(),t=0;for(let[n,s]of this.dm){for(let[o,i]of s){for(let[a,c]of i)c.expires!==1/0&&c.expires<e&&(i.delete(a),this.total--,t++);i.size===0&&s.delete(o)}s.size===0&&this.dm.delete(n)}return t}clearSession(){let e=0;for(let[t,n]of this.dm){for(let[s,o]of n){for(let[i,a]of o)a.expires===1/0&&(o.delete(i),this.total--,e++);o.size===0&&n.delete(s)}n.size===0&&this.dm.delete(t)}return e}clearForDomain(e){let t=be(e),n=0;for(let[s,o]of this.dm)if(s===t||s.endsWith("."+t)){let i=0;for(let a of o.values())i+=a.size;this.dm.delete(s),this.total-=i,n+=i}return n}clearForUrl(e){let t=To(e);return t?this.clearForDomain(t.hostname):0}toJSON(){let e=Date.now(),t=[];for(let[,n]of this.dm)for(let[,s]of n)for(let[,o]of s)o.expires!==1/0&&o.expires<e||t.push({name:o.name,value:o.value,domain:o.domain,path:o.path,expires:o.expires===1/0?null:o.expires,maxAge:o.maxAge,secure:o.secure,httpOnly:o.httpOnly,sameSite:o.sameSite,createdAt:o.createdAt,lastAccessed:o.lastAccessed,hostOnly:o.hostOnly});return t}toString(){return JSON.stringify(this.toJSON(),null,2)}static fromJSON(e){let t=new r,n=typeof e=="string"?JSON.parse(e):e,s=Date.now();for(let o of n){let i=o.expires===null?1/0:o.expires;if(i!==1/0&&i<s)continue;let a={name:o.name,value:o.value,domain:o.domain,path:o.path,expires:i,maxAge:o.maxAge,secure:o.secure,httpOnly:o.httpOnly,sameSite:qh(o.sameSite),createdAt:o.createdAt,lastAccessed:o.lastAccessed,hostOnly:o.hostOnly};t.putCookie(a)}return t}get count(){return this.total}getAll(){let e=[];for(let[,t]of this.dm)for(let[,n]of t)for(let[,s]of n)e.push({...s});return e}getForDomain(e){let t=be(e),n=[];for(let[s,o]of this.dm)if(s===t||s.endsWith("."+t))for(let[,i]of o)for(let[,a]of i)n.push({...a});return n}putCookie(e){let{domain:t,path:n,name:s}=e,o=this.dm.get(t)?.get(n)?.get(s);if(o){this.dm.get(t).get(n).set(s,{...e,createdAt:o.createdAt});return}this.evictForDomain(t),this.evictGlobal();let i=this.dm.get(t);i||(i=new Map,this.dm.set(t,i));let a=i.get(n);a||(a=new Map,i.set(n,a)),a.set(s,e),this.total++}evictForDomain(e){let t=this.dm.get(e);if(!t)return;let n=0;for(let i of t.values())n+=i.size;if(n<this.maxPerDomain)return;let s=[];for(let[i,a]of t)for(let[c,u]of a)s.push([i,c,u]);s.sort((i,a)=>i[2].lastAccessed-a[2].lastAccessed);let o=0;for(;n>=this.maxPerDomain&&o<s.length;){let[i,a]=s[o++];t.get(i)?.delete(a)&&(this.total--,n--)}for(let[i,a]of t)a.size===0&&t.delete(i)}evictGlobal(){if(this.total<this.maxTotal)return;let e=[];for(let[n,s]of this.dm)for(let[o,i]of s)for(let[a,c]of i)e.push([n,o,a,c]);e.sort((n,s)=>n[3].lastAccessed-s[3].lastAccessed);let t=0;for(;this.total>=this.maxTotal&&t<e.length;){let[n,s,o]=e[t++],i=this.dm.get(n),a=i?.get(s);a?.delete(o)&&(this.total--,a.size===0&&i.delete(s),i.size===0&&this.dm.delete(n))}}matchDomain(e,t){if(this.domainMatcherFn)return this.domainMatcherFn(e,t);let n=e.toLowerCase(),s=t.toLowerCase();return n===s?!0:ve(n)?!1:n.endsWith("."+s)}}});var Dc={};le(Dc,{CookieJar:()=>qe,canonicalizeDomainFull:()=>be,createCookieJar:()=>Cn,decodeIDNLabel:()=>Dt,defaultPath:()=>Ut,domainMatch:()=>$t,extractSetCookieHeaders:()=>Bt,formatSetCookieHeader:()=>Oc,getPublicSuffix:()=>_r,getRegistrableDomain:()=>kn,isIPAddress:()=>ve,isPublicSuffix:()=>Pe,loadCookieJar:()=>vn,normalizePath:()=>Rn,parseCookieDate:()=>xr,parseSetCookieHeader:()=>jt,pathMatch:()=>Ht,splitSetCookieHeaders:()=>ot});var Eo=J(()=>{"use strict";Nc();An()});var $c={};le($c,{BatchingTransport:()=>Ft,ConsoleTransport:()=>it,HTTPLogger:()=>We,JSONTransport:()=>qt,LogLevel:()=>zt,MultiTransport:()=>Kt,Redactor:()=>Vt,RemoteTransport:()=>Wt,createDevelopmentLogger:()=>vo,createLogger:()=>Ao,createProductionLogger:()=>Co,toOTelSpan:()=>ko});function Jh(r){let e=r.split(";",1)[0].trim().toLowerCase();return e==="application/json"||e==="text/json"||e.endsWith("+json")}function Yh(){let r=Date.now().toString(36),e=(++Xh).toString(36).padStart(4,"0"),t=Math.random().toString(36).slice(2,6);return`${r}-${e}-${t}`}function Ro(r,e){if(!r||typeof r!="object"||e.length===0)return;if(Array.isArray(r)){for(let o of r)Ro(o,e);return}let[t,...n]=e;if(t===void 0||t==="__proto__"||t==="constructor"||t==="prototype")return;let s=r;if(n.length===0){Object.prototype.hasOwnProperty.call(s,t)&&(s[t]="***");return}typeof s[t]=="object"&&Ro(s[t],n)}function Pn(r){return typeof r=="string"?new TextEncoder().encode(r).byteLength:r.byteLength}function ko(r){let e={"http.request.id":r.requestId,"http.request.method":r.method,"url.full":r.url};return r.type==="response"&&(e["http.response.status_code"]=r.status,e["http.response.body.size"]=r.bodySize,e["http.time_to_first_byte"]=r.durationMs),r.type==="error"&&(e.error=!0,e["error.type"]=r.error.name,e["error.message"]=r.error.message,e["http.status_code"]=r.status),e}function Zh(r){if(r instanceof Error){let e=r.code,t=r.stack;return{name:r.name,message:r.message,...e!==void 0?{code:e}:{},...t!==void 0?{stack:t}:{}}}if(r!==null&&typeof r=="object"){let e=r,t={name:typeof e.name=="string"&&e.name!==""?e.name:"Error",message:typeof e.message=="string"?e.message:tf(r)};return(typeof e.code=="string"||typeof e.code=="number")&&(t.code=String(e.code)),typeof e.stack=="string"&&(t.stack=e.stack),t}return{name:"Error",message:String(r)}}function rf(r,e){let t=new TextEncoder,n=t.encode(r).byteLength;if(n<=e)return{text:r,removed:0};let s=0,o=0;for(let i of r){let a=t.encode(i).byteLength;if(s+a>e)break;s+=a,o+=i.length}return{text:r.slice(0,o),removed:n-s}}function Ao(r){return new We(r)}function Co(r){let e=[new qt];return r.endpoint&&e.push(new Ft(new Wt(r.endpoint))),new We({level:r.level??"INFO",transports:[new Kt(e)],...r.context!==void 0?{context:r.context}:{}})}function vo(r={}){return new We({level:r.level??"DEBUG",transports:[new it({pretty:!0,useColors:!0,onWrite:e=>console.log(e)})],redaction:{logRequestBody:r.logBodies??!0,logResponseBody:r.logBodies??!0,maxBodyLength:2048}})}var Wh,zt,Kh,Vh,Qh,it,Gh,qt,Ft,Wt,Kt,Xh,Vt,Fe,We,ef,tf,Ln=J(()=>{"use strict";U();Wh=()=>{try{return globalThis.process?.env?.NODE_ENV}catch{return}},zt={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Kh=["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-access-token","x-refresh-token","x-csrf-token","x-session-id","x-session-token","x-secret","x-secret-key","x-private-key","api-key","apikey","bearer","token","authentication","credentials","password","passwd","secret"],Vh=["token","api_key","apikey","access_token","refresh_token","secret","password","pass","pwd","key","auth"];Qh=["application/json","application/x-www-form-urlencoded","text/"],it=class{constructor(e={}){f(this,"pretty");f(this,"onWrite");this.pretty=e.pretty??Wh()!=="production",this.onWrite=e.onWrite??(t=>console.log(t)),e.useColors}write(e){let t=this.pretty?this._prettyFormat(e):JSON.stringify(e);this.onWrite(t)}_prettyFormat(e){let t=new Date(e.timestampMs).toISOString().slice(11,23),n=e.level.padEnd(5),s=e.requestId.slice(-8);if(e.type==="request")return`[${t}] ${n} \u2190 ${e.method} ${e.url} [${s}]`;if(e.type==="response"){let o=`${e.durationMs.toFixed(0)}ms`,i=e.cached?" (cached)":"";return`[${t}] ${n} \u2192 ${e.status} ${e.method} ${e.url} ${o}${i} [${s}]`}return`[${t}] ${n} \u2717 ${e.method} ${e.url} ${e.error.message} [${s}]`}},Gh=()=>{try{return typeof globalThis.process?.stdout?.write=="function"}catch{return!1}},qt=class{constructor(e=t=>{Gh()?globalThis.process.stdout.write(t+`
19
+ `):console.log(t)}){f(this,"writeLine");this.writeLine=e}write(e){this.writeLine(JSON.stringify(e))}},Ft=class{constructor(e,t={}){f(this,"inner");f(this,"options");f(this,"buffer",[]);f(this,"timer",null);this.inner=e,this.options=t}write(e){if(this.buffer.push(e),this.buffer.length>=(this.options.maxBatch??100)){this._flush();return}this.timer||(this.timer=setTimeout(()=>this._flush(),this.options.flushMs??5e3))}async flush(){this.timer&&(clearTimeout(this.timer),this.timer=null),this._flush(),this.inner.flush&&await this.inner.flush()}_flush(){if(this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.buffer.length===0)return;let e=this.buffer.splice(0);for(let t of e)this.inner.write(t)}},Wt=class{constructor(e,t={}){f(this,"endpoint");f(this,"options");f(this,"buffer",[]);f(this,"timer",null);this.endpoint=e,this.options=t}write(e){if(this.buffer.push(e),this.buffer.length>=(this.options.batchSize??50)){this._flush();return}this.timer||(this.timer=setTimeout(()=>this._flush(),this.options.flushMs??3e3))}async flush(){this.timer&&(clearTimeout(this.timer),this.timer=null),await this._flushAsync()}_flush(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this._flushAsync().catch(this.options.onError??(e=>console.error("[logging] Flush error:",e)))}async _flushAsync(){if(this.buffer.length===0)return;let e=this.buffer.splice(0),t=this.options.fetch??globalThis.fetch;if(e.length<=10)await t(this.endpoint,{method:"POST",headers:{"content-type":"application/json",...this.options.headers},body:JSON.stringify(e)});else try{let{Readable:n}=await import("node:stream"),s=n.from([JSON.stringify(e)]);await t(this.endpoint,{method:"POST",headers:{"content-type":"application/json",...this.options.headers},body:s,duplex:"half"})}catch{await t(this.endpoint,{method:"POST",headers:{"content-type":"application/json",...this.options.headers},body:JSON.stringify(e)})}}},Kt=class{constructor(e){f(this,"transports");this.transports=e}write(e){for(let t of this.transports)try{t.write(e)}catch{}}async flush(){await Promise.allSettled(this.transports.map(e=>e.flush?.()))}},Xh=0;Vt=class{constructor(e={}){f(this,"headerSet");f(this,"paramSet");f(this,"bodyFields");f(this,"patterns");f(this,"maxBody");f(this,"logReqBody");f(this,"logResBody");f(this,"allowedTypes");let t=e.headers??Kh,n=e.queryParams??Vh;this.headerSet=new Set(t.map(s=>s.toLowerCase())),this.paramSet=new Set(n.map(s=>s.toLowerCase())),this.bodyFields=e.bodyFields??[],this.patterns=e.bodyPatterns??[],this.maxBody=e.maxBodyLength??4096,this.logReqBody=e.logRequestBody??!1,this.logResBody=e.logResponseBody??!1,this.allowedTypes=e.allowedBodyTypes??Qh}redactHeaders(e){return pt(e,this.headerSet,"***")}redactURL(e){try{let t=new URL(e);for(let n of[...t.searchParams.keys()])this.paramSet.has(n.toLowerCase())&&t.searchParams.set(n,"***");return t.toString()}catch{return this._redactRelativeQuery(e)}}_redactRelativeQuery(e){let t=e.indexOf("?");if(t===-1)return e;let n=e.slice(0,t),s=e.slice(t+1),o=s.indexOf("#"),i=o===-1?"":s.slice(o),c=(o===-1?s:s.slice(0,o)).split("&").map(u=>{if(u==="")return u;let l=u.indexOf("="),h=l===-1?u:u.slice(0,l),d=h;try{d=decodeURIComponent(h)}catch{}return this.paramSet.has(d.toLowerCase())?`${h}=***`:u});return`${n}?${c.join("&")}${i}`}redactBody(e,t,n){if(!(n?this.logResBody:this.logReqBody)||!e)return{body:null,size:e?Pn(e):null};let o=t??"";if(!this.allowedTypes.some(l=>o.startsWith(l)))return{body:`[${o||"binary"}]`,size:e?Pn(e):null};let a=Pn(e),c;if(e instanceof Uint8Array)try{c=new TextDecoder().decode(e)}catch{return{body:"[binary]",size:e.byteLength}}else c=e;if(Jh(o)&&this.bodyFields.length>0)try{let l=D(JSON.parse(c));for(let h of this.bodyFields)Ro(l,h.split("."));c=JSON.stringify(l)}catch{}for(let l of this.patterns)c=c.replace(l,"***");if(Pn(c)>this.maxBody){let l=rf(c,this.maxBody);c=`${l.text}... [truncated ${l.removed} bytes]`}return{body:c,size:a}}};Fe=class Fe{constructor(e={}){f(this,"cfg");f(this,"redactor");f(this,"level");f(this,"activeIds",new Map);this.cfg={level:e.level??"INFO",transports:e.transports??[new it],redaction:e.redaction??{},sampleRate:e.sampleRate??1,methods:e.methods??[],statuses:e.statuses??[],excludeURLs:e.excludeURLs??[],context:e.context??{},generateId:e.generateId??Yh},this.redactor=new Vt(this.cfg.redaction),this.level=zt[this.cfg.level]}_cleanupActiveIds(){let e=N();if(this.activeIds.size>Fe.MAX_ACTIVE_IDS){let t=Array.from(this.activeIds.entries()),n=t.slice(0,t.length-Math.floor(Fe.MAX_ACTIVE_IDS*.8));for(let[s]of n)this.activeIds.delete(s)}for(let[t,n]of this.activeIds)e-n.startMs>Fe.IDLE_TIMEOUT_MS&&this.activeIds.delete(t)}logRequest(e,t,n,s,o,i,a={}){if(!this._shouldLog("INFO",t,n))return;this.activeIds.size>500&&this._cleanupActiveIds(),this.activeIds.set(e,{startMs:N(),method:t,url:n});let c=s["content-type"]??s["Content-Type"]??null,u=this.redactor.redactBody(o,c,!1),l={type:"request",requestId:e,timestamp:new Date().toISOString(),timestampMs:Date.now(),level:"INFO",method:t.toUpperCase(),url:this.redactor.redactURL(n),headers:this.redactor.redactHeaders(s),bodySize:u.size,body:u.body,attempt:i,meta:{...this.cfg.context,...a}};this._write(l)}logResponse(e,t,n,s,o,i,a,c={}){let u=this.activeIds.get(e),l=u?N()-u.startMs:0,h=u?.method??"GET",d=u?.url??"";if(this.activeIds.delete(e),!this._shouldLog("INFO",h,d,t))return;let p=s["content-type"]??s["Content-Type"]??null,m=this.redactor.redactBody(o,p,!0),g=t>=500?"ERROR":t>=400?"WARN":"INFO",w={type:"response",requestId:e,timestamp:new Date().toISOString(),timestampMs:Date.now(),level:g,method:h.toUpperCase(),url:this.redactor.redactURL(d),status:t,statusText:n,headers:this.redactor.redactHeaders(s),bodySize:m.size,body:m.body,durationMs:Math.round(l),attempt:i,cached:a,meta:{...this.cfg.context,...c}};this._write(w)}logError(e,t,n,s,o={}){let i=this.activeIds.get(e),a=i?N()-i.startMs:0,c=i?.method??"GET",u=i?.url??"";if(this.activeIds.delete(e),!this._shouldLog("ERROR",c,u))return;let l={type:"error",requestId:e,timestamp:new Date().toISOString(),timestampMs:Date.now(),level:"ERROR",method:c.toUpperCase(),url:this.redactor.redactURL(u),error:Zh(t),status:n,durationMs:Math.round(a),attempt:s,meta:{...this.cfg.context,...o}};this._write(l)}generateRequestId(){return this.cfg.generateId()}child(e){return new Fe({...this.cfg,context:{...this.cfg.context,...e}})}async flush(){await Promise.allSettled(this.cfg.transports.map(e=>e.flush?.()))}_write(e){if(!(zt[e.level]<this.level))for(let n of this.cfg.transports)try{let s=n.write(e);s&&typeof s.then=="function"&&s.catch(()=>{})}catch{}}_shouldLog(e,t,n,s){if(zt[e]<this.level||this.cfg.sampleRate<1&&Math.random()>this.cfg.sampleRate||this.cfg.methods.length>0&&!this.cfg.methods.includes(t.toUpperCase())||s!==void 0&&this.cfg.statuses.length>0&&!this.cfg.statuses.includes(s))return!1;for(let o of this.cfg.excludeURLs)if(o.test(n))return!1;return!0}};f(Fe,"MAX_ACTIVE_IDS",1e4),f(Fe,"IDLE_TIMEOUT_MS",6e4);We=Fe;ef="[circular]",tf=r=>Gn(r,ef)});var No={};le(No,{SSEClient:()=>at,SSEError:()=>xe,SSEMaxReconnectsError:()=>ct,SSEParser:()=>Ke,SSERouter:()=>Tr,SSEServerResponse:()=>Jt,SSETransformStream:()=>Sr,createJSONSSEStream:()=>Io,createSSEResponse:()=>Oo,createSSEStream:()=>Lo,jsonSSE:()=>In,parseSSEText:()=>Mo});async function*In(r,e={}){for await(let t of r)if(!(!t.data&&t.data!==""))try{let n=D(JSON.parse(t.data,e.reviver));yield{event:t.event,data:n,id:t.id}}catch(n){e.onError?.(n,t)}}function Po(r){return r.replace(/[\r\n\u0000]/g,"")}function Lo(r){return new at(r)}function Io(r,e={}){return In(new at(r),e)}function Oo(r,e={}){let t=new Jt;return(async()=>{try{await r(t)}catch(n){console.error("[sse] Generator error:",n)}t.close()})(),t.toResponse(e)}function Mo(r){let e=new Ke,t=e.feed(r),n=e.flush();return n&&t.push(n),t}function nf(r,...e){let t=e.filter(n=>!!n);return t.some(n=>n.aborted)?(r.then(void 0,()=>{}),Promise.resolve(null)):new Promise((n,s)=>{let o=()=>{i(),r.then(void 0,()=>{}),n(null)},i=()=>{for(let a of t)a.removeEventListener("abort",o)};for(let a of t)a.addEventListener("abort",o,{once:!0});r.then(a=>{i(),n(a)},a=>{i(),s(a)})})}function Uc(r,...e){let t=e.filter(n=>!!n);return t.some(n=>n.aborted)?Promise.resolve():new Promise(n=>{let s=[],i=setTimeout(()=>{clearTimeout(i);for(let a of s)a();n()},r);for(let a of t){let c=()=>{clearTimeout(i),a.removeEventListener("abort",c),n()};s.push(()=>a.removeEventListener("abort",c)),a.addEventListener("abort",c,{once:!0})}})}var Ke,Sr,at,Tr,Jt,xe,ct,Er=J(()=>{"use strict";U();Ke=class{constructor(){f(this,"lines",[]);f(this,"id",null);f(this,"event","message");f(this,"data",[]);f(this,"retry",null);f(this,"buffer","")}feed(e){let t=[];this.buffer+=e;let n=this.buffer.split(/\r\n|\r|\n/);this.buffer=n.pop()??"";for(let s of n){let o=this._processLine(s);o&&t.push(o)}return t}flush(){return this.buffer&&(this._processLine(this.buffer),this.buffer=""),this.data.length>0?this._dispatch():null}_processLine(e){if(this.lines.push(e),e==="")return this.data.length===0?(this.lines=[],null):this._dispatch();if(e.startsWith(":"))return null;let t=e.indexOf(":"),n,s;switch(t===-1?(n=e,s=""):(n=e.slice(0,t),s=e.slice(t+1).replace(/^ /,"")),n){case"id":if(s.includes("\0"))break;this.id=s||null;break;case"event":this.event=s;break;case"data":this.data.push(s);break;case"retry":{/^[0-9]+$/.test(s)&&(this.retry=Number(s));break}}return null}_dispatch(){let e={id:this.id,event:this.event,data:this.data.join(`
20
+ `),retry:this.retry,raw:[...this.lines]};return this.lines=[],this.event="message",this.data=[],this.retry=null,e}reset(){this.lines=[],this.id=null,this.event="message",this.data=[],this.retry=null,this.buffer=""}get lastId(){return this.id}},Sr=class extends TransformStream{constructor(t={}){super({transform:(n,s)=>{try{let o=typeof n=="string"?n:this.decoder.decode(n,{stream:!0}),i=this.parser.feed(o);for(let a of i)s.enqueue(a)}catch(o){t.onParseError?.(o,String(n))}},flush:n=>{let s=this.parser.flush();s&&n.enqueue(s)}});f(this,"parser",new Ke);f(this,"decoder",new TextDecoder("utf-8"))}},at=class{constructor(e){f(this,"config");f(this,"health");f(this,"_closed",!1);f(this,"_streamController",null);this.config={fetch:globalThis.fetch,headers:{},signal:e.signal??void 0,lastEventId:"",reconnect:!0,reconnectDelayMs:3e3,maxReconnectDelayMs:3e4,reconnectJitter:.3,maxReconnects:0,onReconnect:()=>{},onParseError:t=>{},heartbeatTimeoutMs:0,method:"GET",body:null,validateResponse:()=>!0,...e},this.health={connected:!1,totalEvents:0,totalReconnects:0,lastEventAt:null,lastEventId:this.config.lastEventId||null,reconnectAttempt:0}}get url(){return this.config.url}get closed(){return this._closed}async*[Symbol.asyncIterator](){yield*this._stream()}async*stream(){yield*this._stream()}async*on(e){for await(let t of this._stream())t.event===e&&(yield t)}async collect(e={}){let t=[],n=0,s=e.signal;if(s?.aborted)return[];let o=()=>{this._streamController?.abort()};s?.addEventListener("abort",o);try{for await(let i of this._stream())if(t.push(i),n++,e.limit&&n>=e.limit||e.signal?.aborted)break}finally{s?.removeEventListener("abort",o)}return t}close(){this._closed=!0,this._streamController&&(this._streamController.abort(),this._streamController=null),this.health.connected=!1}destroy(){this.close(),this.health={connected:!1,totalEvents:this.health.totalEvents,totalReconnects:this.health.totalReconnects,lastEventAt:this.health.lastEventAt,lastEventId:this.health.lastEventId,reconnectAttempt:0}}get streamHealth(){return{...this.health}}async*_stream(){let e=this.config,t=e.reconnectDelayMs,n=0;this._streamController=new AbortController;let s=this._streamController.signal;for(;!this._closed&&!s.aborted;){let o=this._closed;if(o||e.signal?.aborted||this._streamController?.signal.aborted)break;let i=new Ke,a=null;try{let u={accept:"text/event-stream","cache-control":"no-cache",...e.headers};this.health.lastEventId&&(u["last-event-id"]=this.health.lastEventId);let l={method:e.method,headers:u,body:e.body??null,signal:e.signal??null};e.body!==null&&e.body!==void 0&&(l.duplex="half");let h=await e.fetch(e.url,l),d=e.validateResponse(h);if(d!==!0){let S=typeof d=="string"?d:`SSE server returned ${h.status}`;throw new xe(S,h.status,h)}if(!h.ok)throw new xe(`SSE server error: ${h.status}`,h.status,h);if(!h.body)throw new xe("SSE response has no body",h.status,h);let p=h.headers.get("content-type")??"";if(!p.startsWith("text/event-stream"))throw new xe(`Expected text/event-stream, got: ${p}`,h.status,h);this.health.connected=!0,n=0,t=e.reconnectDelayMs;let m=h.body.getReader(),g=new TextDecoder("utf-8"),w=()=>{a&&clearTimeout(a),e.heartbeatTimeoutMs>0&&(a=setTimeout(()=>{m.cancel("heartbeat timeout")},e.heartbeatTimeoutMs))};w();try{for(;!o&&!e.signal?.aborted;){let S=await nf(m.read(),e.signal,s);if(S===null)break;let{done:b,value:E}=S;if(b)break;let A=g.decode(E,{stream:!0}),C=i.feed(A);for(let T of C)w(),T.retry!==null&&(t=Math.min(T.retry,e.maxReconnectDelayMs)),T.id!==null&&(this.health.lastEventId=T.id),this.health.totalEvents++,this.health.lastEventAt=Date.now(),yield T}}finally{a&&clearTimeout(a);try{m.cancel().catch(()=>{})}catch{}}let y=s.aborted||e.signal?.aborted?null:i.flush();y&&(this.health.totalEvents++,this.health.lastEventAt=Date.now(),yield y)}catch(u){if(this.health.connected=!1,o||u instanceof Error&&u.name==="AbortError"||e.signal?.aborted)break;if(u instanceof xe&&u.status&&[401,403,404].includes(u.status)||!e.reconnect)throw u;if(e.maxReconnects>0&&this.health.totalReconnects>=e.maxReconnects)throw new ct(this.health.totalReconnects,e.url);n++,this.health.totalReconnects++,this.health.reconnectAttempt=n;let l=t*e.reconnectJitter*Math.random(),h=Math.min(t+l,e.maxReconnectDelayMs);if(t=Math.min(t*2,e.maxReconnectDelayMs),e.onReconnect(n,h),a&&(clearTimeout(a),a=null),await Uc(h,e.signal,s),e.signal?.aborted||s.aborted)break;i.reset();continue}if(this.health.connected=!1,!e.reconnect)break;if(e.maxReconnects>0&&this.health.totalReconnects>=e.maxReconnects)throw new ct(this.health.totalReconnects,e.url);n++,this.health.totalReconnects++,this.health.reconnectAttempt=n;let c=Math.min(t+t*e.reconnectJitter*Math.random(),e.maxReconnectDelayMs);if(t=Math.min(t*2,e.maxReconnectDelayMs),e.onReconnect(n,c),a&&(clearTimeout(a),a=null),await Uc(c,e.signal,s),e.signal?.aborted||s.aborted)break}this.health.connected=!1}};Tr=class{constructor(){f(this,"handlers",new Map);f(this,"fallback",null)}on(e,t){let n=this.handlers.get(e)??[];return n.push(t),this.handlers.set(e,n),this}onJSON(e,t){return this.on(e,async(n,s)=>{let o;try{o=D(JSON.parse(n))}catch{return}await t(o,s)})}onMessage(e){return this.on("message",e)}onAny(e){return this.fallback=e,this}async dispatch(e){let t=this.handlers.get(e.event);if(t&&t.length>0)for(let n of t)await n(e.data,e);else this.fallback&&await this.fallback(e.data,e)}async consume(e){for await(let t of e)await this.dispatch(t)}};Jt=class{constructor(){f(this,"controller");f(this,"stream");f(this,"_closed",!1);let e;this.stream=new ReadableStream({start:t=>{e=t},cancel:()=>{this._closed=!0}}),this.controller=e}comment(e=""){return this._closed||this.controller.enqueue(`: ${Po(e)}
21
21
 
22
- `),this}send(e,t={}){return this.sendEvent("message",e,t)}sendEvent(e,t,n={}){if(this._closed)return this;let s="";n.id!==void 0&&(s+=`id: ${Eo(n.id)}
23
- `),e!=="message"&&(s+=`event: ${Eo(e)}
22
+ `),this}send(e,t={}){return this.sendEvent("message",e,t)}sendEvent(e,t,n={}){if(this._closed)return this;let s="";n.id!==void 0&&(s+=`id: ${Po(n.id)}
23
+ `),e!=="message"&&(s+=`event: ${Po(e)}
24
24
  `),n.retry!==void 0&&(s+=`retry: ${n.retry}
25
25
  `);for(let o of t.split(/\r\n|\r|\n/))s+=`data: ${o}
26
26
  `;return s+=`
27
27
  `,this.controller.enqueue(s),this}sendJSON(e,t,n={}){return this.sendEvent(e,JSON.stringify(t),n)}heartbeat(){return this.comment("heartbeat")}setReconnectDelay(e){return this._closed||this.controller.enqueue(`retry: ${e}
28
28
 
29
- `),this}close(){if(!this._closed){this._closed=!0;try{this.controller.close()}catch{}}}get closed(){return this._closed}toResponse(e={}){let t=new TextEncoder,n=this.stream.pipeThrough(new TransformStream({transform:(s,o)=>o.enqueue(t.encode(s))}));return new Response(n,{headers:{"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive","x-accel-buffering":"no",...e}})}},me=class extends Error{constructor(t,n,s){super(t);f(this,"status");f(this,"response");f(this,"code","ESSE");this.status=n,this.response=s,this.name="SSEError"}},st=class extends Error{constructor(t,n){super(`SSE max reconnects (${t}) reached for ${n}`);f(this,"attempts");f(this,"url");f(this,"code","ESSEMAXRECONNECTS");this.attempts=t,this.url=n,this.name="SSEMaxReconnectsError"}}});var Ic={};ae(Ic,{GraphQLClient:()=>se,GraphQLClientError:()=>N,authLink:()=>Oo,clearAPQCache:()=>Ho,createGraphQLClient:()=>$o,detectOperationType:()=>vn,errorLink:()=>Mo,extractOperationName:()=>Re,getAPQMetrics:()=>jo,gql:()=>Uo,loggingLink:()=>Do,retryLink:()=>No});function kn(r,e,t){let n=r.map(s=>s.message).join("; ");return new N(n,"EGRAPHQL",r,e,t)}function vc(r){return new Promise(e=>setTimeout(e,r))}function zh(r,e){return r.reduceRight((t,n)=>s=>n(s,t),e)}function vn(r){let e=r.replace(/^\s*#.*$/gm,"").trim();return/^\s*mutation\s/i.test(e)?"mutation":/^\s*subscription\s/i.test(e)?"subscription":"query"}function Re(r){let t=r.replace(/^\s*#.*$/gm,"").trim().match(/^\s*(?:query|mutation|subscription)\s+([A-Za-z_][A-Za-z0-9_]*)/im);return t?t[1]:null}async function Pc(r){let e=new TextEncoder().encode(r),t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function Cn(r,e={}){let t={"content-type":"application/json",accept:"application/json"},n=typeof r.headers=="function"?await r.headers():r.headers??{};return{...t,...n,...e}}function Kh(r){let e=r.split(""),t=0,n=r.length;for(;t<n;){let s=r[t];if(s==="#"){for(;t<n&&r[t]!==`
29
+ `),this}close(){if(!this._closed){this._closed=!0;try{this.controller.close()}catch{}}}get closed(){return this._closed}toResponse(e={}){let t=new TextEncoder,n=this.stream.pipeThrough(new TransformStream({transform:(s,o)=>o.enqueue(t.encode(s))}));return new Response(n,{headers:{"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive","x-accel-buffering":"no",...e}})}},xe=class extends Error{constructor(t,n,s){super(t);f(this,"status");f(this,"response");f(this,"code","ESSE");this.status=n,this.response=s,this.name="SSEError"}},ct=class extends Error{constructor(t,n){super(`SSE max reconnects (${t}) reached for ${n}`);f(this,"attempts");f(this,"url");f(this,"code","ESSEMAXRECONNECTS");this.attempts=t,this.url=n,this.name="SSEMaxReconnectsError"}}});var qc={};le(qc,{GraphQLClient:()=>ie,GraphQLClientError:()=>H,authLink:()=>jo,clearAPQCache:()=>Ko,createGraphQLClient:()=>Fo,detectOperationType:()=>Nn,errorLink:()=>Bo,extractOperationName:()=>Le,getAPQMetrics:()=>Vo,gql:()=>Wo,loggingLink:()=>zo,retryLink:()=>qo});function On(r,e,t){let n=r.map(s=>s.message).join("; ");return new H(n,"EGRAPHQL",r,e,t)}function sf(r,e){return r.reduceRight((t,n)=>s=>n(s,t),e)}function Nn(r){let e=r.replace(/^\s*#.*$/gm,"").trim();return/^\s*mutation\s/i.test(e)?"mutation":/^\s*subscription\s/i.test(e)?"subscription":"query"}function Le(r){let t=r.replace(/^\s*#.*$/gm,"").trim().match(/^\s*(?:query|mutation|subscription)\s+([A-Za-z_][A-Za-z0-9_]*)/im);return t?t[1]:null}async function Mn(r,e={}){let t={"content-type":"application/json",accept:"application/json"},n=typeof r.headers=="function"?await r.headers():r.headers??{};return{...t,...n,...e}}function uf(r){let e=r.split(""),t=0,n=r.length;for(;t<n;){let s=r[t];if(s==="#"){for(;t<n&&r[t]!==`
30
30
  `;)e[t++]=" ";continue}if((s==='"'||s==="'")&&r[t+1]===s&&r[t+2]===s){let o=s.repeat(3),i=r.indexOf(o,t+3),a=i===-1?n:i+3;for(;t<a;)e[t++]=" ";continue}if(s==='"'||s==="'"){let o=s;for(e[t]=" ",t++;t<n&&r[t]!==o&&r[t]!==`
31
- `;)e[t]=" ",t++;t<n&&r[t]===o&&(e[t]=" ",t++);continue}t++}return e.join("")}function Io(r){if(r.length>Ac)throw new G(`GraphQL query exceeds maximum length of ${Ac} bytes`);let e=Kh(r);for(let s of Wh)if(s.test(e))throw new G(`GraphQL query contains potentially malicious pattern: ${s}`);let t=0,n=0;for(let s=0;s<e.length;s++){let o=e[s];o==="{"?(t++,n=Math.max(n,t)):o==="}"&&t--}if(n>kc)throw new G(`GraphQL query exceeds maximum depth of ${kc}`);if(t!==0)throw new G("GraphQL query has unbalanced braces")}function Lo(r,e=1e4){let t=JSON.stringify(r);if(t.length>e)throw new G(`String value exceeds maximum length of ${e} characters`);return t}function Cc(r,e){e.query&&Io(e.query);let t=new URL(r),n=wr(e);return t.searchParams.set("query",e.query),e.operationName&&t.searchParams.set("operationName",e.operationName),e.variables&&Object.keys(e.variables).length>0&&t.searchParams.set("variables",Lo(e.variables)),e.extensions&&Object.keys(e.extensions).length>0&&t.searchParams.set("extensions",Lo(e.extensions)),t.toString()}function wr(r){Io(r.query);let e={query:r.query};return r.operationName&&(e.operationName=r.operationName),r.variables&&(e.variables=r.variables),r.extensions&&(e.extensions=r.extensions),Lo(e,1e5)}function Vh(r,e){let t=new FormData,n=JSON.parse(wr(r)),s={};for(let o=0;o<e.length;o++){let i=e[o],a=i.path==="variables"||i.path.startsWith("variables.")?i.path:`variables.${i.path}`;s[String(o)]=[a],Jh(n,a,null)}t.append("operations",JSON.stringify(n)),t.append("map",JSON.stringify(s));for(let o=0;o<e.length;o++){let i=e[o],a=i.file instanceof File?i.file.name:`file_${o}`;t.append(String(o),i.file,a)}return t}function Jh(r,e,t){let n=e.split("."),s=r;for(let i=0;i<n.length-1;i++){let a=n[i];if(a==="__proto__"||a==="constructor"||a==="prototype")throw new G(`Invalid upload path: "${e}" \u2014 reserved key "${a}"`);let u=/^(0|[1-9][0-9]*)$/.test(n[i+1])?[]:{};(!s[a]||typeof s[a]!="object")&&(s[a]=u),s=s[a]}let o=n[n.length-1];if(o==="__proto__"||o==="constructor"||o==="prototype")throw new G(`Invalid upload path: "${e}" \u2014 reserved key "${o}"`);s[o]=t}async function Lc(r,e){let t=r.headers.get("content-type")??"";if(!r.ok&&!t.includes("application/json")){let s=await r.text().catch(()=>"(unreadable)");throw new N(`HTTP ${r.status}: ${r.statusText}
32
- ${s}`,"ENETWORK",void 0,e,void 0,new Error(`HTTP ${r.status}`))}let n;try{n=D(await r.json())}catch(s){throw new N("Failed to parse GraphQL response as JSON","EPARSE",void 0,e,void 0,s)}return n}async function Po(r,e,t,n="none",s){let o=await Cn(e,r.headers??{}),i=vn(r.query),a=e.useGETForQueries&&i==="query",c=e.url,u=null,l={...o};if(n==="omitQuery"||n==="full"){let g=s?await s(r.query):await Pc(r.query),y={...r.extensions,persistedQuery:{version:1,sha256Hash:g}},w=n==="omitQuery"?{...r,query:"",extensions:y}:{...r,extensions:y};a?c=Cc(e.url,w):u=wr(w)}else a?c=Cc(e.url,r):u=wr(r);a||(l["content-type"]="application/json");let h=new AbortController,p=e.timeoutMs>0?setTimeout(()=>h.abort(),e.timeoutMs):null,d=()=>h.abort();t?.addEventListener("abort",d,{once:!0});let m;try{m=await e.fetch(c,{method:a?"GET":"POST",headers:l,body:u,signal:h.signal})}catch(g){throw p&&clearTimeout(p),h.signal.aborted?new N("Request timed out","ETIMEOUT",void 0,r,void 0,g):new N(g instanceof Error?g.message:"Network error","ENETWORK",void 0,r,void 0,g)}finally{p&&clearTimeout(p),t?.removeEventListener("abort",d)}return Lc(m,r)}function Oo(r,e="Bearer"){return async(t,n)=>{let s=await r();if(s){let o=t.request.headers??{};t.request={...t.request,headers:{...o,authorization:`${e} ${s}`}};let i=typeof t.config.headers=="object"&&!Array.isArray(t.config.headers)?t.config.headers:{};t={...t,config:{...t.config,headers:{...i,authorization:`${e} ${s}`}}}}return n(t)}}function Mo(r){return async(e,t)=>{try{return await t(e)}catch(n){if(!(n instanceof N))throw n;let s=await r(n,e,()=>t(e));if(s)return s;throw n}}}function Do(r=(e,t)=>console.log(e,t)){return async(e,t)=>{let n=Date.now();r("\u2192 GraphQL",{operation:e.request.operationName??"anonymous",url:e.config.url});try{let s=await t(e);return r("\u2190 GraphQL",{operation:e.request.operationName,durationMs:Date.now()-n,errors:s.errors}),s}catch(s){throw r("\u2717 GraphQL",{operation:e.request.operationName,durationMs:Date.now()-n,error:String(s)}),s}}}function No(r={}){let e=r.maxRetries??3,t=r.delayMs??300;if(!Number.isInteger(e)||e<0)throw new RangeError(`retryLink: maxRetries must be a non-negative integer, got ${e}`);if(!Number.isFinite(t)||t<0)throw new RangeError(`retryLink: delayMs must be a non-negative number, got ${t}`);let n=r.shouldRetry??(s=>!(s instanceof N&&s.isGraphQLError));return async(s,o)=>{let i;for(let a=0;a<=e;a++){a>0&&await vc(t*Math.pow(2,a-1));try{return await o(s)}catch(c){if(i=c,!n(c,a))throw c}}throw i}}function $o(r){return new se(r)}async function Uo(r,e,t,n){return await new se({url:r,...n!==void 0?{headers:n}:{}}).query(e,t)}var N,qh,vo,Fh,Ac,kc,Wh,R,se,Qh,Ho,jo,Pn=W(()=>{"use strict";we();q();N=class extends Error{constructor(t,n,s,o,i,a){super(t);f(this,"graphQLErrors");f(this,"request");f(this,"response");f(this,"networkError");f(this,"code");this.graphQLErrors=s,this.request=o,this.response=i,this.networkError=a,this.name="GraphQLClientError",this.code=n}get isGraphQLError(){return!!this.graphQLErrors&&this.graphQLErrors.length>0}get isNetworkError(){return!!this.networkError}get firstErrorMessage(){return this.graphQLErrors?.[0]?.message??null}};qh=1e3,vo=1800*1e3,Fh=300*1e3;Ac=100*1024,kc=100,Wh=[/\{\s*\{/,/<\s*</,/<!--/,/<script/,/javascript:/i,/onerror\s*=/i,/eval\s*\(/i];R=class R{constructor(e){f(this,"config");f(this,"executeLink");this.config={fetch:globalThis.fetch,headers:{},useGETForQueries:!1,enableAPQ:!1,timeoutMs:3e4,retries:0,retryDelayMs:300,links:[],signal:e.signal??new AbortController().signal,onRequest:()=>{},onResponse:()=>{},onError:()=>{},...e};let t=n=>this._executeWithAPQ(n.request,n.signal??null,n.config??this.config);this.executeLink=zh(this.config.links,t)}static _ensureAPQCleanup(){R._apqCleanupTimer||(R._apqCleanupTimer=setInterval(()=>{let e=Date.now();for(let[t,n]of R.apqCache)e-n.createdAt>vo&&(R.apqCache.delete(t),R.apqHashToQuery.delete(n.hash));for(let[t,n]of R.apqHashToQuery)if(e-n.createdAt>vo){R.apqHashToQuery.delete(t);for(let[s,o]of R.apqCache)if(o.hash===t){R.apqCache.delete(s);break}}},Fh),typeof R._apqCleanupTimer=="object"&&R._apqCleanupTimer!==null&&"unref"in R._apqCleanupTimer&&R._apqCleanupTimer.unref())}async _getAPQHash(e){R._ensureAPQCleanup();let t=R.apqCache.get(e);if(t){if(Date.now()-t.createdAt<=vo)return R._apqHits++,t.hash;R.apqCache.delete(e),R.apqHashToQuery.delete(t.hash)}R._apqMisses++;let n=await Pc(e),s=Date.now(),o=R.apqHashToQuery.get(n);if(o&&o.query!==e&&(console.warn("[GraphQL] APQ hash collision detected"),R.apqCache.delete(o.query),R.apqHashToQuery.delete(n)),R.apqCache.size>=qh){let i="",a=1/0;for(let[c,u]of R.apqCache)u.createdAt<a&&(a=u.createdAt,i=c);if(i){let c=R.apqCache.get(i);c&&(R.apqCache.delete(i),R.apqHashToQuery.delete(c.hash))}}return R.apqCache.set(e,{hash:n,createdAt:s}),R.apqHashToQuery.set(n,{query:e,createdAt:s}),n}clearAPQCache(){R.apqCache.clear(),R.apqHashToQuery.clear(),R._apqHits=0,R._apqMisses=0,R._apqCleanupTimer&&(clearInterval(R._apqCleanupTimer),R._apqCleanupTimer=null)}getAPQMetrics(){return{size:R.apqCache.size,hits:R._apqHits,misses:R._apqMisses}}async query(e,t,n={}){let s={query:e,...t!==void 0?{variables:t}:{},...n.operationName!==void 0?{operationName:n.operationName}:Re(e)!==null?{operationName:Re(e)}:{},...n.extensions!==void 0?{extensions:n.extensions}:{}};return await this._execute(s,n.signal??null)}async mutate(e,t,n={}){return await this.query(e,t,n)}async upload(e,t,n,s={}){let o={query:e,variables:t,...s.operationName!==void 0?{operationName:s.operationName}:Re(e)!==null?{operationName:Re(e)}:{}},i=await Cn(this.config,{});delete i["content-type"];let a=Vh(o,n),c=new AbortController,u=()=>c.abort();s.signal?.addEventListener("abort",u,{once:!0}),this.config.onRequest(o);let l;try{l=await this.config.fetch(this.config.url,{method:"POST",headers:i,body:a,signal:c.signal})}catch(p){let d=new N(p instanceof Error?p.message:"Upload network error","ENETWORK",void 0,o,void 0,p);throw this.config.onError(d,o),d}finally{s.signal?.removeEventListener("abort",u)}let h=await Lc(l,o);if(this.config.onResponse(h,o),h.errors?.length){let p=kn(h.errors,o,h);throw this.config.onError(p,o),p}if(h.data===void 0)throw new N("No data in upload response","ENODATA",void 0,o,h);return h.data}async batch(e,t={}){for(let l of e)Io(l.query);let n=await Cn(this.config),s=new AbortController,o=()=>s.abort();t.signal?.addEventListener("abort",o,{once:!0});let i;try{i=await this.config.fetch(this.config.url,{method:"POST",headers:n,body:JSON.stringify(e),signal:s.signal})}catch(l){throw new N(l instanceof Error?l.message:"Batch network error","ENETWORK",void 0,e[0],void 0,l)}finally{t.signal?.removeEventListener("abort",o)}let a=i.headers.get("content-type")??"";if(!i.ok&&!a.includes("application/json")){let l=await i.text().catch(()=>"(unreadable)");throw new N(`HTTP ${i.status}: ${i.statusText}
33
- ${l}`,"ENETWORK",void 0,e[0],void 0,new Error(`HTTP ${i.status}`))}let c;try{c=D(await i.json())}catch(l){throw new N("Failed to parse batch response as JSON","EPARSE",void 0,e[0],void 0,l)}if(!Array.isArray(c))throw new N("Batch response must be an array of GraphQL responses","EINVALIDRESPONSE",void 0,e[0],c);let u=c;if(u.length!==e.length)throw new N(`Batch response has ${u.length} result(s) but ${e.length} request(s) were sent`,"EINVALIDRESPONSE",void 0,e[0],c);return u.map((l,h)=>{if(l.errors?.length)throw kn(l.errors,e[h],l);if(l.data===void 0)throw new N("No data in batch response","ENODATA",void 0,e[h],l);return l.data})}async*subscribe(e,t,n={}){let s={query:e,...t!==void 0?{variables:t}:{},...n.operationName!==void 0?{operationName:n.operationName}:Re(e)!==null?{operationName:Re(e)}:{}},o=n.url??this.config.url,i=await Cn(this.config,{accept:"text/event-stream"}),a=wr(s),{SSEClient:c}=await Promise.resolve().then(()=>(yr(),Co)),u=new c({url:o,method:"POST",headers:i,body:a,signal:n.signal??this.config.signal,reconnect:!1,fetch:this.config.fetch});for await(let l of u){if(l.event==="complete")return;if(!l.data)continue;let h;try{h=D(JSON.parse(l.data))}catch{continue}if(h.errors?.length)throw kn(h.errors,s,h);h.data!==void 0&&(yield h.data)}}async introspect(){return await this.query(Qh)}async raw(e,t){return await this._executeRaw(e,t??null)}async _execute(e,t){this.config.onRequest(e);let n=await this._executeWithRetry(e,t);if(this.config.onResponse(n,e),n.errors?.length){let s=kn(n.errors,e,n);throw this.config.onError(s,e),s}if(n.data===void 0)throw new N("Response contained no data","ENODATA",void 0,e,n);return n.data}async _executeRaw(e,t){return await this.executeLink({request:e,config:this.config,...t!=null?{signal:t}:{}})}async _executeWithRetry(e,t){if(!Number.isInteger(this.config.retries)||this.config.retries<0)throw new RangeError(`retries must be a non-negative integer, got ${this.config.retries}`);let n;for(let s=0;s<=this.config.retries;s++){s>0&&await vc(this.config.retryDelayMs*Math.pow(2,s-1));try{return await this._executeRaw(e,t)}catch(o){if(n=o,o instanceof N&&o.isGraphQLError||t?.aborted)throw o}}throw n}async _executeWithAPQ(e,t,n=this.config){if(!n.enableAPQ)return Po(e,n,t,"none",void 0);let s=await Po(e,n,t,"omitQuery",i=>this._getAPQHash(i));return s.errors?.some(i=>i.extensions?.code==="PERSISTED_QUERY_NOT_FOUND")?Po(e,n,t,"full",i=>this._getAPQHash(i)):s}};f(R,"apqCache",new Map),f(R,"apqHashToQuery",new Map),f(R,"_apqHits",0),f(R,"_apqMisses",0),f(R,"_apqCleanupTimer",null);se=R;Qh=`
31
+ `;)e[t]=" ",t++;t<n&&r[t]===o&&(e[t]=" ",t++);continue}t++}return e.join("")}function Ho(r){if(r.length>Hc)throw new X(`GraphQL query exceeds maximum length of ${Hc} bytes`);let e=uf(r);for(let s of cf)if(s.test(e))throw new X(`GraphQL query contains potentially malicious pattern: ${s}`);let t=0,n=0;for(let s=0;s<e.length;s++){let o=e[s];o==="{"?(t++,n=Math.max(n,t)):o==="}"&&t--}if(n>jc)throw new X(`GraphQL query exceeds maximum depth of ${jc}`);if(t!==0)throw new X("GraphQL query has unbalanced braces")}function Uo(r,e=1e4){let t=JSON.stringify(r);if(t.length>e)throw new X(`String value exceeds maximum length of ${e} characters`);return t}function Bc(r,e){e.query&&Ho(e.query);let t=new URL(r),n=Rr(e);return t.searchParams.set("query",e.query),e.operationName&&t.searchParams.set("operationName",e.operationName),e.variables&&Object.keys(e.variables).length>0&&t.searchParams.set("variables",Uo(e.variables)),e.extensions&&Object.keys(e.extensions).length>0&&t.searchParams.set("extensions",Uo(e.extensions)),t.toString()}function Rr(r){Ho(r.query);let e={query:r.query};return r.operationName&&(e.operationName=r.operationName),r.variables&&(e.variables=r.variables),r.extensions&&(e.extensions=r.extensions),Uo(e,1e5)}function lf(r,e){let t=new FormData,n=JSON.parse(Rr(r)),s={};for(let o=0;o<e.length;o++){let i=e[o],a=i.path==="variables"||i.path.startsWith("variables.")?i.path:`variables.${i.path}`;s[String(o)]=[a],hf(n,a,null)}t.append("operations",JSON.stringify(n)),t.append("map",JSON.stringify(s));for(let o=0;o<e.length;o++){let i=e[o],a=i.file instanceof File?i.file.name:`file_${o}`;t.append(String(o),i.file,a)}return t}function hf(r,e,t){let n=e.split("."),s=r;for(let i=0;i<n.length-1;i++){let a=n[i];if(a==="__proto__"||a==="constructor"||a==="prototype")throw new X(`Invalid upload path: "${e}" \u2014 reserved key "${a}"`);let u=/^(0|[1-9][0-9]*)$/.test(n[i+1])?[]:{};(!s[a]||typeof s[a]!="object")&&(s[a]=u),s=s[a]}let o=n[n.length-1];if(o==="__proto__"||o==="constructor"||o==="prototype")throw new X(`Invalid upload path: "${e}" \u2014 reserved key "${o}"`);s[o]=t}async function zc(r,e){let t=r.headers.get("content-type")??"";if(!r.ok&&!t.includes("application/json")){let s=await r.text().catch(()=>"(unreadable)");throw new H(`HTTP ${r.status}: ${r.statusText}
32
+ ${s}`,"ENETWORK",void 0,e,void 0,new Error(`HTTP ${r.status}`))}let n;try{n=D(await r.json())}catch(s){throw new H("Failed to parse GraphQL response as JSON","EPARSE",void 0,e,void 0,s)}return n}async function $o(r,e,t,n="none",s){let o=await Mn(e,r.headers??{}),i=Nn(r.query),a=e.useGETForQueries&&i==="query",c=e.url,u=null,l={...o};if(n==="omitQuery"||n==="full"){let g=s?await s(r.query):await pe(r.query),w={...r.extensions,persistedQuery:{version:1,sha256Hash:g}},y=n==="omitQuery"?{...r,query:"",extensions:w}:{...r,extensions:w};a?c=Bc(e.url,y):u=Rr(y)}else a?c=Bc(e.url,r):u=Rr(r);a||(l["content-type"]="application/json");let h=new AbortController,d=e.timeoutMs>0?setTimeout(()=>h.abort(),e.timeoutMs):null,p=()=>h.abort();t?.addEventListener("abort",p,{once:!0});let m;try{m=await e.fetch(c,{method:a?"GET":"POST",headers:l,body:u,signal:h.signal})}catch(g){throw d&&clearTimeout(d),h.signal.aborted?new H("Request timed out","ETIMEOUT",void 0,r,void 0,g):new H(g instanceof Error?g.message:"Network error","ENETWORK",void 0,r,void 0,g)}finally{d&&clearTimeout(d),t?.removeEventListener("abort",p)}return zc(m,r)}function jo(r,e="Bearer"){return async(t,n)=>{let s=await r();if(s){let o=t.request.headers??{};t.request={...t.request,headers:{...o,authorization:`${e} ${s}`}};let i=typeof t.config.headers=="object"&&!Array.isArray(t.config.headers)?t.config.headers:{};t={...t,config:{...t.config,headers:{...i,authorization:`${e} ${s}`}}}}return n(t)}}function Bo(r){return async(e,t)=>{try{return await t(e)}catch(n){if(!(n instanceof H))throw n;let s=await r(n,e,()=>t(e));if(s)return s;throw n}}}function zo(r=(e,t)=>console.log(e,t)){return async(e,t)=>{let n=Date.now();r("\u2192 GraphQL",{operation:e.request.operationName??"anonymous",url:e.config.url});try{let s=await t(e);return r("\u2190 GraphQL",{operation:e.request.operationName,durationMs:Date.now()-n,errors:s.errors}),s}catch(s){throw r("\u2717 GraphQL",{operation:e.request.operationName,durationMs:Date.now()-n,error:String(s)}),s}}}function qo(r={}){let e=r.maxRetries??3,t=r.delayMs??300;if(!Number.isInteger(e)||e<0)throw new RangeError(`retryLink: maxRetries must be a non-negative integer, got ${e}`);if(!Number.isFinite(t)||t<0)throw new RangeError(`retryLink: delayMs must be a non-negative number, got ${t}`);let n=r.shouldRetry??(s=>!(s instanceof H&&s.isGraphQLError));return async(s,o)=>{let i;for(let a=0;a<=e;a++){a>0&&await Oe(t*Math.pow(2,a-1));try{return await o(s)}catch(c){if(i=c,!n(c,a))throw c}}throw i}}function Fo(r){return new ie(r)}async function Wo(r,e,t,n){return await new ie({url:r,...n!==void 0?{headers:n}:{}}).query(e,t)}var H,of,Do,af,Hc,jc,cf,R,ie,ff,Ko,Vo,Dn=J(()=>{"use strict";Re();U();U();U();H=class extends Error{constructor(t,n,s,o,i,a){super(t);f(this,"graphQLErrors");f(this,"request");f(this,"response");f(this,"networkError");f(this,"code");this.graphQLErrors=s,this.request=o,this.response=i,this.networkError=a,this.name="GraphQLClientError",this.code=n}get isGraphQLError(){return!!this.graphQLErrors&&this.graphQLErrors.length>0}get isNetworkError(){return!!this.networkError}get firstErrorMessage(){return this.graphQLErrors?.[0]?.message??null}};of=1e3,Do=1800*1e3,af=300*1e3;Hc=100*1024,jc=100,cf=[/\{\s*\{/,/<\s*</,/<!--/,/<script/,/javascript:/i,/onerror\s*=/i,/eval\s*\(/i];R=class R{constructor(e){f(this,"config");f(this,"executeLink");this.config={fetch:globalThis.fetch,headers:{},useGETForQueries:!1,enableAPQ:!1,timeoutMs:3e4,retries:0,retryDelayMs:300,links:[],signal:e.signal??new AbortController().signal,onRequest:()=>{},onResponse:()=>{},onError:()=>{},...e};let t=n=>this._executeWithAPQ(n.request,n.signal??null,n.config??this.config);this.executeLink=sf(this.config.links,t)}static _ensureAPQCleanup(){R._apqCleanupTimer||(R._apqCleanupTimer=setInterval(()=>{let e=Date.now();for(let[t,n]of R.apqCache)e-n.createdAt>Do&&(R.apqCache.delete(t),R.apqHashToQuery.delete(n.hash));for(let[t,n]of R.apqHashToQuery)if(e-n.createdAt>Do){R.apqHashToQuery.delete(t);for(let[s,o]of R.apqCache)if(o.hash===t){R.apqCache.delete(s);break}}},af),typeof R._apqCleanupTimer=="object"&&R._apqCleanupTimer!==null&&"unref"in R._apqCleanupTimer&&R._apqCleanupTimer.unref())}async _getAPQHash(e){R._ensureAPQCleanup();let t=R.apqCache.get(e);if(t){if(Date.now()-t.createdAt<=Do)return R._apqHits++,t.hash;R.apqCache.delete(e),R.apqHashToQuery.delete(t.hash)}R._apqMisses++;let n=await pe(e),s=Date.now(),o=R.apqHashToQuery.get(n);if(o&&o.query!==e&&(console.warn("[GraphQL] APQ hash collision detected"),R.apqCache.delete(o.query),R.apqHashToQuery.delete(n)),R.apqCache.size>=of){let i="",a=1/0;for(let[c,u]of R.apqCache)u.createdAt<a&&(a=u.createdAt,i=c);if(i){let c=R.apqCache.get(i);c&&(R.apqCache.delete(i),R.apqHashToQuery.delete(c.hash))}}return R.apqCache.set(e,{hash:n,createdAt:s}),R.apqHashToQuery.set(n,{query:e,createdAt:s}),n}clearAPQCache(){R.apqCache.clear(),R.apqHashToQuery.clear(),R._apqHits=0,R._apqMisses=0,R._apqCleanupTimer&&(clearInterval(R._apqCleanupTimer),R._apqCleanupTimer=null)}getAPQMetrics(){return{size:R.apqCache.size,hits:R._apqHits,misses:R._apqMisses}}async query(e,t,n={}){let s={query:e,...t!==void 0?{variables:t}:{},...n.operationName!==void 0?{operationName:n.operationName}:Le(e)!==null?{operationName:Le(e)}:{},...n.extensions!==void 0?{extensions:n.extensions}:{}};return await this._execute(s,n.signal??null)}async mutate(e,t,n={}){return await this.query(e,t,n)}async upload(e,t,n,s={}){let o={query:e,variables:t,...s.operationName!==void 0?{operationName:s.operationName}:Le(e)!==null?{operationName:Le(e)}:{}},i=await Mn(this.config,{});delete i["content-type"];let a=lf(o,n),c=new AbortController,u=()=>c.abort();s.signal?.addEventListener("abort",u,{once:!0}),this.config.onRequest(o);let l;try{l=await this.config.fetch(this.config.url,{method:"POST",headers:i,body:a,signal:c.signal})}catch(d){let p=new H(d instanceof Error?d.message:"Upload network error","ENETWORK",void 0,o,void 0,d);throw this.config.onError(p,o),p}finally{s.signal?.removeEventListener("abort",u)}let h=await zc(l,o);if(this.config.onResponse(h,o),h.errors?.length){let d=On(h.errors,o,h);throw this.config.onError(d,o),d}if(h.data===void 0)throw new H("No data in upload response","ENODATA",void 0,o,h);return h.data}async batch(e,t={}){for(let l of e)Ho(l.query);let n=await Mn(this.config),s=new AbortController,o=()=>s.abort();t.signal?.addEventListener("abort",o,{once:!0});let i;try{i=await this.config.fetch(this.config.url,{method:"POST",headers:n,body:JSON.stringify(e),signal:s.signal})}catch(l){throw new H(l instanceof Error?l.message:"Batch network error","ENETWORK",void 0,e[0],void 0,l)}finally{t.signal?.removeEventListener("abort",o)}let a=i.headers.get("content-type")??"";if(!i.ok&&!a.includes("application/json")){let l=await i.text().catch(()=>"(unreadable)");throw new H(`HTTP ${i.status}: ${i.statusText}
33
+ ${l}`,"ENETWORK",void 0,e[0],void 0,new Error(`HTTP ${i.status}`))}let c;try{c=D(await i.json())}catch(l){throw new H("Failed to parse batch response as JSON","EPARSE",void 0,e[0],void 0,l)}if(!Array.isArray(c))throw new H("Batch response must be an array of GraphQL responses","EINVALIDRESPONSE",void 0,e[0],c);let u=c;if(u.length!==e.length)throw new H(`Batch response has ${u.length} result(s) but ${e.length} request(s) were sent`,"EINVALIDRESPONSE",void 0,e[0],c);return u.map((l,h)=>{if(l.errors?.length)throw On(l.errors,e[h],l);if(l.data===void 0)throw new H("No data in batch response","ENODATA",void 0,e[h],l);return l.data})}async*subscribe(e,t,n={}){let s={query:e,...t!==void 0?{variables:t}:{},...n.operationName!==void 0?{operationName:n.operationName}:Le(e)!==null?{operationName:Le(e)}:{}},o=n.url??this.config.url,i=await Mn(this.config,{accept:"text/event-stream"}),a=Rr(s),{SSEClient:c}=await Promise.resolve().then(()=>(Er(),No)),u=new c({url:o,method:"POST",headers:i,body:a,signal:n.signal??this.config.signal,reconnect:!1,fetch:this.config.fetch});for await(let l of u){if(l.event==="complete")return;if(!l.data)continue;let h;try{h=D(JSON.parse(l.data))}catch{continue}if(h.errors?.length)throw On(h.errors,s,h);h.data!==void 0&&(yield h.data)}}async introspect(){return await this.query(ff)}async raw(e,t){return await this._executeRaw(e,t??null)}async _execute(e,t){this.config.onRequest(e);let n=await this._executeWithRetry(e,t);if(this.config.onResponse(n,e),n.errors?.length){let s=On(n.errors,e,n);throw this.config.onError(s,e),s}if(n.data===void 0)throw new H("Response contained no data","ENODATA",void 0,e,n);return n.data}async _executeRaw(e,t){return await this.executeLink({request:e,config:this.config,...t!=null?{signal:t}:{}})}async _executeWithRetry(e,t){if(!Number.isInteger(this.config.retries)||this.config.retries<0)throw new RangeError(`retries must be a non-negative integer, got ${this.config.retries}`);let n;for(let s=0;s<=this.config.retries;s++){s>0&&await Oe(this.config.retryDelayMs*Math.pow(2,s-1));try{return await this._executeRaw(e,t)}catch(o){if(n=o,o instanceof H&&o.isGraphQLError||t?.aborted)throw o}}throw n}async _executeWithAPQ(e,t,n=this.config){if(!n.enableAPQ)return $o(e,n,t,"none",void 0);let s=await $o(e,n,t,"omitQuery",i=>this._getAPQHash(i));return s.errors?.some(i=>i.extensions?.code==="PERSISTED_QUERY_NOT_FOUND")?$o(e,n,t,"full",i=>this._getAPQHash(i)):s}};f(R,"apqCache",new Map),f(R,"apqHashToQuery",new Map),f(R,"_apqHits",0),f(R,"_apqMisses",0),f(R,"_apqCleanupTimer",null);ie=R;ff=`
34
34
  query IntrospectionQuery {
35
35
  __schema {
36
36
  queryType { name }
@@ -87,16 +87,16 @@ ${l}`,"ENETWORK",void 0,e[0],void 0,new Error(`HTTP ${i.status}`))}let c;try{c=D
87
87
  }
88
88
  }
89
89
  }
90
- `;Ho=se.prototype.clearAPQCache.bind(se.prototype),jo=se.prototype.getAPQMetrics.bind(se.prototype)});var Oc={};ae(Oc,{collectAll:()=>qo,collectPages:()=>Fo,createCursorPaginator:()=>Jo,createKeysetPaginator:()=>Yo,createLinkHeaderPaginator:()=>Go,createOffsetPaginator:()=>Ko,createPagePaginator:()=>Vo,createRelayPaginator:()=>Qo,createTokenPaginator:()=>Xo,deserializePaginationState:()=>ei,mergePaginators:()=>ri,paginate:()=>K,paginateItems:()=>Ln,parseLinkHeaderNext:()=>In,prefetchPaginate:()=>ef,serializePaginationState:()=>Zo,takeItems:()=>Wo,toPaginationIterator:()=>ti});function Gh(r,e){return{strategy:e,page:r.startPage??1,offset:r.startOffset??0,cursor:r.startCursor??null,prevCursor:null,token:r.startToken??null,done:!1,totalFetched:0}}function Xh(r,e,t,n,s,o){let i=n.getTotal?.(e)??null,a=n.perPage??null,c=i!==null&&a!==null?Math.ceil(i/a):null,u=t.page>1||t.offset>0||t.prevCursor!==null;return{items:r,total:i,page:t.page,perPage:a,totalPages:c,hasNext:o??n.hasNext(e,t),hasPrev:u,nextCursor:s?.cursor??null,prevCursor:t.prevCursor??null,raw:e}}async function*K(r,e="page"){let t=Gh(r,e),n=0,s=new Set;for(t.cursor!==null&&s.add(t.cursor),t.token!==null&&s.add(t.token);!t.done&&!(r.signal?.aborted||r.maxPages&&n>=r.maxPages);){n>0&&r.delayMs&&r.delayMs>0&&await rf(r.delayMs,r.signal);let o;try{o=await r.fetch(t)}catch(d){if(r.signal?.aborted)break;throw d}let i=r.getItems(o,t),a=i.length,c=i;r.transform&&(c=c.map(r.transform)),r.filter&&(c=c.filter(r.filter));let u=r.getNext?r.getNext(o,t):null,l=r.hasNext(o,t);if(l){let d=u?.cursor??t.cursor,m=u?.token??t.token,g=u?.page??t.page+1,y=u?.offset??t.offset+a,_=Yh.has(t.strategy)&&r.getNext!==void 0&&u==null,b=d!==null&&s.has(d)||m!==null&&s.has(m),T=g===t.page&&y===t.offset&&d===t.cursor&&m===t.token;_||b||T?l=!1:(d!==null&&s.add(d),m!==null&&s.add(m))}let h=Xh(c,o,t,r,u,l),p=t.cursor;if(t={...t,page:u?.page??t.page+1,offset:u?.offset??t.offset+a,cursor:u?.cursor??t.cursor,token:u?.token??t.token,done:!l,totalFetched:t.totalFetched+a,prevCursor:p},n++,r.onPage?.(h,t),yield h,!l)break}}async function*Ln(r,e="page"){for await(let t of K(r,e))for(let n of t.items)yield n}async function qo(r,e="page"){let t=[];for await(let n of K(r,e))t.push(...n.items);return t}async function Fo(r,e="page"){let t=[];for await(let n of K(r,e))t.push(n);return t}async function Wo(r,e,t="page"){if(typeof r!="number"||Number.isNaN(r)||r<=0)return[];let n=Math.floor(r),s=[];for await(let o of Ln(e,t))if(s.push(o),s.length>=n)break;return s}function Ko(r){let e=r.paramNames??{},t=e.offset??"offset",n=e.limit??"limit",s=r.fetch??globalThis.fetch;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},perPage:r.limit,fetch:async o=>{let i=new URL(r.url);return i.searchParams.set(t,String(o.offset)),i.searchParams.set(n,String(r.limit)),(await s(i.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:(o,i)=>r.getItems(o),getTotal:r.getTotal??(()=>null),hasNext:(o,i)=>{let a=r.getTotal?.(o)??null;return r.hasMore?r.hasMore(o,i.totalFetched+r.limit,a):a!==null?i.offset+r.limit<a:r.getItems(o).length===r.limit},getNext:(o,i)=>({offset:i.offset+r.limit})},"offset")}function Vo(r){let e=r.paramNames??{},t=e.page??"page",n=e.perPage??"per_page",s=r.fetch??globalThis.fetch;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.perPage!==void 0?{perPage:r.perPage}:{},startPage:r.startPage??1,fetch:async o=>{let i=new URL(r.url);return i.searchParams.set(t,String(o.page)),i.searchParams.set(n,String(r.perPage)),(await s(i.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:o=>r.getItems(o),getTotal:r.getTotal??(()=>null),hasNext:(o,i)=>{let a=r.getTotalPages?.(o)??null;if(a!==null)return i.page<a;let c=r.getTotal?.(o)??null;return c!==null?i.page*r.perPage<c:r.getItems(o).length===r.perPage},getNext:(o,i)=>({page:i.page+1})},"page")}function Jo(r){let e=r.paramName??"cursor",t=r.fetch??globalThis.fetch;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},startCursor:r.startCursor??null,fetch:async n=>{let s=new URL(r.url);return n.cursor&&s.searchParams.set(e,n.cursor),(await t(s.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:n=>r.getItems(n),hasNext:n=>r.getNextCursor(n)!==null,getNext:n=>{let s=r.getNextCursor(n);return s?{cursor:s}:null}},"cursor")}function Qo(r){let e=r.first??20;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.transform!==void 0?{transform:r.transform}:{},...r.filter!==void 0?{filter:r.filter}:{},...r.onPage!==void 0?{onPage:r.onPage}:{},startCursor:r.startCursor??null,perPage:e,fetch:t=>r.fetch({first:e,after:t.cursor}),getItems:t=>t.edges.map(n=>n.node),getTotal:t=>t.totalCount??null,hasNext:t=>t.pageInfo.hasNextPage,getNext:t=>{let n=t.pageInfo.endCursor??null;return n?{cursor:n}:null}},"relay")}function Go(r){let e=r.fetch??globalThis.fetch;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},fetch:async t=>{let n=t.cursor??r.url,s=await e(n,{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}}),o=In(s.headers.get("link")??"");return{data:await s.json(),headers:s.headers,nextUrl:o}},getItems:t=>r.getItems(t.data),getTotal:t=>r.getTotal?.(t.data,t.headers)??null,hasNext:t=>t.nextUrl!==null,getNext:t=>t.nextUrl?{cursor:t.nextUrl}:null},"link-header")}function In(r){if(!r)return null;let e=r.split(/(?=<)/).filter(t=>t.trimStart().startsWith("<"));for(let t of e){let n=t.match(Zh);if(n&&n[2]&&n[2].toLowerCase().split(/\s+/).includes("next"))return n[1]}return null}function Xo(r){let e=r.tokenParam??"pageToken",t=r.pageSizeParam??"pageSize",n=r.fetch??globalThis.fetch;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.pageSize!==void 0?{perPage:r.pageSize}:{},fetch:async s=>{let o=new URL(r.url);return s.token&&o.searchParams.set(e,s.token),r.pageSize&&o.searchParams.set(t,String(r.pageSize)),(await n(o.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:s=>r.getItems(s),getTotal:r.getTotal??(()=>null),hasNext:s=>r.getNextToken(s)!==null,getNext:s=>{let o=r.getNextToken(s);return o?{token:o}:null}},"token")}function Yo(r){let e=r.pageSizeParam??"limit",t=r.fetch??globalThis.fetch;return K({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.pageSize!==void 0?{perPage:r.pageSize}:{},startCursor:r.startKey??null,fetch:async n=>{let s=new URL(r.url);return n.cursor&&s.searchParams.set(r.keyParam,n.cursor),r.pageSize&&s.searchParams.set(e,String(r.pageSize)),(await t(s.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:n=>r.getItems(n),hasNext:(n,s)=>{let o=r.getItems(n);return r.hasMore?r.hasMore(o,n):r.pageSize?o.length>=r.pageSize:o.length>0},getNext:(n,s)=>{let o=r.getItems(n),i=r.getLastKey(o);return i?{cursor:i}:null}},"keyset")}async function*ef(r,e="page",t=2){let n=Math.max(0,Math.floor(Number.isFinite(t)?t:0)),s=[],o=K(r,e),i=!1;function a(){if(i)return;let c=o.next().then(u=>u.done?(i=!0,null):u.value??null);c.catch(()=>{}),s.push(c)}for(let c=0;c<n+1;c++)a();for(;s.length>0;){let c=await s.shift();if(c==null)break;a(),yield c}}function Zo(r){let e=JSON.stringify(r);if(typeof TextEncoder<"u"&&typeof btoa=="function"){let t=new TextEncoder().encode(e),n="",s=32768;for(let o=0;o<t.length;o+=s)n+=String.fromCharCode(...t.subarray(o,o+s));return btoa(n)}return btoa(e)}function Bo(r){return typeof r=="number"&&Number.isFinite(r)}function zo(r){return r==null||typeof r=="string"}function ei(r){let e;try{let s=atob(r),o=new Uint8Array(s.length);for(let a=0;a<s.length;a++)o[a]=s.charCodeAt(a);let i=typeof TextDecoder<"u"?new TextDecoder("utf-8",{fatal:!0}).decode(o):s;e=JSON.parse(i)}catch{throw new Error("Invalid pagination state string")}let t=D(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Invalid pagination state string");let n=t;if(!Bo(n.page)||!Bo(n.offset)||!Bo(n.totalFetched)||typeof n.strategy!="string"||!tf.has(n.strategy)||typeof n.done!="boolean"||!zo(n.cursor)||!zo(n.prevCursor)||!zo(n.token))throw new Error("Invalid pagination state string");return t}function rf(r,e){return new Promise(t=>{if(e?.aborted){t();return}let n=()=>{clearTimeout(s),e?.removeEventListener("abort",n),t()},s=setTimeout(()=>{e?.removeEventListener("abort",n),t()},r);e?.addEventListener("abort",n,{once:!0})})}function ti(r){let e=r[Symbol.asyncIterator]();return{next:()=>e.next(),return:t=>e.return?.(t)??Promise.resolve({value:t,done:!0}),throw:t=>e.throw?.(t)??Promise.reject(t),[Symbol.asyncIterator](){return this}}}async function*ri(...r){let e=r.map(n=>n[Symbol.asyncIterator]()),t=new Set(e.map((n,s)=>s));for(;t.size>0;)for(let n of[...t]){let s;try{s=await e[n].next()}catch{t.delete(n);continue}if(s.done){t.delete(n);continue}yield s.value}}var Yh,Zh,tf,On=W(()=>{"use strict";q();Yh=new Set(["cursor","relay","link-header","token","keyset"]);Zh=/<([^>]+)>.*?rel=["']([^"']+)["']/i;tf=new Set(["offset","page","cursor","relay","link-header","token","keyset"])});var zf={};ae(zf,{AbortError:()=>mt,AuthError:()=>Mr,BatchQueue:()=>Dn,BatchingTransport:()=>Ut,CONCURRENCY_DEFAULTS:()=>Ns,CircuitBreaker:()=>ct,CircuitBreakerRegistry:()=>Ke,CircuitOpenError:()=>at,CloudflareKVAdapter:()=>yt,ConcurrencyLimitError:()=>Xe,ConcurrencyLimiter:()=>St,ConsoleTransport:()=>rt,ContentTypeError:()=>Ne,CookieJar:()=>He,DedupMap:()=>We,FetchTransport:()=>et,FluentRequest:()=>_r,GraphQLClient:()=>se,GraphQLClientError:()=>N,HAS_NATIVE_FETCH:()=>lo,HTTPCache:()=>le,HTTPError:()=>Tr,HTTPLogger:()=>Be,HTTPResponseError:()=>Ye,HTTPStatusError:()=>pt,HeaderName:()=>S,HookEmitter:()=>Sr,HookRegistry:()=>Nn,HttpHeaders:()=>he,IS_NODE:()=>Ue,InterceptorManager:()=>er,JSONTransport:()=>$t,Kinetex:()=>Ft,KinetexError:()=>x,LogLevel:()=>Nt,MemoryStorageAdapter:()=>Le,MultiPartProgressAggregator:()=>kr,MultiTransport:()=>jt,NetworkError:()=>F,NodeHTTP2Transport:()=>kt,ProgressTracker:()=>J,ProxyError:()=>Dr,RUNTIME:()=>Se,RateLimitError:()=>_t,Redactor:()=>Bt,RedirectError:()=>Pe,RedirectTracker:()=>$n,RemoteTransport:()=>Ht,ResponseDecodeError:()=>Ze,ResponseSizeLimitError:()=>De,ResponseValidationError:()=>Rr,RichHeaders:()=>Ie,SSEClient:()=>nt,SSEError:()=>me,SSEMaxReconnectsError:()=>st,SSEParser:()=>ze,SSERouter:()=>gr,SSEServerResponse:()=>zt,SSETransformStream:()=>mr,SigV4Signer:()=>fe,SizeLimitError:()=>dt,Socks5Error:()=>M,TimeoutError:()=>X,TooManyRedirectsError:()=>Er,TwoTierStorageAdapter:()=>wt,URLBuilder:()=>qe,ValidationError:()=>G,WSClient:()=>Je,WSConnectTimeoutError:()=>ft,WSError:()=>Q,WSMaxReconnectsError:()=>Yt,WSRateLimitError:()=>Or,WebStorageAdapter:()=>Qe,applyDecompression:()=>ir,assertOk:()=>eo,assertOkJSON:()=>to,authLink:()=>Oo,buildDataURL:()=>Lu,cachingCredentials:()=>zs,canonicalizeDomainFull:()=>pe,chainCredentials:()=>Ha,clearAPQCache:()=>Ho,collectAll:()=>qo,collectPages:()=>Fo,collectStream:()=>vi,compilePattern:()=>bu,composeAround:()=>Xc,composeBeforeRequest:()=>Qc,composeBeforeResponse:()=>Gc,computeBodySize:()=>Gr,computeDigestResponse:()=>tn,computeUsernameStar:()=>rn,concatUint8Arrays:()=>Xt,connectWS:()=>na,corsHeaders:()=>Aa,createAPIGatewaySigner:()=>Wa,createAbortHook:()=>tu,createAuthInterceptor:()=>Ls,createBodyNormalizationHook:()=>eu,createCacheInterceptor:()=>Ms,createCircuitBreaker:()=>Mi,createCircuitBreakerRegistry:()=>Di,createCookieJar:()=>_n,createCursorPaginator:()=>Jo,createDedupMap:()=>Oi,createDedupeInterceptor:()=>Ds,createDevelopmentLogger:()=>So,createDigestAuthorization:()=>Za,createDynamoDBSigner:()=>Va,createGraphQLClient:()=>$o,createHARInterceptor:()=>$s,createHeaders:()=>ka,createHookContext:()=>ru,createImmutableHeaders:()=>Pa,createInterceptorSuite:()=>Na,createJSONSSEStream:()=>Ro,createKVCache:()=>Zn,createKeysetPaginator:()=>Yo,createLimitedReader:()=>io,createLinkHeaderPaginator:()=>Go,createLocalStorageCache:()=>Xn,createLogger:()=>xo,createLoggingHooks:()=>Yc,createLoggingInterceptor:()=>Os,createMemoryCache:()=>Gn,createMethodCircuitBreakerKey:()=>qc,createMetricsInterceptor:()=>Us,createOffsetPaginator:()=>Ko,createPagePaginator:()=>Vo,createProductionLogger:()=>_o,createRateLimitInterceptor:()=>tr,createRelayPaginator:()=>Qo,createRequestHeaders:()=>Ca,createResponseHeaders:()=>va,createRetryInterceptor:()=>Ps,createS3Signer:()=>Fa,createSSEResponse:()=>Ao,createSSEStream:()=>To,createSTSSigner:()=>Ka,createSessionStorageCache:()=>Yn,createSocks5Tunnel:()=>pi,createStructuredError:()=>Ji,createTimeoutInterceptor:()=>Is,createTimingHook:()=>Zc,createTokenPaginator:()=>Xo,createTransport:()=>cr,createTwoTierCache:()=>es,decodeBody:()=>or,decodeIDNLabel:()=>pr,decompressBodyStream:()=>hr,decompressStream:()=>an,deepClone:()=>ut,default:()=>Bf,defaultPath:()=>It,denoTcpConnector:()=>ou,deriveSigningKey:()=>Rt,deserializePaginationState:()=>ei,detectClockSkew:()=>Js,detectOperationType:()=>vn,detectRuntime:()=>gn,diffResponses:()=>ro,diffURLs:()=>Iu,domainMatch:()=>Lt,encodePathComponent:()=>mi,encodeQueryValue:()=>ot,envCredentials:()=>Ua,errorLink:()=>Mo,expandTemplate:()=>wu,extractOperationName:()=>Re,extractServerTiming:()=>so,extractSetCookieHeaders:()=>Dt,fillPathParams:()=>bi,formatAmzDate:()=>rr,formatBasic:()=>ga,formatBearer:()=>ma,formatBytes:()=>Jt,formatCSP:()=>Vr,formatCacheControl:()=>ls,formatContentDisposition:()=>cs,formatContentType:()=>is,formatDateStamp:()=>Et,formatDigestAuth:()=>nn,formatETA:()=>zn,formatError:()=>Qi,formatHSTS:()=>Kr,formatLinkHeader:()=>ba,formatProgress:()=>Li,formatRate:()=>Bn,formatServerTiming:()=>_a,fromNodeHeaders:()=>Sa,fromWebHeaders:()=>Ta,generateIdempotencyKey:()=>Jr,getAPQMetrics:()=>jo,getAuthFingerprint:()=>be,getClientIP:()=>gs,getEffectiveRuntime:()=>uo,getOrigin:()=>jn,getPublicSuffix:()=>dr,getRegistrableDomain:()=>bn,getRuntime:()=>Ir,gql:()=>Uo,hasNativeFetch:()=>ra,imdsCredentials:()=>ja,initChunkedSigning:()=>Ks,injectHeaders:()=>Wc,isAbortError:()=>Lr,isAbortSignal:()=>zi,isAbsolute:()=>xi,isArrayBuffer:()=>Hi,isBinary:()=>Ys,isBlob:()=>Wi,isBlobURL:()=>Cu,isBrowserEnvironment:()=>ta,isClockSkewError:()=>Qs,isDataURL:()=>ku,isFormData:()=>Fi,isHTTP:()=>Au,isHTTPS:()=>Ru,isHeaders:()=>Bi,isIPAddress:()=>Ee,isJSON:()=>nr,isLocalhost:()=>vu,isNodeEnvironment:()=>ea,isPlainObject:()=>qi,isPublicSuffix:()=>Te,isReadableStream:()=>ji,isRelative:()=>Tu,isSafeURL:()=>te,isSameOrigin:()=>xu,isSameSite:()=>_u,isText:()=>sn,isURLSearchParams:()=>Ki,isUint8Array:()=>Ui,isValidHeaderName:()=>Ve,isValidHeaderValue:()=>ve,isValidIdempotencyKey:()=>Qr,joinPath:()=>yi,jsonSSE:()=>An,kinetex:()=>ju,loadCookieJar:()=>Sn,loggingLink:()=>Do,mergePaginators:()=>ri,mergeQuery:()=>fu,mergeSignals:()=>Pr,negotiateContentType:()=>wa,nodeTcpConnector:()=>iu,normalizeForwardedHeaders:()=>Wr,normalizeHeaders:()=>ht,normalizePath:()=>wi,normalizeResponse:()=>Xs,normalizeURL:()=>yu,omitQuery:()=>pu,paginate:()=>K,paginateItems:()=>Ln,parseAccept:()=>Fr,parseAcceptEncoding:()=>hs,parseAcceptLanguage:()=>fs,parseAltSvc:()=>_s,parseAuthorization:()=>Ur,parseBody:()=>vt,parseCSP:()=>bs,parseCacheControl:()=>us,parseContentDisposition:()=>as,parseContentLanguage:()=>ya,parseContentRange:()=>ps,parseContentType:()=>$e,parseCookieDate:()=>fr,parseDataURL:()=>Pu,parseDigestChallenge:()=>en,parseForwarded:()=>ms,parseHSTS:()=>ws,parseLinkHeader:()=>jr,parseLinkHeaderNext:()=>In,parseMultipartResponse:()=>fn,parseParams:()=>Y,parseQuery:()=>gi,parseRange:()=>ds,parseRetryAfter:()=>Zt,parseSSEText:()=>ko,parseServerTiming:()=>xs,parseSetCookieHeader:()=>Mt,parseSocks5Url:()=>su,parseUntrustedJSON:()=>$i,parseWWWAuthenticate:()=>Hr,parseWarning:()=>xa,pathMatch:()=>Ot,pathSegments:()=>gu,percentDecode:()=>ie,percentEncode:()=>Hn,perfNow:()=>Xi,pickQuery:()=>du,presignRequest:()=>Ws,readBlob:()=>ln,readBodyWithLimit:()=>on,readBytes:()=>ar,readFormData:()=>no,readJSON:()=>cn,readJSONStream:()=>Zs,readNDJSON:()=>hn,readRawBody:()=>ur,readStream:()=>At,readText:()=>un,redactURL:()=>Hu,relativeURL:()=>Eu,resolveURL:()=>Su,retryLink:()=>No,safeJSONParse:()=>ge,safeParseURL:()=>Fe,sanitizeParsedJSON:()=>D,sanitizeURL:()=>Gi,securityHeaders:()=>Ra,sendWithTimeout:()=>Ct,serializePaginationState:()=>Zo,setRuntime:()=>co,sigV4UriEncode:()=>Fs,signChunk:()=>za,signFinalChunk:()=>qa,signRequest:()=>Yr,signS3PostPolicy:()=>Vs,sleep:()=>Yi,socks5Connector:()=>au,splitSetCookieHeaders:()=>tt,staticCredentials:()=>$a,streamWithProgress:()=>Ci,stringifyQuery:()=>hu,stripHash:()=>Du,stripQuery:()=>Nu,takeItems:()=>Wo,tap:()=>Fc,throttleProgress:()=>Ii,throwOnHTTPError:()=>Vc,toNodeHeaders:()=>Ea,toOTelSpan:()=>bo,toPaginationIterator:()=>ti,toRequestId:()=>Vn,toUint8Array:()=>Zi,tryParseJSON:()=>Ni,uint8ArrayToBase64:()=>re,urlExtension:()=>$u,urlFilename:()=>Uu,validateErrorCode:()=>sa,validateResponse:()=>Jc,withBaseURL:()=>Kc,withBlobUploadProgress:()=>Ai,withDownloadProgress:()=>ki,withTrailingSlash:()=>Ou,withUploadProgress:()=>Qt,withoutTrailingSlash:()=>Mu,xhrFetch:()=>Pi});var J=class{constructor(e,t={}){f(this,"loaded",0);f(this,"total");f(this,"startMs");f(this,"lastMs");f(this,"lastLoaded",0);f(this,"smoothedRate",0);f(this,"smoothing");f(this,"_done",!1);f(this,"lastEmitMs",-1/0);f(this,"minIntervalMs");f(this,"onProgress");this.total=e,this.startMs=Ar(),this.lastMs=this.startMs,this.smoothing=t.smoothingFactor??.3,this.onProgress=t.onProgress??null;let n=t.throttleHz??10;this.minIntervalMs=n>0?1e3/n:0}update(e){this.loaded+=e;let t=this._snapshot();if(this.onProgress){let n=Ar();(this.minIntervalMs===0||n-this.lastEmitMs>=this.minIntervalMs)&&(this.lastEmitMs=n,this.onProgress(t))}return t}complete(){this._done=!0;let e=this._snapshot();return this.onProgress?.(e),e}snapshot(){return this._snapshot()}get bytesLoaded(){return this.loaded}get isDone(){return this._done}_snapshot(){let e=Ar(),t=e-this.startMs,n=e-this.lastMs;if(n>0){let i=(this.loaded-this.lastLoaded)/n*1e3;this.smoothedRate=this.smoothedRate===0?i:this.smoothedRate*(1-this.smoothing)+i*this.smoothing,this.lastMs=e,this.lastLoaded=this.loaded}let s=this.total!==null&&this.total>0?Math.min(100,Math.max(0,this.loaded/this.total*100)):null,o=this.total!==null&&this.smoothedRate>0?Math.max(0,(this.total-this.loaded)/this.smoothedRate*1e3):null;return{loaded:this.loaded,total:this.total,percent:this._done?this.total!==null?100:null:s,rate:this.smoothedRate,eta:this._done?0:o,elapsed:t,done:this._done}}};function Qt(r,e,t={}){let n=new J(e,t);if(!r)return n.complete(),{stream:new ReadableStream({start:l=>l.close()}),tracker:n};let s;if(r instanceof ReadableStream)s=r;else if(typeof r=="string"){let l=new TextEncoder().encode(r);s=new ReadableStream({start(h){h.enqueue(l),h.close()}})}else s=new ReadableStream({start(l){l.enqueue(r),l.close()}});let o=null,i=null,a=!1,c=()=>{i&&(t.signal?.removeEventListener("abort",i),i=null)};return{stream:new ReadableStream({start(l){if(t.signal?.aborted){l.error(new DOMException("Upload aborted","AbortError"));return}o=s.getReader(),i=()=>{if(a)return;a=!0;let h=o;o=null,h?.cancel("aborted").catch(()=>{}),l.error(new DOMException("Upload aborted","AbortError"))},t.signal?.addEventListener("abort",i,{once:!0})},async pull(l){let h=o;if(h)try{let{done:p,value:d}=await h.read();if(p){c(),o===h&&(o=null),h.releaseLock(),a||(n.complete(),l.close());return}n.update(d.byteLength),l.enqueue(d)}catch(p){c(),o===h&&(o=null),a||n.complete(),l.error(p)}},cancel(l){c();let h=o;o=null,h?.cancel(l).catch(()=>{})}}),tracker:n}}function Ai(r,e={}){return Qt(r.stream(),r.size,e)}function ki(r,e={}){let t=r.headers.get("content-length"),n=t?parseInt(t,10):null,s=new J(isNaN(n)?null:n,e);if(!r.body)return s.complete(),{response:r,tracker:s};let o=r.body,i=null,a=!1,c=null,u=()=>{c&&(e.signal?.removeEventListener("abort",c),c=null)},l=new ReadableStream({start(p){if(e.signal?.aborted){a=!0,p.error(new DOMException("Download aborted","AbortError"));return}i=o.getReader(),c=()=>{if(a)return;a=!0;let d=i;i=null,d?.cancel("aborted").catch(()=>{}),p.error(new DOMException("Download aborted","AbortError"))},e.signal?.addEventListener("abort",c,{once:!0})},async pull(p){let d=i;if(d)try{let{done:m,value:g}=await d.read();if(m){u(),i===d&&(i=null),d.releaseLock(),a||s.complete(),p.close();return}s.update(g.byteLength),p.enqueue(g)}catch(m){u(),i===d&&(i=null),a||s.complete(),p.error(m)}},cancel(p){u();let d=i;i=null,d?.cancel(p).catch(()=>{})}}),h=new Response(l,{status:r.status,statusText:r.statusText,headers:r.headers});for(let p of["url","redirected","type"])try{Object.defineProperty(h,p,{value:r[p],enumerable:!0,configurable:!0})}catch{}return{response:h,tracker:s}}async function*Ci(r,e,t={}){let n=new J(e,t),s=r.getReader();try{for(;;){if(t.signal?.aborted)throw new DOMException("Stream aborted","AbortError");let{done:o,value:i}=await s.read();if(o){let c=n.complete();yield{chunk:new Uint8Array(0),progress:c};break}let a=n.update(i.byteLength);yield{chunk:i,progress:a}}}finally{s.releaseLock()}}async function vi(r,e,t={}){let n=new J(e,t),s=[],o=r.getReader();if(t.signal?.aborted)throw o.cancel("aborted").catch(()=>{}),o.releaseLock(),new DOMException("Stream aborted","AbortError");let i=!1,a=()=>{i=!0,o.cancel("aborted").catch(()=>{})};t.signal&&t.signal.addEventListener("abort",a,{once:!0});try{for(;;){let{done:h,value:p}=await o.read();if(h)break;s.push(p),n.update(p.byteLength)}if(i)throw new DOMException("Stream aborted","AbortError")}finally{o.releaseLock(),t.signal?.removeEventListener("abort",a)}n.complete();let c=s.reduce((h,p)=>h+p.byteLength,0),u=new Uint8Array(c),l=0;for(let h of s)u.set(h,l),l+=h.byteLength;return{data:u,tracker:n}}var kr=class{constructor(e,t){f(this,"partCount");f(this,"trackers",new Map);f(this,"totals",new Map);f(this,"onOverall");this.partCount=e,this.onOverall=t??null}createPartTracker(e,t,n={}){let s=this.trackers.get(e);if(s)return s;this.totals.set(e,t);let o=new J(t,{...n,onProgress:i=>{n.onProgress?.(i),this._emit()}});return this.trackers.set(e,o),o}getOverall(){let e=[],t=0,n=0,s=0,o=!0,i=0;for(let h=0;h<this.partCount;h++){let d=this.trackers.get(h)?.snapshot()??{loaded:0,total:this.totals.get(h)??null,percent:0,rate:0,eta:null,elapsed:0,done:!1};e.push(d),t+=d.loaded,d.total!==null&&(n+=d.total),s+=d.rate,d.done||(o=!1),d.elapsed>i&&(i=d.elapsed)}let a=n>0,c=a?Math.max(0,Math.min(100,t/n*100)):null,u=a&&s>0?Math.max(0,(n-t)/s*1e3):null;return{parts:e,overall:{loaded:t,total:a?n:null,percent:c,rate:s,eta:o?0:u,elapsed:i,done:o}}}_emit(){this.onOverall&&this.onOverall(this.getOverall())}},Ti=globalThis.XMLHttpRequest;function Pi(r,e){return new Promise((t,n)=>{if(!Ti){n(new Error("XMLHttpRequest is not available in this runtime. Use fetch() instead."));return}if(e.responseType&&e.responseType!=="text"){n(new TypeError(`xhrFetch: responseType "${e.responseType}" cannot produce a text body. XHRResult.body is a string \u2014 use "text", or omit responseType.`));return}let s=new Ti,o=new J(null,{...e.onUploadProgress!==void 0?{onProgress:e.onUploadProgress}:{},...e.throttleHz!==void 0?{throttleHz:e.throttleHz}:{},...e.smoothingFactor!==void 0?{smoothingFactor:e.smoothingFactor}:{}}),i=new J(null,{...e.onDownloadProgress!==void 0?{onProgress:e.onDownloadProgress}:{},...e.throttleHz!==void 0?{throttleHz:e.throttleHz}:{},...e.smoothingFactor!==void 0?{smoothingFactor:e.smoothingFactor}:{}});s.open(e.method??"GET",r,!0);for(let[u,l]of Object.entries(e.headers??{}))s.setRequestHeader(u,l);e.responseType&&(s.responseType=e.responseType),s.upload&&e.onUploadProgress&&(s.upload.addEventListener("loadstart",u=>{}),s.upload.addEventListener("progress",u=>{o.update(u.loaded-o.bytesLoaded)}),s.upload.addEventListener("load",()=>o.complete())),e.onDownloadProgress&&s.addEventListener("progress",u=>{i.update(u.loaded-i.bytesLoaded)});let a=()=>{s.abort(),n(new DOMException("Request aborted","AbortError"))},c=()=>e.signal?.removeEventListener("abort",a);if(e.signal?.addEventListener("abort",a,{once:!0}),e.signal?.aborted){c(),a();return}s.addEventListener("load",()=>{c(),i.complete();let u=s.getAllResponseHeaders(),l={};for(let h of u.split(/[\r\n]+/)){let p=h.indexOf(":");if(p<=0)continue;let d=h.slice(0,p).trim().toLowerCase();if(d==="")continue;let m=h.slice(p+1).trim();if(d==="__proto__"){Object.defineProperty(l,d,{value:m,writable:!0,enumerable:!0,configurable:!0});continue}l[d]=m}t({status:s.status,statusText:s.statusText,headers:l,body:typeof s.response=="string"?s.response:String(s.response??"")})}),s.addEventListener("error",()=>{c(),n(new TypeError("Network request failed"))}),s.addEventListener("timeout",()=>{c(),n(new TypeError("Request timed out"))}),s.addEventListener("abort",()=>{c(),n(new DOMException("Request aborted","AbortError"))});try{s.send(e.body??null)}catch(u){throw c(),u}})}var Ri=["B","KB","MB","GB","TB"];function Jt(r,e=2){if(Number.isNaN(r))return"NaN B";if(r===1/0)return"\u221E";if(r===-1/0)return"-\u221E";if(r===0)return"0 B";let t=1024,n=Math.max(0,e),s=r<0?"-":"",o=Math.abs(r),i=Math.min(Math.max(0,Math.floor(Math.log(o)/Math.log(t))),Ri.length-1),a=Ri[i];return`${s}${parseFloat((o/Math.pow(t,i)).toFixed(n))} ${a}`}function Bn(r){return`${Jt(r)}/s`}function zn(r){if(!isFinite(r)||r<0)return"\u221E";let e=Math.round(r/1e3),t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=e%60;return t>0?`${t}h ${n}m ${s}s`:n>0?`${n}m ${s}s`:`${s}s`}function Li(r){let e=Jt(r.loaded),t=r.total!==null?` / ${Jt(r.total)}`:"",n=r.percent!==null?` (${r.percent.toFixed(1)}%)`:"",s=r.rate>0?` @ ${Bn(r.rate)}`:"",o=r.eta!==null&&!r.done?` ETA ${zn(r.eta)}`:"";return`${e}${t}${n}${s}${o}`}function Ii(r,e=10){let t=e>0?1e3/e:0,n=-1/0;return s=>{let o=Ar();(s.done||o-n>=t)&&(n=o,r(s))}}function Ar(){return typeof performance<"u"?performance.now():Date.now()}var We=class{constructor(e={}){f(this,"inflight",new Map);f(this,"timeouts",new Map);f(this,"windowMs");f(this,"methods");f(this,"keyFn");f(this,"_globalSignal");f(this,"_hits",0);f(this,"_misses",0);this.windowMs=e.windowMs??0,this.methods=new Set((e.methods??["GET","HEAD"]).map(t=>t.toUpperCase())),this.keyFn=e.keyFn??((t,n)=>`${t}::${n}`),this._globalSignal=e.signal??null}execute(e,t,n,s,o,i){let a=o??this.windowMs,c=i??this._globalSignal;if(c?.aborted)return this._misses++,n();if(!this.methods.has(e.toUpperCase()))return this._misses++,n();let u=e.toUpperCase(),l=this.keyFn(u,t,s),h=this.inflight.get(l);if(h){if(h.resolvedAt===null)return this._hits++,h.promise;if(a>0&&Date.now()-h.resolvedAt<=a)return this._hits++,h.promise;if(a>0)this.inflight.delete(l);else return this._misses++,n()}this._misses++;let p={resolvedAt:null,promise:void 0};return this.inflight.set(l,p),p.promise=(async()=>{let d=c?()=>{this.inflight.delete(l);let m=this.timeouts.get(l);m!==void 0&&(clearTimeout(m),this.timeouts.delete(l))}:null;c&&d&&c.addEventListener("abort",d,{once:!0});try{return await n()}finally{c&&d&&c.removeEventListener("abort",d)}})().then(d=>{if(p.resolvedAt=Date.now(),p.result=d,this.inflight.get(l)!==p)return d;if(a<=0)this.inflight.delete(l);else{let m=this.timeouts.get(l);m!==void 0&&(clearTimeout(m),this.timeouts.delete(l));let g=setTimeout(()=>{this.inflight.delete(l),this.timeouts.delete(l)},a);this.timeouts.set(l,g)}return d},d=>{p.resolvedAt=Date.now(),p.error=d,this.inflight.get(l)===p&&this.inflight.delete(l);let m=this.timeouts.get(l);throw m!==void 0&&(clearTimeout(m),this.timeouts.delete(l)),d}),p.promise}get hits(){return this._hits}get misses(){return this._misses}get inFlightCount(){let e=0;for(let t of this.inflight.values())t.resolvedAt===null&&e++;return e}get keys(){return[...this.inflight.keys()]}getStats(){let e=this._hits+this._misses;return{hits:this._hits,misses:this._misses,totalRequests:e,hitRate:e===0?0:this._hits/e,inFlightCount:this.inFlightCount,trackedKeys:this.inflight.size}}resetMetrics(){this._hits=0,this._misses=0}clear(){this.inflight.clear();for(let e of this.timeouts.values())clearTimeout(e);this.timeouts.clear()}invalidate(e){let t=this.timeouts.get(e);return t&&(clearTimeout(t),this.timeouts.delete(e)),this.inflight.delete(e)}destroy(){this.clear()}};function Oi(r){return new We(r)}var at=class extends Error{constructor(t,n){super(`Circuit breaker ${n.state} for "${t}" \u2014 request rejected`);f(this,"code","ECIRCUITOPEN");f(this,"state");this.name="CircuitOpenError",this.state=n}},ct=class{constructor(e,t={}){f(this,"key");f(this,"failureThreshold");f(this,"windowSize");f(this,"resetTimeoutMs");f(this,"successThreshold");f(this,"halfOpenConcurrency");f(this,"failureFilter");f(this,"cfg");f(this,"_state","CLOSED");f(this,"_window",[]);f(this,"_consecutiveFails",0);f(this,"_consecutiveSucc",0);f(this,"_openedAt",null);f(this,"_halfOpenAt",null);f(this,"_lastFailureAt",null);f(this,"_lastSuccessAt",null);f(this,"_inFlightProbes",0);f(this,"_totalRequests",0);f(this,"_totalFailures",0);f(this,"_totalSuccesses",0);f(this,"_totalRejected",0);this.key=e,this.failureThreshold=t.failureThreshold??5,this.windowSize=t.windowSize??10,this.windowSize>0&&this.windowSize<this.failureThreshold&&(console.warn(`[CircuitBreaker] "${e}": windowSize (${this.windowSize}) is smaller than failureThreshold (${this.failureThreshold}), so the threshold could never be reached and the circuit would never open. Raising windowSize to ${this.failureThreshold}.`),this.windowSize=this.failureThreshold),this.resetTimeoutMs=t.resetTimeoutMs??3e4,this.successThreshold=t.successThreshold??2,this.halfOpenConcurrency=t.halfOpenConcurrency??1,this.failureFilter={networkErrors:t.failures?.networkErrors??!0,timeouts:t.failures?.timeouts??!0,serverErrors:t.failures?.serverErrors??!1,statusCodes:t.failures?.statusCodes??[]},this.cfg=t}get state(){return this._effectiveState()}_effectiveState(){return this._state==="OPEN"&&this._openedAt!==null&&Date.now()-this._openedAt>=this.resetTimeoutMs?"HALF_OPEN":this._state}get snapshot(){let e=this._consecutiveFails;if(this.windowSize>0){e=0;for(let t of this._window)t||e++}return{state:this._effectiveState(),failureCount:e,successCount:this._consecutiveSucc,lastFailureAt:this._lastFailureAt,lastSuccessAt:this._lastSuccessAt,openedAt:this._openedAt,halfOpenAt:this._halfOpenAt,totalRequests:this._totalRequests,totalFailures:this._totalFailures,totalSuccesses:this._totalSuccesses,totalRejected:this._totalRejected,inFlightProbes:this._inFlightProbes}}execute(e){if(this._checkTransition(),this._state==="OPEN"){this._totalRejected++;let n=this.snapshot;return this.cfg.onRejected?.(n),Promise.reject(new at(this.key,n))}let t=!1;if(this._state==="HALF_OPEN"){if(this._inFlightProbes>=this.halfOpenConcurrency){this._totalRejected++;let n=this.snapshot;return this.cfg.onRejected?.(n),Promise.reject(new at(this.key,n))}this._inFlightProbes++,t=!0}return this._totalRequests++,Promise.resolve().then(e).then(n=>(t&&(this._inFlightProbes=Math.max(0,this._inFlightProbes-1)),this._recordSuccess(),n),n=>{throw t&&(this._inFlightProbes=Math.max(0,this._inFlightProbes-1)),this._isCountableFailure(n)&&this._recordFailure(),n})}trip(){this._state!=="OPEN"&&(this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot))}reset(){this._state="CLOSED",this._window=[],this._consecutiveFails=0,this._consecutiveSucc=0,this._openedAt=null,this._halfOpenAt=null,this._inFlightProbes=0,this.cfg.onClose?.(this.snapshot)}_checkTransition(){this._state==="OPEN"&&this._openedAt!==null&&Date.now()-this._openedAt>=this.resetTimeoutMs&&(this._state="HALF_OPEN",this._halfOpenAt=Date.now(),this._consecutiveSucc=0,this._inFlightProbes=0,this.cfg.onHalfOpen?.(this.snapshot))}_recordSuccess(){if(this._lastSuccessAt=Date.now(),this._totalSuccesses++,this._consecutiveFails=0,this._state==="HALF_OPEN"){this._consecutiveSucc++,this._consecutiveSucc>=this.successThreshold&&this.reset();return}this.windowSize>0&&(this._window.push(!0),this._window.length>this.windowSize&&this._window.shift())}_recordFailure(){if(this._lastFailureAt=Date.now(),this._totalFailures++,this._consecutiveSucc=0,this._consecutiveFails++,this._state==="HALF_OPEN"){this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot);return}this.windowSize>0?(this._window.push(!1),this._window.length>this.windowSize&&this._window.shift(),this._window.filter(t=>!t).length>=this.failureThreshold&&(this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot))):this._consecutiveFails>=this.failureThreshold&&(this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot))}_isCountableFailure(e){if(!(e instanceof Error))return!1;let t=e.code;if(this.failureFilter.networkErrors&&t==="ENETWORK"||this.failureFilter.timeouts&&t==="ETIMEOUT")return!0;if(this.failureFilter.serverErrors){let n=e.status;if(n&&n>=500)return!0}if(this.failureFilter.statusCodes&&this.failureFilter.statusCodes.length>0){let n=e.status;if(n&&this.failureFilter.statusCodes.includes(n))return!0}return!1}},Ke=class{constructor(e={}){f(this,"breakers",new Map);f(this,"defaultConfig");this.defaultConfig=e}get(e,t){return this.breakers.has(e)||this.breakers.set(e,new ct(e,{...this.defaultConfig,...t})),this.breakers.get(e)}execute(e,t,n){return this.get(e,n).execute(t)}trip(e){this.get(e).trip()}reset(e){this.get(e).reset()}snapshots(){let e={};for(let[t,n]of this.breakers)e[t]=n.snapshot;return e}delete(e){this.breakers.delete(e)}clear(){this.breakers.clear()}get size(){return this.breakers.size}};function Mi(r,e){return new ct(r,e)}function Di(r){return new Ke(r)}q();var Q=class extends Error{constructor(t,n){super(t,n!=null?{cause:n}:void 0);f(this,"code","EWSCONNECT");f(this,"originalCause");this.name="WSError",this.originalCause=n}},Yt=class extends Error{constructor(t){super(`WebSocket gave up after ${t} reconnect attempts`);f(this,"attempts");f(this,"code","EWSMAXRECONNECTS");this.attempts=t,this.name="WSMaxReconnectsError"}},ft=class extends Error{constructor(t,n){super(`WebSocket connect to ${t} timed out after ${n}ms`);f(this,"code","EWSCONNECTTIMEOUT");this.name="WSConnectTimeoutError"}},Or=class extends Error{constructor(t){super(`WebSocket send rate limited; retry in ${t}ms`);f(this,"delayMs");f(this,"code","EWSRATELIMIT");this.delayMs=t,this.name="WSRateLimitError"}},Je=class{constructor(e){f(this,"_url");f(this,"_protocols");f(this,"_headers");f(this,"_maxReconnects");f(this,"_reconnectBaseMs");f(this,"_reconnectMaxMs");f(this,"_reconnectJitter");f(this,"_pingIntervalMs");f(this,"_pingPayload");f(this,"_pongMatcher");f(this,"_pongTimeoutMs");f(this,"_connectTimeoutMs");f(this,"_bufferMessages");f(this,"_maxBufferSize");f(this,"_cbOpen");f(this,"_cbMessage");f(this,"_cbClose");f(this,"_cbError");f(this,"_cbReconnect");f(this,"_cbGiveUp");f(this,"_ws",null);f(this,"_state","CLOSED");f(this,"_reconnAttempt",0);f(this,"_buffer",[]);f(this,"_pingTimer",null);f(this,"_pongTimer",null);f(this,"_reconnTimer",null);f(this,"_msgListeners",[]);f(this,"_closeListeners",[]);f(this,"_openWaiters",[]);f(this,"_correlations",new Map);f(this,"_aborted",!1);f(this,"_externalSignal",null);f(this,"_onExternalAbort",()=>this.close(1e3,"AbortSignal aborted"));f(this,"_iterQueue",[]);f(this,"_iterWaiter",null);f(this,"_iterDone",!1);f(this,"_rooms",[]);f(this,"_keepRooms");f(this,"_highWaterMark");f(this,"_lowWaterMark");f(this,"_bufferedBytes",0);f(this,"_drainWaiters",[]);f(this,"_cbBackpressure");f(this,"_wasBackpressured",!1);f(this,"_maxSendRate");f(this,"_tokens",0);f(this,"_lastToken",0);f(this,"_serverEndpoint",null);f(this,"_mx",{messagesSent:0,messagesReceived:0,bytesSent:0,bytesReceived:0,reconnectCount:0,totalConnectAttempts:0,connectedAt:null,closedAt:null,uptimeMs:0});f(this,"_openedAt",null);if(this._url=e.url,this._protocols=e.protocols,this._headers=e.headers,this._maxReconnects=e.maxReconnects??10,this._reconnectBaseMs=e.reconnectBaseMs??1e3,this._reconnectMaxMs=e.reconnectMaxMs??3e4,this._reconnectJitter=e.reconnectJitter??.3,this._pingIntervalMs=e.pingIntervalMs??3e4,this._pingPayload=e.pingPayload??"ping",this._pongMatcher=e.pongMatcher,this._pongTimeoutMs=e.pongTimeoutMs??1e4,this._connectTimeoutMs=e.connectTimeoutMs??3e4,this._bufferMessages=e.bufferMessages??!0,this._maxBufferSize=e.maxBufferSize??100,this._cbOpen=e.onOpen,this._cbMessage=e.onMessage,this._cbClose=e.onClose,this._cbError=e.onError,this._cbReconnect=e.onReconnect,this._cbGiveUp=e.onGiveUp,this._cbBackpressure=e.onBackpressure,this._highWaterMark=e.highWaterMark??65536,this._lowWaterMark=e.lowWaterMark??16384,this._maxSendRate=e.maxSendRate??0,this._keepRooms=e.keepRooms??!0,e.rooms&&e.rooms.length>0)for(let t of e.rooms)this._rooms.push({room:t,joinedAt:0});this._externalSignal=e.signal??null,this._externalSignal?.addEventListener("abort",this._onExternalAbort,{once:!0})}get state(){return this._state}get connected(){return this._state==="OPEN"}get bufferedCount(){return this._buffer.length}get metrics(){return{...this._mx,uptimeMs:this._mx.uptimeMs+(this._openedAt!=null?Date.now()-this._openedAt:0)}}connect(){return this._state==="OPEN"?Promise.resolve():this._state==="CONNECTING"||this._state==="RECONNECTING"?new Promise((e,t)=>this._openWaiters.push({resolve:e,reject:t})):this._doConnect(!1)}waitForOpen(e=6e4){return this._state==="OPEN"?Promise.resolve():new Promise((t,n)=>{let s={resolve:()=>{o&&clearTimeout(o),t()},reject:i=>{o&&clearTimeout(o),n(i)}},o=e>0?setTimeout(()=>{let i=this._openWaiters.indexOf(s);i!==-1&&this._openWaiters.splice(i,1),n(new ft(this._url,e))},e):null;this._openWaiters.push(s)})}close(e=1e3,t="Client closed"){this._aborted=!0,this._externalSignal?.removeEventListener("abort",this._onExternalAbort),this._externalSignal=null,this._stopAll();for(let s of this._drainWaiters.splice(0))s();this._state="CLOSING";let n=this._ws;if(n){if(n.onopen=n.onmessage=n.onerror=n.onclose=null,n.readyState<2)try{n.close(e,t)}catch{}this._ws=null}this._buffer=[],this._bufferedBytes=0,this._iterQueue=[],this._iterDone=!0,this._iterWaiter&&(this._iterWaiter({done:!0,value:void 0}),this._iterWaiter=null);for(let s of this._openWaiters.splice(0))s.reject(new Error("Client closed"));this._rooms=[];for(let s of this._correlations.values())s.timer&&clearTimeout(s.timer),s.reject(new Error("Client closed"));this._correlations.clear(),this._openedAt!=null&&(this._mx.uptimeMs+=Date.now()-this._openedAt,this._openedAt=null),this._mx.closedAt=Date.now(),this._state="CLOSED";for(let s of this._closeListeners)try{s({code:e,reason:t})}catch{}this._closeListeners=[],this._msgListeners=[],this._cbClose?.(e,t,!1)}destroy(){this._aborted=!0,this._stopAll();for(let t of this._drainWaiters.splice(0))t();this._state="CLOSING";let e=this._ws;if(e){if(e.onopen=e.onmessage=e.onerror=e.onclose=null,e.readyState<2)try{e.close(1e3,"Destroyed")}catch{}this._ws=null}this._buffer=[],this._bufferedBytes=0,this._iterQueue=[],this._iterDone=!0,this._iterWaiter&&(this._iterWaiter({done:!0,value:void 0}),this._iterWaiter=null),this._msgListeners=[];for(let t of this._openWaiters.splice(0))t.reject(new Error("Client destroyed"));this._rooms=[];for(let t of this._correlations.values())t.timer&&clearTimeout(t.timer),t.reject(new Error("Client destroyed"));this._correlations.clear(),this._openedAt!=null&&(this._mx.uptimeMs+=Date.now()-this._openedAt,this._openedAt=null),this._mx.closedAt=Date.now(),this._state="CLOSED";for(let t of this._closeListeners)try{t({code:1e3,reason:"Destroyed"})}catch{}this._closeListeners=[],this._cbClose?.(1e3,"Destroyed",!1)}send(e){this._tx(e)&&this._mx.messagesSent++}sendBinary(e){let t=e instanceof Uint8Array?e.slice().buffer:e;this._tx(t)&&this._mx.messagesSent++}sendJSON(e){this.send(JSON.stringify(e))}request(e,t,n=o=>o.json??o.data,s=1e4){return new Promise((o,i)=>{let a=`${Date.now()}-${Math.random()}`,c=s>0?setTimeout(()=>{let u=this._correlations.get(a);u?.timer&&clearTimeout(u.timer),this._correlations.delete(a),i(new Q(`request() timed out after ${s}ms waiting for reply`))},s):null;this._correlations.set(a,{matcher:t,extract:n,resolve:o,reject:i,timer:c}),typeof e=="string"?this.send(e):this.sendJSON(e)})}onMessage(e){return this._msgListeners.push(e),()=>{let t=this._msgListeners.indexOf(e);t!==-1&&this._msgListeners.splice(t,1)}}onClose(e){return this._closeListeners.push(e),()=>{let t=this._closeListeners.indexOf(e);t!==-1&&this._closeListeners.splice(t,1)}}drainBuffer(){let e=this._buffer.splice(0);return this._bufferedBytes=0,this._updateBackpressure(),e}join(e,t){this._rooms.some(n=>n.room===e&&n.namespace===t)||(this._rooms.push({room:e,namespace:t,joinedAt:Date.now()}),this.sendJSON({type:"room:join",room:e,namespace:t??null}))}leave(e,t){let n=this._rooms.findIndex(s=>s.room===e&&s.namespace===t);n!==-1&&(this._rooms.splice(n,1),this.sendJSON({type:"room:leave",room:e,namespace:t??null}))}get rooms(){return this._rooms}get backpressure(){return{bufferedBytes:this._bufferedBytes,highWaterMark:this._highWaterMark,lowWaterMark:this._lowWaterMark,isBackpressured:this._bufferedBytes>=this._highWaterMark}}drain(e=3e4){return this._state==="CLOSED"?Promise.reject(new Q("Cannot drain \u2014 socket is CLOSED")):this._bufferedBytes<this._lowWaterMark?Promise.resolve():new Promise((t,n)=>{let s=e>0?setTimeout(()=>n(new Q(`drain() timed out after ${e}ms`)),e):null;this._drainWaiters.push(()=>{s&&clearTimeout(s),t()})})}async drainAndClose(e=3e4){if(this._state!=="CLOSED"){try{await this.drain(e)}catch{}this.close(1e3,"Graceful shutdown")}}get serverEndpoint(){return this._serverEndpoint}[Symbol.asyncIterator](){return{next:()=>this._iterQueue.length>0?Promise.resolve({done:!1,value:this._iterQueue.shift()}):this._iterDone?Promise.resolve({done:!0,value:void 0}):new Promise(e=>{this._iterWaiter=e}),return:()=>(this.close(1e3,"Iterator returned"),Promise.resolve({done:!0,value:void 0}))}}_doConnect(e){return this._mx.totalConnectAttempts++,this._state="CONNECTING",new Promise((t,n)=>{let s=!1,o=null;this._connectTimeoutMs>0&&(o=setTimeout(()=>{if(s)return;s=!0;let l=new ft(this._url,this._connectTimeoutMs);n(l),this._cbError?.(l);let h=this._ws;if(h&&(h.onopen=h.onmessage=h.onerror=h.onclose=null,h.close(),this._ws=null),!this._aborted&&this._canRecon())this._scheduleRecon();else{this._state="CLOSED";for(let p of this._openWaiters.splice(0))p.reject(l);this._rejectCorrelations("Connection timeout")}},this._connectTimeoutMs));let i=()=>{o&&(clearTimeout(o),o=null)},a=this._url,c=(()=>{try{let l=globalThis;if(typeof globalThis.Deno<"u"||typeof globalThis.Bun<"u"||l.process?.versions?.node||typeof window>"u")return!1;let h=window;return typeof h.navigator<"u"&&typeof h.document<"u"}catch{return!1}})();if(this._headers&&c){let l=new URL(a);for(let[h,p]of Object.entries(this._headers))l.searchParams.set(h,p);a=l.href}let u;try{u=this._protocols?new WebSocket(a,this._protocols):new WebSocket(a)}catch(l){i(),this._state="CLOSED",n(new Q("Failed to construct WebSocket",l instanceof Error?l:void 0));return}if(this._headers&&!c){let l=u;if(typeof l.setHeader=="function")for(let[h,p]of Object.entries(this._headers))l.setHeader(h,p)}this._ws=u,u.binaryType="arraybuffer",u.onopen=()=>{if(i(),!s){if(s=!0,this._state="OPEN",this._openedAt=Date.now(),this._mx.connectedAt=this._openedAt,e&&this._mx.reconnectCount++,this._serverEndpoint=u.url??this._url,this._reconnAttempt=0,this._rooms.length>0&&this._keepRooms)for(let l of this._rooms)try{u.send(JSON.stringify({type:"room:join",room:l.room,namespace:l.namespace??null}))}catch{}this._startPing(),this._flushBuf(),this._cbOpen?.(this._mx.reconnectCount),t();for(let l of this._openWaiters.splice(0))l.resolve()}},u.onmessage=async l=>{if(this._aborted)return;let h,p,d;if(typeof l.data=="string"){h=l.data,d=new TextEncoder().encode(h).byteLength;try{p=D(JSON.parse(h))}catch{}}else if(l.data instanceof ArrayBuffer)h=new Uint8Array(l.data),d=h.byteLength;else if(typeof Blob<"u"&&l.data instanceof Blob){let g=await l.data.arrayBuffer();h=new Uint8Array(g),d=h.byteLength}else h=new Uint8Array(l.data),d=h.byteLength;this._mx.messagesReceived++,this._mx.bytesReceived+=d;let m={data:h,json:p,timestamp:Date.now()};if(this._pongMatcher&&typeof h=="string"&&(typeof this._pongMatcher=="string"?h===this._pongMatcher:this._pongMatcher.test(h))){this._pongTimer&&(clearTimeout(this._pongTimer),this._pongTimer=null);return}for(let[g,y]of this._correlations)if(y.matcher(m)){this._correlations.delete(g),y.timer&&clearTimeout(y.timer);try{y.resolve(y.extract(m))}catch(w){y.reject(w)}return}for(let g of this._msgListeners)try{g(m)}catch{}if(this._cbMessage?.(m),this._iterWaiter){let g=this._iterWaiter;this._iterWaiter=null,g({done:!1,value:m})}else this._iterQueue.length>=this._maxBufferSize&&this._iterQueue.shift(),this._iterQueue.push(m)},u.onerror=l=>{this._cbError?.(new Q(l.message??"WebSocket error",l.error))},u.onclose=l=>{i(),this._stopPing(),this._openedAt!=null&&(this._mx.uptimeMs+=Date.now()-this._openedAt,this._openedAt=null),this._mx.closedAt=Date.now();for(let p of this._closeListeners)try{p({code:l.code,reason:l.reason})}catch{}if(s||(s=!0,n(new Q(`Socket closed before open (code ${l.code}: ${l.reason})`))),this._aborted||l.code===1e3||l.code===1001){this._state="CLOSED",this._cbClose?.(l.code,l.reason,!1),this._terminateIter();for(let p of this._openWaiters.splice(0))p.reject(new Q(`Socket closed (code ${l.code})`));this._rejectCorrelations(`Socket closed (code ${l.code})`);return}let h=this._canRecon();if(this._cbClose?.(l.code,l.reason,h),h)this._scheduleRecon();else{this._cbGiveUp?.(this._reconnAttempt),this._state="CLOSED",this._terminateIter();let p=new Yt(this._reconnAttempt);for(let d of this._openWaiters.splice(0))d.reject(p);this._rejectCorrelations("Max reconnects exceeded")}}})}_canRecon(){return this._maxReconnects===0||this._reconnAttempt<this._maxReconnects}_scheduleRecon(){this._reconnTimer&&(clearTimeout(this._reconnTimer),this._reconnTimer=null),this._state="RECONNECTING",this._reconnAttempt++;let e=this._reconnectBaseMs*Math.pow(2,this._reconnAttempt-1),t=Math.min(e,this._reconnectMaxMs),n=Math.floor(t*(1+this._reconnectJitter*Math.random()));this._cbReconnect?.(this._reconnAttempt,n),this._reconnTimer=setTimeout(()=>{this._reconnTimer=null,this._aborted||this._doConnect(!0).catch(()=>{})},n)}_tx(e){let t=this._ws,n=typeof e=="string"?new TextEncoder().encode(e).byteLength:e.byteLength;if(this._maxSendRate>0){let s=Date.now();this._lastToken===0&&(this._lastToken=s,this._tokens=this._maxSendRate);let o=s-this._lastToken;if(this._tokens=Math.min(this._maxSendRate,this._tokens+o*this._maxSendRate/1e3),this._lastToken=s,this._tokens<1)return this._bufferMessage(e,n),!1;this._tokens--}if(this._bufferedBytes>=this._highWaterMark)return this._bufferMessage(e,n),!1;if(t&&t.readyState===1)try{return t.send(e),this._mx.bytesSent+=n,!0}catch(s){if(this._cbError?.(new Q(`WebSocket send failed: ${s instanceof Error?s.message:String(s)}`,s)),t.readyState===1)try{t.close(4001,"Send error")}catch{}return this._ws=null,!this._aborted&&this._canRecon()&&this._scheduleRecon(),!1}return this._bufferMessage(e,n),!1}_bufferMessage(e,t){if(this._bufferMessages&&!this._aborted){let n=this._buffer.length>=this._maxBufferSize?this._buffer.shift():void 0;n!==void 0&&(this._bufferedBytes-=typeof n=="string"?new TextEncoder().encode(n).byteLength:n.byteLength),this._buffer.push(e),this._bufferedBytes+=t,this._updateBackpressure()}}_flushBuf(){let e=this._buffer.splice(0);for(let t of e)try{this._ws?.send(t),this._mx.messagesSent++,this._mx.bytesSent+=typeof t=="string"?new TextEncoder().encode(t).byteLength:t.byteLength}catch{}this._bufferedBytes=0,this._updateBackpressure()}_updateBackpressure(){let e=this._bufferedBytes>=this._highWaterMark;if(e!==this._wasBackpressured&&(this._wasBackpressured=e,this._cbBackpressure?.(e,this.backpressure)),!e&&this._bufferedBytes<this._lowWaterMark&&this._drainWaiters.length>0)for(let t of this._drainWaiters.splice(0))t()}_startPing(){this._pingIntervalMs<=0||(this._pingTimer=setInterval(()=>{let e=this._ws;if(!(!e||e.readyState!==1)){try{e.send(this._pingPayload),this._mx.messagesSent++,this._mx.bytesSent+=new TextEncoder().encode(this._pingPayload).byteLength}catch{}this._pongMatcher&&this._pongTimeoutMs>0&&(this._pongTimer&&clearTimeout(this._pongTimer),this._pongTimer=setTimeout(()=>{this._pongTimer=null;let t=this._ws;t&&(t.onopen=t.onmessage=t.onerror=t.onclose=null,t.close(4e3,"Pong timeout"),this._ws=null),!this._aborted&&this._canRecon()?(this._cbClose?.(4e3,"Pong timeout",!0),this._scheduleRecon()):this._state="CLOSED"},this._pongTimeoutMs),typeof this._pongTimer=="object"&&this._pongTimer!==null&&"unref"in this._pongTimer&&this._pongTimer.unref())}},this._pingIntervalMs),typeof this._pingTimer=="object"&&this._pingTimer!==null&&"unref"in this._pingTimer&&this._pingTimer.unref())}_stopPing(){this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pongTimer&&(clearTimeout(this._pongTimer),this._pongTimer=null)}_stopAll(){this._stopPing(),this._reconnTimer&&(clearTimeout(this._reconnTimer),this._reconnTimer=null)}_terminateIter(){this._iterDone=!0,this._iterWaiter&&(this._iterWaiter({done:!0,value:void 0}),this._iterWaiter=null)}_rejectCorrelations(e){for(let t of this._correlations.values())t.timer&&clearTimeout(t.timer),t.reject(new Q(e));this._correlations.clear()}};async function na(r){let e=new Je(r);return await e.connect(),e}we();q();bt();bt();we();Oe();var Tl=0;function Ss(){return`interceptor_${++Tl}`}function Es(r,e){let t=r.findIndex(n=>n.priority>e.priority);t===-1?r.push(e):r.splice(t,0,e)}var er=class{constructor(){f(this,"requestInterceptors",[]);f(this,"responseInterceptors",[]);f(this,"errorInterceptors",[])}useRequest(e,t={}){let n=t.id??Ss();return Es(this.requestInterceptors,{id:n,priority:t.priority??0,once:t.once??!1,condition:t.condition??null,fn:e}),n}useResponse(e,t={}){let n=t.id??Ss();return Es(this.responseInterceptors,{id:n,priority:t.priority??0,once:t.once??!1,condition:t.condition??null,fn:e}),n}useError(e,t={}){let n=t.id??Ss();return Es(this.errorInterceptors,{id:n,priority:t.priority??0,once:t.once??!1,condition:t.condition??null,fn:e}),n}use(e,t,n={}){let s=e?this.useRequest(e,n):null,o=t?this.useResponse(t,n):null;return{requestId:s,responseId:o}}eject(e){let t=this.requestInterceptors.length+this.responseInterceptors.length+this.errorInterceptors.length;return this.requestInterceptors=this.requestInterceptors.filter(s=>s.id!==e),this.responseInterceptors=this.responseInterceptors.filter(s=>s.id!==e),this.errorInterceptors=this.errorInterceptors.filter(s=>s.id!==e),this.requestInterceptors.length+this.responseInterceptors.length+this.errorInterceptors.length<t}ejectAll(){this.requestInterceptors=[],this.responseInterceptors=[],this.errorInterceptors=[]}has(e){return this.requestInterceptors.some(t=>t.id===e)||this.responseInterceptors.some(t=>t.id===e)||this.errorInterceptors.some(t=>t.id===e)}get requestCount(){return this.requestInterceptors.length}get responseCount(){return this.responseInterceptors.length}get errorCount(){return this.errorInterceptors.length}async execute(e,t){let n={request:e,response:null,error:null,startedAt:ne(),attempt:0,aborted:!1,store:new Map};return await this._run(n,t)}async _run(e,t){e.attempt++;let n=new Set;for(let s of this.requestInterceptors){if(e.aborted)break;if(s.condition&&!s.condition(e))continue;let o;try{o=await s.fn(e)}catch(i){e.error=i;for(let a of n)this.eject(a);return this._runErrorPhase(e,t)}if(s.once&&n.add(s.id),o!=null){if(Ts(o)){e.response=o;for(let i of n)this.eject(i);return this._runResponsePhase(e,t)}La(o)&&(e.request=o)}}for(let s of n)this.eject(s);try{e.response=await t(e.request)}catch(s){return e.error=s,this._runErrorPhase(e,t)}return this._runResponsePhase(e,t)}async _runResponsePhase(e,t){let n=new Set;for(let s of this.responseInterceptors){if(e.aborted)break;if(s.condition&&!s.condition(e))continue;let o;try{o=await s.fn(e)}catch(i){e.error=i;for(let a of n)this.eject(a);return this._runErrorPhase(e,t)}if(s.once&&n.add(s.id),o!=null){if(La(o)){e.request=o,e.response=null,e.error=null;for(let i of n)this.eject(i);return this._run(e,t)}Ts(o)&&(e.response=o)}}for(let s of n)this.eject(s);if(!e.response)throw new Error("Pipeline produced no response");return e.response}async _runErrorPhase(e,t){let n=new Set;for(let s of this.errorInterceptors){if(s.condition&&!s.condition(e))continue;let o;try{o=await s.fn(e)}catch(i){if(i.__retrySignal){for(let a of n)this.eject(a);return e.error=null,e.response=null,this._run(e,t)}e.error=i;continue}if(s.once&&n.add(s.id),o!=null&&Ts(o)){e.response=o,e.error=null;for(let i of n)this.eject(i);return this._runResponsePhase(e,t)}}for(let s of n)this.eject(s);throw e.error}};function Ts(r){return r!==null&&typeof r=="object"&&typeof r.status=="number"&&"headers"in r&&"request"in r}function La(r){return r!==null&&typeof r=="object"&&typeof r.url=="string"&&typeof r.method=="string"&&!("status"in r)}var Rl={maxRetries:3,baseDelayMs:300,maxDelayMs:3e4,jitter:.3,retryStatuses:[408,429,500,502,503,504],retryOnError:!0,retryMethods:["GET","HEAD","PUT","DELETE","OPTIONS","TRACE","POST"],shouldRetry:null,onRetry:null};function Ps(r={}){let e={...Rl,...r};function t(a,c){if(c!==null)return Math.min(c,e.maxDelayMs);let u=e.baseDelayMs*Math.pow(2,a-1),l=Math.min(u,e.maxDelayMs),h=l*e.jitter*Math.random();return Math.min(Math.floor(l+h),e.maxDelayMs)}function n(a){return a.attempt>e.maxRetries||!e.retryMethods.includes(a.request.method.toUpperCase())?!1:e.shouldRetry?e.shouldRetry(a):a.error?e.retryOnError:a.response?e.retryStatuses.includes(a.response.status):!1}function s(a){let c=a.response?.headers["retry-after"]??a.response?.headers["Retry-After"];if(!c)return null;if(/^\d+$/.test(c.trim()))return parseInt(c,10)*1e3;let u=ys(c);return u!==null?Math.max(0,u-Date.now()):null}return{responseInterceptor:async a=>{if(!n(a))return;let c=t(a.attempt,s(a));return e.onRetry?.(a,c),await Da(c),{...a.request}},errorInterceptor:async a=>{if(!n(a))return;let c=t(a.attempt,null);throw e.onRetry?.(a,c),await Da(c),a.error=null,new Cs(a.request)}}}var Cs=class{constructor(e){f(this,"request");f(this,"__retrySignal",!0);this.request=e}},Al={getToken:()=>null,refreshToken:null,headerName:"authorization",scheme:"Bearer ",refreshOnStatuses:[401],maxQueue:50,refreshRetryDelay:3e4};function Ls(r){let e={...Al,...r},t=null,n=[],s=null,o=e.refreshRetryDelay??3e4;async function i(){if(s!==null){let u=Date.now()-s;if(u<o)throw new Error(`Auth refresh circuit breaker: last failure ${Math.round(u/1e3)}s ago, retry after ${Math.round((o-u)/1e3)}s`)}if(t){if(n.length>=e.maxQueue)throw new Error("Auth refresh queue full");return await new Promise((u,l)=>n.push({resolve:u,reject:l}))}return e.refreshToken?(t=e.refreshToken().then(u=>{for(let l of n)l.resolve(u);return n.length=0,t=null,s=null,u},u=>{for(let l of n)l.reject(u);throw n.length=0,t=null,s=Date.now(),u}),t):null}return{requestInterceptor:async u=>{let l=await e.getToken();l&&(u.request.headers[e.headerName]=`${e.scheme}${l}`)},responseInterceptor:async u=>{if(!u.response||!e.refreshOnStatuses.includes(u.response.status)||!e.refreshToken||u.request.meta.__authRetried)return;let l=await i();return l?{...u.request,headers:{...u.request.headers,[e.headerName]:`${e.scheme}${l}`},meta:{...u.request.meta,__authRetried:!0}}:void 0}}}var kl={timeoutMs:3e4,methodTimeouts:{},message:"Request timed out"};function Is(r={}){let e={...kl,...r},t=i=>{let a=e.methodTimeouts[i.request.method.toUpperCase()]??e.timeoutMs;if(a<=0)return;let c=new AbortController,u=setTimeout(()=>{i.aborted=!0,c.abort(new vs(e.message,a))},a),l=i.request.signal;if(l){let h=()=>{clearTimeout(u),c.abort(l.reason)};l.addEventListener("abort",h,{once:!0}),i.store.set(As,{existing:l,onExistingAbort:h})}i.request={...i.request,signal:c.signal},i.store.set(Rs,u)},n=i=>{let a=i.store.get(Rs);a&&(clearTimeout(a),i.store.delete(Rs));let c=i.store.get(As);c&&(c.existing.removeEventListener("abort",c.onExistingAbort),i.store.delete(As))};return{id:"timeout",requestInterceptor:t,responseInterceptor:i=>{n(i)},errorInterceptor:i=>{n(i)}}}var Rs=Symbol("timeoutTimer"),As=Symbol("timeoutSignal"),vs=class extends Error{constructor(t,n){super(t);f(this,"timeoutMs");f(this,"code","ETIMEDOUT");this.timeoutMs=n,this.name="TimeoutError"}},Cl={logger:r=>console.log(JSON.stringify(r)),redactHeaders:["authorization","cookie","set-cookie","proxy-authorization"],logRequests:!0,logResponses:!0,logErrors:!0},Ia=Symbol("requestId"),vl=0;function Os(r={}){let e={...Cl,...r},t=new Set(e.redactHeaders.map(c=>c.toLowerCase()));function n(c){let u={};for(let[l,h]of Object.entries(c))u[l]=t.has(l.toLowerCase())?"**REDACTED**":h;return u}function s(c,u){let l=u.store.get(Ia)??"unknown";return{type:c,timestamp:Date.now(),requestId:l,method:u.request.method,url:u.request.url,status:u.response?.status??null,durationMs:c!=="request"?ne()-u.startedAt:null,attempt:u.attempt,error:u.error instanceof Error?u.error.message:null,headers:n(u.request.headers??{})}}return{requestInterceptor:c=>{let u=`req_${++vl}`;c.store.set(Ia,u),e.logRequests&&e.logger(s("request",c))},responseInterceptor:c=>{e.logResponses&&e.logger(s("response",c))},errorInterceptor:c=>{e.logErrors&&e.logger(s("error",c))}}}var Pl={maxEntries:500,defaultTtlMs:6e4,cacheMethods:["GET","HEAD"],cacheKey:null,honorCacheControl:!0};function Ms(r={}){let e={...Pl,...r},t=new Map,n=[];function s(u){return e.cacheKey?e.cacheKey(u):`${u.method}:${u.url}`}function o(u){let l=n.indexOf(u);for(l!==-1&&n.splice(l,1),n.unshift(u);n.length>e.maxEntries;){let h=n.pop();t.delete(h)}}function i(u){let l=u.headers["cache-control"]??u.headers["Cache-Control"]??"",h=l.match(/max-age=(\d+)/)?.[1],p=l.match(/stale-while-revalidate=(\d+)/)?.[1],d=/no-store/i.test(l),m=/no-cache/i.test(l);if(e.honorCacheControl&&(d||m))return{ttlMs:0,swrMs:0};let g=h?parseInt(h,10)*1e3:e.defaultTtlMs,y=p?parseInt(p,10)*1e3:0;return{ttlMs:g,swrMs:y}}return{requestInterceptor:u=>{if(!e.cacheMethods.includes(u.request.method.toUpperCase()))return;let l=s(u.request),h=t.get(l);if(!h)return;let p=ne();if(h.expiresAt>p)return o(l),u.store.set(Ll,!0),{...h.response,request:u.request};h.staleUntil>p&&(o(l),u.store.set(Oa,h),h.etag?u.request={...u.request,headers:{...u.request.headers,"if-none-match":h.etag}}:h.lastModified&&(u.request={...u.request,headers:{...u.request.headers,"if-modified-since":h.lastModified}}))},responseInterceptor:u=>{if(!u.response||!e.cacheMethods.includes(u.request.method.toUpperCase()))return;let l=s(u.request);if(u.response.status===304){let g=u.store.get(Oa);if(g){let{ttlMs:y,swrMs:w}=i(g.response),_=ne(),b={...g,createdAt:_,expiresAt:_+y,staleUntil:_+y+w};t.set(l,b),o(l),u.response={...g.response,request:u.request};return}}let{ttlMs:h,swrMs:p}=i(u.response);if(h<=0)return;let d=ne(),m={response:u.response,createdAt:d,expiresAt:d+h,staleUntil:d+h+p,etag:u.response.headers.etag??u.response.headers.ETag??null,lastModified:u.response.headers["last-modified"]??null};t.set(l,m),o(l)},store:t}}var Ll=Symbol("cacheHit"),Oa=Symbol("cacheStale");function Ds(){let r=new Map;async function e(o){let i=await be(o.headers??{});return`${o.method.toUpperCase()}:${o.url}${i?":"+i:""}`}return{requestInterceptor:async o=>{if(o.request.method.toUpperCase()!=="GET"&&o.request.method.toUpperCase()!=="HEAD")return;let i=await e(o.request);o.store.set(ks,i);let a=r.get(i);if(!a){r.set(i,{promise:void 0,waiters:[]});return}return new Promise((c,u)=>{let l=o.request.signal,h={resolve:d=>c(d),reject:d=>u(d),cleanup:()=>l?.removeEventListener("abort",p)},p=()=>{let d=a.waiters.indexOf(h);d!==-1&&a.waiters.splice(d,1),u(new Error("Request aborted while queued for deduplication"))};if(l?.aborted){p();return}l?.addEventListener("abort",p,{once:!0}),a.waiters.push(h)})},responseInterceptor:o=>{if(!o.response)return;let i=o.store.get(ks);if(!i)return;let a=r.get(i);if(a){r.delete(i);for(let c of a.waiters.splice(0))c.cleanup(),c.resolve(o.response)}},errorInterceptor:o=>{let i=o.store.get(ks);if(!i)return;let a=r.get(i);if(a){r.delete(i);for(let c of a.waiters.splice(0))c.cleanup(),c.reject(o.error)}}}}var ks=Symbol("dedupeKey"),Il={limit:60,windowMs:6e4,queue:!0,maxQueue:100};function tr(r={}){let e={...Il,...r};if(!Number.isFinite(e.limit)||e.limit<1)throw new RangeError(`rateLimit.limit must be a finite number >= 1, got ${e.limit}`);if(!Number.isFinite(e.windowMs)||e.windowMs<1)throw new RangeError(`rateLimit.windowMs must be a finite number >= 1, got ${e.windowMs}`);if(!Number.isFinite(e.maxQueue)||e.maxQueue<0)throw new RangeError(`rateLimit.maxQueue must be a finite number >= 0, got ${e.maxQueue}`);let t=e.limit,n=ne(),s=[],o=null;function i(){let u=ne(),l=(u-n)/e.windowMs;t=Math.min(e.limit,t+l*e.limit),n=u}function a(){o===null&&(o=setInterval(()=>{for(i();t>=1&&s.length>0;)t--,s.shift()();s.length===0&&o!==null&&(clearInterval(o),o=null)},Math.ceil(e.windowMs/e.limit)),typeof o=="object"&&o!==null&&"unref"in o&&o.unref())}async function c(){if(i(),t>=1){t--;return}if(!e.queue)throw new _t("Rate limit exceeded");if(s.length>=e.maxQueue)throw new _t("Rate limit queue full");await new Promise(u=>{s.push(()=>u()),a()})}return async()=>{await c()}}var _t=class extends Error{constructor(t){super(t);f(this,"code","ERATELIMIT");this.name="RateLimitError"}},Ns={maxConcurrent:10,queue:!0,maxQueue:100},Xe=class extends Error{constructor(t){super(t);f(this,"code","ECONCURRENCY");this.name="ConcurrencyLimitError"}};function Ma(r){r.onAbort&&r.signal&&r.signal.removeEventListener("abort",r.onAbort),r.onAbort=null,r.signal=null}var St=class{constructor(e={}){f(this,"cfg");f(this,"active",0);f(this,"peak",0);f(this,"waiters",[]);if(this.cfg={...Ns,...e},!Number.isFinite(this.cfg.maxConcurrent)||this.cfg.maxConcurrent<1)throw new RangeError(`concurrencyLimit.maxConcurrent must be a finite number >= 1, received ${String(this.cfg.maxConcurrent)}`);if(this.cfg.maxQueue!==Number.POSITIVE_INFINITY&&(!Number.isInteger(this.cfg.maxQueue)||this.cfg.maxQueue<0))throw new RangeError(`concurrencyLimit.maxQueue must be a non-negative integer or Infinity, received ${String(this.cfg.maxQueue)}`)}get inFlight(){return this.active}get waiting(){return this.waiters.length}get highWaterMark(){return this.peak}acquire(e){return e?.aborted?Promise.reject(new x("Concurrency acquire aborted","EABORT")):this.active<this.cfg.maxConcurrent?(this.active++,this.active>this.peak&&(this.peak=this.active),Promise.resolve()):this.cfg.queue?this.waiters.length>=this.cfg.maxQueue?Promise.reject(new Xe(`Concurrency queue is full (${this.cfg.maxQueue} waiting)`)):new Promise((t,n)=>{let s={resolve:t,reject:n,onAbort:null,signal:null};if(e){if(e.aborted){n(new x("Concurrency acquire aborted","EABORT"));return}s.onAbort=()=>{let o=this.waiters.indexOf(s);o!==-1&&this.waiters.splice(o,1),n(new x("Concurrency acquire aborted","EABORT"))},s.signal=e,e.addEventListener("abort",s.onAbort,{once:!0})}this.waiters.push(s)}):Promise.reject(new Xe(`Concurrency limit reached (${this.cfg.maxConcurrent} in flight) and queueing is disabled`))}release(){if(this.active===0)return;let e=this.waiters.shift();if(!e){this.active--;return}Ma(e),e.resolve()}drain(e=new Xe("Client destroyed")){let t=this.waiters.splice(0,this.waiters.length);for(let n of t)Ma(n),n.reject(e)}};function $s(){let r=[],e=Symbol("harStart");function t(i){return Object.entries(i).map(([a,c])=>({name:a,value:c}))}function n(i){try{let a=new URL(i);return Array.from(a.searchParams.entries()).map(([c,u])=>({name:c,value:u}))}catch{return[]}}return{requestInterceptor:i=>{i.store.set(e,ne())},responseInterceptor:i=>{if(!i.response)return;let a=i.store.get(e)??i.startedAt,c=ne()-a,u=i.response.headers["content-type"]??i.response.headers["Content-Type"]??"application/octet-stream",l=i.response.body,h=Math.max(0,Gr(l));r.push({startedDateTime:new Date(Date.now()-c).toISOString(),time:c,request:{method:i.request.method.toUpperCase(),url:i.request.url,httpVersion:"HTTP/1.1",headers:t(i.request.headers),queryString:n(i.request.url),bodySize:Gr(i.request.body)},response:{status:i.response.status,statusText:i.response.statusText,httpVersion:"HTTP/1.1",headers:t(i.response.headers),content:{size:h,mimeType:u,...typeof l=="string"?{text:l}:{}},bodySize:h,redirectURL:i.response.headers.location??""},timings:{send:0,wait:Math.floor(c*.9),receive:Math.floor(c*.1)}})},getHAR:()=>({version:"1.2",creator:{name:"kinetex",version:"0.0.3"},entries:[...r]}),clearHAR:()=>{r.length=0}}}function Us(){let r=Symbol("metricsStart"),e=0,t=0,n=0,s={"2xx":0,"3xx":0,"4xx":0,"5xx":0},o=1e4,i=[],a=d=>{d.store.set(r,ne()),e++,d.attempt>1&&n++},c=d=>{if(!d.response)return;let m=d.store.get(r);if(m!==void 0){let y=ne()-m;i.length>=o&&i.shift(),i.push(y)}let g=`${Math.floor(d.response.status/100)}xx`;if(g in s){let y=s;y[g]=(y[g]??0)+1}},u=()=>{t++};function l(d,m){if(d.length===0)return 0;let g=Math.ceil(m/100*d.length)-1,y=Math.min(Math.max(0,g),d.length-1);return d[y]}return{requestInterceptor:a,responseInterceptor:c,errorInterceptor:u,snapshot:()=>{let d=[...i].sort((g,y)=>g-y),m=d.length?d.reduce((g,y)=>g+y,0)/d.length:0;return{totalRequests:e,totalErrors:t,totalRetries:n,statusBuckets:{...s},avgDurationMs:Math.round(m),p50DurationMs:l(d,50),p95DurationMs:l(d,95),p99DurationMs:l(d,99)}},reset:()=>{e=0,t=0,n=0;for(let d of Object.keys(s))s[d]=0;i.length=0}}}function ne(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Da(r){return new Promise(e=>setTimeout(e,r))}function Gr(r){return r?typeof r=="string"?new TextEncoder().encode(r).length:r instanceof Uint8Array||r instanceof ArrayBuffer?r.byteLength:-1:0}function Na(r={}){let e=new er,t=Is(r.timeout);e.useRequest(t.requestInterceptor,{priority:-100,id:"timeout-req"}),e.useResponse(t.responseInterceptor,{priority:-100,id:"timeout-res"}),e.useError(t.errorInterceptor,{priority:-100,id:"timeout-err"}),r.rateLimit&&e.useRequest(tr(r.rateLimit),{priority:-90,id:"ratelimit"});let n=Ds();e.useRequest(n.requestInterceptor,{priority:-80,id:"dedupe-req"}),e.useResponse(n.responseInterceptor,{priority:-80,id:"dedupe-res"}),e.useError(n.errorInterceptor,{priority:-80,id:"dedupe-err"});let s=Ms(r.cache);e.useRequest(s.requestInterceptor,{priority:-70,id:"cache-req"}),e.useResponse(s.responseInterceptor,{priority:-70,id:"cache-res"});let o=null;r.auth&&(o=Ls(r.auth),e.useRequest(o.requestInterceptor,{priority:-50,id:"auth-req"}),e.useResponse(o.responseInterceptor,{priority:-50,id:"auth-res"}));let i=Ps(r.retry);e.useResponse(i.responseInterceptor,{priority:50,id:"retry-res"}),e.useError(i.errorInterceptor,{priority:50,id:"retry-err"});let a=Os(r.logging);e.useRequest(a.requestInterceptor,{priority:90,id:"log-req"}),e.useResponse(a.responseInterceptor,{priority:90,id:"log-res"}),e.useError(a.errorInterceptor,{priority:90,id:"log-err"});let c=$s();e.useRequest(c.requestInterceptor,{priority:95,id:"har-req"}),e.useResponse(c.responseInterceptor,{priority:95,id:"har-res"});let u=Us();return e.useRequest(u.requestInterceptor,{priority:100,id:"metrics-req"}),e.useResponse(u.responseInterceptor,{priority:100,id:"metrics-res"}),e.useError(u.errorInterceptor,{priority:100,id:"metrics-err"}),{manager:e,retry:i,auth:o,timeout:{id:t.id},logging:a,cache:s,dedupe:n,har:c,metrics:u}}we();function $a(r){return()=>Promise.resolve(r)}function Ua(){return()=>{let r=Hs("AWS_ACCESS_KEY_ID"),e=Hs("AWS_SECRET_ACCESS_KEY"),t=Hs("AWS_SESSION_TOKEN");return!r||!e?Promise.reject(new F("AWS credentials not found in environment. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.")):Promise.resolve({accessKeyId:r,secretAccessKey:e,...t!==void 0?{sessionToken:t}:{}})}}function Ha(...r){return async()=>{let e=[];for(let t of r)try{return await t()}catch(n){e.push(n instanceof Error?n:new Error(String(n)))}throw new F(`All credential providers failed:
90
+ `;Ko=ie.prototype.clearAPQCache.bind(ie.prototype),Vo=ie.prototype.getAPQMetrics.bind(ie.prototype)});var Fc={};le(Fc,{collectAll:()=>Go,collectPages:()=>Xo,createCursorPaginator:()=>ti,createKeysetPaginator:()=>oi,createLinkHeaderPaginator:()=>ni,createOffsetPaginator:()=>Zo,createPagePaginator:()=>ei,createRelayPaginator:()=>ri,createTokenPaginator:()=>si,deserializePaginationState:()=>ai,mergePaginators:()=>ui,paginate:()=>Q,paginateItems:()=>$n,parseLinkHeaderNext:()=>Un,prefetchPaginate:()=>yf,serializePaginationState:()=>ii,takeItems:()=>Yo,toPaginationIterator:()=>ci});function df(r,e){return{strategy:e,page:r.startPage??1,offset:r.startOffset??0,cursor:r.startCursor??null,prevCursor:null,token:r.startToken??null,done:!1,totalFetched:0}}function pf(r,e,t,n,s,o){let i=n.getTotal?.(e)??null,a=n.perPage??null,c=i!==null&&a!==null?Math.ceil(i/a):null,u=t.page>1||t.offset>0||t.prevCursor!==null;return{items:r,total:i,page:t.page,perPage:a,totalPages:c,hasNext:o??n.hasNext(e,t),hasPrev:u,nextCursor:s?.cursor??null,prevCursor:t.prevCursor??null,raw:e}}async function*Q(r,e="page"){let t=df(r,e),n=0,s=new Set;for(t.cursor!==null&&s.add(t.cursor),t.token!==null&&s.add(t.token);!t.done&&!(r.signal?.aborted||r.maxPages&&n>=r.maxPages);){n>0&&r.delayMs&&r.delayMs>0&&await bf(r.delayMs,r.signal);let o;try{o=await r.fetch(t)}catch(p){if(r.signal?.aborted)break;throw p}let i=r.getItems(o,t),a=i.length,c=i;r.transform&&(c=c.map(r.transform)),r.filter&&(c=c.filter(r.filter));let u=r.getNext?r.getNext(o,t):null,l=r.hasNext(o,t);if(l){let p=u?.cursor??t.cursor,m=u?.token??t.token,g=u?.page??t.page+1,w=u?.offset??t.offset+a,S=mf.has(t.strategy)&&r.getNext!==void 0&&u==null,b=p!==null&&s.has(p)||m!==null&&s.has(m),E=g===t.page&&w===t.offset&&p===t.cursor&&m===t.token;S||b||E?l=!1:(p!==null&&s.add(p),m!==null&&s.add(m))}let h=pf(c,o,t,r,u,l),d=t.cursor;if(t={...t,page:u?.page??t.page+1,offset:u?.offset??t.offset+a,cursor:u?.cursor??t.cursor,token:u?.token??t.token,done:!l,totalFetched:t.totalFetched+a,prevCursor:d},n++,r.onPage?.(h,t),yield h,!l)break}}async function*$n(r,e="page"){for await(let t of Q(r,e))for(let n of t.items)yield n}async function Go(r,e="page"){let t=[];for await(let n of Q(r,e))t.push(...n.items);return t}async function Xo(r,e="page"){let t=[];for await(let n of Q(r,e))t.push(n);return t}async function Yo(r,e,t="page"){if(typeof r!="number"||Number.isNaN(r)||r<=0)return[];let n=Math.floor(r),s=[];for await(let o of $n(e,t))if(s.push(o),s.length>=n)break;return s}function Zo(r){let e=r.paramNames??{},t=e.offset??"offset",n=e.limit??"limit",s=r.fetch??globalThis.fetch;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},perPage:r.limit,fetch:async o=>{let i=new URL(r.url);return i.searchParams.set(t,String(o.offset)),i.searchParams.set(n,String(r.limit)),(await s(i.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:(o,i)=>r.getItems(o),getTotal:r.getTotal??(()=>null),hasNext:(o,i)=>{let a=r.getTotal?.(o)??null;return r.hasMore?r.hasMore(o,i.totalFetched+r.limit,a):a!==null?i.offset+r.limit<a:r.getItems(o).length===r.limit},getNext:(o,i)=>({offset:i.offset+r.limit})},"offset")}function ei(r){let e=r.paramNames??{},t=e.page??"page",n=e.perPage??"per_page",s=r.fetch??globalThis.fetch;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.perPage!==void 0?{perPage:r.perPage}:{},startPage:r.startPage??1,fetch:async o=>{let i=new URL(r.url);return i.searchParams.set(t,String(o.page)),i.searchParams.set(n,String(r.perPage)),(await s(i.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:o=>r.getItems(o),getTotal:r.getTotal??(()=>null),hasNext:(o,i)=>{let a=r.getTotalPages?.(o)??null;if(a!==null)return i.page<a;let c=r.getTotal?.(o)??null;return c!==null?i.page*r.perPage<c:r.getItems(o).length===r.perPage},getNext:(o,i)=>({page:i.page+1})},"page")}function ti(r){let e=r.paramName??"cursor",t=r.fetch??globalThis.fetch;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},startCursor:r.startCursor??null,fetch:async n=>{let s=new URL(r.url);return n.cursor&&s.searchParams.set(e,n.cursor),(await t(s.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:n=>r.getItems(n),hasNext:n=>r.getNextCursor(n)!==null,getNext:n=>{let s=r.getNextCursor(n);return s?{cursor:s}:null}},"cursor")}function ri(r){let e=r.first??20;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.transform!==void 0?{transform:r.transform}:{},...r.filter!==void 0?{filter:r.filter}:{},...r.onPage!==void 0?{onPage:r.onPage}:{},startCursor:r.startCursor??null,perPage:e,fetch:t=>r.fetch({first:e,after:t.cursor}),getItems:t=>t.edges.map(n=>n.node),getTotal:t=>t.totalCount??null,hasNext:t=>t.pageInfo.hasNextPage,getNext:t=>{let n=t.pageInfo.endCursor??null;return n?{cursor:n}:null}},"relay")}function ni(r){let e=r.fetch??globalThis.fetch;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},fetch:async t=>{let n=t.cursor??r.url,s=await e(n,{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}}),o=Un(s.headers.get("link")??"");return{data:await s.json(),headers:s.headers,nextUrl:o}},getItems:t=>r.getItems(t.data),getTotal:t=>r.getTotal?.(t.data,t.headers)??null,hasNext:t=>t.nextUrl!==null,getNext:t=>t.nextUrl?{cursor:t.nextUrl}:null},"link-header")}function Un(r){if(!r)return null;let e=r.split(/(?=<)/).filter(t=>t.trimStart().startsWith("<"));for(let t of e){let n=t.match(gf);if(n&&n[2]&&n[2].toLowerCase().split(/\s+/).includes("next"))return n[1]}return null}function si(r){let e=r.tokenParam??"pageToken",t=r.pageSizeParam??"pageSize",n=r.fetch??globalThis.fetch;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.pageSize!==void 0?{perPage:r.pageSize}:{},fetch:async s=>{let o=new URL(r.url);return s.token&&o.searchParams.set(e,s.token),r.pageSize&&o.searchParams.set(t,String(r.pageSize)),(await n(o.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:s=>r.getItems(s),getTotal:r.getTotal??(()=>null),hasNext:s=>r.getNextToken(s)!==null,getNext:s=>{let o=r.getNextToken(s);return o?{token:o}:null}},"token")}function oi(r){let e=r.pageSizeParam??"limit",t=r.fetch??globalThis.fetch;return Q({...r.signal!==void 0?{signal:r.signal}:{},...r.maxPages!==void 0?{maxPages:r.maxPages}:{},...r.delayMs!==void 0?{delayMs:r.delayMs}:{},...r.pageSize!==void 0?{perPage:r.pageSize}:{},startCursor:r.startKey??null,fetch:async n=>{let s=new URL(r.url);return n.cursor&&s.searchParams.set(r.keyParam,n.cursor),r.pageSize&&s.searchParams.set(e,String(r.pageSize)),(await t(s.toString(),{...r.headers!==void 0?{headers:r.headers}:{},...r.signal!==void 0?{signal:r.signal}:{}})).json()},getItems:n=>r.getItems(n),hasNext:(n,s)=>{let o=r.getItems(n);return r.hasMore?r.hasMore(o,n):r.pageSize?o.length>=r.pageSize:o.length>0},getNext:(n,s)=>{let o=r.getItems(n),i=r.getLastKey(o);return i?{cursor:i}:null}},"keyset")}async function*yf(r,e="page",t=2){let n=Math.max(0,Math.floor(Number.isFinite(t)?t:0)),s=[],o=Q(r,e),i=!1;function a(){if(i)return;let c=o.next().then(u=>u.done?(i=!0,null):u.value??null);c.catch(()=>{}),s.push(c)}for(let c=0;c<n+1;c++)a();for(;s.length>0;){let c=await s.shift();if(c==null)break;a(),yield c}}function ii(r){let e=JSON.stringify(r);if(typeof TextEncoder<"u"&&typeof btoa=="function"){let t=new TextEncoder().encode(e),n="",s=32768;for(let o=0;o<t.length;o+=s)n+=String.fromCharCode(...t.subarray(o,o+s));return btoa(n)}return btoa(e)}function Jo(r){return typeof r=="number"&&Number.isFinite(r)}function Qo(r){return r==null||typeof r=="string"}function ai(r){let e;try{let s=atob(r),o=new Uint8Array(s.length);for(let a=0;a<s.length;a++)o[a]=s.charCodeAt(a);let i=typeof TextDecoder<"u"?new TextDecoder("utf-8",{fatal:!0}).decode(o):s;e=JSON.parse(i)}catch{throw new Error("Invalid pagination state string")}let t=D(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Invalid pagination state string");let n=t;if(!Jo(n.page)||!Jo(n.offset)||!Jo(n.totalFetched)||typeof n.strategy!="string"||!wf.has(n.strategy)||typeof n.done!="boolean"||!Qo(n.cursor)||!Qo(n.prevCursor)||!Qo(n.token))throw new Error("Invalid pagination state string");return t}function bf(r,e){return new Promise(t=>{if(e?.aborted){t();return}let n=()=>{clearTimeout(s),e?.removeEventListener("abort",n),t()},s=setTimeout(()=>{e?.removeEventListener("abort",n),t()},r);e?.addEventListener("abort",n,{once:!0})})}function ci(r){let e=r[Symbol.asyncIterator]();return{next:()=>e.next(),return:t=>e.return?.(t)??Promise.resolve({value:t,done:!0}),throw:t=>e.throw?.(t)??Promise.reject(t),[Symbol.asyncIterator](){return this}}}async function*ui(...r){let e=r.map(n=>n[Symbol.asyncIterator]()),t=new Set(e.map((n,s)=>s));for(;t.size>0;)for(let n of[...t]){let s;try{s=await e[n].next()}catch{t.delete(n);continue}if(s.done){t.delete(n);continue}yield s.value}}var mf,gf,wf,Hn=J(()=>{"use strict";U();mf=new Set(["cursor","relay","link-header","token","keyset"]);gf=/<([^>]+)>.*?rel=["']([^"']+)["']/i;wf=new Set(["offset","page","cursor","relay","link-header","token","keyset"])});var nd={};le(nd,{AbortError:()=>_t,AuthError:()=>zr,BatchQueue:()=>jn,BatchingTransport:()=>Ft,CONCURRENCY_DEFAULTS:()=>zs,CircuitBreaker:()=>yt,CircuitBreakerRegistry:()=>Ge,CircuitOpenError:()=>gt,CloudflareKVAdapter:()=>Tt,ConcurrencyLimitError:()=>tt,ConcurrencyLimiter:()=>Ct,ConsoleTransport:()=>it,ContentTypeError:()=>je,CookieJar:()=>qe,DedupMap:()=>Qe,FetchTransport:()=>st,FluentRequest:()=>Cr,GraphQLClient:()=>ie,GraphQLClientError:()=>H,HAS_NATIVE_FETCH:()=>go,HTTPCache:()=>me,HTTPError:()=>Lr,HTTPLogger:()=>We,HTTPResponseError:()=>rt,HTTPStatusError:()=>xt,HeaderName:()=>_,HookEmitter:()=>vr,HookRegistry:()=>Bn,HttpHeaders:()=>ge,IS_NODE:()=>ze,InterceptorManager:()=>or,JSONTransport:()=>qt,Kinetex:()=>Gt,KinetexError:()=>x,LogLevel:()=>zt,MemoryStorageAdapter:()=>Ne,MultiPartProgressAggregator:()=>jr,MultiTransport:()=>Kt,NetworkError:()=>V,NodeHTTP2Transport:()=>It,ProgressTracker:()=>G,ProxyError:()=>qr,RUNTIME:()=>Ce,RateLimitError:()=>At,Redactor:()=>Vt,RedirectError:()=>Me,RedirectTracker:()=>zn,RemoteTransport:()=>Wt,ResponseDecodeError:()=>nt,ResponseSizeLimitError:()=>He,ResponseValidationError:()=>Ir,RichHeaders:()=>De,SSEClient:()=>at,SSEError:()=>xe,SSEMaxReconnectsError:()=>ct,SSEParser:()=>Ke,SSERouter:()=>Tr,SSEServerResponse:()=>Jt,SSETransformStream:()=>Sr,SigV4Signer:()=>ye,SizeLimitError:()=>bt,Socks5Error:()=>I,TimeoutError:()=>Y,TooManyRedirectsError:()=>Pr,TwoTierStorageAdapter:()=>Et,URLBuilder:()=>Ve,ValidationError:()=>X,WSClient:()=>Xe,WSConnectTimeoutError:()=>wt,WSError:()=>W,WSMaxReconnectsError:()=>nr,WSRateLimitError:()=>Br,WebStorageAdapter:()=>Ye,applyDecompression:()=>dr,assertOk:()=>oo,assertOkJSON:()=>io,authLink:()=>jo,buildDataURL:()=>Wu,cachingCredentials:()=>Js,canonicalizeDomainFull:()=>be,chainCredentials:()=>Qa,clearAPQCache:()=>Ko,collectAll:()=>Go,collectPages:()=>Xo,collectStream:()=>sa,compilePattern:()=>Ou,composeAround:()=>hu,composeBeforeRequest:()=>uu,composeBeforeResponse:()=>lu,computeBodySize:()=>sn,computeDigestResponse:()=>ln,computeUsernameStar:()=>hn,concatUint8Arrays:()=>er,connectWS:()=>pa,corsHeaders:()=>$a,createAPIGatewaySigner:()=>tc,createAbortHook:()=>mu,createAuthInterceptor:()=>$s,createBodyNormalizationHook:()=>pu,createCacheInterceptor:()=>js,createCircuitBreaker:()=>fa,createCircuitBreakerRegistry:()=>da,createCookieJar:()=>Cn,createCursorPaginator:()=>ti,createDedupMap:()=>ha,createDedupeInterceptor:()=>Bs,createDevelopmentLogger:()=>vo,createDigestAuthorization:()=>cc,createDynamoDBSigner:()=>nc,createGraphQLClient:()=>Fo,createHARInterceptor:()=>qs,createHeaders:()=>Ua,createHookContext:()=>gu,createImmutableHeaders:()=>Ba,createInterceptorSuite:()=>Ka,createJSONSSEStream:()=>Io,createKVCache:()=>os,createKeysetPaginator:()=>oi,createLimitedReader:()=>ho,createLinkHeaderPaginator:()=>ni,createLocalStorageCache:()=>ns,createLogger:()=>Ao,createLoggingHooks:()=>fu,createLoggingInterceptor:()=>Hs,createMemoryCache:()=>rs,createMethodCircuitBreakerKey:()=>nu,createMetricsInterceptor:()=>Fs,createOffsetPaginator:()=>Zo,createPagePaginator:()=>ei,createProductionLogger:()=>Co,createRateLimitInterceptor:()=>ir,createRelayPaginator:()=>ri,createRequestHeaders:()=>Ha,createResponseHeaders:()=>ja,createRetryInterceptor:()=>Ds,createS3Signer:()=>ec,createSSEResponse:()=>Oo,createSSEStream:()=>Lo,createSTSSigner:()=>rc,createSessionStorageCache:()=>ss,createSocks5Tunnel:()=>Si,createStructuredError:()=>Ki,createTimeoutInterceptor:()=>Us,createTimingHook:()=>du,createTokenPaginator:()=>si,createTransport:()=>gr,createTwoTierCache:()=>is,decodeBody:()=>fr,decodeIDNLabel:()=>Dt,decompressBodyStream:()=>br,decompressStream:()=>mn,deepClone:()=>ft,default:()=>rd,defaultPath:()=>Ut,denoTcpConnector:()=>bu,deriveSigningKey:()=>Pt,deserializePaginationState:()=>ai,detectClockSkew:()=>Zs,detectOperationType:()=>Nn,detectRuntime:()=>Tn,diffResponses:()=>ao,diffURLs:()=>Ku,domainMatch:()=>$t,encodePathComponent:()=>Ti,encodeQueryValue:()=>ut,envCredentials:()=>Ja,errorLink:()=>Bo,expandTemplate:()=>Iu,extractOperationName:()=>Le,extractServerTiming:()=>uo,extractSetCookieHeaders:()=>Bt,fillPathParams:()=>Ai,formatAmzDate:()=>cr,formatBasic:()=>Aa,formatBearer:()=>ka,formatBytes:()=>tr,formatCSP:()=>tn,formatCacheControl:()=>gs,formatContentDisposition:()=>ps,formatContentType:()=>fs,formatDateStamp:()=>vt,formatDigestAuth:()=>fn,formatETA:()=>Yn,formatError:()=>Vi,formatHSTS:()=>en,formatLinkHeader:()=>Pa,formatProgress:()=>ia,formatRate:()=>Xn,formatServerTiming:()=>Ia,fromNodeHeaders:()=>Oa,fromWebHeaders:()=>Na,generateIdempotencyKey:()=>rn,getAPQMetrics:()=>Vo,getAuthFingerprint:()=>Ze,getClientIP:()=>Ss,getEffectiveRuntime:()=>mo,getOrigin:()=>Wn,getPublicSuffix:()=>_r,getRegistrableDomain:()=>kn,getRuntime:()=>Hr,gql:()=>Wo,hasNativeFetch:()=>Yi,imdsCredentials:()=>Ga,initChunkedSigning:()=>Xs,injectHeaders:()=>ou,isAbortError:()=>Ur,isAbortSignal:()=>Ui,isAbsolute:()=>Ci,isArrayBuffer:()=>Ni,isBinary:()=>no,isBlob:()=>Bi,isBlobURL:()=>zu,isBrowserEnvironment:()=>Xi,isClockSkewError:()=>eo,isDataURL:()=>Bu,isFormData:()=>ji,isHTTP:()=>ju,isHTTPS:()=>Hu,isHeaders:()=>$i,isIPAddress:()=>ve,isJSON:()=>lr,isLocalhost:()=>qu,isNodeEnvironment:()=>Gi,isPlainObject:()=>Hi,isPublicSuffix:()=>Pe,isReadableStream:()=>Di,isRelative:()=>Uu,isSafeURL:()=>ne,isSameOrigin:()=>Mu,isSameSite:()=>Nu,isText:()=>dn,isURLSearchParams:()=>zi,isUint8Array:()=>Mi,isValidHeaderName:()=>Te,isValidHeaderValue:()=>de,isValidIdempotencyKey:()=>nn,joinPath:()=>Ri,jsonSSE:()=>In,kinetex:()=>el,loadCookieJar:()=>vn,loggingLink:()=>zo,mergePaginators:()=>ui,mergeQuery:()=>ku,mergeSignals:()=>$r,negotiateContentType:()=>va,nodeTcpConnector:()=>xu,normalizeForwardedHeaders:()=>Zr,normalizeHeaders:()=>mt,normalizePath:()=>ki,normalizeResponse:()=>ro,normalizeURL:()=>Lu,omitQuery:()=>Cu,paginate:()=>Q,paginateItems:()=>$n,parseAccept:()=>Yr,parseAcceptEncoding:()=>ys,parseAcceptLanguage:()=>ws,parseAltSvc:()=>As,parseAuthorization:()=>Kr,parseBody:()=>Mt,parseCSP:()=>Rs,parseCacheControl:()=>ms,parseContentDisposition:()=>ds,parseContentLanguage:()=>Ca,parseContentRange:()=>xs,parseContentType:()=>Be,parseCookieDate:()=>xr,parseDataURL:()=>Fu,parseDigestChallenge:()=>un,parseForwarded:()=>_s,parseHSTS:()=>Es,parseLinkHeader:()=>Jr,parseLinkHeaderNext:()=>Un,parseMultipartResponse:()=>xn,parseParams:()=>Z,parseQuery:()=>Ei,parseRange:()=>bs,parseRetryAfter:()=>sr,parseSSEText:()=>Mo,parseServerTiming:()=>ks,parseSetCookieHeader:()=>jt,parseSocks5Url:()=>wu,parseUntrustedJSON:()=>Oi,parseWWWAuthenticate:()=>Vr,parseWarning:()=>La,pathMatch:()=>Ht,pathSegments:()=>Pu,percentDecode:()=>ce,percentEncode:()=>Fn,perfNow:()=>N,pickQuery:()=>Au,presignRequest:()=>Gs,readBlob:()=>wn,readBodyWithLimit:()=>ur,readBytes:()=>pr,readFormData:()=>co,readJSON:()=>gn,readJSONStream:()=>so,readNDJSON:()=>bn,readRawBody:()=>yr,readStream:()=>Lt,readText:()=>yn,redactURL:()=>Zu,relativeURL:()=>$u,resolveURL:()=>Du,retryLink:()=>qo,safeJSONParse:()=>Se,safeParseURL:()=>Je,sanitizeParsedJSON:()=>D,sanitizeURL:()=>Ji,securityHeaders:()=>Da,sendWithTimeout:()=>Ot,serializePaginationState:()=>ii,setRuntime:()=>po,sigV4UriEncode:()=>Qs,signChunk:()=>Ya,signFinalChunk:()=>Za,signRequest:()=>an,signS3PostPolicy:()=>Ys,sleep:()=>Oe,socks5Connector:()=>_u,splitSetCookieHeaders:()=>ot,staticCredentials:()=>Va,streamWithProgress:()=>na,stringifyQuery:()=>Ru,stripHash:()=>Qu,stripQuery:()=>Gu,takeItems:()=>Yo,tap:()=>su,throttleProgress:()=>aa,throwOnHTTPError:()=>au,toNodeHeaders:()=>Ma,toOTelSpan:()=>ko,toPaginationIterator:()=>ci,toRequestId:()=>Zn,toUint8Array:()=>Qi,tryParseJSON:()=>Ii,uint8ArrayToBase64:()=>se,urlExtension:()=>Xu,urlFilename:()=>Yu,validateErrorCode:()=>ma,validateResponse:()=>cu,withBaseURL:()=>iu,withBlobUploadProgress:()=>ta,withDownloadProgress:()=>ra,withTrailingSlash:()=>Vu,withUploadProgress:()=>rr,withoutTrailingSlash:()=>Ju,xhrFetch:()=>oa});U();var G=class{constructor(e,t={}){f(this,"loaded",0);f(this,"total");f(this,"startMs");f(this,"lastMs");f(this,"lastLoaded",0);f(this,"smoothedRate",0);f(this,"smoothing");f(this,"_done",!1);f(this,"lastEmitMs",-1/0);f(this,"minIntervalMs");f(this,"onProgress");this.total=e,this.startMs=N(),this.lastMs=this.startMs,this.smoothing=t.smoothingFactor??.3,this.onProgress=t.onProgress??null;let n=t.throttleHz??10;this.minIntervalMs=n>0?1e3/n:0}update(e){this.loaded+=e;let t=this._snapshot();if(this.onProgress){let n=N();(this.minIntervalMs===0||n-this.lastEmitMs>=this.minIntervalMs)&&(this.lastEmitMs=n,this.onProgress(t))}return t}complete(){this._done=!0;let e=this._snapshot();return this.onProgress?.(e),e}snapshot(){return this._snapshot()}get bytesLoaded(){return this.loaded}get isDone(){return this._done}_snapshot(){let e=N(),t=e-this.startMs,n=e-this.lastMs;if(n>0){let i=(this.loaded-this.lastLoaded)/n*1e3;this.smoothedRate=this.smoothedRate===0?i:this.smoothedRate*(1-this.smoothing)+i*this.smoothing,this.lastMs=e,this.lastLoaded=this.loaded}let s=this.total!==null&&this.total>0?Math.min(100,Math.max(0,this.loaded/this.total*100)):null,o=this.total!==null&&this.smoothedRate>0?Math.max(0,(this.total-this.loaded)/this.smoothedRate*1e3):null;return{loaded:this.loaded,total:this.total,percent:this._done?this.total!==null?100:null:s,rate:this.smoothedRate,eta:this._done?0:o,elapsed:t,done:this._done}}};function rr(r,e,t={}){let n=new G(e,t);if(!r)return n.complete(),{stream:new ReadableStream({start:l=>l.close()}),tracker:n};let s;if(r instanceof ReadableStream)s=r;else if(typeof r=="string"){let l=new TextEncoder().encode(r);s=new ReadableStream({start(h){h.enqueue(l),h.close()}})}else s=new ReadableStream({start(l){l.enqueue(r),l.close()}});let o=null,i=null,a=!1,c=()=>{i&&(t.signal?.removeEventListener("abort",i),i=null)};return{stream:new ReadableStream({start(l){if(t.signal?.aborted){l.error(new DOMException("Upload aborted","AbortError"));return}o=s.getReader(),i=()=>{if(a)return;a=!0;let h=o;o=null,h?.cancel("aborted").catch(()=>{}),l.error(new DOMException("Upload aborted","AbortError"))},t.signal?.addEventListener("abort",i,{once:!0})},async pull(l){let h=o;if(h)try{let{done:d,value:p}=await h.read();if(d){c(),o===h&&(o=null),h.releaseLock(),a||(n.complete(),l.close());return}n.update(p.byteLength),l.enqueue(p)}catch(d){c(),o===h&&(o=null),a||n.complete(),l.error(d)}},cancel(l){c();let h=o;o=null,h?.cancel(l).catch(()=>{})}}),tracker:n}}function ta(r,e={}){return rr(r.stream(),r.size,e)}function ra(r,e={}){let t=r.headers.get("content-length"),n=t?parseInt(t,10):null,s=new G(isNaN(n)?null:n,e);if(!r.body)return s.complete(),{response:r,tracker:s};let o=r.body,i=null,a=!1,c=null,u=()=>{c&&(e.signal?.removeEventListener("abort",c),c=null)},l=new ReadableStream({start(d){if(e.signal?.aborted){a=!0,d.error(new DOMException("Download aborted","AbortError"));return}i=o.getReader(),c=()=>{if(a)return;a=!0;let p=i;i=null,p?.cancel("aborted").catch(()=>{}),d.error(new DOMException("Download aborted","AbortError"))},e.signal?.addEventListener("abort",c,{once:!0})},async pull(d){let p=i;if(p)try{let{done:m,value:g}=await p.read();if(m){u(),i===p&&(i=null),p.releaseLock(),a||s.complete(),d.close();return}s.update(g.byteLength),d.enqueue(g)}catch(m){u(),i===p&&(i=null),a||s.complete(),d.error(m)}},cancel(d){u();let p=i;i=null,p?.cancel(d).catch(()=>{})}}),h=new Response(l,{status:r.status,statusText:r.statusText,headers:r.headers});for(let d of["url","redirected","type"])try{Object.defineProperty(h,d,{value:r[d],enumerable:!0,configurable:!0})}catch{}return{response:h,tracker:s}}async function*na(r,e,t={}){let n=new G(e,t),s=r.getReader();try{for(;;){if(t.signal?.aborted)throw new DOMException("Stream aborted","AbortError");let{done:o,value:i}=await s.read();if(o){let c=n.complete();yield{chunk:new Uint8Array(0),progress:c};break}let a=n.update(i.byteLength);yield{chunk:i,progress:a}}}finally{s.releaseLock()}}async function sa(r,e,t={}){let n=new G(e,t),s=[],o=r.getReader();if(t.signal?.aborted)throw o.cancel("aborted").catch(()=>{}),o.releaseLock(),new DOMException("Stream aborted","AbortError");let i=!1,a=()=>{i=!0,o.cancel("aborted").catch(()=>{})};t.signal&&t.signal.addEventListener("abort",a,{once:!0});try{for(;;){let{done:h,value:d}=await o.read();if(h)break;s.push(d),n.update(d.byteLength)}if(i)throw new DOMException("Stream aborted","AbortError")}finally{o.releaseLock(),t.signal?.removeEventListener("abort",a)}n.complete();let c=s.reduce((h,d)=>h+d.byteLength,0),u=new Uint8Array(c),l=0;for(let h of s)u.set(h,l),l+=h.byteLength;return{data:u,tracker:n}}var jr=class{constructor(e,t){f(this,"partCount");f(this,"trackers",new Map);f(this,"totals",new Map);f(this,"onOverall");this.partCount=e,this.onOverall=t??null}createPartTracker(e,t,n={}){let s=this.trackers.get(e);if(s)return s;this.totals.set(e,t);let o=new G(t,{...n,onProgress:i=>{n.onProgress?.(i),this._emit()}});return this.trackers.set(e,o),o}getOverall(){let e=[],t=0,n=0,s=0,o=!0,i=0;for(let h=0;h<this.partCount;h++){let p=this.trackers.get(h)?.snapshot()??{loaded:0,total:this.totals.get(h)??null,percent:0,rate:0,eta:null,elapsed:0,done:!1};e.push(p),t+=p.loaded,p.total!==null&&(n+=p.total),s+=p.rate,p.done||(o=!1),p.elapsed>i&&(i=p.elapsed)}let a=n>0,c=a?Math.max(0,Math.min(100,t/n*100)):null,u=a&&s>0?Math.max(0,(n-t)/s*1e3):null;return{parts:e,overall:{loaded:t,total:a?n:null,percent:c,rate:s,eta:o?0:u,elapsed:i,done:o}}}_emit(){this.onOverall&&this.onOverall(this.getOverall())}},Zi=globalThis.XMLHttpRequest;function oa(r,e){return new Promise((t,n)=>{if(!Zi){n(new Error("XMLHttpRequest is not available in this runtime. Use fetch() instead."));return}if(e.responseType&&e.responseType!=="text"){n(new TypeError(`xhrFetch: responseType "${e.responseType}" cannot produce a text body. XHRResult.body is a string \u2014 use "text", or omit responseType.`));return}let s=new Zi,o=new G(null,{...e.onUploadProgress!==void 0?{onProgress:e.onUploadProgress}:{},...e.throttleHz!==void 0?{throttleHz:e.throttleHz}:{},...e.smoothingFactor!==void 0?{smoothingFactor:e.smoothingFactor}:{}}),i=new G(null,{...e.onDownloadProgress!==void 0?{onProgress:e.onDownloadProgress}:{},...e.throttleHz!==void 0?{throttleHz:e.throttleHz}:{},...e.smoothingFactor!==void 0?{smoothingFactor:e.smoothingFactor}:{}});s.open(e.method??"GET",r,!0);for(let[u,l]of Object.entries(e.headers??{}))s.setRequestHeader(u,l);e.responseType&&(s.responseType=e.responseType),s.upload&&e.onUploadProgress&&(s.upload.addEventListener("loadstart",u=>{}),s.upload.addEventListener("progress",u=>{o.update(u.loaded-o.bytesLoaded)}),s.upload.addEventListener("load",()=>o.complete())),e.onDownloadProgress&&s.addEventListener("progress",u=>{i.update(u.loaded-i.bytesLoaded)});let a=()=>{s.abort(),n(new DOMException("Request aborted","AbortError"))},c=()=>e.signal?.removeEventListener("abort",a);if(e.signal?.addEventListener("abort",a,{once:!0}),e.signal?.aborted){c(),a();return}s.addEventListener("load",()=>{c(),i.complete();let u=s.getAllResponseHeaders(),l={};for(let h of u.split(/[\r\n]+/)){let d=h.indexOf(":");if(d<=0)continue;let p=h.slice(0,d).trim().toLowerCase();if(p==="")continue;let m=h.slice(d+1).trim();if(p==="__proto__"){Object.defineProperty(l,p,{value:m,writable:!0,enumerable:!0,configurable:!0});continue}l[p]=m}t({status:s.status,statusText:s.statusText,headers:l,body:typeof s.response=="string"?s.response:String(s.response??"")})}),s.addEventListener("error",()=>{c(),n(new TypeError("Network request failed"))}),s.addEventListener("timeout",()=>{c(),n(new TypeError("Request timed out"))}),s.addEventListener("abort",()=>{c(),n(new DOMException("Request aborted","AbortError"))});try{s.send(e.body??null)}catch(u){throw c(),u}})}var ea=["B","KB","MB","GB","TB"];function tr(r,e=2){if(Number.isNaN(r))return"NaN B";if(r===1/0)return"\u221E";if(r===-1/0)return"-\u221E";if(r===0)return"0 B";let t=1024,n=Math.max(0,e),s=r<0?"-":"",o=Math.abs(r),i=Math.min(Math.max(0,Math.floor(Math.log(o)/Math.log(t))),ea.length-1),a=ea[i];return`${s}${parseFloat((o/Math.pow(t,i)).toFixed(n))} ${a}`}function Xn(r){return`${tr(r)}/s`}function Yn(r){if(!isFinite(r)||r<0)return"\u221E";let e=Math.round(r/1e3),t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=e%60;return t>0?`${t}h ${n}m ${s}s`:n>0?`${n}m ${s}s`:`${s}s`}function ia(r){let e=tr(r.loaded),t=r.total!==null?` / ${tr(r.total)}`:"",n=r.percent!==null?` (${r.percent.toFixed(1)}%)`:"",s=r.rate>0?` @ ${Xn(r.rate)}`:"",o=r.eta!==null&&!r.done?` ETA ${Yn(r.eta)}`:"";return`${e}${t}${n}${s}${o}`}function aa(r,e=10){let t=e>0?1e3/e:0,n=-1/0;return s=>{let o=N();(s.done||o-n>=t)&&(n=o,r(s))}}var ca=["traceparent","tracestate","baggage","x-request-id","x-correlation-id","x-trace-id"];async function ua(r){if(r===void 0)return"";let e=new Map;for(let[s,o]of Object.entries(r))e.set(s.toLowerCase(),o);let t=[];for(let s of ca)e.delete(s);for(let s of[...e.keys()].sort())t.push(`${s}=${e.get(s)}`);if(t.length===0)return"";let n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t.join("|")));return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}function la(r,e,t){return t?`${r}:${e}:${t}`:`${r}:${e}`}function bl(r,e,t){if(t===void 0)return`${r}::${e}`;let n=Object.entries(t).filter(([s])=>!ca.includes(s.toLowerCase())).map(([s,o])=>`${s.toLowerCase()}=${o}`).sort();return n.length===0?`${r}::${e}`:`${r}::${e}::${n.join("&")}`}var Qe=class{constructor(e={}){f(this,"inflight",new Map);f(this,"timeouts",new Map);f(this,"_setTimeout");f(this,"_clearTimeout");f(this,"windowMs");f(this,"methods");f(this,"keyFn");f(this,"_globalSignal");f(this,"_hits",0);f(this,"_misses",0);this.windowMs=e.windowMs??0,this.methods=new Set((e.methods??["GET","HEAD"]).map(t=>t.toUpperCase())),this.keyFn=e.keyFn??bl,this._globalSignal=e.signal??null,this._setTimeout=e.timers?.setTimeout??((t,n)=>setTimeout(t,n)),this._clearTimeout=e.timers?.clearTimeout??(t=>clearTimeout(t))}execute(e,t,n,s,o,i){let a=o??this.windowMs,c=i??this._globalSignal;if(c?.aborted)return this._misses++,n();if(!this.methods.has(e.toUpperCase()))return this._misses++,n();let u=e.toUpperCase(),l=this.keyFn(u,t,s),h=this.inflight.get(l);if(h){if(h.resolvedAt===null)return this._hits++,h.promise;if(a>0&&Date.now()-h.resolvedAt<=a)return this._hits++,h.promise;if(a>0)this.inflight.delete(l);else return this._misses++,n()}this._misses++;let d={resolvedAt:null,promise:void 0};return this.inflight.set(l,d),d.promise=(async()=>{let p=c?()=>{this.inflight.delete(l);let m=this.timeouts.get(l);m!==void 0&&(this._clearTimeout(m),this.timeouts.delete(l))}:null;c&&p&&c.addEventListener("abort",p,{once:!0});try{return await n()}finally{c&&p&&c.removeEventListener("abort",p)}})().then(p=>{if(d.resolvedAt=Date.now(),d.result=p,this.inflight.get(l)!==d)return p;if(a<=0)this.inflight.delete(l);else{let m=this.timeouts.get(l);m!==void 0&&(this._clearTimeout(m),this.timeouts.delete(l));let g=this._setTimeout(()=>{this.inflight.delete(l),this.timeouts.delete(l)},a);this.timeouts.set(l,g)}return p},p=>{d.resolvedAt=Date.now(),d.error=p,this.inflight.get(l)===d&&this.inflight.delete(l);let m=this.timeouts.get(l);throw m!==void 0&&(this._clearTimeout(m),this.timeouts.delete(l)),p}),d.promise}get hits(){return this._hits}get misses(){return this._misses}get inFlightCount(){let e=0;for(let t of this.inflight.values())t.resolvedAt===null&&e++;return e}get keys(){return[...this.inflight.keys()]}getStats(){let e=this._hits+this._misses;return{hits:this._hits,misses:this._misses,totalRequests:e,hitRate:e===0?0:this._hits/e,inFlightCount:this.inFlightCount,trackedKeys:this.inflight.size}}resetMetrics(){this._hits=0,this._misses=0}clear(){this.inflight.clear();for(let e of this.timeouts.values())this._clearTimeout(e);this.timeouts.clear()}invalidate(e){let t=this.timeouts.get(e);return t&&(this._clearTimeout(t),this.timeouts.delete(e)),this.inflight.delete(e)}destroy(){this.clear()}};function ha(r){return new Qe(r)}var gt=class extends Error{constructor(t,n){super(`Circuit breaker ${n.state} for "${t}" \u2014 request rejected`);f(this,"code","ECIRCUITOPEN");f(this,"state");this.name="CircuitOpenError",this.state=n}},yt=class{constructor(e,t={}){f(this,"key");f(this,"failureThreshold");f(this,"windowSize");f(this,"resetTimeoutMs");f(this,"successThreshold");f(this,"halfOpenConcurrency");f(this,"failureFilter");f(this,"cfg");f(this,"_state","CLOSED");f(this,"_window",[]);f(this,"_consecutiveFails",0);f(this,"_consecutiveSucc",0);f(this,"_openedAt",null);f(this,"_halfOpenAt",null);f(this,"_lastFailureAt",null);f(this,"_lastSuccessAt",null);f(this,"_inFlightProbes",0);f(this,"_totalRequests",0);f(this,"_totalFailures",0);f(this,"_totalSuccesses",0);f(this,"_totalRejected",0);this.key=e,this.failureThreshold=t.failureThreshold??5,this.windowSize=t.windowSize??10,this.windowSize>0&&this.windowSize<this.failureThreshold&&(console.warn(`[CircuitBreaker] "${e}": windowSize (${this.windowSize}) is smaller than failureThreshold (${this.failureThreshold}), so the threshold could never be reached and the circuit would never open. Raising windowSize to ${this.failureThreshold}.`),this.windowSize=this.failureThreshold),this.resetTimeoutMs=t.resetTimeoutMs??3e4,this.successThreshold=t.successThreshold??2,this.halfOpenConcurrency=t.halfOpenConcurrency??1,this.failureFilter={networkErrors:t.failures?.networkErrors??!0,timeouts:t.failures?.timeouts??!0,serverErrors:t.failures?.serverErrors??!1,statusCodes:t.failures?.statusCodes??[]},this.cfg=t}get state(){return this._effectiveState()}_effectiveState(){return this._state==="OPEN"&&this._openedAt!==null&&Date.now()-this._openedAt>=this.resetTimeoutMs?"HALF_OPEN":this._state}get snapshot(){let e=this._consecutiveFails;if(this.windowSize>0){e=0;for(let t of this._window)t||e++}return{state:this._effectiveState(),failureCount:e,successCount:this._consecutiveSucc,lastFailureAt:this._lastFailureAt,lastSuccessAt:this._lastSuccessAt,openedAt:this._openedAt,halfOpenAt:this._halfOpenAt,totalRequests:this._totalRequests,totalFailures:this._totalFailures,totalSuccesses:this._totalSuccesses,totalRejected:this._totalRejected,inFlightProbes:this._inFlightProbes}}execute(e){if(this._checkTransition(),this._state==="OPEN"){this._totalRejected++;let n=this.snapshot;return this.cfg.onRejected?.(n),Promise.reject(new gt(this.key,n))}let t=!1;if(this._state==="HALF_OPEN"){if(this._inFlightProbes>=this.halfOpenConcurrency){this._totalRejected++;let n=this.snapshot;return this.cfg.onRejected?.(n),Promise.reject(new gt(this.key,n))}this._inFlightProbes++,t=!0}return this._totalRequests++,Promise.resolve().then(e).then(n=>(t&&(this._inFlightProbes=Math.max(0,this._inFlightProbes-1)),this._recordSuccess(),n),n=>{throw t&&(this._inFlightProbes=Math.max(0,this._inFlightProbes-1)),this._isCountableFailure(n)&&this._recordFailure(),n})}trip(){this._state!=="OPEN"&&(this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot))}reset(){this._state="CLOSED",this._window=[],this._consecutiveFails=0,this._consecutiveSucc=0,this._openedAt=null,this._halfOpenAt=null,this._inFlightProbes=0,this.cfg.onClose?.(this.snapshot)}_checkTransition(){this._state==="OPEN"&&this._openedAt!==null&&Date.now()-this._openedAt>=this.resetTimeoutMs&&(this._state="HALF_OPEN",this._halfOpenAt=Date.now(),this._consecutiveSucc=0,this._inFlightProbes=0,this.cfg.onHalfOpen?.(this.snapshot))}_recordSuccess(){if(this._lastSuccessAt=Date.now(),this._totalSuccesses++,this._consecutiveFails=0,this._state==="HALF_OPEN"){this._consecutiveSucc++,this._consecutiveSucc>=this.successThreshold&&this.reset();return}this.windowSize>0&&(this._window.push(!0),this._window.length>this.windowSize&&this._window.shift())}_recordFailure(){if(this._lastFailureAt=Date.now(),this._totalFailures++,this._consecutiveSucc=0,this._consecutiveFails++,this._state==="HALF_OPEN"){this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot);return}this.windowSize>0?(this._window.push(!1),this._window.length>this.windowSize&&this._window.shift(),this._window.filter(t=>!t).length>=this.failureThreshold&&(this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot))):this._consecutiveFails>=this.failureThreshold&&(this._openedAt=Date.now(),this._state="OPEN",this.cfg.onOpen?.(this.snapshot))}_isCountableFailure(e){if(!(e instanceof Error))return!1;let t=e.code;if(this.failureFilter.networkErrors&&t==="ENETWORK"||this.failureFilter.timeouts&&(t==="ETIMEOUT"||t==="ETIMEDOUT"))return!0;if(this.failureFilter.serverErrors){let n=e.status;if(n&&n>=500)return!0}if(this.failureFilter.statusCodes&&this.failureFilter.statusCodes.length>0){let n=e.status;if(n&&this.failureFilter.statusCodes.includes(n))return!0}return!1}},Ge=class{constructor(e={}){f(this,"breakers",new Map);f(this,"defaultConfig");this.defaultConfig=e}get(e,t){return this.breakers.has(e)||this.breakers.set(e,new yt(e,{...this.defaultConfig,...t})),this.breakers.get(e)}execute(e,t,n){return this.get(e,n).execute(t)}trip(e){this.get(e).trip()}reset(e){this.get(e).reset()}snapshots(){let e={};for(let[t,n]of this.breakers)e[t]=n.snapshot;return e}delete(e){this.breakers.delete(e)}clear(){this.breakers.clear()}get size(){return this.breakers.size}};function fa(r,e){return new yt(r,e)}function da(r){return new Ge(r)}U();function xl(r){if(r)for(let[e,t]of Object.entries(r)){if(!Te(e))throw new W(`Invalid WebSocket handshake header name: ${JSON.stringify(e)}`);if(!de(t))throw new W(`Invalid value for WebSocket handshake header ${JSON.stringify(e)}: must be a string of printable characters with no control characters`)}}var W=class extends Error{constructor(t,n){super(t,n!=null?{cause:n}:void 0);f(this,"code","EWSCONNECT");f(this,"originalCause");this.name="WSError",this.originalCause=n}},nr=class extends Error{constructor(t){super(`WebSocket gave up after ${t} reconnect attempts`);f(this,"attempts");f(this,"code","EWSMAXRECONNECTS");this.attempts=t,this.name="WSMaxReconnectsError"}},wt=class extends Error{constructor(t,n){super(`WebSocket connect to ${t} timed out after ${n}ms`);f(this,"code","EWSCONNECTTIMEOUT");this.name="WSConnectTimeoutError"}},Br=class extends Error{constructor(t){super(`WebSocket send rate limited; retry in ${t}ms`);f(this,"delayMs");f(this,"code","EWSRATELIMIT");this.delayMs=t,this.name="WSRateLimitError"}},Xe=class{constructor(e){f(this,"_url");f(this,"_protocols");f(this,"_headers");f(this,"_maxReconnects");f(this,"_reconnectBaseMs");f(this,"_reconnectMaxMs");f(this,"_reconnectJitter");f(this,"_pingIntervalMs");f(this,"_pingPayload");f(this,"_pongMatcher");f(this,"_pongTimeoutMs");f(this,"_connectTimeoutMs");f(this,"_bufferMessages");f(this,"_maxBufferSize");f(this,"_cbOpen");f(this,"_cbMessage");f(this,"_cbClose");f(this,"_cbError");f(this,"_cbReconnect");f(this,"_cbGiveUp");f(this,"_ws",null);f(this,"_state","CLOSED");f(this,"_reconnAttempt",0);f(this,"_buffer",[]);f(this,"_pingTimer",null);f(this,"_pongTimer",null);f(this,"_reconnTimer",null);f(this,"_msgListeners",[]);f(this,"_closeListeners",[]);f(this,"_openWaiters",[]);f(this,"_correlations",new Map);f(this,"_aborted",!1);f(this,"_externalSignal",null);f(this,"_onExternalAbort",()=>this.close(1e3,"AbortSignal aborted"));f(this,"_iterQueue",[]);f(this,"_iterWaiter",null);f(this,"_iterDone",!1);f(this,"_rooms",[]);f(this,"_keepRooms");f(this,"_highWaterMark");f(this,"_lowWaterMark");f(this,"_bufferedBytes",0);f(this,"_drainWaiters",[]);f(this,"_cbBackpressure");f(this,"_wasBackpressured",!1);f(this,"_maxSendRate");f(this,"_tokens",0);f(this,"_lastToken",0);f(this,"_serverEndpoint",null);f(this,"_mx",{messagesSent:0,messagesReceived:0,bytesSent:0,bytesReceived:0,reconnectCount:0,totalConnectAttempts:0,connectedAt:null,closedAt:null,uptimeMs:0});f(this,"_openedAt",null);if(this._url=e.url,this._protocols=e.protocols,this._headers=e.headers,xl(e.headers),this._maxReconnects=e.maxReconnects??10,this._reconnectBaseMs=e.reconnectBaseMs??1e3,this._reconnectMaxMs=e.reconnectMaxMs??3e4,this._reconnectJitter=e.reconnectJitter??.3,this._pingIntervalMs=e.pingIntervalMs??3e4,this._pingPayload=e.pingPayload??"ping",this._pongMatcher=e.pongMatcher,this._pongTimeoutMs=e.pongTimeoutMs??1e4,this._connectTimeoutMs=e.connectTimeoutMs??3e4,this._bufferMessages=e.bufferMessages??!0,this._maxBufferSize=e.maxBufferSize??100,this._cbOpen=e.onOpen,this._cbMessage=e.onMessage,this._cbClose=e.onClose,this._cbError=e.onError,this._cbReconnect=e.onReconnect,this._cbGiveUp=e.onGiveUp,this._cbBackpressure=e.onBackpressure,this._highWaterMark=e.highWaterMark??65536,this._lowWaterMark=e.lowWaterMark??16384,this._maxSendRate=e.maxSendRate??0,this._keepRooms=e.keepRooms??!0,e.rooms&&e.rooms.length>0)for(let t of e.rooms)this._rooms.push({room:t,joinedAt:0});this._externalSignal=e.signal??null,this._externalSignal?.addEventListener("abort",this._onExternalAbort,{once:!0})}get state(){return this._state}get connected(){return this._state==="OPEN"}get bufferedCount(){return this._buffer.length}get metrics(){return{...this._mx,uptimeMs:this._mx.uptimeMs+(this._openedAt!=null?Date.now()-this._openedAt:0)}}connect(){return this._state==="OPEN"?Promise.resolve():this._state==="CONNECTING"||this._state==="RECONNECTING"?new Promise((e,t)=>this._openWaiters.push({resolve:e,reject:t})):this._doConnect(!1)}waitForOpen(e=6e4){return this._state==="OPEN"?Promise.resolve():new Promise((t,n)=>{let s={resolve:()=>{o&&clearTimeout(o),t()},reject:i=>{o&&clearTimeout(o),n(i)}},o=e>0?setTimeout(()=>{let i=this._openWaiters.indexOf(s);i!==-1&&this._openWaiters.splice(i,1),n(new wt(this._url,e))},e):null;this._openWaiters.push(s)})}close(e=1e3,t="Client closed"){this._aborted=!0,this._externalSignal?.removeEventListener("abort",this._onExternalAbort),this._externalSignal=null,this._stopAll();for(let s of this._drainWaiters.splice(0))s();this._state="CLOSING";let n=this._ws;if(n){if(n.onopen=n.onmessage=n.onerror=n.onclose=null,n.readyState<2)try{n.close(e,t)}catch{}this._ws=null}this._buffer=[],this._bufferedBytes=0,this._iterQueue=[],this._iterDone=!0,this._iterWaiter&&(this._iterWaiter({done:!0,value:void 0}),this._iterWaiter=null);for(let s of this._openWaiters.splice(0))s.reject(new Error("Client closed"));this._rooms=[];for(let s of this._correlations.values())s.timer&&clearTimeout(s.timer),s.reject(new Error("Client closed"));this._correlations.clear(),this._openedAt!=null&&(this._mx.uptimeMs+=Date.now()-this._openedAt,this._openedAt=null),this._mx.closedAt=Date.now(),this._state="CLOSED";for(let s of this._closeListeners)try{s({code:e,reason:t})}catch{}this._closeListeners=[],this._msgListeners=[],this._cbClose?.(e,t,!1)}destroy(){this._aborted=!0,this._stopAll();for(let t of this._drainWaiters.splice(0))t();this._state="CLOSING";let e=this._ws;if(e){if(e.onopen=e.onmessage=e.onerror=e.onclose=null,e.readyState<2)try{e.close(1e3,"Destroyed")}catch{}this._ws=null}this._buffer=[],this._bufferedBytes=0,this._iterQueue=[],this._iterDone=!0,this._iterWaiter&&(this._iterWaiter({done:!0,value:void 0}),this._iterWaiter=null),this._msgListeners=[];for(let t of this._openWaiters.splice(0))t.reject(new Error("Client destroyed"));this._rooms=[];for(let t of this._correlations.values())t.timer&&clearTimeout(t.timer),t.reject(new Error("Client destroyed"));this._correlations.clear(),this._openedAt!=null&&(this._mx.uptimeMs+=Date.now()-this._openedAt,this._openedAt=null),this._mx.closedAt=Date.now(),this._state="CLOSED";for(let t of this._closeListeners)try{t({code:1e3,reason:"Destroyed"})}catch{}this._closeListeners=[],this._cbClose?.(1e3,"Destroyed",!1)}send(e){this._tx(e)&&this._mx.messagesSent++}sendBinary(e){let t=e instanceof Uint8Array?e.slice().buffer:e;this._tx(t)&&this._mx.messagesSent++}sendJSON(e){this.send(JSON.stringify(e))}request(e,t,n=o=>o.json??o.data,s=1e4){return new Promise((o,i)=>{let a=`${Date.now()}-${Math.random()}`,c=s>0?setTimeout(()=>{let u=this._correlations.get(a);u?.timer&&clearTimeout(u.timer),this._correlations.delete(a),i(new W(`request() timed out after ${s}ms waiting for reply`))},s):null;this._correlations.set(a,{matcher:t,extract:n,resolve:o,reject:i,timer:c}),typeof e=="string"?this.send(e):this.sendJSON(e)})}onMessage(e){return this._msgListeners.push(e),()=>{let t=this._msgListeners.indexOf(e);t!==-1&&this._msgListeners.splice(t,1)}}onClose(e){return this._closeListeners.push(e),()=>{let t=this._closeListeners.indexOf(e);t!==-1&&this._closeListeners.splice(t,1)}}drainBuffer(){let e=this._buffer.splice(0);return this._bufferedBytes=0,this._updateBackpressure(),e}join(e,t){this._rooms.some(n=>n.room===e&&n.namespace===t)||(this._rooms.push({room:e,namespace:t,joinedAt:Date.now()}),this.sendJSON({type:"room:join",room:e,namespace:t??null}))}leave(e,t){let n=this._rooms.findIndex(s=>s.room===e&&s.namespace===t);n!==-1&&(this._rooms.splice(n,1),this.sendJSON({type:"room:leave",room:e,namespace:t??null}))}get rooms(){return this._rooms}get backpressure(){return{bufferedBytes:this._bufferedBytes,highWaterMark:this._highWaterMark,lowWaterMark:this._lowWaterMark,isBackpressured:this._bufferedBytes>=this._highWaterMark}}drain(e=3e4){return this._state==="CLOSED"?Promise.reject(new W("Cannot drain \u2014 socket is CLOSED")):this._bufferedBytes<this._lowWaterMark?Promise.resolve():new Promise((t,n)=>{let s=e>0?setTimeout(()=>n(new W(`drain() timed out after ${e}ms`)),e):null;this._drainWaiters.push(()=>{s&&clearTimeout(s),t()})})}async drainAndClose(e=3e4){if(this._state!=="CLOSED"){try{await this.drain(e)}catch{}this.close(1e3,"Graceful shutdown")}}get serverEndpoint(){return this._serverEndpoint}[Symbol.asyncIterator](){return{next:()=>this._iterQueue.length>0?Promise.resolve({done:!1,value:this._iterQueue.shift()}):this._iterDone?Promise.resolve({done:!0,value:void 0}):new Promise(e=>{this._iterWaiter=e}),return:()=>(this.close(1e3,"Iterator returned"),Promise.resolve({done:!0,value:void 0}))}}_doConnect(e){return this._mx.totalConnectAttempts++,this._state="CONNECTING",new Promise((t,n)=>{let s=!1,o=null;this._connectTimeoutMs>0&&(o=setTimeout(()=>{if(s)return;s=!0;let l=new wt(this._url,this._connectTimeoutMs);n(l),this._cbError?.(l);let h=this._ws;if(h&&(h.onopen=h.onmessage=h.onerror=h.onclose=null,h.close(),this._ws=null),!this._aborted&&this._canRecon())this._scheduleRecon();else{this._state="CLOSED";for(let d of this._openWaiters.splice(0))d.reject(l);this._rejectCorrelations("Connection timeout")}},this._connectTimeoutMs));let i=()=>{o&&(clearTimeout(o),o=null)},a=this._url,c=(()=>{try{let l=globalThis;if(typeof globalThis.Deno<"u"||typeof globalThis.Bun<"u"||l.process?.versions?.node||typeof window>"u")return!1;let h=window;return typeof h.navigator<"u"&&typeof h.document<"u"}catch{return!1}})();if(this._headers&&c){let l=new URL(a);for(let[h,d]of Object.entries(this._headers))l.searchParams.set(h,d);a=l.href}let u;try{u=this._protocols?new WebSocket(a,this._protocols):new WebSocket(a)}catch(l){i(),this._state="CLOSED",n(new W("Failed to construct WebSocket",l instanceof Error?l:void 0));return}if(this._headers&&!c){let l=u;if(typeof l.setHeader=="function")for(let[h,d]of Object.entries(this._headers))l.setHeader(h,d)}this._ws=u,u.binaryType="arraybuffer",u.onopen=()=>{if(i(),!s){if(s=!0,this._state="OPEN",this._openedAt=Date.now(),this._mx.connectedAt=this._openedAt,e&&this._mx.reconnectCount++,this._serverEndpoint=u.url??this._url,this._reconnAttempt=0,this._rooms.length>0&&this._keepRooms)for(let l of this._rooms)try{u.send(JSON.stringify({type:"room:join",room:l.room,namespace:l.namespace??null}))}catch{}this._startPing(),this._flushBuf(),this._cbOpen?.(this._mx.reconnectCount),t();for(let l of this._openWaiters.splice(0))l.resolve()}},u.onmessage=async l=>{if(this._aborted)return;let h,d,p;if(typeof l.data=="string"){h=l.data,p=new TextEncoder().encode(h).byteLength;try{d=D(JSON.parse(h))}catch{}}else if(l.data instanceof ArrayBuffer)h=new Uint8Array(l.data),p=h.byteLength;else if(typeof Blob<"u"&&l.data instanceof Blob){let g=await l.data.arrayBuffer();h=new Uint8Array(g),p=h.byteLength}else h=new Uint8Array(l.data),p=h.byteLength;this._mx.messagesReceived++,this._mx.bytesReceived+=p;let m={data:h,json:d,timestamp:Date.now()};if(this._pongMatcher&&typeof h=="string"&&(typeof this._pongMatcher=="string"?h===this._pongMatcher:this._pongMatcher.test(h))){this._pongTimer&&(clearTimeout(this._pongTimer),this._pongTimer=null);return}for(let[g,w]of this._correlations)if(w.matcher(m)){this._correlations.delete(g),w.timer&&clearTimeout(w.timer);try{w.resolve(w.extract(m))}catch(y){w.reject(y)}return}for(let g of this._msgListeners)try{g(m)}catch{}if(this._cbMessage?.(m),this._iterWaiter){let g=this._iterWaiter;this._iterWaiter=null,g({done:!1,value:m})}else this._iterQueue.length>=this._maxBufferSize&&this._iterQueue.shift(),this._iterQueue.push(m)},u.onerror=l=>{this._cbError?.(new W(l.message??"WebSocket error",l.error))},u.onclose=l=>{i(),this._stopPing(),this._openedAt!=null&&(this._mx.uptimeMs+=Date.now()-this._openedAt,this._openedAt=null),this._mx.closedAt=Date.now();for(let d of this._closeListeners)try{d({code:l.code,reason:l.reason})}catch{}if(s||(s=!0,n(new W(`Socket closed before open (code ${l.code}: ${l.reason})`))),this._aborted||l.code===1e3||l.code===1001){this._state="CLOSED",this._cbClose?.(l.code,l.reason,!1),this._terminateIter();for(let d of this._openWaiters.splice(0))d.reject(new W(`Socket closed (code ${l.code})`));this._rejectCorrelations(`Socket closed (code ${l.code})`);return}let h=this._canRecon();if(this._cbClose?.(l.code,l.reason,h),h)this._scheduleRecon();else{this._cbGiveUp?.(this._reconnAttempt),this._state="CLOSED",this._terminateIter();let d=new nr(this._reconnAttempt);for(let p of this._openWaiters.splice(0))p.reject(d);this._rejectCorrelations("Max reconnects exceeded")}}})}_canRecon(){return this._maxReconnects===0||this._reconnAttempt<this._maxReconnects}_scheduleRecon(){this._reconnTimer&&(clearTimeout(this._reconnTimer),this._reconnTimer=null),this._state="RECONNECTING",this._reconnAttempt++;let e=this._reconnectBaseMs*Math.pow(2,this._reconnAttempt-1),t=Math.min(e,this._reconnectMaxMs),n=Math.floor(t*(1+this._reconnectJitter*Math.random()));this._cbReconnect?.(this._reconnAttempt,n),this._reconnTimer=setTimeout(()=>{this._reconnTimer=null,this._aborted||this._doConnect(!0).catch(()=>{})},n)}_tx(e){let t=this._ws,n=typeof e=="string"?new TextEncoder().encode(e).byteLength:e.byteLength;if(this._maxSendRate>0){let s=Date.now();this._lastToken===0&&(this._lastToken=s,this._tokens=this._maxSendRate);let o=s-this._lastToken;if(this._tokens=Math.min(this._maxSendRate,this._tokens+o*this._maxSendRate/1e3),this._lastToken=s,this._tokens<1)return this._bufferMessage(e,n),!1;this._tokens--}if(this._bufferedBytes>=this._highWaterMark)return this._bufferMessage(e,n),!1;if(t&&t.readyState===1)try{return t.send(e),this._mx.bytesSent+=n,!0}catch(s){if(this._cbError?.(new W(`WebSocket send failed: ${s instanceof Error?s.message:String(s)}`,s)),t.readyState===1)try{t.close(4001,"Send error")}catch{}return this._ws=null,!this._aborted&&this._canRecon()&&this._scheduleRecon(),!1}return this._bufferMessage(e,n),!1}_bufferMessage(e,t){if(!this._bufferMessages){this._aborted||this._cbError?.(new W(`WebSocket message dropped: the socket is not open and bufferMessages is disabled (${t} bytes). Reconnect, or enable bufferMessages to queue sends made while reconnecting.`));return}if(!this._aborted){let n=this._buffer.length>=this._maxBufferSize?this._buffer.shift():void 0;n!==void 0&&(this._bufferedBytes-=typeof n=="string"?new TextEncoder().encode(n).byteLength:n.byteLength),this._buffer.push(e),this._bufferedBytes+=t,this._updateBackpressure()}}_flushBuf(){let e=this._buffer.splice(0);for(let t of e)try{this._ws?.send(t),this._mx.messagesSent++,this._mx.bytesSent+=typeof t=="string"?new TextEncoder().encode(t).byteLength:t.byteLength}catch{}this._bufferedBytes=0,this._updateBackpressure()}_updateBackpressure(){let e=this._bufferedBytes>=this._highWaterMark;if(e!==this._wasBackpressured&&(this._wasBackpressured=e,this._cbBackpressure?.(e,this.backpressure)),!e&&this._bufferedBytes<this._lowWaterMark&&this._drainWaiters.length>0)for(let t of this._drainWaiters.splice(0))t()}_startPing(){this._pingIntervalMs<=0||(this._pingTimer=setInterval(()=>{let e=this._ws;if(!(!e||e.readyState!==1)){try{e.send(this._pingPayload),this._mx.messagesSent++,this._mx.bytesSent+=new TextEncoder().encode(this._pingPayload).byteLength}catch{}this._pongMatcher&&this._pongTimeoutMs>0&&(this._pongTimer&&clearTimeout(this._pongTimer),this._pongTimer=setTimeout(()=>{this._pongTimer=null;let t=this._ws;t&&(t.onopen=t.onmessage=t.onerror=t.onclose=null,t.close(4e3,"Pong timeout"),this._ws=null),!this._aborted&&this._canRecon()?(this._cbClose?.(4e3,"Pong timeout",!0),this._scheduleRecon()):this._state="CLOSED"},this._pongTimeoutMs),typeof this._pongTimer=="object"&&this._pongTimer!==null&&"unref"in this._pongTimer&&this._pongTimer.unref())}},this._pingIntervalMs),typeof this._pingTimer=="object"&&this._pingTimer!==null&&"unref"in this._pingTimer&&this._pingTimer.unref())}_stopPing(){this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pongTimer&&(clearTimeout(this._pongTimer),this._pongTimer=null)}_stopAll(){this._stopPing(),this._reconnTimer&&(clearTimeout(this._reconnTimer),this._reconnTimer=null)}_terminateIter(){this._iterDone=!0,this._iterWaiter&&(this._iterWaiter({done:!0,value:void 0}),this._iterWaiter=null)}_rejectCorrelations(e){for(let t of this._correlations.values())t.timer&&clearTimeout(t.timer),t.reject(new W(e));this._correlations.clear()}};async function pa(r){let e=new Xe(r);return await e.connect(),e}Re();U();Rt();Rt();U();Re();$e();var $l=0;function Cs(){return`interceptor_${++$l}`}function vs(r,e){let t=r.findIndex(n=>n.priority>e.priority);t===-1?r.push(e):r.splice(t,0,e)}var or=class{constructor(){f(this,"requestInterceptors",[]);f(this,"responseInterceptors",[]);f(this,"errorInterceptors",[])}useRequest(e,t={}){let n=t.id??Cs();return vs(this.requestInterceptors,{id:n,priority:t.priority??0,once:t.once??!1,condition:t.condition??null,fn:e}),n}useResponse(e,t={}){let n=t.id??Cs();return vs(this.responseInterceptors,{id:n,priority:t.priority??0,once:t.once??!1,condition:t.condition??null,fn:e}),n}useError(e,t={}){let n=t.id??Cs();return vs(this.errorInterceptors,{id:n,priority:t.priority??0,once:t.once??!1,condition:t.condition??null,fn:e}),n}use(e,t,n={}){let s=e?this.useRequest(e,n):null,o=t?this.useResponse(t,n):null;return{requestId:s,responseId:o}}eject(e){let t=this.requestInterceptors.length+this.responseInterceptors.length+this.errorInterceptors.length;return this.requestInterceptors=this.requestInterceptors.filter(s=>s.id!==e),this.responseInterceptors=this.responseInterceptors.filter(s=>s.id!==e),this.errorInterceptors=this.errorInterceptors.filter(s=>s.id!==e),this.requestInterceptors.length+this.responseInterceptors.length+this.errorInterceptors.length<t}ejectAll(){this.requestInterceptors=[],this.responseInterceptors=[],this.errorInterceptors=[]}has(e){return this.requestInterceptors.some(t=>t.id===e)||this.responseInterceptors.some(t=>t.id===e)||this.errorInterceptors.some(t=>t.id===e)}get requestCount(){return this.requestInterceptors.length}get responseCount(){return this.responseInterceptors.length}get errorCount(){return this.errorInterceptors.length}async execute(e,t){let n={request:e,response:null,error:null,startedAt:oe(),attempt:0,aborted:!1,store:new Map};return await this._run(n,t)}async _run(e,t){e.attempt++;let n=new Set;for(let s of this.requestInterceptors){if(e.aborted)break;if(s.condition&&!s.condition(e))continue;let o;try{o=await s.fn(e)}catch(i){e.error=i;for(let a of n)this.eject(a);return this._runErrorPhase(e,t)}if(s.once&&n.add(s.id),o!=null){if(Ps(o)){e.response=o;for(let i of n)this.eject(i);return this._runResponsePhase(e,t)}za(o)&&(e.request=o)}}for(let s of n)this.eject(s);try{e.response=await t(e.request)}catch(s){return e.error=s,this._runErrorPhase(e,t)}return this._runResponsePhase(e,t)}async _runResponsePhase(e,t){let n=new Set;for(let s of this.responseInterceptors){if(e.aborted)break;if(s.condition&&!s.condition(e))continue;let o;try{o=await s.fn(e)}catch(i){e.error=i;for(let a of n)this.eject(a);return this._runErrorPhase(e,t)}if(s.once&&n.add(s.id),o!=null){if(za(o)){e.request=o,e.response=null,e.error=null;for(let i of n)this.eject(i);return this._run(e,t)}Ps(o)&&(e.response=o)}}for(let s of n)this.eject(s);if(!e.response)throw new Error("Pipeline produced no response");return e.response}async _runErrorPhase(e,t){let n=new Set;for(let s of this.errorInterceptors){if(s.condition&&!s.condition(e))continue;let o;try{o=await s.fn(e)}catch(i){if(i.__retrySignal){for(let a of n)this.eject(a);return e.error=null,e.response=null,this._run(e,t)}e.error=i;continue}if(s.once&&n.add(s.id),o!=null&&Ps(o)){e.response=o,e.error=null;for(let i of n)this.eject(i);return this._runResponsePhase(e,t)}}for(let s of n)this.eject(s);throw e.error}};function Ps(r){return r!==null&&typeof r=="object"&&typeof r.status=="number"&&"headers"in r&&"request"in r}function za(r){return r!==null&&typeof r=="object"&&typeof r.url=="string"&&typeof r.method=="string"&&!("status"in r)}var Ul={maxRetries:3,baseDelayMs:300,maxDelayMs:3e4,jitter:.3,retryStatuses:[408,429,500,502,503,504],retryOnError:!0,retryMethods:["GET","HEAD","PUT","DELETE","OPTIONS","TRACE","POST"],shouldRetry:null,onRetry:null};function Ds(r={}){let e={...Ul,...r};function t(a,c){if(c!==null)return Math.min(c,e.maxDelayMs);let u=e.baseDelayMs*Math.pow(2,a-1),l=Math.min(u,e.maxDelayMs),h=l*e.jitter*Math.random();return Math.min(Math.floor(l+h),e.maxDelayMs)}function n(a){return a.attempt>e.maxRetries||!e.retryMethods.includes(a.request.method.toUpperCase())?!1:e.shouldRetry?e.shouldRetry(a):a.error?e.retryOnError:a.response?e.retryStatuses.includes(a.response.status):!1}function s(a){let c=a.response?.headers["retry-after"]??a.response?.headers["Retry-After"];if(!c)return null;if(/^\d+$/.test(c.trim()))return parseInt(c,10)*1e3;let u=Ts(c);return u!==null?Math.max(0,u-Date.now()):null}return{responseInterceptor:async a=>{if(!n(a))return;let c=t(a.attempt,s(a));return e.onRetry?.(a,c),await Oe(c),{...a.request}},errorInterceptor:async a=>{if(!n(a))return;let c=t(a.attempt,null);throw e.onRetry?.(a,c),await Oe(c),a.error=null,new Ms(a.request)}}}var Ms=class{constructor(e){f(this,"request");f(this,"__retrySignal",!0);this.request=e}},Hl={getToken:()=>null,refreshToken:null,headerName:"authorization",scheme:"Bearer ",refreshOnStatuses:[401],maxQueue:50,refreshRetryDelay:3e4};function $s(r){let e={...Hl,...r},t=null,n=[],s=null,o=e.refreshRetryDelay??3e4;async function i(){if(s!==null){let u=Date.now()-s;if(u<o)throw new Error(`Auth refresh circuit breaker: last failure ${Math.round(u/1e3)}s ago, retry after ${Math.round((o-u)/1e3)}s`)}if(t){if(n.length>=e.maxQueue)throw new Error("Auth refresh queue full");return await new Promise((u,l)=>n.push({resolve:u,reject:l}))}return e.refreshToken?(t=e.refreshToken().then(u=>{for(let l of n)l.resolve(u);return n.length=0,t=null,s=null,u},u=>{for(let l of n)l.reject(u);throw n.length=0,t=null,s=Date.now(),u}),t):null}return{requestInterceptor:async u=>{let l=await e.getToken();l&&(u.request.headers[e.headerName]=`${e.scheme}${l}`)},responseInterceptor:async u=>{if(!u.response||!e.refreshOnStatuses.includes(u.response.status)||!e.refreshToken||u.request.meta.__authRetried)return;let l=await i();return l?{...u.request,headers:{...u.request.headers,[e.headerName]:`${e.scheme}${l}`},meta:{...u.request.meta,__authRetried:!0}}:void 0}}}var jl={timeoutMs:3e4,methodTimeouts:{},message:"Request timed out"};function Us(r={}){let e={...jl,...r},t=i=>{let a=e.methodTimeouts[i.request.method.toUpperCase()]??e.timeoutMs;if(a<=0)return;let c=new AbortController,u=setTimeout(()=>{i.aborted=!0,c.abort(new Ns(e.message,a))},a),l=i.request.signal;if(l){let h=()=>{clearTimeout(u),c.abort(l.reason)};l.addEventListener("abort",h,{once:!0}),i.store.set(Is,{existing:l,onExistingAbort:h})}i.request={...i.request,signal:c.signal},i.store.set(Ls,u)},n=i=>{let a=i.store.get(Ls);a&&(clearTimeout(a),i.store.delete(Ls));let c=i.store.get(Is);c&&(c.existing.removeEventListener("abort",c.onExistingAbort),i.store.delete(Is))};return{id:"timeout",requestInterceptor:t,responseInterceptor:i=>{n(i)},errorInterceptor:i=>{n(i)}}}var Ls=Symbol("timeoutTimer"),Is=Symbol("timeoutSignal"),Ns=class extends Error{constructor(t,n){super(t);f(this,"timeoutMs");f(this,"code","ETIMEDOUT");this.timeoutMs=n,this.name="TimeoutError"}},Bl={logger:r=>console.log(JSON.stringify(r)),redactHeaders:["authorization","cookie","set-cookie","proxy-authorization"],logRequests:!0,logResponses:!0,logErrors:!0},qa=Symbol("requestId"),zl=0;function Hs(r={}){let e={...Bl,...r},t=new Set(e.redactHeaders.map(c=>c.toLowerCase())),n=c=>pt(c,t,"**REDACTED**");function s(c,u){let l=u.store.get(qa)??"unknown";return{type:c,timestamp:Date.now(),requestId:l,method:u.request.method,url:u.request.url,status:u.response?.status??null,durationMs:c!=="request"?oe()-u.startedAt:null,attempt:u.attempt,error:u.error instanceof Error?u.error.message:null,headers:n(u.request.headers??{})}}return{requestInterceptor:c=>{let u=`req_${++zl}`;c.store.set(qa,u),e.logRequests&&e.logger(s("request",c))},responseInterceptor:c=>{e.logResponses&&e.logger(s("response",c))},errorInterceptor:c=>{e.logErrors&&e.logger(s("error",c))}}}var ql={maxEntries:500,defaultTtlMs:6e4,cacheMethods:["GET","HEAD"],cacheKey:null,honorCacheControl:!0};function js(r={}){let e={...ql,...r},t=new Map,n=[];function s(u){return e.cacheKey?e.cacheKey(u):`${u.method}:${u.url}`}function o(u){let l=n.indexOf(u);for(l!==-1&&n.splice(l,1),n.unshift(u);n.length>e.maxEntries;){let h=n.pop();t.delete(h)}}function i(u){let l=u.headers["cache-control"]??u.headers["Cache-Control"]??"",h=l.match(/max-age=(\d+)/)?.[1],d=l.match(/stale-while-revalidate=(\d+)/)?.[1],p=/no-store/i.test(l),m=/no-cache/i.test(l);if(e.honorCacheControl&&(p||m))return{ttlMs:0,swrMs:0};let g=h?parseInt(h,10)*1e3:e.defaultTtlMs,w=d?parseInt(d,10)*1e3:0;return{ttlMs:g,swrMs:w}}return{requestInterceptor:u=>{if(!e.cacheMethods.includes(u.request.method.toUpperCase()))return;let l=s(u.request),h=t.get(l);if(!h)return;let d=oe();if(h.expiresAt>d)return o(l),u.store.set(Fl,!0),{...h.response,request:u.request};h.staleUntil>d&&(o(l),u.store.set(Fa,h),h.etag?u.request={...u.request,headers:{...u.request.headers,"if-none-match":h.etag}}:h.lastModified&&(u.request={...u.request,headers:{...u.request.headers,"if-modified-since":h.lastModified}}))},responseInterceptor:u=>{if(!u.response||!e.cacheMethods.includes(u.request.method.toUpperCase()))return;let l=s(u.request);if(u.response.status===304){let g=u.store.get(Fa);if(g){let{ttlMs:w,swrMs:y}=i(g.response),S=oe(),b={...g,createdAt:S,expiresAt:S+w,staleUntil:S+w+y};t.set(l,b),o(l),u.response={...g.response,request:u.request};return}}let{ttlMs:h,swrMs:d}=i(u.response);if(h<=0)return;let p=oe(),m={response:u.response,createdAt:p,expiresAt:p+h,staleUntil:p+h+d,etag:u.response.headers.etag??u.response.headers.ETag??null,lastModified:u.response.headers["last-modified"]??null};t.set(l,m),o(l)},store:t}}var Fl=Symbol("cacheHit"),Fa=Symbol("cacheStale");function Bs(){let r=new Map;async function e(o){let i=await Ze(o.headers??{});return`${o.method.toUpperCase()}:${o.url}${i?":"+i:""}`}return{requestInterceptor:async o=>{if(o.request.method.toUpperCase()!=="GET"&&o.request.method.toUpperCase()!=="HEAD")return;let i=await e(o.request);o.store.set(Os,i);let a=r.get(i);if(!a){r.set(i,{promise:void 0,waiters:[]});return}return new Promise((c,u)=>{let l=o.request.signal,h={resolve:p=>c(p),reject:p=>u(p),cleanup:()=>l?.removeEventListener("abort",d)},d=()=>{let p=a.waiters.indexOf(h);p!==-1&&a.waiters.splice(p,1),u(new Error("Request aborted while queued for deduplication"))};if(l?.aborted){d();return}l?.addEventListener("abort",d,{once:!0}),a.waiters.push(h)})},responseInterceptor:o=>{if(!o.response)return;let i=o.store.get(Os);if(!i)return;let a=r.get(i);if(a){r.delete(i);for(let c of a.waiters.splice(0))c.cleanup(),c.resolve(o.response)}},errorInterceptor:o=>{let i=o.store.get(Os);if(!i)return;let a=r.get(i);if(a){r.delete(i);for(let c of a.waiters.splice(0))c.cleanup(),c.reject(o.error)}}}}var Os=Symbol("dedupeKey"),Wl={limit:60,windowMs:6e4,queue:!0,maxQueue:100};function ir(r={}){let e={...Wl,...r};if(!Number.isFinite(e.limit)||e.limit<1)throw new RangeError(`rateLimit.limit must be a finite number >= 1, got ${e.limit}`);if(!Number.isFinite(e.windowMs)||e.windowMs<1)throw new RangeError(`rateLimit.windowMs must be a finite number >= 1, got ${e.windowMs}`);if(!Number.isFinite(e.maxQueue)||e.maxQueue<0)throw new RangeError(`rateLimit.maxQueue must be a finite number >= 0, got ${e.maxQueue}`);let t=e.limit,n=oe(),s=[],o=null;function i(){let u=oe(),l=(u-n)/e.windowMs;t=Math.min(e.limit,t+l*e.limit),n=u}function a(){o===null&&(o=setInterval(()=>{for(i();t>=1&&s.length>0;)t--,s.shift()();s.length===0&&o!==null&&(clearInterval(o),o=null)},Math.ceil(e.windowMs/e.limit)),typeof o=="object"&&o!==null&&"unref"in o&&o.unref())}async function c(){if(i(),t>=1){t--;return}if(!e.queue)throw new At("Rate limit exceeded");if(s.length>=e.maxQueue)throw new At("Rate limit queue full");await new Promise(u=>{s.push(()=>u()),a()})}return async()=>{await c()}}var At=class extends Error{constructor(t){super(t);f(this,"code","ERATELIMIT");this.name="RateLimitError"}},zs={maxConcurrent:10,queue:!0,maxQueue:100},tt=class extends Error{constructor(t){super(t);f(this,"code","ECONCURRENCY");this.name="ConcurrencyLimitError"}};function Wa(r){r.onAbort&&r.signal&&r.signal.removeEventListener("abort",r.onAbort),r.onAbort=null,r.signal=null}var Ct=class{constructor(e={}){f(this,"cfg");f(this,"active",0);f(this,"peak",0);f(this,"waiters",[]);if(this.cfg={...zs,...e},!Number.isFinite(this.cfg.maxConcurrent)||this.cfg.maxConcurrent<1)throw new RangeError(`concurrencyLimit.maxConcurrent must be a finite number >= 1, received ${String(this.cfg.maxConcurrent)}`);if(this.cfg.maxQueue!==Number.POSITIVE_INFINITY&&(!Number.isInteger(this.cfg.maxQueue)||this.cfg.maxQueue<0))throw new RangeError(`concurrencyLimit.maxQueue must be a non-negative integer or Infinity, received ${String(this.cfg.maxQueue)}`)}get inFlight(){return this.active}get waiting(){return this.waiters.length}get highWaterMark(){return this.peak}acquire(e){return e?.aborted?Promise.reject(new x("Concurrency acquire aborted","EABORT")):this.active<this.cfg.maxConcurrent?(this.active++,this.active>this.peak&&(this.peak=this.active),Promise.resolve()):this.cfg.queue?this.waiters.length>=this.cfg.maxQueue?Promise.reject(new tt(`Concurrency queue is full (${this.cfg.maxQueue} waiting)`)):new Promise((t,n)=>{let s={resolve:t,reject:n,onAbort:null,signal:null};if(e){if(e.aborted){n(new x("Concurrency acquire aborted","EABORT"));return}s.onAbort=()=>{let o=this.waiters.indexOf(s);o!==-1&&this.waiters.splice(o,1),n(new x("Concurrency acquire aborted","EABORT"))},s.signal=e,e.addEventListener("abort",s.onAbort,{once:!0})}this.waiters.push(s)}):Promise.reject(new tt(`Concurrency limit reached (${this.cfg.maxConcurrent} in flight) and queueing is disabled`))}release(){if(this.active===0)return;let e=this.waiters.shift();if(!e){this.active--;return}Wa(e),e.resolve()}drain(e=new tt("Client destroyed")){let t=this.waiters.splice(0,this.waiters.length);for(let n of t)Wa(n),n.reject(e)}};function qs(){let r=[],e=Symbol("harStart");function t(i){return Object.entries(i).map(([a,c])=>({name:a,value:c}))}function n(i){try{let a=new URL(i);return Array.from(a.searchParams.entries()).map(([c,u])=>({name:c,value:u}))}catch{return[]}}return{requestInterceptor:i=>{i.store.set(e,oe())},responseInterceptor:i=>{if(!i.response)return;let a=i.store.get(e)??i.startedAt,c=oe()-a,u=i.response.headers["content-type"]??i.response.headers["Content-Type"]??"application/octet-stream",l=i.response.body,h=Math.max(0,sn(l));r.push({startedDateTime:new Date(Date.now()-c).toISOString(),time:c,request:{method:i.request.method.toUpperCase(),url:i.request.url,httpVersion:"HTTP/1.1",headers:t(i.request.headers),queryString:n(i.request.url),bodySize:sn(i.request.body)},response:{status:i.response.status,statusText:i.response.statusText,httpVersion:"HTTP/1.1",headers:t(i.response.headers),content:{size:h,mimeType:u,...typeof l=="string"?{text:l}:{}},bodySize:h,redirectURL:i.response.headers.location??""},timings:{send:0,wait:Math.floor(c*.9),receive:Math.floor(c*.1)}})},getHAR:()=>({version:"1.2",creator:{name:"kinetex",version:"0.0.3"},entries:[...r]}),clearHAR:()=>{r.length=0}}}function Fs(){let r=Symbol("metricsStart"),e=0,t=0,n=0,s={"2xx":0,"3xx":0,"4xx":0,"5xx":0},o=1e4,i=[],a=p=>{p.store.set(r,oe()),e++,p.attempt>1&&n++},c=p=>{if(!p.response)return;let m=p.store.get(r);if(m!==void 0){let w=oe()-m;i.length>=o&&i.shift(),i.push(w)}let g=`${Math.floor(p.response.status/100)}xx`;if(g in s){let w=s;w[g]=(w[g]??0)+1}},u=()=>{t++};function l(p,m){if(p.length===0)return 0;let g=Math.ceil(m/100*p.length)-1,w=Math.min(Math.max(0,g),p.length-1);return p[w]}return{requestInterceptor:a,responseInterceptor:c,errorInterceptor:u,snapshot:()=>{let p=[...i].sort((g,w)=>g-w),m=p.length?p.reduce((g,w)=>g+w,0)/p.length:0;return{totalRequests:e,totalErrors:t,totalRetries:n,statusBuckets:{...s},avgDurationMs:Math.round(m),p50DurationMs:l(p,50),p95DurationMs:l(p,95),p99DurationMs:l(p,99)}},reset:()=>{e=0,t=0,n=0;for(let p of Object.keys(s))s[p]=0;i.length=0}}}var oe=N;function sn(r){return r?typeof r=="string"?new TextEncoder().encode(r).length:r instanceof Uint8Array||r instanceof ArrayBuffer?r.byteLength:-1:0}function Ka(r={}){let e=new or,t=Us(r.timeout);e.useRequest(t.requestInterceptor,{priority:-100,id:"timeout-req"}),e.useResponse(t.responseInterceptor,{priority:-100,id:"timeout-res"}),e.useError(t.errorInterceptor,{priority:-100,id:"timeout-err"}),r.rateLimit&&e.useRequest(ir(r.rateLimit),{priority:-90,id:"ratelimit"});let n=Bs();e.useRequest(n.requestInterceptor,{priority:-80,id:"dedupe-req"}),e.useResponse(n.responseInterceptor,{priority:-80,id:"dedupe-res"}),e.useError(n.errorInterceptor,{priority:-80,id:"dedupe-err"});let s=js(r.cache);e.useRequest(s.requestInterceptor,{priority:-70,id:"cache-req"}),e.useResponse(s.responseInterceptor,{priority:-70,id:"cache-res"});let o=null;r.auth&&(o=$s(r.auth),e.useRequest(o.requestInterceptor,{priority:-50,id:"auth-req"}),e.useResponse(o.responseInterceptor,{priority:-50,id:"auth-res"}));let i=Ds(r.retry);e.useResponse(i.responseInterceptor,{priority:50,id:"retry-res"}),e.useError(i.errorInterceptor,{priority:50,id:"retry-err"});let a=Hs(r.logging);e.useRequest(a.requestInterceptor,{priority:90,id:"log-req"}),e.useResponse(a.responseInterceptor,{priority:90,id:"log-res"}),e.useError(a.errorInterceptor,{priority:90,id:"log-err"});let c=qs();e.useRequest(c.requestInterceptor,{priority:95,id:"har-req"}),e.useResponse(c.responseInterceptor,{priority:95,id:"har-res"});let u=Fs();return e.useRequest(u.requestInterceptor,{priority:100,id:"metrics-req"}),e.useResponse(u.responseInterceptor,{priority:100,id:"metrics-res"}),e.useError(u.errorInterceptor,{priority:100,id:"metrics-err"}),{manager:e,retry:i,auth:o,timeout:{id:t.id},logging:a,cache:s,dedupe:n,har:c,metrics:u}}Re();U();function ar(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}function Va(r){return()=>Promise.resolve(r)}function Ja(){return()=>{let r=Ws("AWS_ACCESS_KEY_ID"),e=Ws("AWS_SECRET_ACCESS_KEY"),t=Ws("AWS_SESSION_TOKEN");return!r||!e?Promise.reject(new V("AWS credentials not found in environment. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.")):Promise.resolve({accessKeyId:r,secretAccessKey:e,...t!==void 0?{sessionToken:t}:{}})}}function Qa(...r){return async()=>{let e=[];for(let t of r)try{return await t()}catch(n){e.push(n instanceof Error?n:new Error(String(n)))}throw new V(`All credential providers failed:
91
91
  ${e.map(t=>` - ${t.message}`).join(`
92
- `)}`)}}function zs(r,e=300*1e3){let t=null,n=null;return()=>{let s=Date.now();return t&&(!t.expiration||new Date(t.expiration).getTime()-s>e)?Promise.resolve(t):n||(n=r().then(o=>(t=o,n=null,o),o=>{throw n=null,o}),n)}}var Ol=new Set(["http://169.254.169.254","http://169.254.170.2","http://fd00:ec2::254"]);function Ml(r){try{let e=new URL(r),t=e.hostname;t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1));let n=`${e.protocol}//${t}`;return Ol.has(n)}catch{return!1}}function ja(r={}){let e=r.endpoint??"http://169.254.169.254",t=r.timeout??5e3;if(!Ml(e))throw new Error(`Invalid IMDS endpoint: ${e}. Only AWS metadata service endpoints are allowed.`);return zs(async()=>{let n=await js(`${e}/latest/api/token`,{method:"PUT",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"21600"}},t);if(!n.ok)throw new F(`IMDS token fetch failed: ${n.status}`);let s=await n.text(),o=await js(`${e}/latest/meta-data/iam/security-credentials/`,{headers:{"x-aws-ec2-metadata-token":s}},t);if(!o.ok)throw new F(`IMDS role fetch failed: ${o.status}`);let a=(await o.text()).trim().split(`
93
- `)[0]?.trim();if(!a)throw new F("No IAM role found in IMDS response");let c=await js(`${e}/latest/meta-data/iam/security-credentials/${encodeURIComponent(a)}`,{headers:{"x-aws-ec2-metadata-token":s}},t);if(!c.ok)throw new F(`IMDS credentials fetch failed: ${c.status}`);let u;try{u=await c.json()}catch(b){throw new F(`IMDS credentials response was not JSON: ${b instanceof Error?b.message:String(b)}`)}if(u===null||typeof u!="object")throw new F(`IMDS credentials response was not an object: ${typeof u}`);let{AccessKeyId:l,SecretAccessKey:h,Token:p,Expiration:d}=u,m=[];if((typeof l!="string"||l.length===0)&&m.push("AccessKeyId"),(typeof h!="string"||h.length===0)&&m.push("SecretAccessKey"),(typeof p!="string"||p.length===0)&&m.push("Token"),m.length>0)throw new F(`IMDS credentials response is missing ${m.join(", ")} \u2014 the metadata endpoint returned a body this client cannot sign with`);let g=(b,T)=>{if(typeof b!="string"||b.length===0)throw new F(`IMDS credentials response is missing ${T}`);return b},y=g(l,"AccessKeyId"),w=g(h,"SecretAccessKey"),_=g(p,"Token");return{accessKeyId:y,secretAccessKey:w,sessionToken:_,...typeof d=="string"?{expiration:d}:{}}})}function rr(r){return r.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,"")}function Et(r){return r.toISOString().slice(0,10).replace(/-/g,"")}function Xr(r){if(r.signingDate){let t=r.signingDate instanceof Date?r.signingDate:new Date(r.signingDate);return r.clockSkewSecs?new Date(t.getTime()+r.clockSkewSecs*1e3):t}let e=new Date;return r.clockSkewSecs?new Date(e.getTime()+r.clockSkewSecs*1e3):e}async function _e(r,e){let t=new TextEncoder,n=typeof r=="string"?t.encode(r):r,s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),o=await crypto.subtle.importKey("raw",s,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),i=await crypto.subtle.sign("HMAC",o,t.encode(e));return new Uint8Array(i)}async function qs(r){let e=new TextEncoder,t=typeof r=="string"?e.encode(r):r,n=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),s=await crypto.subtle.digest("SHA-256",n);return Tt(new Uint8Array(s))}function Tt(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}var Dl=new Set(["user-agent","x-forwarded-for","x-forwarded-host","x-forwarded-proto","accept-encoding","connection","expect","transfer-encoding"]),Nl=new Set(["host","content-type","content-md5"]);function Fs(r,e=!0){let t=encodeURIComponent(r).replace(/[!'()*]/g,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase());return e?t.replace(/%/g,"%25").replace(/%2525/g,"%25"):t}function $l(r,e){if(!r||r==="/")return"/";let n=r.split("/").map(i=>i===""||i==="."||i===".."?i:Fs(decodeURIComponent(i.replace(/\+/g," ")),e)),s=[];for(let i of n)if(i!=="."){if(i===".."){s.pop();continue}s.push(i)}let o=s.join("/");return o.startsWith("/")?o:"/"+o}function Ul(r){let e=[];for(let[t,n]of r.entries())e.push([encodeURIComponent(t).replace(/[!'()*]/g,s=>"%"+s.charCodeAt(0).toString(16).toUpperCase()),encodeURIComponent(n).replace(/[!'()*]/g,s=>"%"+s.charCodeAt(0).toString(16).toUpperCase())]);return e.sort(([t,n],[s,o])=>t<s?-1:t>s?1:n<o?-1:n>o?1:0),e.map(([t,n])=>`${t}=${n}`).join("&")}function Hl(r,e){let t=new Set([...Dl,...e.map(a=>a.toLowerCase())]),n=[];for(let[a,c]of Object.entries(r)){let u=a.toLowerCase();if(u===""||t.has(u)&&!Nl.has(u))continue;let l=c.trim().replace(/\s+/g," ");n.push([u,l])}n.sort(([a],[c])=>a<c?-1:a>c?1:0);let s=new Map;for(let[a,c]of n){let u=s.get(a);s.set(a,u?`${u},${c}`:c)}let o=Array.from(s.entries()).map(([a,c])=>`${a}:${c}`).join(`
92
+ `)}`)}}function Js(r,e=300*1e3){let t=null,n=null;return()=>{let s=Date.now();return t&&(!t.expiration||new Date(t.expiration).getTime()-s>e)?Promise.resolve(t):n||(n=r().then(o=>(t=o,n=null,o),o=>{throw n=null,o}),n)}}var Kl=new Set(["http://169.254.169.254","http://169.254.170.2","http://fd00:ec2::254"]);function Vl(r){try{let e=new URL(r),t=e.hostname;t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1));let n=`${e.protocol}//${t}`;return Kl.has(n)}catch{return!1}}function Ga(r={}){let e=r.endpoint??"http://169.254.169.254",t=r.timeout??5e3;if(!Vl(e))throw new Error(`Invalid IMDS endpoint: ${e}. Only AWS metadata service endpoints are allowed.`);return Js(async()=>{let n=await Ks(`${e}/latest/api/token`,{method:"PUT",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"21600"}},t);if(!n.ok)throw new V(`IMDS token fetch failed: ${n.status}`);let s=await n.text(),o=await Ks(`${e}/latest/meta-data/iam/security-credentials/`,{headers:{"x-aws-ec2-metadata-token":s}},t);if(!o.ok)throw new V(`IMDS role fetch failed: ${o.status}`);let a=(await o.text()).trim().split(`
93
+ `)[0]?.trim();if(!a)throw new V("No IAM role found in IMDS response");let c=await Ks(`${e}/latest/meta-data/iam/security-credentials/${encodeURIComponent(a)}`,{headers:{"x-aws-ec2-metadata-token":s}},t);if(!c.ok)throw new V(`IMDS credentials fetch failed: ${c.status}`);let u;try{u=await c.json()}catch(b){throw new V(`IMDS credentials response was not JSON: ${b instanceof Error?b.message:String(b)}`)}if(u===null||typeof u!="object")throw new V(`IMDS credentials response was not an object: ${typeof u}`);let{AccessKeyId:l,SecretAccessKey:h,Token:d,Expiration:p}=u,m=[];if((typeof l!="string"||l.length===0)&&m.push("AccessKeyId"),(typeof h!="string"||h.length===0)&&m.push("SecretAccessKey"),(typeof d!="string"||d.length===0)&&m.push("Token"),m.length>0)throw new V(`IMDS credentials response is missing ${m.join(", ")} \u2014 the metadata endpoint returned a body this client cannot sign with`);let g=(b,E)=>{if(typeof b!="string"||b.length===0)throw new V(`IMDS credentials response is missing ${E}`);return b},w=g(l,"AccessKeyId"),y=g(h,"SecretAccessKey"),S=g(d,"Token");return{accessKeyId:w,secretAccessKey:y,sessionToken:S,...typeof p=="string"?{expiration:p}:{}}})}function cr(r){return r.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,"")}function vt(r){return r.toISOString().slice(0,10).replace(/-/g,"")}function on(r){if(r.signingDate){let t=r.signingDate instanceof Date?r.signingDate:new Date(r.signingDate);return r.clockSkewSecs?new Date(t.getTime()+r.clockSkewSecs*1e3):t}let e=new Date;return r.clockSkewSecs?new Date(e.getTime()+r.clockSkewSecs*1e3):e}async function Ae(r,e){let t=new TextEncoder,n=typeof r=="string"?t.encode(r):r,s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),o=await crypto.subtle.importKey("raw",s,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),i=await crypto.subtle.sign("HMAC",o,t.encode(e));return new Uint8Array(i)}var Jl=new Set(["user-agent","x-forwarded-for","x-forwarded-host","x-forwarded-proto","accept-encoding","connection","expect","transfer-encoding"]),Ql=new Set(["host","content-type","content-md5"]);function Qs(r,e=!0){let t=encodeURIComponent(r).replace(/[!'()*]/g,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase());return e?t.replace(/%/g,"%25").replace(/%2525/g,"%25"):t}function Gl(r,e){if(!r||r==="/")return"/";let n=r.split("/").map(i=>i===""||i==="."||i===".."?i:Qs(decodeURIComponent(i.replace(/\+/g," ")),e)),s=[];for(let i of n)if(i!=="."){if(i===".."){s.pop();continue}s.push(i)}let o=s.join("/");return o.startsWith("/")?o:"/"+o}function Xl(r){let e=[];for(let[t,n]of r.entries())e.push([encodeURIComponent(t).replace(/[!'()*]/g,s=>"%"+s.charCodeAt(0).toString(16).toUpperCase()),encodeURIComponent(n).replace(/[!'()*]/g,s=>"%"+s.charCodeAt(0).toString(16).toUpperCase())]);return e.sort(([t,n],[s,o])=>t<s?-1:t>s?1:n<o?-1:n>o?1:0),e.map(([t,n])=>`${t}=${n}`).join("&")}function Yl(r,e){let t=new Set([...Jl,...e.map(a=>a.toLowerCase())]),n=[];for(let[a,c]of Object.entries(r)){let u=a.toLowerCase();if(u===""||t.has(u)&&!Ql.has(u))continue;let l=c.trim().replace(/\s+/g," ");n.push([u,l])}n.sort(([a],[c])=>a<c?-1:a>c?1:0);let s=new Map;for(let[a,c]of n){let u=s.get(a);s.set(a,u?`${u},${c}`:c)}let o=Array.from(s.entries()).map(([a,c])=>`${a}:${c}`).join(`
94
94
  `)+`
95
- `,i=Array.from(s.keys()).join(";");return{canonicalHeaders:o,signedHeaders:i}}async function Bs(r,e,t,n,s,o,i){let a=r.toUpperCase(),c=$l(e.pathname,o),u=Ul(e.searchParams),l;s?l="UNSIGNED-PAYLOAD":n?l=await qs(n):l="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";let{canonicalHeaders:h,signedHeaders:p}=Hl(t,i);return{canonicalRequest:[a,c,u,h,p,l].join(`
96
- `),signedHeaders:p,payloadHash:l}}async function Rt(r,e,t,n){let s=new TextEncoder,o=s.encode("AWS4"),i=s.encode(r),a=new Uint8Array(o.length+i.length);a.set(o),a.set(i,o.length),i.fill(0);let c=await _e(a,e),u=await _e(c,t),l=await _e(u,n),h=await _e(l,"aws4_request");return a.fill(0),h}async function Ba(r,e,t){let n=await qs(t);return["AWS4-HMAC-SHA256",r,e,n].join(`
97
- `)}async function Yr(r,e){let t=await Zr(e.credentials),n=Xr(e),s=rr(n),o=Et(n),i=new URL(r.url),a=Object.keys(r.headers).some(T=>T.toLowerCase()==="host"),c={...r.headers,...a?{}:{host:i.host},"x-amz-date":s};e.unsignedPayload&&(c["x-amz-content-sha256"]="UNSIGNED-PAYLOAD"),t.sessionToken&&(c["x-amz-security-token"]=t.sessionToken);let u=e.doubleEncodeUri!==!1,l=e.unsignedHeaders??[],{canonicalRequest:h,signedHeaders:p,payloadHash:d}=await Bs(r.method,i,c,r.body,e.unsignedPayload??!1,u,l);!c["x-amz-content-sha256"]&&!e.unsignedPayload&&(c["x-amz-content-sha256"]=d);let m=`${o}/${e.region}/${e.service}/aws4_request`,g=await Ba(s,m,h),y=await Rt(t.secretAccessKey,o,e.region,e.service),w=await _e(y,g),_=Tt(w),b=`AWS4-HMAC-SHA256 Credential=${t.accessKeyId}/${m}, SignedHeaders=${p}, Signature=${_}`;return{method:r.method,url:r.url,headers:{...c,authorization:b},body:r.body,authorization:b,amzDate:s,signature:_,canonicalRequest:h,stringToSign:g}}async function Ws(r,e,t={}){let n=await Zr(e.credentials),s=Xr(e),o=rr(s),i=Et(s),a=e.service==="s3"?604800:3600,c=t.expiresIn??3600,u=Number.isFinite(c)?Math.min(Math.max(Math.floor(c),1),a):a;u!==c&&console.warn(`[aws-sigv4] presignRequest: expiresIn must be an integer in 1-${a} for ${e.service}, got ${c} \u2014 clamped to ${u}`);let l=new URL(r.url),h=`${i}/${e.region}/${e.service}/aws4_request`;if(l.searchParams.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),l.searchParams.set("X-Amz-Credential",`${n.accessKeyId}/${h}`),l.searchParams.set("X-Amz-Date",o),l.searchParams.set("X-Amz-Expires",String(u)),n.sessionToken&&!t.omitSessionToken&&l.searchParams.set("X-Amz-Security-Token",n.sessionToken),t.extraParams)for(let[C,E]of Object.entries(t.extraParams))l.searchParams.set(C,E);let p=Object.keys(r.headers).some(C=>C.toLowerCase()==="host"),d={...r.headers,...p?{}:{host:l.host}},m=e.unsignedHeaders??[],{canonicalRequest:g,signedHeaders:y}=await Bs(r.method,l,d,null,!0,e.doubleEncodeUri!==!1,m);l.searchParams.set("X-Amz-SignedHeaders",y);let{canonicalRequest:w}=await Bs(r.method,l,d,null,!0,e.doubleEncodeUri!==!1,m),_=await Ba(o,h,w),b=await Rt(n.secretAccessKey,i,e.region,e.service),T=await _e(b,_),k=Tt(T);return l.searchParams.set("X-Amz-Signature",k),l.toString()}async function Ks(r,e){let t={...r,body:null};t.headers={...t.headers,"x-amz-content-sha256":"STREAMING-AWS4-HMAC-SHA256-PAYLOAD","content-encoding":"aws-chunked"};let n=await Yr(t,{...e,unsignedPayload:!1}),s=await Zr(e.credentials),o=Xr(e),i=Et(o),a=rr(o),c=await Rt(s.secretAccessKey,i,e.region,e.service),u=`${i}/${e.region}/${e.service}/aws4_request`;return{signedRequest:n,state:{previousSignature:n.signature,signingKey:c,scope:u,signingDate:a}}}async function za(r,e){let t=typeof r=="string"?new TextEncoder().encode(r):r,n=await qs(t),o=["AWS4-HMAC-SHA256-PAYLOAD",e.signingDate,e.scope,e.previousSignature,"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n].join(`
98
- `),i=await _e(e.signingKey,o),a=Tt(i);return{chunkHeader:`${t.byteLength.toString(16)};chunk-signature=${a}\r
99
- `,newState:{...e,previousSignature:a}}}async function qa(r){let e="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",t=["AWS4-HMAC-SHA256-PAYLOAD",r.signingDate,r.scope,r.previousSignature,e,e].join(`
100
- `),n=await _e(r.signingKey,t);return`0;chunk-signature=${Tt(n)}\r
95
+ `,i=Array.from(s.keys()).join(";");return{canonicalHeaders:o,signedHeaders:i}}async function Vs(r,e,t,n,s,o,i){let a=r.toUpperCase(),c=Gl(e.pathname,o),u=Xl(e.searchParams),l;s?l="UNSIGNED-PAYLOAD":n?l=await pe(n):l="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";let{canonicalHeaders:h,signedHeaders:d}=Yl(t,i);return{canonicalRequest:[a,c,u,h,d,l].join(`
96
+ `),signedHeaders:d,payloadHash:l}}async function Pt(r,e,t,n){let s=new TextEncoder,o=s.encode("AWS4"),i=s.encode(r),a=new Uint8Array(o.length+i.length);a.set(o),a.set(i,o.length),i.fill(0);let c=await Ae(a,e),u=await Ae(c,t),l=await Ae(u,n),h=await Ae(l,"aws4_request");return a.fill(0),h}async function Xa(r,e,t){let n=await pe(t);return["AWS4-HMAC-SHA256",r,e,n].join(`
97
+ `)}async function an(r,e){let t=await cn(e.credentials),n=on(e),s=cr(n),o=vt(n),i=new URL(r.url),a=Object.keys(r.headers).some(E=>E.toLowerCase()==="host"),c={...r.headers,...a?{}:{host:i.host},"x-amz-date":s};e.unsignedPayload&&(c["x-amz-content-sha256"]="UNSIGNED-PAYLOAD"),t.sessionToken&&(c["x-amz-security-token"]=t.sessionToken);let u=e.doubleEncodeUri!==!1,l=e.unsignedHeaders??[],{canonicalRequest:h,signedHeaders:d,payloadHash:p}=await Vs(r.method,i,c,r.body,e.unsignedPayload??!1,u,l);!c["x-amz-content-sha256"]&&!e.unsignedPayload&&(c["x-amz-content-sha256"]=p);let m=`${o}/${e.region}/${e.service}/aws4_request`,g=await Xa(s,m,h),w=await Pt(t.secretAccessKey,o,e.region,e.service),y=await Ae(w,g),S=ar(y),b=`AWS4-HMAC-SHA256 Credential=${t.accessKeyId}/${m}, SignedHeaders=${d}, Signature=${S}`;return{method:r.method,url:r.url,headers:{...c,authorization:b},body:r.body,authorization:b,amzDate:s,signature:S,canonicalRequest:h,stringToSign:g}}async function Gs(r,e,t={}){let n=await cn(e.credentials),s=on(e),o=cr(s),i=vt(s),a=e.service==="s3"?604800:3600,c=t.expiresIn??3600,u=Number.isFinite(c)?Math.min(Math.max(Math.floor(c),1),a):a;u!==c&&console.warn(`[aws-sigv4] presignRequest: expiresIn must be an integer in 1-${a} for ${e.service}, got ${c} \u2014 clamped to ${u}`);let l=new URL(r.url),h=`${i}/${e.region}/${e.service}/aws4_request`;if(l.searchParams.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),l.searchParams.set("X-Amz-Credential",`${n.accessKeyId}/${h}`),l.searchParams.set("X-Amz-Date",o),l.searchParams.set("X-Amz-Expires",String(u)),n.sessionToken&&!t.omitSessionToken&&l.searchParams.set("X-Amz-Security-Token",n.sessionToken),t.extraParams)for(let[C,T]of Object.entries(t.extraParams))l.searchParams.set(C,T);let d=Object.keys(r.headers).some(C=>C.toLowerCase()==="host"),p={...r.headers,...d?{}:{host:l.host}},m=e.unsignedHeaders??[],{canonicalRequest:g,signedHeaders:w}=await Vs(r.method,l,p,null,!0,e.doubleEncodeUri!==!1,m);l.searchParams.set("X-Amz-SignedHeaders",w);let{canonicalRequest:y}=await Vs(r.method,l,p,null,!0,e.doubleEncodeUri!==!1,m),S=await Xa(o,h,y),b=await Pt(n.secretAccessKey,i,e.region,e.service),E=await Ae(b,S),A=ar(E);return l.searchParams.set("X-Amz-Signature",A),l.toString()}async function Xs(r,e){let t={...r,body:null};t.headers={...t.headers,"x-amz-content-sha256":"STREAMING-AWS4-HMAC-SHA256-PAYLOAD","content-encoding":"aws-chunked"};let n=await an(t,{...e,unsignedPayload:!1}),s=await cn(e.credentials),o=on(e),i=vt(o),a=cr(o),c=await Pt(s.secretAccessKey,i,e.region,e.service),u=`${i}/${e.region}/${e.service}/aws4_request`;return{signedRequest:n,state:{previousSignature:n.signature,signingKey:c,scope:u,signingDate:a}}}async function Ya(r,e){let t=typeof r=="string"?new TextEncoder().encode(r):r,n=await pe(t),o=["AWS4-HMAC-SHA256-PAYLOAD",e.signingDate,e.scope,e.previousSignature,"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n].join(`
98
+ `),i=await Ae(e.signingKey,o),a=ar(i);return{chunkHeader:`${t.byteLength.toString(16)};chunk-signature=${a}\r
99
+ `,newState:{...e,previousSignature:a}}}async function Za(r){let e="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",t=["AWS4-HMAC-SHA256-PAYLOAD",r.signingDate,r.scope,r.previousSignature,e,e].join(`
100
+ `),n=await Ae(r.signingKey,t);return`0;chunk-signature=${ar(n)}\r
101
101
  \r
102
- `}async function Vs(r,e){let t=await Zr(e.credentials),n=Xr(e),s=Et(n),o=`${s}/${e.region}/${e.service}/aws4_request`,i=`${t.accessKeyId}/${o}`,a=JSON.stringify(r),c=btoa(a),u=await Rt(t.secretAccessKey,s,e.region,e.service),l=await _e(u,c),h=Tt(l),p={policy:c,signature:h,credential:i,date:s};return t.sessionToken&&(p.securityToken=t.sessionToken),p}function Js(r){let e=r["x-amz-date"]??r["X-Amz-Date"],t;if(e!==void 0){if(t=jl(e),isNaN(t))return 0}else{let n=r.date??r.Date;if(!n||(t=new Date(n).getTime(),isNaN(t)))return 0}return Math.round((t-Date.now())/1e3)}function jl(r){let e=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(r.trim());if(!e)return NaN;let[,t,n,s,o,i,a]=e,c=Date.UTC(Number(t),Number(n)-1,Number(s),Number(o),Number(i),Number(a)),u=new Date(c);return u.getUTCFullYear()!==Number(t)||u.getUTCMonth()+1!==Number(n)?NaN:u.getUTCDate()!==Number(s)?NaN:c}function Qs(r,e){return r!==403&&r!==400?!1:e.includes("RequestTimeTooSkewed")||e.includes("RequestExpired")||e.includes("InvalidSignatureException")||e.includes("AuthFailure")||e.includes("SignatureDoesNotMatch")}var fe=class{constructor(e){f(this,"config");f(this,"clockSkewSecs",0);this.config=e}async sign(e){return await Yr(e,{...this.config,clockSkewSecs:this.clockSkewSecs})}async presign(e,t){return await Ws(e,{...this.config,clockSkewSecs:this.clockSkewSecs},t)}async signPostPolicy(e){return await Vs(e,{...this.config,clockSkewSecs:this.clockSkewSecs})}async initChunked(e){return await Ks(e,{...this.config,clockSkewSecs:this.clockSkewSecs})}updateClockSkew(e){let t=Js(e);t!==0&&(this.clockSkewSecs=t)}handleClockSkewError(e,t,n){return Qs(e,t)?(this.updateClockSkew(n),!0):!1}};async function Zr(r){return await(typeof r=="function"?r():Promise.resolve(r))}function Hs(r){let e=globalThis.Deno;if(typeof e<"u")try{return e.env.get(r)}catch{}try{return globalThis.process?.env?.[r]}catch{}}async function js(r,e,t){let n=new AbortController,s=setTimeout(()=>n.abort(),t);try{let o=e.signal&&typeof AbortSignal<"u"&&"any"in AbortSignal?AbortSignal.any([e.signal,n.signal]):n.signal,i=await fetch(r,{...e,signal:o});return clearTimeout(s),i}catch(o){throw n.signal.aborted?new X(t):o}finally{clearTimeout(s)}}function Fa(r){return new fe({credentials:r.credentials,region:r.region,service:"s3",doubleEncodeUri:!1,unsignedPayload:r.unsignedPayload??!1})}function Wa(r){return new fe({credentials:r.credentials,region:r.region,service:"execute-api"})}function Ka(r){return new fe({credentials:r.credentials,region:r.region,service:"sts"})}function Va(r){return new fe({credentials:r.credentials,region:r.region,service:"dynamodb"})}q();function Ja(r){let e=[];for(let l=0;l<r.length;l++){let h=r.charCodeAt(l);if(h<128)e.push(h);else if(h<2048)e.push(192|h>>6,128|h&63);else if(h<55296||h>=57344)e.push(224|h>>12,128|h>>6&63,128|h&63);else{l++;let p=r.charCodeAt(l),d=65536+((h&1023)<<10|p&1023);e.push(240|d>>18,128|d>>12&63,128|d>>6&63,128|d&63)}}let t=e.length*8;for(e.push(128);e.length*8%512!==448;)e.push(0);for(let l=0;l<4;l++)e.push(t>>>l*8&255);for(let l=4;l<8;l++)e.push(0);let n=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],s=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],o=1732584193,i=4023233417,a=2562383102,c=271733878;for(let l=0;l<e.length;l+=64){let h=[];for(let y=0;y<16;y++){let w=e[l+y*4],_=e[l+y*4+1],b=e[l+y*4+2],T=e[l+y*4+3];h[y]=(w|_<<8|b<<16|T<<24)>>>0}let p=o,d=i,m=a,g=c;for(let y=0;y<64;y++){let w,_;y<16?(w=d&m|~d&g,_=y):y<32?(w=g&d|~g&m,_=(5*y+1)%16):y<48?(w=d^m^g,_=(3*y+5)%16):(w=m^(d|~g),_=7*y%16),w=w+p+n[y]+h[_]>>>0,p=g,g=m,m=d,d=d+(w<<s[y]|w>>>32-s[y])>>>0}o=o+p>>>0,i=i+d>>>0,a=a+m>>>0,c=c+g>>>0}function u(l){let h="";for(let p=0;p<4;p++)h+=(l>>>p*8&255).toString(16).padStart(2,"0");return h}return u(o)+u(i)+u(a)+u(c)}function Qa(r){let e=new Uint8Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=parseInt(r.substr(t*2,2),16);return e}function Bl(r){return r.replace(/\\(.)/g,"$1")}function en(r){let e={algorithm:"MD5"},t=r.replace(/^Digest\s+/i,"").trim(),n='"((?:[^"\\\\]|\\\\.)*)"',s=new RegExp(`(\\w+)\\s*=\\s*(?:${n}|([^,\\s]+))`,"g"),o;for(;(o=s.exec(t))!==null;){let i=o[1].toLowerCase(),a=o[2]!==void 0?Bl(o[2]):o[3];switch(i){case"realm":e.realm=a;break;case"nonce":e.nonce=a;break;case"opaque":e.opaque=a;break;case"algorithm":e.algorithm=a.toUpperCase();break;case"qop":e.qop=a;break;case"domain":e.domain=a;break;case"charset":e.charset=a;break;case"userhash":e.userhash=a==="true";break;case"stale":e.stale=a==="true";break}}if(!e.realm)throw new Error("Digest challenge missing 'realm'");if(!e.nonce)throw new Error("Digest challenge missing 'nonce'");return e}async function Ga(r){let e=new TextEncoder,t=await crypto.subtle.digest("SHA-256",e.encode(r)),n=new Uint8Array(t);return Array.from(n).map(s=>s.toString(16).padStart(2,"0")).join("")}function Xa(r){let e=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],t=[0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n],n=[];for(let c=0;c<r.length;c++){let u=r.charCodeAt(c);if(u<128)n.push(u);else if(u<2048)n.push(192|u>>6,128|u&63);else if(u<55296||u>=57344)n.push(224|u>>12,128|u>>6&63,128|u&63);else{c++;let l=r.charCodeAt(c),h=65536+((u&1023)<<10|l&1023);n.push(240|h>>18,128|h>>12&63,128|h>>6&63,128|h&63)}}let s=BigInt(n.length*8);for(n.push(128);n.length*8%1024!==896;)n.push(0);for(let c=15;c>=0;c--)n.push(Number(s>>BigInt(c*8)&0xffn));function o(c,u){return c>>u|c<<64n-u&0xffffffffffffffffn}let i=t.slice();for(let c=0;c<n.length;c+=128){let u=new Array(80);for(let _=0;_<16;_++){let b=0n;for(let T=0;T<8;T++)b=b<<8n|BigInt(n[c+_*8+T]);u[_]=b}for(let _=16;_<80;_++){let b=o(u[_-15],1n)^o(u[_-15],8n)^u[_-15]>>7n,T=o(u[_-2],19n)^o(u[_-2],61n)^u[_-2]>>6n;u[_]=u[_-16]+b+u[_-7]+T&0xffffffffffffffffn}let l=i[0],h=i[1],p=i[2],d=i[3],m=i[4],g=i[5],y=i[6],w=i[7];for(let _=0;_<80;_++){let b=o(m,14n)^o(m,18n)^o(m,41n),T=m&g^~m&y,k=w+b+T+e[_]+u[_]&0xffffffffffffffffn,C=o(l,28n)^o(l,34n)^o(l,39n),E=l&h^l&p^h&p,I=C+E&0xffffffffffffffffn;w=y,y=g,g=m,m=d+k&0xffffffffffffffffn,d=p,p=h,h=l,l=k+I&0xffffffffffffffffn}i=[i[0]+l&0xffffffffffffffffn,i[1]+h&0xffffffffffffffffn,i[2]+p&0xffffffffffffffffn,i[3]+d&0xffffffffffffffffn,i[4]+m&0xffffffffffffffffn,i[5]+g&0xffffffffffffffffn,i[6]+y&0xffffffffffffffffn,i[7]+w&0xffffffffffffffffn]}let a="";for(let c=0;c<4;c++)a+=i[c].toString(16).padStart(16,"0");return a}async function tn(r,e,t,n,s,o,i){let a=r.qop||"",c=r.nonce,u=r.realm,l=o||ye(5),h=i||"00000001",p=Ya(r.algorithm);if(p===null)throw new Error(`Unsupported digest algorithm: ${r.algorithm}`);let{algo:d,sess:m}=p;async function g(k){return d==="MD5"?Ja(k):d==="SHA-512-256"?Xa(k):await Ga(k)}let y=r.userhash?re(Qa(await g(`${e}:${u}`))):e,w=await g(`${y}:${u}:${t}`);if(m){if(!r.qop)throw new Error(`Digest algorithm ${r.algorithm} requires a qop parameter`);w=await g(`${w}:${c}:${l}`)}let _=await g(`${n}:${s}`),b,T=a.split(/\s*,\s*/).filter(Boolean);if(T.length>0){if(!T.includes("auth"))throw new Error(`Digest challenge offers only unsupported qop values: ${T.join(", ")}. "auth-int" requires the entity body, which this API does not receive.`);b=await g(`${w}:${c}:${h}:${l}:auth:${_}`)}else b=await g(`${w}:${c}:${_}`);return b}async function rn(r,e){if(!r.userhash)return null;let t=Ya(r.algorithm);if(t===null)throw new Error(`Unsupported digest algorithm: ${r.algorithm}`);let{algo:n}=t,s=n==="MD5"?Ja(`${e}:${r.realm}`):n==="SHA-512-256"?Xa(`${e}:${r.realm}`):await Ga(`${e}:${r.realm}`);return re(Qa(s))}function Ya(r){let e=r.trim(),t=/-sess$/i.test(e),n=e.replace(/-sess$/i,"").toUpperCase().replace(/-/g,"");return n==="MD5"?{algo:"MD5",sess:t}:n==="SHA256"?{algo:"SHA-256",sess:t}:n==="SHA512256"?{algo:"SHA-512-256",sess:t}:null}function Me(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function nn(r,e,t,n,s,o,i){let a=[],c=s||ye(5),u=o||"00000001";if(r.userhash){if(i===void 0)throw new Error("challenge offers userhash=true: pass the value from computeUsernameStar() as `usernameStar` \u2014 sending a plaintext username would defeat it");a.push(`username*="${Me(i)}"`)}else{if(i!==void 0)throw new Error("usernameStar was given but the challenge does not offer userhash");a.push(`username="${Me(e)}"`)}return a.push(`realm="${Me(r.realm)}"`),a.push(`nonce="${Me(r.nonce)}"`),a.push(`uri="${Me(n)}"`),a.push(`response="${Me(t)}"`),r.opaque&&a.push(`opaque="${Me(r.opaque)}"`),r.algorithm&&r.algorithm!=="MD5"&&a.push(`algorithm=${r.algorithm}`),r.qop&&(a.push("qop=auth"),a.push(`nc=${u}`),a.push(`cnonce="${Me(c)}"`)),`Digest ${a.join(", ")}`}async function Za(r,e,t,n,s){let o=en(r),i=ye(5),a="00000001",c=await tn(o,e,t,n,s,i,a),u=await rn(o,e);return nn(o,e,c,s,i,a,u??void 0)}function ec(){let r=new Map;return async(e,t,n,s,o)=>{let i=en(e),a=ye(5),c=`${i.realm}\0${i.nonce}`,u=(r.get(c)??0)+1;r.set(c,u);let l=u.toString(16).padStart(8,"0"),h=await tn(i,t,n,s,o,a,l),p=await rn(i,t);return nn(i,t,h,o,a,l,p??void 0)}}Oe();Pt();Pt();var nf=20,sf={maxRetries:3,baseDelayMs:300,maxDelayMs:3e4,jitter:.3,statuses:[408,429,500,502,503,504],onNetworkError:!0,onTimeout:!1,methods:["GET","HEAD","PUT","DELETE","OPTIONS","TRACE"]},ii=class{constructor(){f(this,"_req",new Map);f(this,"_res",new Map);f(this,"_err",new Map);f(this,"_seq",0)}get request(){return Array.from(this._req.values())}get response(){return Array.from(this._res.values())}get error(){return Array.from(this._err.values())}addRequest(e){let t=++this._seq;return this._req.set(t,e),()=>{this._req.delete(t)}}addResponse(e){let t=++this._seq;return this._res.set(t,e),()=>{this._res.delete(t)}}addError(e){let t=++this._seq;return this._err.set(t,e),()=>{this._err.delete(t)}}clear(){this._req.clear(),this._res.clear(),this._err.clear()}};function of(r){if(r){let n=r.spanContext(),s=n.traceFlags.toString(16).padStart(2,"0");return{traceparent:`00-${n.traceId}-${n.spanId}-${s}`,traceId:n.traceId,spanId:n.spanId}}let e=ai(32),t=ai(16);return{traceparent:`00-${e}-${t}-01`,traceId:e,spanId:t}}function ai(r){return ye(r/2)}var af=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-access-token","x-refresh-token","x-csrf-token","x-session-id","x-session-token","x-secret","x-secret-key","x-private-key","api-key","apikey","bearer","token","authentication","credentials","password","passwd","secret"]),Mc="__awsSkewCorrected",Dc="__interceptorResendDepth",Nc=5,cf=new Set(["api_key","apikey","access_token","refresh_token","id_token","token","auth","authorization","key","secret","password","passwd","signature","sig","x-amz-signature","x-amz-credential","x-amz-security-token","x-goog-signature","sas","session","sessionid","jwt","code"]),Bc=8192;function zc(r){if(!r)return!1;let e=r.toLowerCase();return e.includes("json")||e.includes("xml")||e.includes("text/plain")||e.includes("application/javascript")}function ni(r){try{let e=new URL(r),t=!1;for(let n of[...e.searchParams.keys()])cf.has(n.toLowerCase())&&(e.searchParams.set(n,"***REDACTED***"),t=!0);return e.hash&&(e.hash.includes("token")||e.hash.includes("sig")||e.hash.length>1)&&(e.hash="#***REDACTED***",t=!0),t?e.toString():r}catch{return r.replace(/([?&])(api_key|apikey|access_token|refresh_token|token|secret|password|signature|sig)=([^&#]*)/gi,"$1$2=***REDACTED***")}}function $c(r,e){return af.has(r.toLowerCase())?{name:r,value:"***REDACTED***"}:{name:r,value:e}}function uf(r){if(!r.body)return{};let e=r.headers["content-type"]??"";if(e&&!zc(e))return{};let t;if(typeof r.body=="string")t=r.body;else if(r.body instanceof Uint8Array)t=new TextDecoder().decode(r.body);else if(r.body instanceof ArrayBuffer)t=new TextDecoder().decode(new Uint8Array(r.body));else return{};return{postData:{mimeType:e,text:t.slice(0,Bc)}}}var ci=class{constructor(e=1e4){f(this,"_buf",new Map);f(this,"_head",0);f(this,"_tail",0);f(this,"maxEntries");this.maxEntries=e}get entries(){return Array.from(this._buf.values())}record(e,t,n){let s=t.durationMs,o=0,i=s,a=0;try{if(typeof performance<"u"&&typeof performance.getEntriesByType=="function"){let u=typeof performance.getEntriesByName=="function"?performance.getEntriesByName(t.url):performance.getEntriesByType("resource").filter(h=>h.name===t.url),l=u[u.length-1];l&&l.requestStart>0&&Date.now()-l.startTime<6e4&&(o=Math.max(0,l.responseStart-l.requestStart),a=Math.max(0,l.responseEnd-l.responseStart),i=Math.max(0,s-o-a))}}catch{}let c={startedDateTime:new Date(n).toISOString(),time:s,request:{method:e.method,url:ni(e.url),httpVersion:t.httpVersion,headers:Object.entries(e.headers).map(([u,l])=>$c(u,l)),queryString:(()=>{try{return Array.from(new URL(ni(e.url)).searchParams.entries()).map(([u,l])=>({name:u,value:l}))}catch{return[]}})(),bodySize:e.body?typeof e.body=="string"?new TextEncoder().encode(e.body).byteLength:e.body instanceof Uint8Array||e.body instanceof ArrayBuffer?e.body.byteLength:-1:0,...uf(e)},response:{status:t.status,statusText:t.statusText,httpVersion:t.httpVersion,headers:Object.entries(t.headers).map(([u,l])=>$c(u,l)),content:{size:t.rawBody?.byteLength??0,mimeType:t.headers["content-type"]??"application/octet-stream",...typeof t.data=="string"&&zc(t.headers["content-type"])?{text:t.data.slice(0,Bc)}:{}},redirectURL:t.headers.location?ni(t.headers.location):"",bodySize:t.rawBody?.byteLength??0},timings:{send:o,wait:i,receive:a},cache:{}};this._buf.set(this._tail++,c),this._buf.size>this.maxEntries&&this._buf.delete(this._head++)}getHAR(){return{version:"1.2",creator:{name:"kinetex",version:"1.0.0",comment:`runtime:${Se}`},entries:[...this.entries]}}clear(){this._buf.clear(),this._head=0,this._tail=0}get count(){return this._buf.size}};async function Uc(r,e){let t={...r.headers};switch(e.type){case"bearer":{let s=`Bearer ${typeof e.token=="function"?await e.token():e.token}`;if(!ve(s))throw new x("Invalid bearer token \u2014 contains forbidden characters (CRLF/CTL)","EVALIDATION");t.authorization=s;break}case"basic":{let n=new TextEncoder,s=n.encode(e.username),o=n.encode(e.password),i=s.length+1+o.length,a=new Uint8Array(i);a.set(s),a.set(n.encode(":"),s.length),a.set(o,s.length+1);let c=re(a);t.authorization=`Basic ${c}`,s.fill(0),o.fill(0),a.fill(0);break}case"apikey":{let n=typeof e.key=="function"?await e.key():e.key;if(!Ve(e.header))throw new x(`Invalid apikey auth header name: "${e.header}"`,"EVALIDATION");if(!ve(String(n)))throw new x(`Invalid apikey value for "${e.header}" \u2014 contains forbidden characters`,"EVALIDATION");t[e.header.toLowerCase()]=String(n);break}case"digest":break;case"custom":{let n=e.apply(r);if(!n)throw new Error("Custom auth 'apply' must return a KinetexRequest");return n}default:{let n=e;throw new Error(`Unknown auth type: ${n.type}`)}}return{...r,headers:t}}var lf=new Set([...$r,"www-authenticate"]);function xr(r){try{let e=new URL(r);return e.username||e.password?(e.username="",e.password="",e.toString()):r}catch{return r.replace(/\/\/[^/@]*@/,"//")}}function br(r,e,t,n=["http","https"]){let i;if(/^https?:\/\//i.test(e))i=e;else{let a=r??"";try{let c=a.replace(/\/$/,""),u=e.startsWith("/")?e.slice(1):e;i=new URL(u,c+"/").href}catch{let c=a.endsWith("/")?a:a+"/",u=e.startsWith("/")?e.slice(1):e;i=c+u}}if(!t||Object.keys(t).length===0){if(!te(i,n))throw new x(`URL "${xr(i)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");return i}try{let a=new URL(i);if(!te(a,n))throw new x(`URL "${xr(i)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");let c=0;for(let[l,h]of Object.entries(t)){if(h==null)continue;let p=String(h);if(Array.isArray(h)){for(let d of h)if(d!=null){if(c++,c>100)throw new x(`Query parameter count ${c} exceeds limit of 100`,"EVALIDATION");a.searchParams.append(l,String(d))}}else{if(c++,c>100)throw new x(`Query parameter count ${c} exceeds limit of 100`,"EVALIDATION");a.searchParams.set(l,p)}}let u=a.toString();if(u.length>8192)throw new x(`URL length ${u.length} bytes exceeds limit of 8192 bytes`,"EVALIDATION");if(!te(u))throw new x(`URL "${xr(u)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");return u}catch(a){if(a instanceof x)throw a;i.includes("?")?i+="&":i+="?";let c=[],u=0;for(let[h,p]of Object.entries(t??{}))if(p!=null)if(Array.isArray(p)){for(let d of p)if(d!=null){if(u++,u>100)throw new x(`Query parameter count ${u} exceeds limit of 100`,"EVALIDATION");c.push(`${encodeURIComponent(h)}=${encodeURIComponent(String(d))}`)}}else{if(u++,u>100)throw new x(`Query parameter count ${u} exceeds limit of 100`,"EVALIDATION");c.push(`${encodeURIComponent(h)}=${encodeURIComponent(String(p))}`)}let l=i+c.join("&");if(l.length>8192)throw new x(`URL length ${l.length} bytes exceeds limit of 8192 bytes`,"EVALIDATION");if(!te(l))throw new x(`URL "${xr(l)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");return l}}function qt(...r){let e=Object.create(null);for(let t of r){if(!t)continue;let n=Object.keys(t);for(let s of n){if(s==="__proto__"||s==="constructor"||s==="prototype")continue;if(!Ve(s))throw new x(`Invalid header name: "${s}" \u2014 contains forbidden characters`,"EVALIDATION");let o=t[s];if(o==null)continue;let i=Array.isArray(o)?o.map(String).join(", "):String(o);if(!ve(i))throw new x(`Invalid header value for ${s}: contains forbidden characters`,"EVALIDATION");e[s.toLowerCase()]=i}}return e}function Hc(r,e){if(e.attempt>r.maxRetries||!r.methods.includes(e.request.method))return!1;if(r.shouldRetry)return r.shouldRetry(e);if(e.error){let t=e.error,n=t.code;switch(n){case"EHTTPSTATUS":return r.statuses.includes(t.status??0);case"ETIMEOUT":return r.onTimeout===!0;case"ENETWORK":return r.onNetworkError;case"EABORT":return!1;case"ESIZELIMIT":return!1;case"EPARSE":return!1;case"EVALIDATION":return!1;case"EAUTH":return!1;case"EPROXY":return!1;case"EREDIRECT":return!1;case"EUNKNOWN":return!1;default:return!1}}return e.response?r.statuses.includes(e.response.status):!1}function si(r,e,t){if(t!==null)return Math.min(t,r.maxDelayMs);let n=Math.min(e,31),s=r.baseDelayMs*Math.pow(2,n-1);if(!isFinite(s)||s>r.maxDelayMs)return r.maxDelayMs;let o=Math.min(s,r.maxDelayMs),i=o+o*r.jitter*Math.random();return Math.min(Math.floor(i),r.maxDelayMs)}function jc(r){let e=r["retry-after"];if(!e)return null;let t=Zt(e);return t.delay!==null?Math.min(t.delay,86400)*1e3:t.date?Math.max(0,Math.min(t.date.getTime()-Date.now(),864e5)):null}var Ft=class r{constructor(e={}){f(this,"cfg");f(this,"transport");f(this,"interceptors");f(this,"harRecorder");f(this,"retryConfig");f(this,"_cache",null);f(this,"_cookieJar",null);f(this,"_logger",null);f(this,"_cacheInitLock",null);f(this,"_cookieJarInitLock",null);f(this,"_loggerInitLock",null);f(this,"_otelTracer",null);f(this,"_dedup",null);f(this,"_circuitBreakers",null);f(this,"_circuitBreakerKeyFn",null);f(this,"_wsClients",new Set);f(this,"_concurrencyLimiter");f(this,"_awsSigner",null);if(this.cfg=e,this.interceptors=new ii,this.harRecorder=e.har===!0?new ci:null,this.retryConfig={...sf,...e.retry},e.circuitBreakerKeyFn&&(this._circuitBreakerKeyFn=e.circuitBreakerKeyFn),e.rateLimit){let t=tr(e.rateLimit);this.interceptors.addRequest(t)}if(this._concurrencyLimiter=e.concurrencyLimit?new St(e.concurrencyLimit):null,e.awsSigning){let t=new fe(e.awsSigning);this._awsSigner=t,this.interceptors.addRequest(async n=>{let s=n.request,o=null;(s.body instanceof Uint8Array||typeof s.body=="string")&&(o=s.body);let i=await t.sign({method:s.method,url:s.url,headers:{...s.headers},body:o});n.request={...s,headers:i.headers}})}if(this.transport=cr(e.fetch,e.httpVersion!=="HTTP/1.1",e.sessionPool,{...e.strictHeaders?{strict:!0}:{},...e.dispatcher!==void 0?{dispatcher:e.dispatcher}:{},...e.proxy!==void 0?{proxy:e.proxy}:{}}),e.interceptors&&(e.interceptors.request?.forEach(t=>this.interceptors.addRequest(t)),e.interceptors.response?.forEach(t=>this.interceptors.addResponse(t)),e.interceptors.error?.forEach(t=>this.interceptors.addError(t))),e.auth?.type==="digest"){let t=e.auth,n=ec();this.interceptors.addResponse(async s=>{if(!s.response||s.response.status!==401)return;let o=s.response.headers["www-authenticate"];if(!o||!o.toLowerCase().startsWith("digest")||s.request.meta.__digestRetried)return;let i=s.request.method,a=new URL(s.request.url),c=a.pathname+a.search,u=await n(o,t.username,t.password,i,c);return{...s.request,headers:{...s.request.headers,authorization:u},meta:{...s.request.meta,__digestRetried:!0}}})}}useRequest(e){return this.interceptors.addRequest(e)}attachHookRegistry(e){let t=this.useRequest(async o=>{let i={url:o.request.url,method:o.request.method,headers:o.request.headers,body:o.request.body,signal:o.request.signal,meta:o.request.meta},a={request:i,response:null,error:null,startedAt:o.startedAt,attempt:o.attempt,meta:o.request.meta},c=await e.runBeforeRequest(i,a);c!==i&&(o.request={...o.request,...c})}),n=this.useResponse(async o=>{if(!o.response)return;let i={status:o.response.status,statusText:o.response.statusText,headers:o.response.headers,body:o.response.rawBody??null,request:{url:o.request.url,method:o.request.method,headers:o.request.headers,body:o.request.body,signal:o.request.signal,meta:o.request.meta}},a={request:i.request,response:i,error:null,startedAt:o.startedAt,attempt:o.attempt,meta:o.request.meta};await e.runAfterResponse(i,a)}),s=this.useError(async o=>{if(!o.error)return;let i={url:o.request.url,method:o.request.method,headers:o.request.headers,body:o.request.body,signal:o.request.signal,meta:o.request.meta},a=hf(o.error.response,i),c={error:o.error,request:i,response:a,attempt:o.attempt},u={request:c.request,response:a,error:o.error,startedAt:o.startedAt,attempt:o.attempt,meta:o.request.meta};await e.runOnError(c,u)});return()=>{t(),n(),s()}}useResponse(e){return this.interceptors.addResponse(e)}useError(e){return this.interceptors.addError(e)}getHAR(){if(!this.harRecorder)throw new x("HAR recording not enabled. Pass `har: true` in config.","EUNKNOWN");return this.harRecorder.getHAR()}clearHAR(){this.harRecorder?.clear()}async getCache(){if(this._cache)return this._cache;if(!this.cfg.cache)return null;if(this._cacheInitLock)return await this._cacheInitLock,this._cache;let e=()=>{};this._cacheInitLock=new Promise(t=>{e=t});try{let{HTTPCache:t}=await Promise.resolve().then(()=>(bt(),ua));return this._cache=new t(this.cfg.cache),this._cache}finally{e(),this._cacheInitLock=null}}async getCookieJar(){if(this._cookieJar)return this._cookieJar;if(!this.cfg.cookieJar)return null;if(this._cookieJarInitLock)return await this._cookieJarInitLock,this._cookieJar;if(this.cfg.cookieJar instanceof Object&&"setCookie"in this.cfg.cookieJar)return this._cookieJar=this.cfg.cookieJar,this._cookieJar;let e=()=>{};this._cookieJarInitLock=new Promise(t=>{e=t});try{let{CookieJar:t}=await Promise.resolve().then(()=>(yo(),Ec));return this._cookieJar=new t,this._cookieJar}finally{e(),this._cookieJarInitLock=null}}async getLogger(){if(this._logger)return this._logger;if(!this.cfg.logger)return null;if(this._loggerInitLock)return await this._loggerInitLock,this._logger;let e=()=>{};this._loggerInitLock=new Promise(t=>{e=t});try{let{createLogger:t}=await Promise.resolve().then(()=>(Rn(),Tc));return this._logger=t(this.cfg.logger),this._logger}finally{e(),this._loggerInitLock=null}}extend(e){let t=this.cfg.interceptors?.request??[],n=this.cfg.interceptors?.response??[],s=this.cfg.interceptors?.error??[],o=e.interceptors?.request??[],i=e.interceptors?.response??[],a=e.interceptors?.error??[],c=new r({...this.cfg,...e,headers:qt(this.cfg.headers,e.headers),params:{...this.cfg.params,...e.params},interceptors:{request:[...t,...o],response:[...n,...i],error:[...s,...a]}}),u=new Set([...t,...o]),l=new Set([...n,...i]),h=new Set([...s,...a]);for(let p of this.interceptors.request)u.has(p)||c.useRequest(p);for(let p of this.interceptors.response)l.has(p)||c.useResponse(p);for(let p of this.interceptors.error)h.has(p)||c.useError(p);return this._circuitBreakers&&!c._circuitBreakers&&(c._circuitBreakers=this._circuitBreakers),this._dedup&&!c._dedup&&(c._dedup=this._dedup),this._otelTracer&&!c._otelTracer&&(c._otelTracer=this._otelTracer),c}setTracer(e){return this._otelTracer=e,this}enableDedup(e){return this._dedup=new We(e),this}disableDedup(){return this._dedup=null,this}get dedupMetrics(){return this._dedup?this._dedup.getStats():null}enableCircuitBreaker(e){return this._circuitBreakers=new Ke(e),this}disableCircuitBreaker(){return this._circuitBreakers=null,this}tripCircuit(e){return this._circuitBreakers?.trip(e),this}resetCircuit(e){return this._circuitBreakers?.reset(e),this}get circuitSnapshots(){return this._circuitBreakers?.snapshots()??{}}async ws(e,t={}){let n=br(this.cfg.baseURL,e,this.cfg.params,["http","https","ws","wss"]),s=qt(this.cfg.headers,t.headers),o={},i=this.cfg.auth;if(i){if(i.type==="bearer"){let d=typeof i.token=="function"?await i.token():i.token;o.authorization=`Bearer ${d}`}else if(i.type==="basic"){let d=new TextEncoder,m=d.encode(i.username),g=d.encode(i.password),y=new Uint8Array(m.length+1+g.length);y.set(m),y[m.length]=58,y.set(g,m.length+1);let w=re(y);y.fill(0),m.fill(0),g.fill(0),o.authorization=`Basic ${w}`}else if(i.type==="apikey"){let d=typeof i.key=="function"?await i.key():i.key;o[i.header.toLowerCase()]=typeof d=="string"?d:await d}}let a=await this.getCookieJar();if(a){let d=a.getCookieHeader({url:n,http:!1});d&&(s.cookie=d)}try{let d=new URL(n);if(this.cfg.baseURL){let m=new URL(this.cfg.baseURL),g=d.protocol==="wss:",y=m.protocol==="https:"||m.protocol==="wss:";if(g!==y||d.host!==m.host)throw new x(`WebSocket origin ${d.origin} does not match baseURL origin ${m.origin}`,"EVALIDATION")}}catch(d){throw d instanceof x?d:new x(`Invalid WebSocket URL: ${d}`,"EVALIDATION")}if(this._circuitBreakers){let d=this._circuitBreakerKeyFn?this._circuitBreakerKeyFn({url:n,method:"GET",headers:s,body:null,signal:null,meta:{}}):new URL(n).origin;if(this._circuitBreakers.get(d).state==="OPEN")throw new x(`Circuit breaker is open for WebSocket origin ${new URL(n).origin}`,"ENETWORK")}let c=this.cfg.ws,u={...c?.highWaterMark!==void 0?{highWaterMark:c.highWaterMark}:{},...c?.lowWaterMark!==void 0?{lowWaterMark:c.lowWaterMark}:{},...c?.maxSendRate!==void 0?{maxSendRate:c.maxSendRate}:{},...c?.keepRooms!==void 0?{keepRooms:c.keepRooms}:{},...t},l=u.onClose,h=(d,m,g)=>{g||this._wsClients.delete(p),l?.(d,m,g)},p=new Je({url:n,headers:{...o,...s},...u,onClose:h});return this._wsClients.add(p),await p.connect().catch(d=>{throw this._wsClients.delete(p),d}),p}async send(e,t,n={}){let s=Mn(),o=Date.now(),i=n.timeout!==void 0?n.timeout:this.cfg.timeout??3e4,a=n.retry===!1?!1:{...this.retryConfig,...n.retry??{}},c=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE","CONNECT"],u=t.toUpperCase();if(!c.includes(u))throw new x(`Invalid HTTP method '${t}'. Valid methods: ${c.join(", ")}`,"EVALIDATION");let l=br(n.baseURL??this.cfg.baseURL,e,ff(this.cfg.params,n.params));if(n.proxy)throw new x("A per-request `proxy` is not supported because the transport pools one connection per origin \u2014 set `proxy` on the client instead, or use a custom `fetch` with a proxy agent for per-request routing. SOCKS5 requires createSocks5Tunnel() from kinetex/socks5.","EVALIDATION");if(this.cfg.httpsOnly)try{let E=new URL(l);if(E.protocol!=="https:")throw new x(`HTTPS-only mode enabled but URL uses ${E.protocol}. Use HTTPS URLs only.`,"EVALIDATION")}catch(E){throw E instanceof x?E:new x(`Invalid URL: ${E}`,"EVALIDATION")}let p,d=n.maxRequestSize??this.cfg.maxRequestSize??0;if(d>0&&n.body){let E=0;if(typeof n.body=="string")E=new TextEncoder().encode(n.body).byteLength;else if(n.body instanceof Uint8Array)E=n.body.byteLength;else if(n.body instanceof ArrayBuffer)E=n.body.byteLength;else if(n.body instanceof Blob)E=n.body.size;else if(ArrayBuffer.isView(n.body))E=n.body.byteLength;else if(n.body instanceof URLSearchParams)E=new TextEncoder().encode(n.body.toString()).byteLength;else if(n.body instanceof FormData)p=await lr(n.body),E=p.bytes.byteLength;else{if(n.body instanceof ReadableStream)throw new x("maxRequestSize cannot be enforced for ReadableStream bodies \u2014 pass maxRequestSize: 0 to opt out, or buffer the body first","EVALIDATION");if(n.body&&typeof n.body=="object")try{E=new TextEncoder().encode(JSON.stringify(n.body)).byteLength}catch(I){throw new x(`Cannot measure request body size: ${I instanceof Error?I.message:String(I)}`,"EVALIDATION")}}if(E>d)throw new x(`Request body size ${E} bytes exceeds limit of ${d} bytes`,"EVALIDATION")}let m={url:l,method:u,headers:qt(this.cfg.headers,n.headers),body:n.body??null,signal:n.signal??null,...n.followRedirects!==void 0||this.cfg.followRedirects!==void 0?{followRedirects:n.followRedirects??this.cfg.followRedirects}:{},...n.maxRedirects!==void 0||this.cfg.maxRedirects!==void 0?{maxRedirects:n.maxRedirects??this.cfg.maxRedirects}:{},meta:{...n.meta},httpVersion:n.httpVersion??this.cfg.httpVersion??"HTTP/2"};if(m.body!==null&&m.body instanceof FormData&&!m.headers["content-type"]){let E=p??await lr(m.body);m={...m,headers:{...m.headers,"content-type":`multipart/form-data; boundary=${E.boundary}`},body:E.bytes}}m.body!==null&&typeof m.body=="object"&&!(m.body instanceof Uint8Array)&&!(m.body instanceof ArrayBuffer)&&!(m.body instanceof ReadableStream)&&!(m.body instanceof FormData)&&!(m.body instanceof URLSearchParams)&&!(m.body instanceof Blob)&&!m.headers["content-type"]&&(m={...m,headers:{...m.headers,"content-type":"application/json"},body:JSON.stringify(m.body)}),m.body!==null&&typeof URLSearchParams<"u"&&m.body instanceof URLSearchParams&&!m.headers["content-type"]&&(m={...m,headers:{...m.headers,"content-type":"application/x-www-form-urlencoded"}});let g=n.auth!==!1?n.auth??this.cfg.auth:void 0;g&&(m=await Uc(m,g)),this.cfg.transformRequest&&(m=await this.cfg.transformRequest(m));let y=await this.getCookieJar();if(y){let E=y.getCookieHeader({url:m.url,http:!0});E&&(m={...m,headers:{...m.headers,cookie:E}})}let w=null;try{if(this._otelTracer){w=this._otelTracer.startSpan(`HTTP ${m.method}`,{kind:3});let{traceparent:E,traceId:I,spanId:$}=of(w);w.setAttribute("http.request.method",m.method),w.setAttribute("url.full",m.url);try{w.setAttribute("server.address",new URL(m.url).hostname)}catch{}m={...m,headers:{...m.headers,traceparent:E},meta:{...m.meta,traceId:I,spanId:$}}}else if(m.meta.traceId&&!m.headers.traceparent){let E=String(m.meta.traceId),I=ai(16);m={...m,headers:{...m.headers,traceparent:`00-${E}-${I}-01`},meta:{...m.meta,spanId:I}}}}catch(E){throw w&&(w.setStatus({code:2,message:E instanceof Error?E.message:String(E)}),E instanceof Error&&w.recordException(E),w.end()),E}let _;if(this._circuitBreakerKeyFn)try{_=this._circuitBreakerKeyFn(m)}catch{_=m.url}else try{_=new URL(m.url).origin}catch{_=m.url}let b=()=>this._executeWithRetry(m,a,i,n,s,o),T="";if(this._dedup){let E=await be(m.headers??{});T=`${m.method}:${m.url}${E?":"+E:""}`}let k=this._dedup?()=>this._dedup.execute(m.method,T,b).then(E=>E):b,C=this._circuitBreakers?()=>this._circuitBreakers.execute(_,k).then(E=>E):k;try{let E=await C();return w&&(w.setAttribute("http.response.status_code",E.status),w.setStatus({code:E.status<400?1:2}),w.end()),E}catch(E){throw w&&(w.setStatus({code:2,message:E instanceof Error?E.message:String(E)}),E instanceof Error&&w.recordException(E),w.end()),E}}async _executeWithRetry(e,t,n,s,o,i){let a=async()=>{if(!this._concurrencyLimiter)return await this._executeWithRetryInner(e,t,n,s,o,i);await this._concurrencyLimiter.acquire(e.signal);try{return await this._executeWithRetryInner(e,t,n,s,o,i)}finally{this._concurrencyLimiter.release()}},c=Date.now(),u,l;try{let h=await a();return u=h.status,h}catch(h){throw l=h.code,h}finally{this._recordMetrics(e,u,l,Date.now()-c)}}_recordMetrics(e,t,n,s){let o=this._otelTracer;if(!o)return;let i={"http.request.method":e.method,"server.address":new URL(e.url).hostname};t!==void 0&&(i["http.response.status_code"]=t),n!==void 0&&(i["error.type"]=n);try{o.recordHistogram?.("http.client.request.duration",s/1e3,i),o.incrementCounter?.("http.client.request.count",1,i),n!==void 0&&o.incrementCounter?.("http.client.error.count",1,i)}catch{}}async _executeWithRetryInner(e,t,n,s,o,i){let a=0;for(;;){if(a++,e.signal?.aborted)throw ui(e);if(a>1&&df(e.body))throw new x("Cannot retry a request whose body is a stream or Blob \u2014 the body was consumed by the first attempt. Buffer it first, or disable retry for this request.","EVALIDATION",{request:e});try{let c=await this._executeOnce(e,n,s,o,a,i,t);if(t&&a<=t.maxRetries){let u={request:e,response:c,error:null,attempt:a,maxRetries:t.maxRetries};if(t.shouldRetry?await t.shouldRetry(u):Hc(t,u)){let h=si(t,a,jc(c.headers));await t.onRetry?.(u,h),await this.cfg.hooks?.onRetry?.reduce(async(p,d)=>{await p,await d(u)},Promise.resolve()),await oi(h,e.signal);continue}}return c}catch(c){globalThis.__KINETEX_DEBUG_RETRY&&console.log("DBG catch",{attempt:a,maxRetries:t===!1?"FALSE":t?.maxRetries,methods:t===!1?"FALSE":t?.methods,code:c?.code,method:e.method});let u=!1,l=c.response;if(this._awsSigner&&l&&c.code==="EHTTPSTATUS"){let p=l.data,d=typeof p=="string"?p:p instanceof Uint8Array?new TextDecoder().decode(p):p instanceof ArrayBuffer?new TextDecoder().decode(new Uint8Array(p)):JSON.stringify(p??"");this._awsSigner.handleClockSkewError(l.status,d,l.headers)&&(u=!e.meta[Mc],u&&(e.meta[Mc]=!0))}if(t&&(a<=t.maxRetries||u)){let p=l??null,d={request:e,response:p,error:c,attempt:a,maxRetries:t.maxRetries};if(u?!0:t.shouldRetry?await t.shouldRetry(d):Hc(t,d)){let g=si(t,a,p?jc(p.headers):null);await t.onRetry?.(d,g),await this.cfg.hooks?.onRetry?.reduce(async(y,w)=>{await y,await w(d)},Promise.resolve()),await oi(g,e.signal);continue}}let h=await this._runErrorInterceptors(e,c,a,o);if(h)return h;if(s.onError){let p=c instanceof x?c:new x(String(c),"EUNKNOWN",{request:e,cause:c});throw s.onError(p),p}throw c}}}async _sendFollowingRedirects(e,t,n,s){let o=Math.max(0,e.maxRedirects??nf),i=e.followRedirects!==!1&&o>0,a={...e,redirect:"manual"},c=(()=>{try{return new URL(e.url).origin}catch{return null}})(),u=new Set;for(let l=0;l<=o;l++){if(l>0&&s&&(()=>{try{return new URL(a.url).origin===c}catch{return!1}})()&&(a=await Uc(a,s)),l>0&&this.cfg.hooks?.onBeforeRequest)for(let d of this.cfg.hooks.onBeforeRequest){let m=await d(a,{request:a,response:null,error:null,startedAt:Mn(),attempt:1,meta:a.meta});m&&(a={...m,redirect:"manual"})}let h=await Ct(this.transport,a,t);if(l>0){let d=await this.getLogger();if(d){let m=a.meta.requestId??"redirect";d.logResponse(m,h.status,h.statusText,h.headers,new Uint8Array(0),1,!1)}}if(h.status>=300&&h.status<400&&!!h.headers.location){if(u.has(h.url))throw new Pe(`Redirect loop detected: ${h.url}`,e);if(u.add(h.url),n?.processResponseHeaders(h.headers,{url:h.url}),!i)return{...h,redirected:!1};if(l===o)throw new Pe(`Too many redirects (exceeded ${o})`,e);if(h.body)try{await h.body.cancel()}catch{}let d=h.headers.location,m;try{let b=new URL(d,h.url);m=b.href;let T=b.protocol.toLowerCase();if(T!=="http:"&&T!=="https:")throw new x(`Unsafe redirect to ${T} detected \u2014 only HTTP(S) allowed`,"ENETWORK",{request:e});if(!te(m))throw new x(`Unsafe redirect target blocked: ${xr(d)}`,"EVALIDATION",{request:e});if(this.cfg.httpsOnly&&T!=="https:")throw new x(`HTTPS-only mode enabled but redirect target uses ${T}`,"EVALIDATION",{request:e})}catch(b){throw b instanceof x?b:new x(`Invalid redirect location: ${d}`,"ENETWORK",{request:e,cause:b})}let g=h.status===301||h.status===302||h.status===303?"GET":a.method,y=g==="GET"||g==="HEAD"?null:a.body,w={...a.headers},_=!1;try{_=new URL(m).origin!==new URL(a.url).origin}catch{}if(_){for(let b of lf)delete w[b];s&&s.type==="apikey"&&delete w[s.header.toLowerCase()]}if(n){let b=n.getCookieHeader({url:m,http:!0});b?w.cookie=b:delete w.cookie}else _&&delete w.cookie;a={...a,url:m,method:g,body:y,headers:w,redirect:"manual"};continue}return l>0?{...h,redirected:!0}:h}throw new Pe("Redirect loop",e)}async _executeOnce(e,t,n,s,o,i,a){let c={request:e,response:null,error:null,startedAt:s,attempt:o,aborted:!1,store:new Map},u=e.meta.requestId??`req-${o}-${Date.now()}`;if(this._trace(u,"request_interceptors","start",s,o),e=await this._runRequestInterceptors(c),this._trace(u,"request_interceptors","end",s,o),this._trace(u,"lifecycle_before","start",s,o),this.cfg.hooks?.onBeforeRequest)for(let A of this.cfg.hooks.onBeforeRequest){let O=await A(e,this._hookCtx(c));O&&(e=O)}this._trace(u,"lifecycle_before","end",s,o);let l=n.cache!==!1&&n.cache?.forceRefresh===!0;if(n.cache!==!1&&this.cfg.cache){let A=await this.getCache();if(A&&!l){let O={url:e.url,method:e.method,headers:e.headers},L=await A.get(O);if(L&&!L.stale){let H=await this._buildResponse(L.entry.response,e,!0,o,s,n);if(this.cfg.hooks?.onBeforeResponse)for(let B of this.cfg.hooks.onBeforeResponse)await B(H,this._hookCtx(c));return H}if(L?.stale){if(await A.markSWRInFlight(O)){let j={...e,headers:{...e.headers,...A.buildConditionalHeaders(L.entry)}};(async()=>{try{let U=await Ct(this.transport,j,t),it=await this.getCache();if(it)if(U.status===304)await it.revalidate({url:j.url,method:j.method,headers:j.headers},{status:304,statusText:"Not Modified",headers:U.headers,body:null});else{let{decompressBodyStream:Bu,readRawBody:zu}=await Promise.resolve().then(()=>(Pt(),yc)),qu=await Bu(U.body,U.headers),Fu=await zu(qu,0,U.url,j.signal);await it.set({url:j.url,method:j.method,headers:j.headers},{status:U.status,statusText:U.statusText,headers:U.headers,body:Fu},{tags:n.tags??[]})}}catch(U){if(this.cfg.onSWRError)try{this.cfg.onSWRError(U,j)}catch{}}finally{try{(await this.getCache())?.clearSWRInFlight(O)}catch{}}})()}return await this._buildResponse(L.entry.response,e,!0,o,s,n)}}}let h=[];n.onUploadProgress&&h.push(n.onUploadProgress),this.cfg.hooks?.onUploadProgress&&h.push(...this.cfg.hooks.onUploadProgress);let p=h.length>0?h:null,d=null;if(p!==null&&e.body!==null){let A=null,O=null;if(e.body instanceof ReadableStream)A=e.body;else if(typeof e.body=="string"){let L=new TextEncoder().encode(e.body);O=L.byteLength,A=new ReadableStream({start:H=>{H.enqueue(L),H.close()}})}else if(e.body instanceof Uint8Array)O=e.body.byteLength,A=new ReadableStream({start:L=>{L.enqueue(e.body),L.close()}});else if(e.body instanceof ArrayBuffer){let L=new Uint8Array(e.body);O=L.byteLength,A=new ReadableStream({start:H=>{H.enqueue(L),H.close()}})}else if(typeof Blob<"u"&&e.body instanceof Blob)O=e.body.size,A=e.body.stream();else if(typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams){let L=new TextEncoder().encode(e.body.toString());O=L.byteLength,A=new ReadableStream({start:H=>{H.enqueue(L),H.close()}})}if(A){let{stream:L}=Qt(A,O,{onProgress:H=>{let B=H;for(let j of h)j(B)},...e.signal!==null?{signal:e.signal}:{}});d=L,e={...e,body:L}}}e.headers["accept-encoding"]||(e={...e,headers:{...e.headers,"accept-encoding":yn}});let m=await this.getCookieJar(),g=n.auth!==!1?n.auth??this.cfg.auth:void 0;this._trace(u,"transport_send","start",s,o);let y;try{y=await this._sendFollowingRedirects(e,t,m??void 0,g)}catch(A){if(d)try{d.cancel("Request failed").catch(()=>{})}catch{}throw A}if(this._trace(u,"transport_send","end",s,o),this.cfg.hooks?.onAfterRequest)for(let A of this.cfg.hooks.onAfterRequest)await A(e,this._hookCtx(c));if(y.status===304){let A=await this.getCache();if(A){let O=await A.revalidate({url:e.url,method:e.method,headers:e.headers},{status:304,statusText:"Not Modified",headers:y.headers,body:null});if(O)return await this._buildResponse(O.response,e,!0,o,s,n)}}y.alreadyDecompressed&&(delete y.headers["content-encoding"],delete y.headers["Content-Encoding"]);let w=await hr(y.body,y.headers),_=[];n.onDownloadProgress&&_.push(n.onDownloadProgress),this.cfg.hooks?.onDownloadProgress&&_.push(...this.cfg.hooks.onDownloadProgress);let b=_.length>0?_:null,T=w;if(b&&T){let A=y.headers["content-length"],O=A?parseInt(A,10):null,L=new J(O&&!isNaN(O)?O:null,{onProgress:B=>{let j=B;for(let U of _)U(j)},...e.signal!==null?{signal:e.signal}:{}}),H=T;T=new ReadableStream({async start(B){let j=H.getReader();try{for(;;){let{done:U,value:it}=await j.read();if(U){L.complete(),B.close();break}L.update(it.byteLength),B.enqueue(it)}}catch(U){B.error(U)}finally{j.releaseLock()}},cancel(B){H.cancel(B).catch(()=>{})}})}let k=n.maxResponseSize??this.cfg.maxResponseSize??0,C=await ur(T,k,y.url,e.signal),E=await this.getCookieJar();E&&E.processResponseHeaders(y.headers,{url:y.url});let I=y.headers["content-type"]??null;this._trace(u,"response_parse","start",s,o);let $=await vt(C,I,n.parseResponse,n.parseFailure,y.headers,y.url);this._trace(u,"response_parse","end",s,o);let v=Mn()-s,P={status:y.status,statusText:y.statusText,headers:y.headers,data:$,rawBody:C,url:y.url,cached:!1,redirected:y.redirected,httpVersion:y.httpVersion,durationMs:v,request:e,attempt:o};if(this.cfg.transformResponse&&(P.data=this.cfg.transformResponse(P.data,P)),n.cache!==!1&&this.cfg.cache){let A=await this.getCache();A&&y.status!==304&&await A.set({url:e.url,method:e.method,headers:e.headers},{status:y.status,statusText:y.statusText,headers:y.headers,body:C},{tags:n.tags??[]})}let Ae=await this.getLogger();if(Ae){let A=c.store.get("requestId")??e.meta.requestId??"unknown";Ae.logResponse(A,P.status,P.statusText,P.headers,C,o,!1)}this.harRecorder?.record(e,P,i??Date.now()-P.durationMs),c.response=P,this._trace(u,"response_interceptors","start",s,o);let V=await this._runResponseInterceptors(c,P,e,t,n,s,o,a??!1);if(this._trace(u,"response_interceptors","end",s,o),this.cfg.hooks?.onBeforeResponse){let A=V;for(let O of this.cfg.hooks.onBeforeResponse){let L=await O(A,this._hookCtx(c));L&&(A=L)}}if((n.throwOnError??this.cfg.throwOnError??!0)&&V.status>=400)throw new pt(V,e);if(this.cfg.hooks?.onAfterResponse)for(let A of this.cfg.hooks.onAfterResponse)await A(V,this._hookCtx(c));return n.onSuccess?.(V),V}async _runRequestInterceptors(e){let t=e.request;for(let n of this.interceptors.request){e.request=t;let s=await n(e);s&&"url"in s&&!("status"in s)?t=s:e.request!==t&&(t=e.request)}return e.request=t,t}async _runResponseInterceptors(e,t,n,s,o,i,a,c){let u=t;for(let l of this.interceptors.response){let h=await l(e);if(h){if("status"in h&&"headers"in h)u=h;else if("url"in h&&"method"in h&&!("status"in h)){let p=Number(n.meta[Dc]??0);if(p>=Nc)throw new x(`Response interceptor re-send limit reached (${Nc}) \u2014 refusing to loop`,"EVALIDATION",{request:n});if(c&&a<=c.maxRetries){let d={request:n,response:t,error:null,attempt:a,maxRetries:c.maxRetries},m=si(c,a,0);await c.onRetry?.(d,m),await this.cfg.hooks?.onRetry?.reduce(async(g,y)=>{await g,await y(d)},Promise.resolve()),await oi(m,n.signal)}return this._executeOnce({...h,meta:{...h.meta,[Dc]:p+1}},s,o,i,a+1,void 0,c)}}}return u}async _runErrorInterceptors(e,t,n,s){let o={request:e,response:null,error:t,startedAt:s,attempt:n,aborted:!1,store:new Map};for(let i of this.interceptors.error){let a=await i(o);if(a&&"status"in a)return a}if(this.cfg.hooks?.onError)for(let i of this.cfg.hooks.onError){let a=await i(t,this._hookCtx(o));if(a)return a}return null}async _buildResponse(e,t,n,s,o,i){let a=e.body,c=a instanceof Uint8Array?a:typeof a=="string"?new TextEncoder().encode(a):null,u=c?await vt(c,e.headers["content-type"]??null,i.parseResponse,i.parseFailure,e.headers,"url"in e?e.url:t.url):null,l=Mn()-o,h="url"in e?e.url:t.url,p="redirected"in e?e.redirected:!1,d="httpVersion"in e?e.httpVersion:"HTTP/1.1";return{status:e.status,statusText:e.statusText,headers:e.headers,data:u,rawBody:c,url:h,cached:n,redirected:p,httpVersion:d,durationMs:l,request:t,attempt:s}}_hookCtx(e){return{request:e.request,response:e.response,error:e.error,startedAt:e.startedAt,attempt:e.attempt,meta:e.request.meta}}_trace(e,t,n,s,o,i){if(this.cfg.onPipelineTrace)try{console.debug("[kinetex:trace]",e,t,n,o),this.cfg.onPipelineTrace({requestId:e,stage:t,event:n,elapsedMs:typeof performance<"u"?performance.now()-s:Date.now()-s,attempt:o,...i})}catch{}}get(e,t){return this.send(e,"GET",t)}post(e,t,n){return this.send(e,"POST",{...n,...t!==void 0?{body:t}:{}})}put(e,t,n){return this.send(e,"PUT",{...n,...t!==void 0?{body:t}:{}})}patch(e,t,n){return this.send(e,"PATCH",{...n,...t!==void 0?{body:t}:{}})}delete(e,t){return this.send(e,"DELETE",t)}head(e,t){return this.send(e,"HEAD",t)}options(e,t){return this.send(e,"OPTIONS",t)}request(e,t){return new _r(this,e,t)}GET(e){return this.request("GET",e)}POST(e){return this.request("POST",e)}PUT(e){return this.request("PUT",e)}PATCH(e){return this.request("PATCH",e)}DELETE(e){return this.request("DELETE",e)}async sse(e,t={}){let{SSEClient:n}=await Promise.resolve().then(()=>(yr(),Co)),s=qt(this.cfg.headers,t.headers),o=br(this.cfg.baseURL,e,this.cfg.params),i=async(a,c)=>{let u=typeof a=="string"?a:a.url,l=c,h=await this.send(u,l.method??"GET",{headers:l.headers,body:l.body,signal:l.signal,throwOnError:!1,parseResponse:d=>d}),p={...h.headers};return delete p["content-encoding"],delete p["Content-Encoding"],new Response(h.rawBody?.buffer??null,{status:h.status,headers:p})};return new n({url:o,headers:s,fetch:i,...t})}async graphql(e,t={}){let{GraphQLClient:n}=await Promise.resolve().then(()=>(Pn(),Ic)),s=qt(this.cfg.headers,t.headers),o=br(this.cfg.baseURL,e,this.cfg.params),i=async(a,c)=>{let u=typeof a=="string"?a:a.url,l=c,h=await this.send(u,l.method??"POST",{headers:l.headers,body:l.body,signal:l.signal,throwOnError:!1,parseResponse:d=>d}),p={...h.headers};return delete p["content-encoding"],delete p["Content-Encoding"],new Response(h.rawBody?.buffer??null,{status:h.status,headers:p})};return new n({url:o,headers:s,fetch:i,...t})}async paginate(e,t){let{createPagePaginator:n}=await Promise.resolve().then(()=>(On(),Oc)),s=br(this.cfg.baseURL,e,this.cfg.params);return n({url:s,fetch:async(i,a)=>{let c=typeof i=="string"?i:i.url,u=a,l=await this.send(c,u.method??"GET",{headers:u.headers,body:u.body,signal:u.signal,throwOnError:!1,parseResponse:p=>p}),h={...l.headers};return delete h["content-encoding"],delete h["Content-Encoding"],new Response(l.rawBody?.buffer??null,{status:l.status,headers:h})},headers:qt(this.cfg.headers),...t})}destroy(){for(let e of this._wsClients)try{e.close(1e3,"Client destroyed")}catch{}return this._wsClients.clear(),Ue&&this.transport&&"destroy"in this.transport&&this.transport.destroy(),this._concurrencyLimiter?.drain(),this._cookieJar=null,this._logger=null,this._dedup?.clear(),this._circuitBreakers?.clear?.(),this._otelTracer=null,this.interceptors.clear(),Promise.resolve()}},_r=class{constructor(e,t,n){f(this,"client");f(this,"method");f(this,"_options",{});f(this,"_url");this.client=e,this.method=t,this._url=n}header(e,t){return this._options.headers={...this._options.headers,[e.toLowerCase()]:t},this}idempotencyKey(e){let t=e===void 0?Jr():e;if(!Qr(t))throw new TypeError(`idempotencyKey: ${typeof t=="string"?JSON.stringify(t):typeof t} is not a valid Idempotency-Key \u2014 expected 1-255 visible ASCII characters`);return this._options.headers={...this._options.headers,"idempotency-key":t},this}headers(e){return this._options.headers={...this._options.headers,...e},this}param(e,t){return this._options.params={...this._options.params,[e]:t},this}params(e){return this._options.params={...this._options.params,...e},this}withBody(e){return this._options.body=e,this}withJSON(e){return this._options.body=JSON.stringify(e),this._options.headers={...this._options.headers,"content-type":"application/json"},this}withForm(e){return this._options.body=e,this}bearer(e){return this._options.auth={type:"bearer",token:e},this}basic(e,t){return this._options.auth={type:"basic",username:e,password:t},this}apiKey(e,t){return this._options.auth={type:"apikey",header:e,key:t},this}digest(e,t){return this._options.auth={type:"digest",username:e,password:t},this}noAuth(){return this._options.auth=!1,this}retry(e,t){return this._options.retry={maxRetries:e,...t},this}noRetry(){return this._options.retry=!1,this}timeout(e){return this._options.timeout=e,this}proxy(e){return this._options.proxy=e,this}cache(e){return this._options.cache=e,this}noCache(){return this._options.cache={forceRefresh:!0},this}onUploadProgress(e){return this._options.onUploadProgress=e,this}onDownloadProgress(e){return this._options.onDownloadProgress=e,this}signal(e){return this._options.signal=e,this}maxSize(e){return this._options.maxResponseSize=e,this}http2(){return this._options.httpVersion="HTTP/2",this}http1(){return this._options.httpVersion="HTTP/1.1",this}noThrow(){return this._options.throwOnError=!1,this}tags(...e){return this._options.tags=e,this}meta(e){return this._options.meta={...this._options.meta,...e},this}send(){return this.client.send(this._url,this.method,this._options)}async data(){return(await this.client.send(this._url,this.method,this._options)).data}async json(){let e={...this._options};return e.headers={...e.headers,accept:"application/json"},(await this.client.send(this._url,this.method,e)).data}async text(){let e={...this._options};return e.parseResponse=n=>new TextDecoder("utf-8").decode(n),(await this.client.send(this._url,this.method,e)).data}async bytes(){let e={...this._options};return e.parseResponse=n=>n,(await this.client.send(this._url,this.method,e)).data}async blob(){let e=await this.bytes(),t="application/octet-stream";if(typeof Blob>"u")throw new x("Blob is not available in this runtime","EUNKNOWN");return new Blob([e.buffer],{type:t})}subscribe(e,t){this.client.send(this._url,this.method,{...this._options,onSuccess:e,...t!==void 0?{onError:t}:{}}).catch(n=>t?.(n instanceof x?n:new x(String(n),"EUNKNOWN")))}};function hf(r,e){return r?{status:r.status,statusText:r.statusText,headers:r.headers,body:r.rawBody??null,request:e}:null}function ui(r){return new mt(r)}function ff(r,e){if(!(!r&&!e))return{...r,...e}}function oi(r,e){return new Promise((t,n)=>{if(e?.aborted){n(ui());return}let s=()=>{clearTimeout(o),n(ui())},o=setTimeout(()=>{e?.removeEventListener("abort",s),t()},r);e?.addEventListener("abort",s,{once:!0})})}function df(r){return r instanceof ReadableStream?!0:typeof Blob<"u"&&r instanceof Blob}function Mn(){return typeof performance<"u"?performance.now():Date.now()}function qc(r){try{return`${r.method}:${new URL(r.url).origin}`}catch{return`${r.method}:${r.url}`}}var Dn=class{constructor(e,t={}){f(this,"_client");f(this,"_maxBatch");f(this,"_flushMs");f(this,"_queue",[]);f(this,"_timer",null);this._client=e;let n=t.maxBatch??100;if(!Number.isInteger(n)||n<1)throw new RangeError(`BatchQueue maxBatch must be a positive integer (got ${n})`);this._maxBatch=n;let s=t.flushMs??0;if(!Number.isFinite(s)||s<0)throw new RangeError(`BatchQueue flushMs must be a non-negative finite number (got ${s})`);this._flushMs=s}enqueue(e,t="GET",n={}){return new Promise((s,o)=>{let i={url:e,method:t,options:n,resolve:s,reject:o};this._queue.push(i);let a=n.signal;if(a){let c=()=>{let u=this._queue.indexOf(i);u!==-1&&(this._queue.splice(u,1),o(new x("Request aborted while queued","EABORT")))};if(i._abortCleanup=()=>a.removeEventListener("abort",c),a.addEventListener("abort",c,{once:!0}),a.aborted){a.removeEventListener("abort",c);let u=this._queue.indexOf(i);u!==-1&&this._queue.splice(u,1),o(new x("Request aborted before flush","EABORT"));return}}this._queue.length>=this._maxBatch?this._flushNow():this._timer||(this._flushMs===0?queueMicrotask(()=>{this._timer=null,this._flushNow()}):this._timer=setTimeout(()=>this._flushNow(),this._flushMs))})}flush(){let e=this._queue.length+1;for(;this._queue.length>0&&e-- >0;)this._flushNow()}get pendingCount(){return this._queue.length}_flushNow(){if(this._timer!==null&&(clearTimeout(this._timer),this._timer=null),this._queue.length===0)return;let e=this._queue.splice(0,this._maxBatch);for(let t of e){let n=o=>{t._abortCleanup?.(),t.resolve(o)},s=o=>{t._abortCleanup?.(),t.reject(o)};try{this._client.send(t.url,t.method,t.options).then(n,s)}catch(o){s(o)}}}};bt();xn();Pt();Pn();Oe();var Sr=class{constructor(){f(this,"listeners",new Map)}on(e,t){let n=this.listeners.get(e)??[];return n.push({fn:t,once:!1}),this.listeners.set(e,n),this}once(e,t){let n=this.listeners.get(e)??[];return n.push({fn:t,once:!0}),this.listeners.set(e,n),this}off(e,t){let n=this.listeners.get(e);return n?(this.listeners.set(e,n.filter(s=>s.fn!==t)),this):this}async emit(e,t){let n=this.listeners.get(e);if(!n||n.length===0)return;let s=[...n],o=new Set;for(let i of s){try{await i.fn(t)}catch{}i.once&&o.add(i)}if(o.size>0){let i=this.listeners.get(e)??[];this.listeners.set(e,i.filter(a=>!o.has(a)))}}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}},pf=0;function mf(){return`hook_${++pf}`}function Z(r){return[...r].sort((e,t)=>e.priority-t.priority)}var Nn=class{constructor(){f(this,"beforeRequest",[]);f(this,"afterRequest",[]);f(this,"beforeResponse",[]);f(this,"afterResponse",[]);f(this,"onError",[]);f(this,"onRetry",[]);f(this,"onRedirect",[]);f(this,"onUploadProgress",[]);f(this,"onDownloadProgress",[]);f(this,"onCancel",[]);f(this,"onConnection",[]);f(this,"aroundHooks",[]);f(this,"emitter",new Sr)}addBeforeRequest(e,t={}){return this._add(this.beforeRequest,e,t)}addAfterRequest(e,t={}){return this._add(this.afterRequest,e,t)}addBeforeResponse(e,t={}){return this._add(this.beforeResponse,e,t)}addAfterResponse(e,t={}){return this._add(this.afterResponse,e,t)}addOnError(e,t={}){return this._add(this.onError,e,t)}addOnRetry(e,t={}){return this._add(this.onRetry,e,t)}addOnRedirect(e,t={}){return this._add(this.onRedirect,e,t)}addOnUploadProgress(e,t={}){return this._add(this.onUploadProgress,e,t)}addOnDownloadProgress(e,t={}){return this._add(this.onDownloadProgress,e,t)}addOnCancel(e,t={}){return this._add(this.onCancel,e,t)}addOnConnection(e,t={}){return this._add(this.onConnection,e,t)}addAround(e,t={}){return this._add(this.aroundHooks,e,t)}remove(e){let t=!1,n=[this.beforeRequest,this.afterRequest,this.beforeResponse,this.afterResponse,this.onError,this.onRetry,this.onRedirect,this.onUploadProgress,this.onDownloadProgress,this.onCancel,this.onConnection,this.aroundHooks];for(let s of n){let o=s.length,i=s.filter(a=>a.id!==e);i.length<o&&(s.length=0,s.push(...i),t=!0)}return t}removeAll(){this.beforeRequest.length=0,this.afterRequest.length=0,this.beforeResponse.length=0,this.afterResponse.length=0,this.onError.length=0,this.onRetry.length=0,this.onRedirect.length=0,this.onUploadProgress.length=0,this.onDownloadProgress.length=0,this.onCancel.length=0,this.onConnection.length=0,this.aroundHooks.length=0}has(e){return[this.beforeRequest,this.afterRequest,this.beforeResponse,this.afterResponse,this.onError,this.onRetry,this.onRedirect,this.onUploadProgress,this.onDownloadProgress,this.onCancel,this.onConnection,this.aroundHooks].some(n=>n.some(s=>s.id===e))}async runBeforeRequest(e,t){let n=e;for(let s of Z(this.beforeRequest)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(n,t));o&&typeof o=="object"&&"url"in o&&(n=o),this._maybeEject(s,this.beforeRequest)}return await this.emitter.emit("before:request",n),n}async runAfterRequest(e,t){for(let n of Z(this.afterRequest))this._shouldRun(n,t)&&(await this._safeRun(n,()=>n.fn(e,t)),this._maybeEject(n,this.afterRequest));await this.emitter.emit("after:request",e)}async runBeforeResponse(e,t){let n=e;for(let s of Z(this.beforeResponse)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(n,t));o&&typeof o=="object"&&"status"in o&&(n=o),this._maybeEject(s,this.beforeResponse)}return await this.emitter.emit("before:response",n),n}async runAfterResponse(e,t){for(let n of Z(this.afterResponse))this._shouldRun(n,t)&&(await this._safeRun(n,()=>n.fn(e,t)),this._maybeEject(n,this.afterResponse));await this.emitter.emit("after:response",e)}async runOnError(e,t){let n=null;for(let s of Z(this.onError)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(e,t));if(this._maybeEject(s,this.onError),o&&typeof o=="object"&&"status"in o){n=o;break}}return await this.emitter.emit("error",e),n}async runOnRetry(e,t){for(let n of Z(this.onRetry))this._shouldRun(n,t)&&(await this._safeRun(n,()=>n.fn(e,t)),this._maybeEject(n,this.onRetry));await this.emitter.emit("retry",e)}async runOnRedirect(e,t){let n=!0;for(let s of Z(this.onRedirect)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(e,t));if(this._maybeEject(s,this.onRedirect),o===!1){n=!1;break}}return await this.emitter.emit("redirect",e),n}runOnUploadProgress(e,t){for(let n of Z(this.onUploadProgress))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e,t)),this._maybeEject(n,this.onUploadProgress));this.emitter.emit("upload:progress",e)}runOnDownloadProgress(e,t){for(let n of Z(this.onDownloadProgress))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e,t)),this._maybeEject(n,this.onDownloadProgress));this.emitter.emit("download:progress",e)}runOnCancel(e,t){for(let n of Z(this.onCancel))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e,t)),this._maybeEject(n,this.onCancel));this.emitter.emit("cancel",e)}runOnConnection(e,t){for(let n of Z(this.onConnection))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e)),this._maybeEject(n,this.onConnection));this.emitter.emit("connection",e)}wrapWithAround(e,t){let n=Z(this.aroundHooks).reverse(),s=t;for(let o of n){let i=s;s=()=>{if(!this._shouldRun(o,e))return i();let a=!1,c=this._safeRunSync(o,()=>(a=!0,o.fn(e,i)));return this._maybeEject(o,this.aroundHooks),a?i():c}}return s}_add(e,t,n){let s=n.id??mf();return e.push({id:s,priority:n.priority??0,once:n.once??!1,condition:n.condition??null,safe:n.safe??!1,fn:t}),s}_shouldRun(e,t){return e.condition?e.condition(t):!0}async _safeRun(e,t){try{return await t()}catch(n){if(!e.safe)throw n;console.error(`[lifecycle] Hook "${e.id}" threw:`,n);return}}_safeRunSync(e,t){try{return t()}catch(n){if(!e.safe)throw n;console.error(`[lifecycle] Hook "${e.id}" threw:`,n);return}}_maybeEject(e,t){if(!e.once)return;let n=t.indexOf(e);n!==-1&&t.splice(n,1)}};var $n=class{constructor(e=10){f(this,"maxRedirects");f(this,"count",0);this.maxRedirects=e}record(e,t,n,s){if(this.count++,this.count>this.maxRedirects)throw new Er(this.count,e);return{from:e,to:t,status:n,count:this.count,request:s}}get redirectCount(){return this.count}reset(){this.count=0}},Er=class extends Error{constructor(t,n){super(`Too many redirects (${t}) at ${n}`);f(this,"count");f(this,"url");f(this,"code","ETOOMANYREDIRECTS");this.count=t,this.url=n,this.name="TooManyRedirectsError"}};function Fc(r){return async e=>(await r(e),e)}function Wc(r){return async e=>({...e,headers:{...e.headers,...typeof r=="function"?await r():r}})}function Kc(r){return e=>{if(/^https?:\/\//i.test(e.url))return;let t=r.replace(/\/+$/,""),n=e.url.replace(/^\/+/,"");return{...e,url:`${t}/${n}`}}}function Vc(r=e=>e>=400){return e=>{if(e.response&&r(e.response.status))throw new Tr(e.response.status,e.response.statusText,e.response)}}function Jc(r){return e=>{let t=r(e);if(t===!0)return;let n=typeof t=="string"?t:`Response validation failed (status ${e.status})`;throw new Rr(n,e)}}var Tr=class extends Error{constructor(t,n,s){super(`HTTP ${t}: ${n}`);f(this,"status");f(this,"statusText");f(this,"response");f(this,"code","EHTTPERROR");this.status=t,this.statusText=n,this.response=s,this.name="HTTPError"}},Rr=class extends Error{constructor(t,n){super(t);f(this,"response");f(this,"code","EVALIDATION");this.response=n,this.name="ResponseValidationError"}};function Qc(...r){return async(e,t)=>{let n=e;for(let s of r){let o=await s(n,t);o&&typeof o=="object"&&"url"in o&&(n=o)}return n}}function Gc(...r){return async(e,t)=>{let n=e;for(let s of r){let o=await s(n,t);o&&typeof o=="object"&&"status"in o&&(n=o)}return n}}function Xc(...r){return(e,t)=>r.reduceRight((s,o)=>()=>o(e,s),t)()}function Yc(r={}){let e=r.logger??((s,o)=>console.log(s,JSON.stringify(o))),t=new Set((r.redactHeaders??["authorization","cookie","set-cookie","proxy-authorization"]).map(s=>s.toLowerCase()));function n(s){let o={};for(let[i,a]of Object.entries(s))o[i]=t.has(i.toLowerCase())?"***":a;return o}return{beforeRequest:s=>{e("\u2192 request",{method:s.method,url:s.url,headers:n(s.headers)})},afterResponse:s=>{e("\u2190 response",{status:s.status,url:s.request.url,headers:n(s.headers)})},onError:s=>{e("\u2717 error",{url:s.request.url,error:s.error instanceof Error?s.error.message:String(s.error),status:s.response?.status??null})}}}function Zc(){let r="__kinetex_timing__";return{beforeRequest:(e,t)=>{t.meta[r]=li()},afterResponse:(e,t)=>{let n=t.meta[r],s=n!==void 0?li()-n:null;s!==null&&(t.meta.durationMs=s)}}}function eu(r="utf-8"){return e=>{if(e.body instanceof Uint8Array)return{...e,body:new TextDecoder(r).decode(e.body)}}}function tu(){return{beforeRequest:(r,e)=>{if(r.signal?.aborted)throw e.meta.aborted=!0,gf("Request aborted before sending")},onCancel:r=>{console.debug(`[lifecycle] Request cancelled: ${r.request.url}`,r.reason)}}}function gf(r){if(typeof DOMException<"u")return new DOMException(r,"AbortError");let e=new Error(r);return e.name="AbortError",e}function li(){return typeof performance<"u"?performance.now():Date.now()}function ru(r,e={}){return{request:r,response:null,error:null,startedAt:li(),attempt:1,meta:{},...e}}Rn();On();dn();var Wt={NoAuth:0,GSSAPI:1,UserPassword:2,NoAcceptable:255},oe={IPv4:1,Domain:3,IPv6:4},yf={Connect:1,Bind:2,UdpAssociate:3},ee={Succeeded:0,GeneralFailure:1,ConnNotAllowed:2,NetworkUnreachable:3,HostUnreachable:4,ConnRefused:5,TtlExpired:6,CmdNotSupported:7,AddrTypeNotSupported:8},wf={[ee.Succeeded]:"Succeeded",[ee.GeneralFailure]:"General SOCKS server failure",[ee.ConnNotAllowed]:"Connection not allowed by ruleset",[ee.NetworkUnreachable]:"Network unreachable",[ee.HostUnreachable]:"Host unreachable",[ee.ConnRefused]:"Connection refused",[ee.TtlExpired]:"TTL expired",[ee.CmdNotSupported]:"Command not supported",[ee.AddrTypeNotSupported]:"Address type not supported"},M=class extends Error{constructor(t,n,s=!1){super(t);f(this,"code");f(this,"retriable");this.code=n,this.retriable=s,this.name="Socks5Error"}};function bf(r){let e=wf[r]??`Unknown reply code 0x${r.toString(16)}`,t=r===ee.NetworkUnreachable||r===ee.TtlExpired;return new M(`SOCKS5 proxy error: ${e}`,`SOCKS5_REPLY_${r}`,t)}var fi=class{constructor(e,t){f(this,"conn");f(this,"timeoutMs");f(this,"buf",new Uint8Array(0));this.conn=e,this.timeoutMs=t}async readExact(e){for(;this.buf.length<e;){let n=new Uint8Array(4096),o=await nu(this.conn.read(n),this.timeoutMs,"SOCKS5 handshake read timed out");if(o===null||o===0)throw new M("Connection closed during SOCKS5 handshake","SOCKS5_EOF");let i=new Uint8Array(this.buf.length+o);i.set(this.buf),i.set(n.subarray(0,o),this.buf.length),this.buf=i}let t=this.buf.slice(0,e);return this.buf=this.buf.slice(e),t}};function nu(r,e,t){return!Number.isFinite(e)||e<=0?r:new Promise((n,s)=>{let o=setTimeout(()=>s(new M(t,"SOCKS5_TIMEOUT",!0)),e);r.then(i=>{clearTimeout(o),n(i)},i=>{clearTimeout(o),s(i)})})}function xf(r,e){let t=r.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(t){let o=t.slice(1).map(Number);if(o.every(i=>i>=0&&i<=255))return new Uint8Array([oe.IPv4,...o])}let n=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(_f(n)){let o=Sf(n);return new Uint8Array([oe.IPv6,...o])}e||console.warn("[socks5] remoteDns=false but got a hostname; sending as DOMAINNAME");let s=new TextEncoder().encode(r);if(s.length>255)throw new M("Hostname too long for SOCKS5 (max 255 bytes)","SOCKS5_ADDR_TOO_LONG");return new Uint8Array([oe.Domain,s.length,...s])}var di=/^[0-9a-fA-F]{1,4}$/;function _f(r){if(!r.includes(":"))return!1;let e=r.split("::");if(e.length>2)return!1;let t=s=>s===void 0||s===""?[]:s.split(":"),n=t(e[0]);if(e.length===2){let s=t(e[1]);return n.length+s.length>7?!1:[...n,...s].every(o=>di.test(o))}return n.length===8&&n.every(s=>di.test(s))}function Sf(r){let e=r.split("::"),t=o=>o?o.split(":").map(i=>di.test(i)?parseInt(i,16):Number.NaN):[],n;if(e.length===2){let o=t(e[0]),i=t(e[1]),a=new Array(8-o.length-i.length).fill(0);n=[...o,...a,...i]}else n=t(r);if(n.length!==8)throw new M(`Invalid IPv6 address: ${r}`,"SOCKS5_INVALID_ADDR");for(let o of n)if(!Number.isFinite(o)||o<0||o>65535)throw new M(`Invalid IPv6 group: ${o} out of range (0-65535)`,"SOCKS5_INVALID_ADDR");let s=[];for(let o of n)s.push(o>>8&255,o&255);return s}function hi(r,e){if(r===oe.IPv4)return Array.from(e).join(".");if(r===oe.IPv6){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return t.join(":")}return new TextDecoder().decode(e)}async function Ef(r,e,t){let n=new fi(r,t.handshakeTimeoutMs),s=!!(t.username&&t.password),o=s?[Wt.NoAuth,Wt.UserPassword]:[Wt.NoAuth],i=new Uint8Array([5,o.length,...o]);await r.write(i);let a=await n.readExact(2);if(a[0]!==5)throw new M(`Unexpected SOCKS version in method response: ${a[0]}`,"SOCKS5_BAD_VERSION");let c=a[1];if(c===Wt.NoAcceptable)throw new M("SOCKS5 proxy rejected all authentication methods","SOCKS5_NO_ACCEPTABLE_METHOD");if(c===Wt.UserPassword){if(!s)throw new M("SOCKS5 proxy requires username/password but none provided","SOCKS5_AUTH_REQUIRED");await Tf(r,n,t.username,t.password)}else if(c!==Wt.NoAuth)throw new M(`SOCKS5 proxy chose unsupported auth method: 0x${c.toString(16)}`,"SOCKS5_UNSUPPORTED_METHOD");let u=xf(e.host,t.remoteDns),l=e.port,h=[l>>8&255,l&255],p=new Uint8Array([5,yf.Connect,0,...u,...h]);await r.write(p);let d=await n.readExact(4);if(d[0]!==5)throw new M(`Unexpected SOCKS version in reply: ${d[0]}`,"SOCKS5_BAD_VERSION");if(d[1]!==ee.Succeeded)throw bf(d[1]);let m=d[3],g,y;if(m===oe.IPv4)y=await n.readExact(4),g=hi(oe.IPv4,y);else if(m===oe.IPv6)y=await n.readExact(16),g=hi(oe.IPv6,y);else if(m===oe.Domain){let b=await n.readExact(1);y=await n.readExact(b[0]),g=hi(oe.Domain,y)}else throw new M(`Unsupported bound address type in reply: 0x${m.toString(16)}`,"SOCKS5_UNSUPPORTED_ADDR_TYPE");let w=await n.readExact(2),_=w[0]<<8|w[1];return{boundAddr:g,boundPort:_}}async function Tf(r,e,t,n){let s=new TextEncoder,o=s.encode(t),i=s.encode(n);if(o.length>255||i.length>255)throw new M("Username or password too long (max 255 bytes)","SOCKS5_AUTH_TOO_LONG");let a=new Uint8Array([1,o.length,...o,i.length,...i]);await r.write(a);let c=await e.readExact(2);if(c[0]!==1&&c[0]!==5)throw new M(`Unexpected auth sub-negotiation version: ${c[0]}`,"SOCKS5_BAD_AUTH_VERSION");if(c[1]!==0)throw new M("SOCKS5 authentication failed (invalid credentials)","SOCKS5_AUTH_FAILED")}async function Rf(r,e,t){let n;for(let s=0;s<=e;s++)try{return await r()}catch(o){if(n=o,!(o instanceof M&&o.retriable)||s===e)break;await Af(t*Math.pow(2,s))}throw n}function Af(r){return new Promise(e=>setTimeout(e,r))}var kf=new Set(["ECONNREFUSED","ECONNRESET","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ETIMEDOUT","EPIPE","EAI_AGAIN"]);function Cf(r){return{host:r.host,port:r.port??1080,username:r.username??"",password:r.password??"",remoteDns:r.remoteDns??!0,connectTimeoutMs:r.connectTimeoutMs??1e4,handshakeTimeoutMs:r.handshakeTimeoutMs??1e4,maxRetries:r.maxRetries??2,retryDelayMs:r.retryDelayMs??300}}async function pi(r,e,t){let n=Cf(r);return await Rf(async()=>{let s=await nu(t(n.host,n.port,n.connectTimeoutMs),n.connectTimeoutMs,`TCP connection to SOCKS5 proxy ${n.host}:${n.port} timed out`).catch(o=>{if(o instanceof M||o instanceof DOMException)throw o;let i=o?.code,a=typeof i=="string"?i:"UNKNOWN";throw new M(`Cannot reach SOCKS5 proxy ${n.host}:${n.port}: ${o instanceof Error?o.message:String(o)}`,"SOCKS5_CONNECT_FAILED",kf.has(a))});try{let{boundAddr:o,boundPort:i}=await Ef(s,e,n);return{conn:s,boundAddr:o,boundPort:i}}catch(o){throw s.close(),o}},n.maxRetries,n.retryDelayMs)}function su(r){let e;try{vf(r),e=new URL(r)}catch{throw new M("Invalid SOCKS5 proxy URL: malformed URL","SOCKS5_BAD_URL")}if(e.protocol!=="socks5:"&&e.protocol!=="socks5h:")throw new M(`Expected socks5:// or socks5h:// scheme, got: ${e.protocol}`,"SOCKS5_BAD_SCHEME");let t=e.protocol==="socks5h:",n=e.hostname,s=e.port?parseInt(e.port,10):1080;if(!Number.isFinite(s)||s<1||s>65535)throw new M("Invalid SOCKS5 proxy URL: port must be between 1 and 65535","SOCKS5_BAD_URL");if(!n)throw new M("Invalid SOCKS5 proxy URL: no hostname specified (e.g., socks5://host:port)","SOCKS5_BAD_URL");let o={host:n,port:s,remoteDns:t},i=(a,c)=>{try{return decodeURIComponent(a)}catch{throw new M(`Invalid SOCKS5 proxy URL: malformed percent-encoding in the ${c}`,"SOCKS5_BAD_URL")}};return e.username&&(o.username=i(e.username,"username")),e.password&&(o.password=i(e.password,"password")),o}function vf(r){try{let e=new URL(r);return`${e.protocol}//${e.host}${e.pathname}${e.search}${e.hash}`}catch{return"[redacted]"}}var ou=async(r,e,t)=>{let n=globalThis,s=async(a,c)=>{if(!t||t<=0)return a;let u;try{return await Promise.race([a,new Promise((l,h)=>{u=setTimeout(()=>h(new M(c,"SOCKS5_TIMEOUT",!0)),t)})])}finally{u!==void 0&&clearTimeout(u)}},o=await s(n.Deno.connect({hostname:r,port:e,transport:"tcp"}),"TCP connect to proxy timed out");return{read:a=>{let c=o.read(a).catch(()=>null);return s(c,"TCP read timed out")},write:a=>o.write(a),close:()=>{try{o.close()}catch{}}}},iu=(r,e,t)=>new Promise((n,s)=>{import("node:net").then(({createConnection:o})=>{let i=o({host:r,port:e}),a;Number.isFinite(t)&&t>0&&(a=setTimeout(()=>{i.destroy(),s(new M("TCP connect to proxy timed out","SOCKS5_TIMEOUT",!0))},t));let c=()=>{a!==void 0&&clearTimeout(a)},u=new Uint8Array(0),l=null,h=null,p=null,d=null;function m(){if(!l||!p||u.length===0)return;let w=Math.min(u.length,p.length);p.set(u.subarray(0,w)),u=u.slice(w);let _=l;l=null,h=null,p=null,_(w)}function g(w){if(h){let _=h;l=null,h=null,p=null,_(w)}}i.on("data",w=>{let _=new Uint8Array(u.length+w.length);_.set(u),_.set(w,u.length),u=_,m()});let y=!1;i.on("end",()=>{y=!0,l&&(l(null),l=null,h=null,p=null)}),i.on("close",()=>{y=!0}),i.once("error",w=>{c(),d=w,g(w),s(w)}),i.once("connect",()=>{c(),i.on("error",w=>{d=w,g(w)}),n({read:w=>new Promise((_,b)=>{if(d){b(d);return}if(y&&u.length===0){_(null);return}if(u.length>0){let T=Math.min(u.length,w.length);w.set(u.subarray(0,T)),u=u.slice(T),_(T);return}l=_,h=b,p=w}),write:w=>new Promise((_,b)=>{i.write(w,T=>T?b(T):_(w.length))}),close:()=>i.destroy()})})}).catch(s)});function au(r,e){return async(t,n,s)=>{let o=Number.isFinite(s)&&s>0?s:void 0,i=o??r.connectTimeoutMs;return(await pi({...r,...i!==void 0?{connectTimeoutMs:i}:{},...o!==void 0?{handshakeTimeoutMs:o}:{}},{host:t,port:n},e)).conn}}yr();we();we();Pt();bt();yo();yr();Pn();On();Rn();dn();Oe();q();var Un=class extends Error{constructor(t){super(t);f(this,"code","URL_VALIDATION_ERROR");this.name="URLValidationError"}},Pf=/^[A-Za-z0-9\-._~]$/,Lf=/^[:/?#\[\]@!$&'()*+,;=]$/;function Hn(r,e=!1){return Array.from(r).map(t=>{if(Pf.test(t)||e&&Lf.test(t))return t;let n=t.codePointAt(0);if(n>65535){let s=new TextEncoder().encode(t);return Array.from(s).map(o=>"%"+o.toString(16).toUpperCase().padStart(2,"0")).join("")}if(n>127){let s=new TextEncoder().encode(t);return Array.from(s).map(o=>"%"+o.toString(16).toUpperCase().padStart(2,"0")).join("")}return"%"+n.toString(16).toUpperCase().padStart(2,"0")}).join("")}function ie(r){try{return decodeURIComponent(r.replace(/\+/g,"%20"))}catch{return r.replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}}function mi(r){return encodeURIComponent(r).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function ot(r){return encodeURIComponent(r).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function hu(r,e={}){let{sort:t=!1,arrayFormat:n="repeat"}=e,s=[];for(let[o,i]of Object.entries(r)){if(i==null)continue;let a=ot(o);if(Array.isArray(i)){let c=i.filter(u=>u!=null);if(c.length===0)continue;if(n==="comma")s.push([a,c.map(u=>ot(String(u))).join(",")]);else if(n==="bracket")for(let u of c)s.push([`${a}[]`,ot(String(u))]);else for(let u of c)s.push([a,ot(String(u))])}else s.push([a,ot(String(i))])}return t&&s.sort(([o],[i])=>o<i?-1:o>i?1:0),s.map(([o,i])=>`${o}=${i}`).join("&")}function gi(r){let e=r.startsWith("?")?r.slice(1):r,t={};if(!e)return t;let n=(o,i)=>Object.prototype.hasOwnProperty.call(o,i),s=(o,i)=>{o==="__proto__"?Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):t[o]=i};for(let o of e.split("&")){if(!o)continue;let i=o.indexOf("="),a=ie(i===-1?o:o.slice(0,i)),c=i===-1?"":ie(o.slice(i+1));if(!n(t,a))s(a,c);else{let u=t[a];Array.isArray(u)?u.push(c):s(a,[u,c])}}return t}function fu(r,e){let t={...r};for(let[n,s]of Object.entries(e))s==null?delete t[n]:t[n]=s;return t}function du(r,...e){let t={};for(let n of e)n in r&&(t[n]=r[n]);return t}function pu(r,...e){let t=new Set(e),n={};for(let[s,o]of Object.entries(r))t.has(s)||(n[s]=o);return n}function yi(...r){if(r.length===0)return"/";let e=[];for(let i of r)i&&e.push(...i.split("/").filter((a,c)=>a!==""||c===0));let n=mu(e).join("/"),o=r[r.length-1]?.endsWith("/")&&n!=="/"?"/":"";return(n.startsWith("/")?"":"/")+n+o}function mu(r){let e=[];for(let t of r)t!=="."&&(t===".."?e.pop():e.push(t));return e}function wi(r,e={}){let{trailingSlash:t="preserve"}=e,n=r.endsWith("/")&&r!=="/",s=r.split("/").filter(Boolean),i="/"+mu(s).join("/");return t==="add"&&i!=="/"?i+="/":t==="remove"||t==="preserve"&&n&&i!=="/"&&(i+="/"),i}function gu(r){return r.split("/").filter(Boolean).map(ie)}function bi(r,e){return r.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g,(t,n)=>{let s=e[n];if(s===void 0)throw new Un(`Missing path param: "${n}"`);return mi(String(s))})}var If={"http:":"80","https:":"443","ftp:":"21","ws:":"80","wss:":"443"};function yu(r,e={}){let t=Fe(r);if(!t)throw new TypeError(`Invalid URL: ${r}`);let n=If[t.protocol],s=t.port===n?"":t.port,o=wi(t.pathname,{trailingSlash:e.trailingSlash??"preserve"});e.sortParams&&t.searchParams.sort();let i=t.searchParams.toString()?`?${t.searchParams}`:"",a=e.removeFragment?"":t.hash,c=t.username?`${encodeURIComponent(t.username)}${t.password?":"+encodeURIComponent(t.password):""}@`:"",u=s?`${t.hostname}:${s}`:t.hostname;return`${t.protocol}//${c}${u}${o}${i}${a}`}var qe=class r{constructor(e,t){f(this,"_url");try{this._url=new URL(String(e),t)}catch{throw new TypeError(`Invalid URL: "${e}"${t?` (base: "${t}")`:""}`)}}static from(e,t){return new r(e,t)}static https(e,t){return new r(`https://${e}${t??"/"}`)}static http(e,t){return new r(`http://${e}${t??"/"}`)}withProtocol(e){let t=this._clone();return t._url.protocol=e.endsWith(":")?e:e+":",t}withHostname(e){let t=this._clone();return t._url.hostname=e,t}withHost(e){let t=this._clone();return t._url.host=e,t}withPort(e){let t=this._clone();return t._url.port=String(e),t}withUsername(e){let t=this._clone();return t._url.username=encodeURIComponent(e),t}withPassword(e){let t=this._clone();return t._url.password=encodeURIComponent(e),t}withPathname(e){let t=this._clone();return t._url.pathname=e,t}appendPath(...e){let t=this._clone(),n=t._url.pathname.replace(/\/$/,""),s=e.map(o=>o.replace(/^\/|\/$/g,"")).filter(Boolean);return t._url.pathname=n+"/"+s.join("/"),t}path(...e){let t=this._clone();return t._url.pathname=yi(...e),t}params(e){let t=this._clone();t._url.pathname=bi(t._url.pathname,e);for(let[n,s]of Object.entries(e))t._url.searchParams.set(n,String(s));return t}addTrailingSlash(){let e=this._clone();return e._url.pathname.endsWith("/")||(e._url.pathname+="/"),e}removeTrailingSlash(){let e=this._clone();return e._url.pathname!=="/"&&e._url.pathname.endsWith("/")&&(e._url.pathname=e._url.pathname.slice(0,-1)),e}setParam(e,t){let n=this._clone();return t==null?n._url.searchParams.delete(e):n._url.searchParams.set(e,String(t)),n}appendParam(e,t){if(t==null)return this;let n=this._clone();return n._url.searchParams.append(e,String(t)),n}deleteParam(e){let t=this._clone();return t._url.searchParams.delete(e),t}query(e){let t=this._clone();for(let[n,s]of Object.entries(e))if(s==null)t._url.searchParams.delete(n);else if(Array.isArray(s)){t._url.searchParams.delete(n);for(let o of s)o!=null&&t._url.searchParams.append(n,String(o))}else t._url.searchParams.set(n,String(s));return t}setQuery(e){let t=this._clone();return t._url.search="",t.query(e)}pickParams(...e){let t=this._clone(),n=new Set(e),s=[];for(let[o,i]of t._url.searchParams.entries())n.has(o)&&s.push([o,i]);t._url.search="";for(let[o,i]of s)t._url.searchParams.append(o,i);return t}omitParams(...e){let t=this._clone(),n=new Set(e);for(let s of n)t._url.searchParams.delete(s);return t}sortParams(){let e=this._clone();return e._url.searchParams.sort(),e}redactParams(...e){let t=this._clone();for(let n of e)t._url.searchParams.has(n)&&(t=t.setParam(n,"REDACTED"));return t}withHash(e){let t=this._clone();return t._url.hash=e.startsWith("#")?e:"#"+e,t}removeHash(){let e=this._clone();return e._url.hash="",e}toString(){return this._url.toString()}toURL(){return new URL(this._url.toString())}get href(){return this._url.href}get protocol(){return this._url.protocol}get hostname(){return this._url.hostname}get host(){return this._url.host}get port(){return this._url.port}get pathname(){return this._url.pathname}get search(){return this._url.search}get hash(){return this._url.hash}get origin(){return this._url.origin}get searchParams(){return new URLSearchParams(this._url.searchParams)}get queryObject(){return gi(this._url.search)}_clone(){return new r(this._url.toString())}};function wu(r,e){return r.replace(/\{([^}]+)\}/g,(t,n)=>{let s=n[0],o="+#./;?&".includes(s),i=(o?n.slice(1):n).split(",");return Of(o?s:"",i,e)})}function Of(r,e,t){let n=Nf(r),s=$f(r),o=Uf(r),i=Hf(r),a=r==="+"||r==="#",c=[];for(let u of e){let{name:l,explode:h,maxLength:p}=Mf(u.trim()),d=t[l];if(d==null)continue;let m=Df(d,l,o,h,p,a,n,i);m!==null&&c.push(m)}return c.length===0?"":s+c.join(n)}function Mf(r){if(r.endsWith("*"))return{name:r.slice(0,-1),explode:!0,maxLength:null};let e=r.lastIndexOf(":");if(e!==-1){let t=parseInt(r.slice(e+1),10);return{name:r.slice(0,e),explode:!1,maxLength:isNaN(t)?null:t}}return{name:r,explode:!1,maxLength:null}}function Df(r,e,t,n,s,o,i,a){let c=u=>o?Hn(u,!0):Hn(u);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"){let u=String(r);s!==null&&(u=u.slice(0,s));let l=c(u);return t?`${e}${l===""?a:"="+l}`:l}if(Array.isArray(r)){if(r.length===0)return null;if(n)return r.map(l=>{let h=c(String(l));return t?`${e}=${h}`:h}).join(i);let u=r.map(l=>c(String(l))).join(",");return t?`${e}=${u}`:u}if(typeof r=="object"&&r!==null){let u=Object.entries(r);if(u.length===0)return null;if(n)return u.map(([h,p])=>`${c(h)}=${c(p)}`).join(i);let l=u.flatMap(([h,p])=>[c(h),c(p)]).join(",");return t?`${e}=${l}`:l}return null}function Nf(r){switch(r){case".":return".";case"/":return"/";case";":return";";case"?":case"&":return"&";default:return","}}function $f(r){switch(r){case"#":return"#";case".":return".";case"/":return"/";case";":return";";case"?":return"?";case"&":return"&";default:return""}}function Uf(r){return r===";"||r==="?"||r==="&"}function Hf(r){return r===";"?"":"="}function cu(r){return r.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function bu(r){let e=[],t=/:([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]+)\))?|\*\*|\*/g,n="",s=0;for(let i of r.matchAll(t))n+=cu(r.slice(s,i.index)),s=i.index+i[0].length,i[1]!==void 0?(e.push({kind:"param",name:i[1]}),n+=`(${i[2]??"[^/]+"})`):i[0]==="**"?(e.push({kind:"wildcard",greedy:!0}),n+="(.+?)"):(e.push({kind:"wildcard",greedy:!1}),n+="([^/]+)");n+=cu(r.slice(s));let o=new RegExp(`^${n}\\/?$`);return{match(i){let a=uu(i),c=o.exec(a);if(!c)return null;let u={},l=[],h={};for(let p=0;p<e.length;p++){let d=e[p],m=c[p+1]??"";if(d.kind==="param"){let g=ie(m);u[d.name]=g,h[d.name]=g;continue}if(d.greedy)for(let g of m.split("/").filter(Boolean))l.push(ie(g));else l.push(ie(m));h[String(p+1)]=ie(m)}return{params:u,wildcards:l,groups:h}},test(i){return o.test(uu(i))}}}function uu(r){try{return new URL(r).pathname}catch{return r}}function jn(r){let e=Fe(r);return e?["file:","data:","blob:"].includes(e.protocol)?"null":e.origin:null}function xu(r,e){let t=jn(r),n=jn(e);return!t||!n?!1:t===n}function _u(r,e){let t=Fe(r),n=Fe(e);return!t||!n||t.protocol!==n.protocol?!1:lu(t.hostname)===lu(n.hostname)}function lu(r){let e=new Set(["co.uk","co.jp","co.kr","co.nz","co.za","co.in","com.au","com.br","com.mx","com.cn","com.tw","com.hk","com.sg","com.my","com.ph","com.vn","com.tr","net.au","net.uk","net.br","org.uk","org.au","org.nz","org.cn","org.in","ac.uk","gov.uk","gov.au","gov.cn","or.kr","pe.kr","go.jp","ne.jp","ac.jp","github.io","herokuapp.com","cloudfront.net"]),t=r.split(".");if(t.length>=3){let n=t.slice(-2).join(".");if(e.has(n))return t.slice(-3).join(".")}return t.slice(-2).join(".")}function Su(r,e){try{return new URL(r,e).toString()}catch{throw new TypeError(`Cannot resolve "${r}" against base "${e}"`)}}function Eu(r,e){try{let t=new URL(r),n=new URL(e);return t.origin!==n.origin||!t.pathname.startsWith(n.pathname)||t.pathname.length>n.pathname.length&&!n.pathname.endsWith("/")&&t.pathname[n.pathname.length]!=="/"?null:t.pathname.slice(n.pathname.length)+t.search+t.hash}catch{return null}}function xi(r){try{if(/^[A-Za-z][A-Za-z0-9+\-.]*:\/\//.test(r))return!0;let e=new URL(r);return e.protocol!==""&&e.protocol!=="file:"}catch{return!1}}function Tu(r){return!xi(r)}function Ru(r){try{return new URL(r).protocol==="https:"}catch{return!1}}function Au(r){try{let e=new URL(r).protocol;return e==="http:"||e==="https:"}catch{return!1}}function ku(r){return r.trimStart().startsWith("data:")}function Cu(r){return r.trimStart().startsWith("blob:")}function vu(r){try{let e=new URL(r).hostname;return e==="localhost"||e==="127.0.0.1"||e==="::1"||e.endsWith(".localhost")}catch{return!1}}function Pu(r){if(!r.startsWith("data:"))return null;let e=r.indexOf(",");if(e===-1)return null;let t=r.slice(5,e),n=r.slice(e+1),s=t.lastIndexOf(";"),o=!1;return s!==-1&&t.slice(s+1).toLowerCase()==="base64"&&(o=!0,t=t.slice(0,s)),t=t.replace(/^;+/,""),{mediaType:t.includes("/")?t:t===""?"text/plain":`text/plain;${t}`,isBase64:o,data:n}}function Lu(r,e,t=!0){if(/[,;]/.test(e))throw new Un(`Invalid media type for a data URL: ${JSON.stringify(e)} (it must not contain "," or ";")`);return typeof r=="string"?t?`data:${e};base64,${re(new TextEncoder().encode(r))}`:`data:${e},${encodeURIComponent(r)}`:`data:${e};base64,${re(r)}`}function Iu(r,e){let t=Fe(r),n=Fe(e);if(!t||!n)throw new TypeError(`Cannot diff invalid URLs: "${r}" vs "${e}"`);let s={addedParams:{},removedParams:{},changedParams:{}};t.protocol!==n.protocol&&(s.protocol=[t.protocol,n.protocol]),t.hostname!==n.hostname&&(s.hostname=[t.hostname,n.hostname]),t.port!==n.port&&(s.port=[t.port,n.port]),t.pathname!==n.pathname&&(s.pathname=[t.pathname,n.pathname]),t.hash!==n.hash&&(s.hash=[t.hash,n.hash]);for(let[o,i]of t.searchParams.entries()){let a=n.searchParams.get(o);a===null?s.removedParams[o]=i:a!==i&&(s.changedParams[o]=[i,a])}for(let[o,i]of n.searchParams.entries())t.searchParams.has(o)||(s.addedParams[o]=i);return t.search!==n.search&&!Object.keys(s.changedParams).length&&!Object.keys(s.addedParams).length&&!Object.keys(s.removedParams).length&&(s.search=[t.search,n.search]),s}function Fe(r){try{return new URL(r)}catch{return null}}function Ou(r){return qe.from(r).addTrailingSlash().toString()}function Mu(r){return qe.from(r).removeTrailingSlash().toString()}function Du(r){try{return qe.from(r).removeHash().toString()}catch{return r}}function Nu(r){try{let e=new URL(r);return e.search="",e.toString()}catch{return r}}function $u(r){try{let t=new URL(r).pathname.split("/").pop()??"",n=t.lastIndexOf(".");return n===-1?"":t.slice(n+1).toLowerCase()}catch{return""}}function Uu(r){try{let e=new URL(r).pathname;return ie(e.split("/").filter(Boolean).pop()??"")}catch{return""}}function Hu(r,...e){try{return qe.from(r).redactParams(...e).toString()}catch{return jf(r,e)}}function jf(r,e){if(e.length===0)return r;let t=r.indexOf("#"),n=t===-1?r:r.slice(0,t),s=t===-1?"":r.slice(t),o=n.indexOf("?");if(o===-1)return r;let i=n.slice(0,o),a=n.slice(o+1).split("&").map(c=>{let u=c.indexOf("="),l=u===-1?c:c.slice(0,u);return e.includes(l)||e.includes(ie(l))?`${l}=REDACTED`:c});return`${i}?${a.join("&")}${s}`}Oe();q();function ju(r={}){return new Ft(r)}var Bf=ju;return Xu(zf);})();
102
+ `}async function Ys(r,e){let t=await cn(e.credentials),n=on(e),s=vt(n),o=`${s}/${e.region}/${e.service}/aws4_request`,i=`${t.accessKeyId}/${o}`,a=JSON.stringify(r),c=btoa(a),u=await Pt(t.secretAccessKey,s,e.region,e.service),l=await Ae(u,c),h=ar(l),d={policy:c,signature:h,credential:i,date:s};return t.sessionToken&&(d.securityToken=t.sessionToken),d}function Zs(r){let e=r["x-amz-date"]??r["X-Amz-Date"],t;if(e!==void 0){if(t=Zl(e),isNaN(t))return 0}else{let n=r.date??r.Date;if(!n||(t=new Date(n).getTime(),isNaN(t)))return 0}return Math.round((t-Date.now())/1e3)}function Zl(r){let e=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(r.trim());if(!e)return NaN;let[,t,n,s,o,i,a]=e,c=Date.UTC(Number(t),Number(n)-1,Number(s),Number(o),Number(i),Number(a)),u=new Date(c);return u.getUTCFullYear()!==Number(t)||u.getUTCMonth()+1!==Number(n)?NaN:u.getUTCDate()!==Number(s)?NaN:c}function eo(r,e){return r!==403&&r!==400?!1:e.includes("RequestTimeTooSkewed")||e.includes("RequestExpired")||e.includes("InvalidSignatureException")||e.includes("AuthFailure")||e.includes("SignatureDoesNotMatch")}var ye=class{constructor(e){f(this,"config");f(this,"clockSkewSecs",0);this.config=e}async sign(e){return await an(e,{...this.config,clockSkewSecs:this.clockSkewSecs})}async presign(e,t){return await Gs(e,{...this.config,clockSkewSecs:this.clockSkewSecs},t)}async signPostPolicy(e){return await Ys(e,{...this.config,clockSkewSecs:this.clockSkewSecs})}async initChunked(e){return await Xs(e,{...this.config,clockSkewSecs:this.clockSkewSecs})}updateClockSkew(e){let t=Zs(e);t!==0&&(this.clockSkewSecs=t)}handleClockSkewError(e,t,n){return eo(e,t)?(this.updateClockSkew(n),!0):!1}};async function cn(r){return await(typeof r=="function"?r():Promise.resolve(r))}function Ws(r){let e=globalThis.Deno;if(typeof e<"u")try{return e.env.get(r)}catch{}try{return globalThis.process?.env?.[r]}catch{}}async function Ks(r,e,t){let n=new AbortController,s=setTimeout(()=>n.abort(),t);try{let o=e.signal&&typeof AbortSignal<"u"&&"any"in AbortSignal?AbortSignal.any([e.signal,n.signal]):n.signal,i=await fetch(r,{...e,signal:o});return clearTimeout(s),i}catch(o){throw n.signal.aborted?new Y(t):o}finally{clearTimeout(s)}}function ec(r){return new ye({credentials:r.credentials,region:r.region,service:"s3",doubleEncodeUri:!1,unsignedPayload:r.unsignedPayload??!1})}function tc(r){return new ye({credentials:r.credentials,region:r.region,service:"execute-api"})}function rc(r){return new ye({credentials:r.credentials,region:r.region,service:"sts"})}function nc(r){return new ye({credentials:r.credentials,region:r.region,service:"dynamodb"})}U();U();function sc(r){let e=[];for(let l=0;l<r.length;l++){let h=r.charCodeAt(l);if(h<128)e.push(h);else if(h<2048)e.push(192|h>>6,128|h&63);else if(h<55296||h>=57344)e.push(224|h>>12,128|h>>6&63,128|h&63);else{l++;let d=r.charCodeAt(l),p=65536+((h&1023)<<10|d&1023);e.push(240|p>>18,128|p>>12&63,128|p>>6&63,128|p&63)}}let t=e.length*8;for(e.push(128);e.length*8%512!==448;)e.push(0);for(let l=0;l<4;l++)e.push(t>>>l*8&255);for(let l=4;l<8;l++)e.push(0);let n=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],s=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],o=1732584193,i=4023233417,a=2562383102,c=271733878;for(let l=0;l<e.length;l+=64){let h=[];for(let w=0;w<16;w++){let y=e[l+w*4],S=e[l+w*4+1],b=e[l+w*4+2],E=e[l+w*4+3];h[w]=(y|S<<8|b<<16|E<<24)>>>0}let d=o,p=i,m=a,g=c;for(let w=0;w<64;w++){let y,S;w<16?(y=p&m|~p&g,S=w):w<32?(y=g&p|~g&m,S=(5*w+1)%16):w<48?(y=p^m^g,S=(3*w+5)%16):(y=m^(p|~g),S=7*w%16),y=y+d+n[w]+h[S]>>>0,d=g,g=m,m=p,p=p+(y<<s[w]|y>>>32-s[w])>>>0}o=o+d>>>0,i=i+p>>>0,a=a+m>>>0,c=c+g>>>0}function u(l){let h="";for(let d=0;d<4;d++)h+=(l>>>d*8&255).toString(16).padStart(2,"0");return h}return u(o)+u(i)+u(a)+u(c)}function oc(r){let e=new Uint8Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}function eh(r){return r.replace(/\\(.)/g,"$1")}function un(r){let e={algorithm:"MD5"},t=r.replace(/^Digest\s+/i,"").trim(),n='"((?:[^"\\\\]|\\\\.)*)"',s=new RegExp(`(\\w+)\\s*=\\s*(?:${n}|([^,\\s]+))`,"g"),o;for(;(o=s.exec(t))!==null;){let i=o[1].toLowerCase(),a=o[2]!==void 0?eh(o[2]):o[3];switch(i){case"realm":e.realm=a;break;case"nonce":e.nonce=a;break;case"opaque":e.opaque=a;break;case"algorithm":e.algorithm=a.toUpperCase();break;case"qop":e.qop=a;break;case"domain":e.domain=a;break;case"charset":e.charset=a;break;case"userhash":e.userhash=a==="true";break;case"stale":e.stale=a==="true";break}}if(!e.realm)throw new Error("Digest challenge missing 'realm'");if(!e.nonce)throw new Error("Digest challenge missing 'nonce'");return e}function ic(r){let e=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n],t=[0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n],n=[];for(let c=0;c<r.length;c++){let u=r.charCodeAt(c);if(u<128)n.push(u);else if(u<2048)n.push(192|u>>6,128|u&63);else if(u<55296||u>=57344)n.push(224|u>>12,128|u>>6&63,128|u&63);else{c++;let l=r.charCodeAt(c),h=65536+((u&1023)<<10|l&1023);n.push(240|h>>18,128|h>>12&63,128|h>>6&63,128|h&63)}}let s=BigInt(n.length*8);for(n.push(128);n.length*8%1024!==896;)n.push(0);for(let c=15;c>=0;c--)n.push(Number(s>>BigInt(c*8)&0xffn));function o(c,u){return c>>u|c<<64n-u&0xffffffffffffffffn}let i=t.slice();for(let c=0;c<n.length;c+=128){let u=new Array(80);for(let S=0;S<16;S++){let b=0n;for(let E=0;E<8;E++)b=b<<8n|BigInt(n[c+S*8+E]);u[S]=b}for(let S=16;S<80;S++){let b=o(u[S-15],1n)^o(u[S-15],8n)^u[S-15]>>7n,E=o(u[S-2],19n)^o(u[S-2],61n)^u[S-2]>>6n;u[S]=u[S-16]+b+u[S-7]+E&0xffffffffffffffffn}let l=i[0],h=i[1],d=i[2],p=i[3],m=i[4],g=i[5],w=i[6],y=i[7];for(let S=0;S<80;S++){let b=o(m,14n)^o(m,18n)^o(m,41n),E=m&g^~m&w,A=y+b+E+e[S]+u[S]&0xffffffffffffffffn,C=o(l,28n)^o(l,34n)^o(l,39n),T=l&h^l&d^h&d,P=C+T&0xffffffffffffffffn;y=w,w=g,g=m,m=p+A&0xffffffffffffffffn,p=d,d=h,h=l,l=A+P&0xffffffffffffffffn}i=[i[0]+l&0xffffffffffffffffn,i[1]+h&0xffffffffffffffffn,i[2]+d&0xffffffffffffffffn,i[3]+p&0xffffffffffffffffn,i[4]+m&0xffffffffffffffffn,i[5]+g&0xffffffffffffffffn,i[6]+w&0xffffffffffffffffn,i[7]+y&0xffffffffffffffffn]}let a="";for(let c=0;c<4;c++)a+=i[c].toString(16).padStart(16,"0");return a}async function ln(r,e,t,n,s,o,i){let a=r.qop||"",c=r.nonce,u=r.realm,l=o||Ee(5),h=i||"00000001",d=ac(r.algorithm);if(d===null)throw new Error(`Unsupported digest algorithm: ${r.algorithm}`);let{algo:p,sess:m}=d;async function g(A){return p==="MD5"?sc(A):p==="SHA-512-256"?ic(A):await pe(A)}let w=r.userhash?se(oc(await g(`${e}:${u}`))):e,y=await g(`${w}:${u}:${t}`);if(m){if(!r.qop)throw new Error(`Digest algorithm ${r.algorithm} requires a qop parameter`);y=await g(`${y}:${c}:${l}`)}let S=await g(`${n}:${s}`),b,E=a.split(/\s*,\s*/).filter(Boolean);if(E.length>0){if(!E.includes("auth"))throw new Error(`Digest challenge offers only unsupported qop values: ${E.join(", ")}. "auth-int" requires the entity body, which this API does not receive.`);b=await g(`${y}:${c}:${h}:${l}:auth:${S}`)}else b=await g(`${y}:${c}:${S}`);return b}async function hn(r,e){if(!r.userhash)return null;let t=ac(r.algorithm);if(t===null)throw new Error(`Unsupported digest algorithm: ${r.algorithm}`);let{algo:n}=t,s=n==="MD5"?sc(`${e}:${r.realm}`):n==="SHA-512-256"?ic(`${e}:${r.realm}`):await pe(`${e}:${r.realm}`);return se(oc(s))}function ac(r){let e=r.trim(),t=/-sess$/i.test(e),n=e.replace(/-sess$/i,"").toUpperCase().replace(/-/g,"");return n==="MD5"?{algo:"MD5",sess:t}:n==="SHA256"?{algo:"SHA-256",sess:t}:n==="SHA512256"?{algo:"SHA-512-256",sess:t}:null}function Ue(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function fn(r,e,t,n,s,o,i){let a=[],c=s||Ee(5),u=o||"00000001";if(r.userhash){if(i===void 0)throw new Error("challenge offers userhash=true: pass the value from computeUsernameStar() as `usernameStar` \u2014 sending a plaintext username would defeat it");a.push(`username*="${Ue(i)}"`)}else{if(i!==void 0)throw new Error("usernameStar was given but the challenge does not offer userhash");a.push(`username="${Ue(e)}"`)}return a.push(`realm="${Ue(r.realm)}"`),a.push(`nonce="${Ue(r.nonce)}"`),a.push(`uri="${Ue(n)}"`),a.push(`response="${Ue(t)}"`),r.opaque&&a.push(`opaque="${Ue(r.opaque)}"`),r.algorithm&&r.algorithm!=="MD5"&&a.push(`algorithm=${r.algorithm}`),r.qop&&(a.push("qop=auth"),a.push(`nc=${u}`),a.push(`cnonce="${Ue(c)}"`)),`Digest ${a.join(", ")}`}async function cc(r,e,t,n,s){let o=un(r),i=Ee(5),a="00000001",c=await ln(o,e,t,n,s,i,a),u=await hn(o,e);return fn(o,e,c,s,i,a,u??void 0)}function uc(){let r=new Map,e=64,t=(n,s)=>{if(!r.has(n)){if(r.set(n,s),r.size>e){let o=r.keys().next();o.done||r.delete(o.value)}return}r.delete(n),r.set(n,s)};return async(n,s,o,i,a)=>{let c=un(n),u=Ee(5),l=`${c.realm}\0${c.nonce}`,h=(r.get(l)??0)+1;t(l,h);let d=h.toString(16).padStart(8,"0"),p=await ln(c,s,o,i,a,u,d),m=await hn(c,s);return fn(c,s,p,a,u,d,m??void 0)}}$e();Nt();Nt();var xf=20,_f={maxRetries:3,baseDelayMs:300,maxDelayMs:3e4,jitter:.3,statuses:[408,429,500,502,503,504],onNetworkError:!0,onTimeout:!1,methods:["GET","HEAD","PUT","DELETE","OPTIONS","TRACE"]},di=class{constructor(){f(this,"_req",new Map);f(this,"_res",new Map);f(this,"_err",new Map);f(this,"_seq",0)}get request(){return Array.from(this._req.values())}get response(){return Array.from(this._res.values())}get error(){return Array.from(this._err.values())}addRequest(e){let t=++this._seq;return this._req.set(t,e),()=>{this._req.delete(t)}}addResponse(e){let t=++this._seq;return this._res.set(t,e),()=>{this._res.delete(t)}}addError(e){let t=++this._seq;return this._err.set(t,e),()=>{this._err.delete(t)}}clear(){this._req.clear(),this._res.clear(),this._err.clear()}};function Sf(r){if(r){let n=r.spanContext(),s=n.traceFlags.toString(16).padStart(2,"0");return{traceparent:`00-${n.traceId}-${n.spanId}-${s}`,traceId:n.traceId,spanId:n.spanId}}let e=pi(32),t=pi(16);return{traceparent:`00-${e}-${t}-01`,traceId:e,spanId:t}}function pi(r){return Ee(r/2)}var Tf=100*1024*1024,Zc=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-access-token","x-refresh-token","x-csrf-token","x-session-id","x-session-token","x-secret","x-secret-key","x-private-key","api-key","apikey","bearer","token","authentication","credentials","password","passwd","secret"]),Wc="__awsSkewCorrected",Kc="__interceptorResendDepth",Vc=5,yi=new Set(["api_key","apikey","access_token","refresh_token","id_token","token","auth","authorization","key","secret","password","passwd","signature","sig","x-amz-signature","x-amz-credential","x-amz-security-token","x-goog-signature","sas","session","sessionid","jwt","code"]);function eu(r,e){let t=[],n=i=>{typeof i=="string"&&i.length>=8&&t.push(i)};for(let[i,a]of Object.entries(e.headers??{}))if(Dr(i,Zc)&&typeof a=="string"){n(a);let c=a.indexOf(" ");c!==-1&&n(a.slice(c+1))}let s;try{s=new URL(e.url).searchParams}catch{s=new URLSearchParams}for(let[i,a]of s.entries())yi.has(i.toLowerCase())&&typeof a=="string"&&a.length>=8&&t.push(a);let o=r;for(let i of t)o=o.split(i).join(wi);return o}function Ef(r,e){if(!/json/i.test(e))return r;let t;try{t=JSON.parse(r)}catch{return r}let n=s=>{if(Array.isArray(s))return s.map(n);if(s!==null&&typeof s=="object"){let o={};for(let[i,a]of Object.entries(s))o[i]=yi.has(i.toLowerCase())?wi:n(a);return o}return s};try{return JSON.stringify(n(t))}catch{return r}}var tu=8192;function ru(r){if(!r)return!1;let e=r.toLowerCase();return e.includes("json")||e.includes("xml")||e.includes("text/plain")||e.includes("application/javascript")}function li(r){try{let e=new URL(r),t=!1;for(let n of[...e.searchParams.keys()])yi.has(n.toLowerCase())&&(e.searchParams.set(n,"***REDACTED***"),t=!0);return e.hash&&(e.hash.includes("token")||e.hash.includes("sig")||e.hash.length>1)&&(e.hash="#***REDACTED***",t=!0),t?e.toString():r}catch{return r.replace(/([?&])(api_key|apikey|access_token|refresh_token|token|secret|password|signature|sig)=([^&#]*)/gi,"$1$2=***REDACTED***")}}var wi="***REDACTED***";function Jc(r,e){return{name:r,value:Dr(r,Zc)?wi:e}}function Rf(r){if(!r.body)return{};let e=r.headers["content-type"]??"";if(e&&!ru(e))return{};let t;if(typeof r.body=="string")t=r.body;else if(r.body instanceof Uint8Array)t=new TextDecoder().decode(r.body);else if(r.body instanceof ArrayBuffer)t=new TextDecoder().decode(new Uint8Array(r.body));else return{};let n=eu(Ef(t,e),r);return{postData:{mimeType:e,text:n.slice(0,tu)}}}var mi=class{constructor(e=1e4){f(this,"_buf",new Map);f(this,"_head",0);f(this,"_tail",0);f(this,"maxEntries");this.maxEntries=e}get entries(){return Array.from(this._buf.values())}record(e,t,n){let s=t.durationMs,o=0,i=s,a=0;try{if(typeof performance<"u"&&typeof performance.getEntriesByType=="function"){let u=typeof performance.getEntriesByName=="function"?performance.getEntriesByName(t.url):performance.getEntriesByType("resource").filter(h=>h.name===t.url),l=u[u.length-1];l&&l.requestStart>0&&Date.now()-l.startTime<6e4&&(o=Math.max(0,l.responseStart-l.requestStart),a=Math.max(0,l.responseEnd-l.responseStart),i=Math.max(0,s-o-a))}}catch{}let c={startedDateTime:new Date(n).toISOString(),time:s,request:{method:e.method,url:li(e.url),httpVersion:t.httpVersion,headers:Object.entries(e.headers).map(([u,l])=>Jc(u,l)),queryString:(()=>{try{return Array.from(new URL(li(e.url)).searchParams.entries()).map(([u,l])=>({name:u,value:l}))}catch{return[]}})(),bodySize:e.body?typeof e.body=="string"?new TextEncoder().encode(e.body).byteLength:e.body instanceof Uint8Array||e.body instanceof ArrayBuffer?e.body.byteLength:-1:0,...Rf(e)},response:{status:t.status,statusText:t.statusText,httpVersion:t.httpVersion,headers:Object.entries(t.headers).map(([u,l])=>Jc(u,l)),content:{size:t.rawBody?.byteLength??0,mimeType:t.headers["content-type"]??"application/octet-stream",...typeof t.data=="string"&&ru(t.headers["content-type"])?{text:eu(t.data,e).slice(0,tu)}:{}},redirectURL:t.headers.location?li(t.headers.location):"",bodySize:t.rawBody?.byteLength??0},timings:{send:o,wait:i,receive:a},cache:{}};this._buf.set(this._tail++,c),this._buf.size>this.maxEntries&&this._buf.delete(this._head++)}getHAR(){return{version:"1.2",creator:{name:"kinetex",version:"1.0.0",comment:`runtime:${Ce}`},entries:[...this.entries]}}clear(){this._buf.clear(),this._head=0,this._tail=0}get count(){return this._buf.size}};async function Qc(r,e){let t={...r.headers};switch(e.type){case"bearer":{let s=`Bearer ${typeof e.token=="function"?await e.token():e.token}`;if(!de(s))throw new x("Invalid bearer token \u2014 contains forbidden characters (CRLF/CTL)","EVALIDATION");t.authorization=s;break}case"basic":{let n=new TextEncoder,s=n.encode(e.username),o=n.encode(e.password),i=s.length+1+o.length,a=new Uint8Array(i);a.set(s),a.set(n.encode(":"),s.length),a.set(o,s.length+1);let c=se(a);t.authorization=`Basic ${c}`,s.fill(0),o.fill(0),a.fill(0);break}case"apikey":{let n=typeof e.key=="function"?await e.key():e.key;if(!Te(e.header))throw new x(`Invalid apikey auth header name: "${e.header}"`,"EVALIDATION");if(!de(String(n)))throw new x(`Invalid apikey value for "${e.header}" \u2014 contains forbidden characters`,"EVALIDATION");t[e.header.toLowerCase()]=String(n);break}case"digest":break;case"custom":{let n=e.apply(r);if(!n)throw new Error("Custom auth 'apply' must return a KinetexRequest");return n}default:{let n=e;throw new Error(`Unknown auth type: ${n.type}`)}}return{...r,headers:t}}var kf=new Set([...Wr,"www-authenticate"]);function Ar(r){try{let e=new URL(r);return e.username||e.password?(e.username="",e.password="",e.toString()):r}catch{return r.replace(/\/\/[^/@]*@/,"//")}}function kr(r,e,t,n=["http","https"],s=!1){let i=(u,l)=>{let h=0,d=()=>{if(h++,h>100)throw new x(`Query parameter count ${h} exceeds limit of 100`,"EVALIDATION")};for(let[p,m]of Object.entries(u))if(m!=null)if(Array.isArray(m))for(let g of m)g!=null&&(d(),l(p,String(g),!0));else d(),l(p,String(m),!1)},c;if(/^https?:\/\//i.test(e))c=e;else{let u=r??"";try{let l=u.replace(/\/$/,""),h=e.startsWith("/")?e.slice(1):e;c=new URL(h,l+"/").href}catch{let l=u.endsWith("/")?u:u+"/",h=e.startsWith("/")?e.slice(1):e;c=l+h}}if(!t||Object.keys(t).length===0){if(!ne(c,n,{allowPrivateNetwork:s}))throw new x(`URL "${Ar(c)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");return c}try{let u=new URL(c);if(!ne(u,n,{allowPrivateNetwork:s}))throw new x(`URL "${Ar(c)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");i(t,(h,d,p)=>{p?u.searchParams.append(h,d):u.searchParams.set(h,d)});let l=u.toString();if(l.length>8192)throw new x(`URL length ${l.length} bytes exceeds limit of 8192 bytes`,"EVALIDATION");if(!ne(l,n,{allowPrivateNetwork:s}))throw new x(`URL "${Ar(l)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");return l}catch(u){if(u instanceof x)throw u;c.includes("?")?c+="&":c+="?";let l=[];i(t??{},(d,p)=>{l.push(`${encodeURIComponent(d)}=${encodeURIComponent(p)}`)});let h=c+l.join("&");if(h.length>8192)throw new x(`URL length ${h.length} bytes exceeds limit of 8192 bytes`,"EVALIDATION");if(!ne(h,n,{allowPrivateNetwork:s}))throw new x(`URL "${Ar(h)}" failed safety check \u2014 blocked private/loopback address or forbidden scheme`,"EVALIDATION");return h}}function Qt(...r){let e=Object.create(null);for(let t of r){if(!t)continue;let n=Object.keys(t);for(let s of n){if(s==="__proto__"||s==="constructor"||s==="prototype")continue;if(!Te(s))throw new x(`Invalid header name: "${s}" \u2014 contains forbidden characters`,"EVALIDATION");let o=t[s];if(o==null)continue;let i=Array.isArray(o)?o.map(String).join(", "):String(o);if(!de(i))throw new x(`Invalid header value for ${s}: contains forbidden characters`,"EVALIDATION");e[s.toLowerCase()]=i}}return e}function Af(r){if(r==null)return null;if(typeof r=="string"||r instanceof Uint8Array)return r;try{return JSON.stringify(r)}catch{return null}}function Gc(r,e){if(e.attempt>r.maxRetries||!Object.keys(e.request.headers??{}).some(n=>n.toLowerCase()==="idempotency-key"&&e.request.headers[n]!=="")&&!r.methods.includes(e.request.method))return!1;if(r.shouldRetry)return r.shouldRetry(e);if(e.error){let n=e.error,s=n.code;switch(s){case"EHTTPSTATUS":return r.statuses.includes(n.status??0);case"ETIMEOUT":return r.onTimeout===!0;case"ENETWORK":return r.onNetworkError;case"EABORT":return!1;case"ESIZELIMIT":return!1;case"EPARSE":return!1;case"EVALIDATION":return!1;case"EAUTH":return!1;case"EPROXY":return!1;case"EREDIRECT":return!1;case"EBLOCKEDHOST":return!1;case"EUNKNOWN":return!1;default:return!1}}return e.response?r.statuses.includes(e.response.status):!1}function hi(r,e,t){if(t!==null)return Math.min(t,r.maxDelayMs);let n=Math.min(e,31),s=r.baseDelayMs*Math.pow(2,n-1);if(!isFinite(s)||s>r.maxDelayMs)return r.maxDelayMs;let o=Math.min(s,r.maxDelayMs),i=o+o*r.jitter*Math.random();return Math.min(Math.floor(i),r.maxDelayMs)}function Xc(r){let e=r["retry-after"];if(!e)return null;let t=sr(e);return t.delay!==null?Math.min(t.delay,86400)*1e3:t.date?Math.max(0,Math.min(t.date.getTime()-Date.now(),864e5)):null}var Gt=class r{constructor(e={}){f(this,"cfg");f(this,"transport");f(this,"interceptors");f(this,"harRecorder");f(this,"retryConfig");f(this,"_cache",null);f(this,"_cookieJar",null);f(this,"_logger",null);f(this,"_cacheInitLock",null);f(this,"_cookieJarInitLock",null);f(this,"_loggerInitLock",null);f(this,"_otelTracer",null);f(this,"_dedup",null);f(this,"_circuitBreakers",null);f(this,"_circuitBreakerKeyFn",null);f(this,"_wsClients",new Set);f(this,"_concurrencyLimiter");f(this,"_awsSigner",null);if(this.cfg=e,this.interceptors=new di,this.harRecorder=e.har===!0?new mi:null,this.retryConfig={..._f,...e.retry},e.circuitBreakerKeyFn&&(this._circuitBreakerKeyFn=e.circuitBreakerKeyFn),e.rateLimit){let t=ir(e.rateLimit);this.interceptors.addRequest(t)}if(this._concurrencyLimiter=e.concurrencyLimit?new Ct(e.concurrencyLimit):null,e.awsSigning){let t=new ye(e.awsSigning);this._awsSigner=t,this.interceptors.addRequest(async n=>{let s=n.request,o=null;(s.body instanceof Uint8Array||typeof s.body=="string")&&(o=s.body);let i=await t.sign({method:s.method,url:s.url,headers:{...s.headers},body:o});n.request={...s,headers:i.headers}})}if(this.transport=gr(e.fetch,e.httpVersion!=="HTTP/1.1",e.sessionPool,{...e.strictHeaders?{strict:!0}:{},...e.dispatcher!==void 0?{dispatcher:e.dispatcher}:{},...e.proxy!==void 0?{proxy:e.proxy}:{},...e.allowPrivateNetwork!==void 0?{allowPrivateNetwork:e.allowPrivateNetwork}:{},...e.ca!==void 0?{ca:e.ca}:{}}),e.interceptors&&(e.interceptors.request?.forEach(t=>this.interceptors.addRequest(t)),e.interceptors.response?.forEach(t=>this.interceptors.addResponse(t)),e.interceptors.error?.forEach(t=>this.interceptors.addError(t))),e.auth?.type==="digest"){let t=e.auth,n=uc();this.interceptors.addResponse(async s=>{if(!s.response||s.response.status!==401)return;let o=s.response.headers["www-authenticate"];if(!o||!o.toLowerCase().startsWith("digest")||s.request.meta.__digestRetried)return;let i=s.request.method,a=new URL(s.request.url),c=a.pathname+a.search,u=await n(o,t.username,t.password,i,c);return{...s.request,headers:{...s.request.headers,authorization:u},meta:{...s.request.meta,__digestRetried:!0}}})}}useRequest(e){return this.interceptors.addRequest(e)}attachHookRegistry(e){let t=this.useRequest(async o=>{let i={url:o.request.url,method:o.request.method,headers:o.request.headers,body:o.request.body,signal:o.request.signal,meta:o.request.meta},a={request:i,response:null,error:null,startedAt:o.startedAt,attempt:o.attempt,meta:o.request.meta},c=await e.runBeforeRequest(i,a);c!==i&&(o.request={...o.request,...c})}),n=this.useResponse(async o=>{if(!o.response)return;let i={status:o.response.status,statusText:o.response.statusText,headers:o.response.headers,body:o.response.body??null,request:{url:o.request.url,method:o.request.method,headers:o.request.headers,body:o.request.body,signal:o.request.signal,meta:o.request.meta}},a={request:i.request,response:i,error:null,startedAt:o.startedAt,attempt:o.attempt,meta:o.request.meta};await e.runAfterResponse(i,a)}),s=this.useError(async o=>{if(!o.error)return;let i={url:o.request.url,method:o.request.method,headers:o.request.headers,body:o.request.body,signal:o.request.signal,meta:o.request.meta},a=Cf(o.error.response,i),c={error:o.error,request:i,response:a,attempt:o.attempt},u={request:c.request,response:a,error:o.error,startedAt:o.startedAt,attempt:o.attempt,meta:o.request.meta};await e.runOnError(c,u)});return()=>{t(),n(),s()}}useResponse(e){return this.interceptors.addResponse(e)}useError(e){return this.interceptors.addError(e)}getHAR(){if(!this.harRecorder)throw new x("HAR recording not enabled. Pass `har: true` in config.","EUNKNOWN");return this.harRecorder.getHAR()}clearHAR(){this.harRecorder?.clear()}async getCache(){if(this._cache)return this._cache;if(!this.cfg.cache)return null;if(this._cacheInitLock)return await this._cacheInitLock,this._cache;let e=()=>{};this._cacheInitLock=new Promise(t=>{e=t});try{let{HTTPCache:t}=await Promise.resolve().then(()=>(Rt(),xa));return this._cache=new t(this.cfg.cache),this._cache}finally{e(),this._cacheInitLock=null}}async getCookieJar(){if(this._cookieJar)return this._cookieJar;if(!this.cfg.cookieJar)return null;if(this._cookieJarInitLock)return await this._cookieJarInitLock,this._cookieJar;if(this.cfg.cookieJar instanceof Object&&"setCookie"in this.cfg.cookieJar)return this._cookieJar=this.cfg.cookieJar,this._cookieJar;let e=()=>{};this._cookieJarInitLock=new Promise(t=>{e=t});try{let{CookieJar:t}=await Promise.resolve().then(()=>(Eo(),Dc));return this._cookieJar=new t,this._cookieJar}finally{e(),this._cookieJarInitLock=null}}async getLogger(){if(this._logger)return this._logger;if(!this.cfg.logger)return null;if(this._loggerInitLock)return await this._loggerInitLock,this._logger;let e=()=>{};this._loggerInitLock=new Promise(t=>{e=t});try{let{createLogger:t}=await Promise.resolve().then(()=>(Ln(),$c));return this._logger=t(this.cfg.logger),this._logger}finally{e(),this._loggerInitLock=null}}extend(e){let t=this.cfg.interceptors?.request??[],n=this.cfg.interceptors?.response??[],s=this.cfg.interceptors?.error??[],o=e.interceptors?.request??[],i=e.interceptors?.response??[],a=e.interceptors?.error??[],c=new r({...this.cfg,...e,headers:Qt(this.cfg.headers,e.headers),params:{...this.cfg.params,...e.params},interceptors:{request:[...t,...o],response:[...n,...i],error:[...s,...a]}}),u=new Set([...t,...o]),l=new Set([...n,...i]),h=new Set([...s,...a]);for(let d of this.interceptors.request)u.has(d)||c.useRequest(d);for(let d of this.interceptors.response)l.has(d)||c.useResponse(d);for(let d of this.interceptors.error)h.has(d)||c.useError(d);return this._circuitBreakers&&!c._circuitBreakers&&(c._circuitBreakers=this._circuitBreakers),this._dedup&&!c._dedup&&(c._dedup=this._dedup),this._otelTracer&&!c._otelTracer&&(c._otelTracer=this._otelTracer),c}setTracer(e){return this._otelTracer=e,this}enableDedup(e){return this._dedup=new Qe(e),this}disableDedup(){return this._dedup=null,this}get dedupMetrics(){return this._dedup?this._dedup.getStats():null}enableCircuitBreaker(e){return this._circuitBreakers=new Ge(e),this}disableCircuitBreaker(){return this._circuitBreakers=null,this}tripCircuit(e){return this._circuitBreakers?.trip(e),this}resetCircuit(e){return this._circuitBreakers?.reset(e),this}get circuitSnapshots(){return this._circuitBreakers?.snapshots()??{}}async ws(e,t={}){let n=kr(this.cfg.baseURL,e,this.cfg.params,["http","https","ws","wss"],this.cfg.allowPrivateNetwork),s=Qt(this.cfg.headers,t.headers),o={},i=this.cfg.auth;if(i){if(i.type==="bearer"){let p=typeof i.token=="function"?await i.token():i.token;o.authorization=`Bearer ${p}`}else if(i.type==="basic"){let p=new TextEncoder,m=p.encode(i.username),g=p.encode(i.password),w=new Uint8Array(m.length+1+g.length);w.set(m),w[m.length]=58,w.set(g,m.length+1);let y=se(w);w.fill(0),m.fill(0),g.fill(0),o.authorization=`Basic ${y}`}else if(i.type==="apikey"){let p=typeof i.key=="function"?await i.key():i.key;o[i.header.toLowerCase()]=typeof p=="string"?p:await p}}let a=await this.getCookieJar();if(a){let p=a.getCookieHeader({url:n,http:!1,sameSiteContext:"strict"});p&&(s.cookie=p)}try{let p=new URL(n);if(this.cfg.baseURL){let m=new URL(this.cfg.baseURL),g=p.protocol==="wss:"||p.protocol==="https:",w=m.protocol==="https:"||m.protocol==="wss:";if(g!==w||p.host!==m.host)throw new x(`WebSocket origin ${p.origin} does not match baseURL origin ${m.origin}`,"EVALIDATION")}}catch(p){throw p instanceof x?p:new x(`Invalid WebSocket URL: ${p}`,"EVALIDATION")}if(this._circuitBreakers){let p=this._circuitBreakerKeyFn?this._circuitBreakerKeyFn({url:n,method:"GET",headers:s,body:null,signal:null,meta:{}}):new URL(n).origin;if(this._circuitBreakers.get(p).state==="OPEN")throw new x(`Circuit breaker is open for WebSocket origin ${new URL(n).origin}`,"ENETWORK")}let c=this.cfg.ws,u={...c?.highWaterMark!==void 0?{highWaterMark:c.highWaterMark}:{},...c?.lowWaterMark!==void 0?{lowWaterMark:c.lowWaterMark}:{},...c?.maxSendRate!==void 0?{maxSendRate:c.maxSendRate}:{},...c?.keepRooms!==void 0?{keepRooms:c.keepRooms}:{},...t},l=u.onClose,h=(p,m,g)=>{g||this._wsClients.delete(d),l?.(p,m,g)},d=new Xe({url:n,headers:{...o,...s},...u,onClose:h});return this._wsClients.add(d),await d.connect().catch(p=>{throw this._wsClients.delete(d),d.destroy(),p}),d}async send(e,t,n={}){let s=N(),o=Date.now(),i=n.timeout!==void 0?n.timeout:this.cfg.timeout??3e4,a=n.retry===!1?!1:{...this.retryConfig,...n.retry??{},...n.retry?.totalTimeoutMs!==void 0?{}:{totalTimeoutMs:n.totalTimeoutMs??this.cfg.totalTimeoutMs??i}},c=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE","CONNECT"],u=t.toUpperCase();if(!c.includes(u))throw new x(`Invalid HTTP method '${t}'. Valid methods: ${c.join(", ")}`,"EVALIDATION");let l=kr(n.baseURL??this.cfg.baseURL,e,vf(this.cfg.params,n.params),void 0,this.cfg.allowPrivateNetwork===!0);if(n.proxy)throw new x("A per-request `proxy` is not supported because the transport pools one connection per origin \u2014 set `proxy` on the client instead, or use a custom `fetch` with a proxy agent for per-request routing. SOCKS5 requires createSocks5Tunnel() from kinetex/socks5.","EVALIDATION");if(this.cfg.httpsOnly)try{let T=new URL(l);if(T.protocol!=="https:")throw new x(`HTTPS-only mode enabled but URL uses ${T.protocol}. Use HTTPS URLs only.`,"EVALIDATION")}catch(T){throw T instanceof x?T:new x(`Invalid URL: ${T}`,"EVALIDATION")}let d,p=n.maxRequestSize??this.cfg.maxRequestSize??0;if(p>0&&n.body){let T=0;if(typeof n.body=="string")T=new TextEncoder().encode(n.body).byteLength;else if(n.body instanceof Uint8Array)T=n.body.byteLength;else if(n.body instanceof ArrayBuffer)T=n.body.byteLength;else if(n.body instanceof Blob)T=n.body.size;else if(ArrayBuffer.isView(n.body))T=n.body.byteLength;else if(n.body instanceof URLSearchParams)T=new TextEncoder().encode(n.body.toString()).byteLength;else if(n.body instanceof FormData)d=await wr(n.body),T=d.bytes.byteLength;else{if(n.body instanceof ReadableStream)throw new x("maxRequestSize cannot be enforced for ReadableStream bodies \u2014 pass maxRequestSize: 0 to opt out, or buffer the body first","EVALIDATION");if(n.body&&typeof n.body=="object")try{T=new TextEncoder().encode(JSON.stringify(n.body)).byteLength}catch(P){throw new x(`Cannot measure request body size: ${P instanceof Error?P.message:String(P)}`,"EVALIDATION")}}if(T>p)throw new x(`Request body size ${T} bytes exceeds limit of ${p} bytes`,"EVALIDATION")}let m={url:l,method:u,headers:Qt(this.cfg.headers,n.headers),body:n.body??null,signal:n.signal??null,...n.followRedirects!==void 0||this.cfg.followRedirects!==void 0?{followRedirects:n.followRedirects??this.cfg.followRedirects}:{},...n.maxRedirects!==void 0||this.cfg.maxRedirects!==void 0?{maxRedirects:n.maxRedirects??this.cfg.maxRedirects}:{},meta:{...n.meta},httpVersion:n.httpVersion??this.cfg.httpVersion??"HTTP/2"};if(m.body!==null&&m.body instanceof FormData&&!m.headers["content-type"]){let T=d??await wr(m.body);m={...m,headers:{...m.headers,"content-type":`multipart/form-data; boundary=${T.boundary}`},body:T.bytes}}m.body!==null&&typeof m.body=="object"&&!(m.body instanceof Uint8Array)&&!(m.body instanceof ArrayBuffer)&&!(m.body instanceof ReadableStream)&&!(m.body instanceof FormData)&&!(m.body instanceof URLSearchParams)&&!(m.body instanceof Blob)&&!m.headers["content-type"]&&(m={...m,headers:{...m.headers,"content-type":"application/json"},body:JSON.stringify(m.body)}),m.body!==null&&typeof URLSearchParams<"u"&&m.body instanceof URLSearchParams&&!m.headers["content-type"]&&(m={...m,headers:{...m.headers,"content-type":"application/x-www-form-urlencoded"}});let g=n.auth!==!1?n.auth??this.cfg.auth:void 0;g&&(m=await Qc(m,g)),this.cfg.transformRequest&&(m=await this.cfg.transformRequest(m));let w=await this.getCookieJar();if(w){let T=w.getCookieHeader({url:m.url,http:!0,sameSiteContext:"strict"});T&&(m={...m,headers:{...m.headers,cookie:T}})}let y=null,S="";try{if(this._otelTracer){y=this._otelTracer.startSpan(`HTTP ${m.method}`,{kind:3});let{traceparent:T,traceId:P,spanId:j}=Sf(y);y.setAttribute("http.request.method",m.method),y.setAttribute("url.full",m.url);try{y.setAttribute("server.address",new URL(m.url).hostname)}catch{}m={...m,headers:{...m.headers,traceparent:T},meta:{...m.meta,traceId:P,spanId:j}}}else if(m.meta.traceId&&!m.headers.traceparent){let T=String(m.meta.traceId),P=pi(16);m={...m,headers:{...m.headers,traceparent:`00-${T}-${P}-01`},meta:{...m.meta,spanId:P}}}if(this._dedup){let T=await ua(m.headers);S=la(m.method,m.url,T)}}catch(T){throw y&&(y.setStatus({code:2,message:T instanceof Error?T.message:String(T)}),T instanceof Error&&y.recordException(T),y.end()),T}let b;if(this._circuitBreakerKeyFn)try{b=this._circuitBreakerKeyFn(m)}catch{b=m.url}else try{b=new URL(m.url).origin}catch{b=m.url}let E=()=>this._executeWithRetry(m,a,i,n,s,o),A=this._dedup?()=>this._dedup.execute(m.method,S,E).then(T=>T):E,C=this._circuitBreakers?()=>this._circuitBreakers.execute(b,A).then(T=>T):A;try{let T=await C();return y&&(y.setAttribute("http.response.status_code",T.status),y.setStatus({code:T.status<400?1:2}),y.end()),T}catch(T){throw y&&(y.setStatus({code:2,message:T instanceof Error?T.message:String(T)}),T instanceof Error&&y.recordException(T),y.end()),T}}async _executeWithRetry(e,t,n,s,o,i){let a=async()=>{if(!this._concurrencyLimiter)return await this._executeWithRetryInner(e,t,n,s,o,i);await this._concurrencyLimiter.acquire(e.signal);try{return await this._executeWithRetryInner(e,t,n,s,o,i)}finally{this._concurrencyLimiter.release()}},c=Date.now(),u,l;try{let h=await a();return u=h.status,h}catch(h){throw l=h.code,h}finally{this._recordMetrics(e,u,l,Date.now()-c)}}_recordMetrics(e,t,n,s){let o=this._otelTracer;if(!o)return;let i={"http.request.method":e.method,"server.address":new URL(e.url).hostname};t!==void 0&&(i["http.response.status_code"]=t),n!==void 0&&(i["error.type"]=n);try{o.recordHistogram?.("http.client.request.duration",s/1e3,i),o.incrementCounter?.("http.client.request.count",1,i),n!==void 0&&o.incrementCounter?.("http.client.error.count",1,i)}catch{}}async _executeWithRetryInner(e,t,n,s,o,i){let a=0;for(;;){if(a++,e.signal?.aborted)throw gi(e);if(a>1&&Yc(e.body))throw new x("Cannot retry a request whose body is a stream or Blob \u2014 the body was consumed by the first attempt. Buffer it first, or disable retry for this request.","EVALIDATION",{request:e});try{let c=await this._executeOnce(e,n,s,o,a,i,t);if(t&&a<=t.maxRetries){let u={request:e,response:c,error:null,attempt:a,maxRetries:t.maxRetries};if(t.shouldRetry?await t.shouldRetry(u):Gc(t,u)){let h=hi(t,a,Xc(c.headers));if(t.totalTimeoutMs!==void 0&&t.totalTimeoutMs>0&&N()-o+h>=t.totalTimeoutMs)return c;await t.onRetry?.(u,h),await this.cfg.hooks?.onRetry?.reduce(async(d,p)=>{await d,await p(u)},Promise.resolve()),await fi(h,e.signal);continue}}return c}catch(c){globalThis.__KINETEX_DEBUG_RETRY&&console.log("DBG catch",{attempt:a,maxRetries:t===!1?"FALSE":t?.maxRetries,methods:t===!1?"FALSE":t?.methods,code:c?.code,method:e.method});let u=!1,l=c.response;if(this._awsSigner&&l&&c.code==="EHTTPSTATUS"){let d=l.data,p=typeof d=="string"?d:d instanceof Uint8Array?new TextDecoder().decode(d):d instanceof ArrayBuffer?new TextDecoder().decode(new Uint8Array(d)):JSON.stringify(d??"");this._awsSigner.handleClockSkewError(l.status,p,l.headers)&&(u=!e.meta[Wc],u&&(e.meta[Wc]=!0))}if(t&&(a<=t.maxRetries||u)){let d=l??null,p={request:e,response:d,error:c,attempt:a,maxRetries:t.maxRetries};if(u?!0:t.shouldRetry?await t.shouldRetry(p):Gc(t,p)){let g=hi(t,a,d?Xc(d.headers):null);if(t.totalTimeoutMs!==void 0&&t.totalTimeoutMs>0&&N()-o+g>=t.totalTimeoutMs)throw c;await t.onRetry?.(p,g),await this.cfg.hooks?.onRetry?.reduce(async(w,y)=>{await w,await y(p)},Promise.resolve()),await fi(g,e.signal);continue}}let h=await this._runErrorInterceptors(e,c,a,o);if(h)return h;if(s.onError){let d=c instanceof x?c:new x(String(c),"EUNKNOWN",{request:e,cause:c});throw s.onError(d),d}throw c}}}async _sendFollowingRedirects(e,t,n,s){let o=Math.max(0,e.maxRedirects??xf),i=e.followRedirects!==!1&&o>0,a={...e,redirect:"manual"},c=(()=>{try{return new URL(e.url).origin}catch{return null}})(),u=new Set;for(let l=0;l<=o;l++){if(l>0&&s&&(()=>{try{return new URL(a.url).origin===c}catch{return!1}})()&&(a=await Qc(a,s)),l>0&&this.cfg.hooks?.onBeforeRequest)for(let p of this.cfg.hooks.onBeforeRequest){let m=await p(a,{request:a,response:null,error:null,startedAt:N(),attempt:1,meta:a.meta});m&&(a={...m,redirect:"manual"})}let h=await Ot(this.transport,a,t);if(l>0){let p=await this.getLogger();if(p){let m=a.meta.requestId??"redirect";p.logResponse(m,h.status,h.statusText,h.headers,new Uint8Array(0),1,!1)}}if(h.status>=300&&h.status<400&&!!h.headers.location){if(u.has(h.url))throw new Me(`Redirect loop detected: ${h.url}`,e);if(u.add(h.url),n?.processResponseHeaders(h.headers,{url:h.url}),!i)return{...h,redirected:!1};if(l===o)throw new Me(`Too many redirects (exceeded ${o})`,e);if(h.body)try{await h.body.cancel()}catch{}let p=h.headers.location,m;try{let b=new URL(p,h.url);m=b.href;let E=b.protocol.toLowerCase();if(E!=="http:"&&E!=="https:")throw new x(`Unsafe redirect to ${E} detected \u2014 only HTTP(S) allowed`,"ENETWORK",{request:e});if(!ne(m,void 0,{allowPrivateNetwork:this.cfg.allowPrivateNetwork===!0}))throw new x(`Unsafe redirect target blocked: ${Ar(p)}`,"EVALIDATION",{request:e});if(this.cfg.httpsOnly&&E!=="https:")throw new x(`HTTPS-only mode enabled but redirect target uses ${E}`,"EVALIDATION",{request:e})}catch(b){throw b instanceof x?b:new x(`Invalid redirect location: ${p}`,"ENETWORK",{request:e,cause:b})}let g=h.status===301||h.status===302||h.status===303?"GET":a.method,w=g==="GET"||g==="HEAD"?null:a.body;if(w!==null&&Yc(w))throw new x("Cannot follow this redirect: a 307/308 preserves the method and body, and this request's body is a stream or Blob that the first attempt already consumed. Buffer it first, or disable redirects for this request.","EVALIDATION",{request:a});let y={...a.headers},S=!1;try{S=new URL(m).origin!==new URL(a.url).origin}catch{}if(S){for(let b of kf)delete y[b];s&&s.type==="apikey"&&delete y[s.header.toLowerCase()]}if(n){let b=n.getCookieHeader({url:m,http:!0,sameSiteContext:"strict"});b?y.cookie=b:delete y.cookie}else S&&delete y.cookie;a={...a,url:m,method:g,body:w,headers:y,redirect:"manual"};continue}return l>0?{...h,redirected:!0}:h}throw new Me("Redirect loop",e)}async _executeOnce(e,t,n,s,o,i,a){let c={request:e,response:null,error:null,startedAt:s,attempt:o,aborted:!1,store:new Map},u=e.meta.requestId??`req-${o}-${Date.now()}`;if(this._trace(u,"request_interceptors","start",s,o),e=await this._runRequestInterceptors(c),this._trace(u,"request_interceptors","end",s,o),this._trace(u,"lifecycle_before","start",s,o),this.cfg.hooks?.onBeforeRequest)for(let k of this.cfg.hooks.onBeforeRequest){let O=await k(e,this._hookCtx(c));O&&(e=O)}this._trace(u,"lifecycle_before","end",s,o);let l=await this.getLogger();l&&l.logRequest(u,e.method,e.url,e.headers,Af(e.body),o);let h=n.cache!==!1&&n.cache?.forceRefresh===!0;if(n.cache!==!1&&this.cfg.cache){let k=await this.getCache();if(k&&!h){let O={url:e.url,method:e.method,headers:e.headers},L=await k.get(O);if(L&&!L.stale){let $=await this._buildResponse(L.entry.response,e,!0,o,s,n);if(this.cfg.hooks?.onBeforeResponse)for(let K of this.cfg.hooks.onBeforeResponse)await K($,this._hookCtx(c));return $}if(L?.stale){if(await k.markSWRInFlight(O)){let B={...e,headers:{...e.headers,...k.buildConditionalHeaders(L.entry)}};(async()=>{try{let F=await Ot(this.transport,B,t),lt=await this.getCache();if(lt)if(F.status===304)await lt.revalidate({url:B.url,method:B.method,headers:B.headers},{status:304,statusText:"Not Modified",headers:F.headers,body:null});else{let{decompressBodyStream:tl,readRawBody:rl}=await Promise.resolve().then(()=>(Nt(),Pc)),nl=await tl(F.body,F.headers),sl=await rl(nl,0,F.url,B.signal);await lt.set({url:B.url,method:B.method,headers:B.headers},{status:F.status,statusText:F.statusText,headers:F.headers,body:sl},{tags:n.tags??[]})}}catch(F){if(this.cfg.onSWRError)try{this.cfg.onSWRError(F,B)}catch{}}finally{try{(await this.getCache())?.clearSWRInFlight(O)}catch{}}})()}return await this._buildResponse(L.entry.response,e,!0,o,s,n)}}}let d=[];n.onUploadProgress&&d.push(n.onUploadProgress),this.cfg.hooks?.onUploadProgress&&d.push(...this.cfg.hooks.onUploadProgress);let p=d.length>0?d:null,m=null;if(p!==null&&e.body!==null){let k=null,O=null;if(e.body instanceof ReadableStream)k=e.body;else if(typeof e.body=="string"){let L=new TextEncoder().encode(e.body);O=L.byteLength,k=new ReadableStream({start:$=>{$.enqueue(L),$.close()}})}else if(e.body instanceof Uint8Array)O=e.body.byteLength,k=new ReadableStream({start:L=>{L.enqueue(e.body),L.close()}});else if(e.body instanceof ArrayBuffer){let L=new Uint8Array(e.body);O=L.byteLength,k=new ReadableStream({start:$=>{$.enqueue(L),$.close()}})}else if(typeof Blob<"u"&&e.body instanceof Blob)O=e.body.size,k=e.body.stream();else if(typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams){let L=new TextEncoder().encode(e.body.toString());O=L.byteLength,k=new ReadableStream({start:$=>{$.enqueue(L),$.close()}})}if(k){let{stream:L}=rr(k,O,{onProgress:$=>{let K=$;for(let B of d)B(K)},...e.signal!==null?{signal:e.signal}:{}});m=L,e={...e,body:L}}}e.headers["accept-encoding"]||(e={...e,headers:{...e.headers,"accept-encoding":En}});let g=await this.getCookieJar(),w=n.auth!==!1?n.auth??this.cfg.auth:void 0;this._trace(u,"transport_send","start",s,o);let y;try{y=await this._sendFollowingRedirects(e,t,g??void 0,w)}catch(k){if(m)try{m.cancel("Request failed").catch(()=>{})}catch{}throw k}if(this._trace(u,"transport_send","end",s,o),this.cfg.hooks?.onAfterRequest)for(let k of this.cfg.hooks.onAfterRequest)await k(e,this._hookCtx(c));if(y.status===304){let k=await this.getCache();if(k){let O=await k.revalidate({url:e.url,method:e.method,headers:e.headers},{status:304,statusText:"Not Modified",headers:y.headers,body:null});if(O)return await this._buildResponse(O.response,e,!0,o,s,n)}}y.alreadyDecompressed&&(delete y.headers["content-encoding"],delete y.headers["Content-Encoding"]);let S=await br(y.body,y.headers),b=[];n.onDownloadProgress&&b.push(n.onDownloadProgress),this.cfg.hooks?.onDownloadProgress&&b.push(...this.cfg.hooks.onDownloadProgress);let E=b.length>0?b:null,A=S;if(E&&A){let k=y.headers["content-length"],O=k?parseInt(k,10):null,L=new G(O&&!isNaN(O)?O:null,{onProgress:K=>{let B=K;for(let F of b)F(B)},...e.signal!==null?{signal:e.signal}:{}}),$=A;A=new ReadableStream({async start(K){let B=$.getReader();try{for(;;){let{done:F,value:lt}=await B.read();if(F){L.complete(),K.close();break}L.update(lt.byteLength),K.enqueue(lt)}}catch(F){K.error(F)}finally{B.releaseLock()}},cancel(K){$.cancel(K).catch(()=>{})}})}let C=n.maxResponseSize??this.cfg.maxResponseSize??Tf,T=await yr(A,C,y.url,e.signal),P=await this.getCookieJar();P&&P.processResponseHeaders(y.headers,{url:y.url});let j=y.headers["content-type"]??null;this._trace(u,"response_parse","start",s,o);let v=await Mt(T,j,n.parseResponse,n.parseFailure,y.headers,y.url);this._trace(u,"response_parse","end",s,o);let M=N()-s,q={status:y.status,statusText:y.statusText,headers:y.headers,data:v,rawBody:T,body:T,url:y.url,cached:!1,redirected:y.redirected,httpVersion:y.httpVersion,durationMs:M,request:e,attempt:o};if(this.cfg.transformResponse&&(q.data=this.cfg.transformResponse(q.data,q)),n.cache!==!1&&this.cfg.cache){let k=await this.getCache();k&&y.status!==304&&await k.set({url:e.url,method:e.method,headers:e.headers},{status:y.status,statusText:y.statusText,headers:y.headers,body:T},{tags:n.tags??[]})}let _e=l??await this.getLogger();if(_e){let k=c.store.get("requestId")??e.meta.requestId??u;_e.logResponse(k,q.status,q.statusText,q.headers,T,o,!1)}this.harRecorder?.record(e,q,i??Date.now()-q.durationMs),c.response=q,this._trace(u,"response_interceptors","start",s,o);let re=await this._runResponseInterceptors(c,q,e,t,n,s,o,a??!1);if(this._trace(u,"response_interceptors","end",s,o),this.cfg.hooks?.onBeforeResponse){let k=re;for(let O of this.cfg.hooks.onBeforeResponse){let L=await O(k,this._hookCtx(c));L&&(k=L)}}if((n.throwOnError??this.cfg.throwOnError??!0)&&re.status>=400)throw new xt(re,e);if(this.cfg.hooks?.onAfterResponse)for(let k of this.cfg.hooks.onAfterResponse)await k(re,this._hookCtx(c));return n.onSuccess?.(re),re}async _runRequestInterceptors(e){let t=e.request;for(let n of this.interceptors.request){e.request=t;let s=await n(e);s&&"url"in s&&!("status"in s)?t=s:e.request!==t&&(t=e.request)}return e.request=t,t}async _runResponseInterceptors(e,t,n,s,o,i,a,c){let u=t;for(let l of this.interceptors.response){let h=await l(e);if(h){if("status"in h&&"headers"in h)u=h;else if("url"in h&&"method"in h&&!("status"in h)){let d=Number(n.meta[Kc]??0);if(d>=Vc)throw new x(`Response interceptor re-send limit reached (${Vc}) \u2014 refusing to loop`,"EVALIDATION",{request:n});if(c&&a<=c.maxRetries){let p={request:n,response:t,error:null,attempt:a,maxRetries:c.maxRetries},m=hi(c,a,0);await c.onRetry?.(p,m),await this.cfg.hooks?.onRetry?.reduce(async(g,w)=>{await g,await w(p)},Promise.resolve()),await fi(m,n.signal)}return this._executeOnce({...h,meta:{...h.meta,[Kc]:d+1}},s,o,i,a+1,void 0,c)}}}return u}async _runErrorInterceptors(e,t,n,s){let o={request:e,response:null,error:t,startedAt:s,attempt:n,aborted:!1,store:new Map};for(let i of this.interceptors.error){let a=await i(o);if(a&&"status"in a)return a}if(this.cfg.hooks?.onError)for(let i of this.cfg.hooks.onError){let a=await i(t,this._hookCtx(o));if(a)return a}return null}async _buildResponse(e,t,n,s,o,i){let a=e.body,c=a instanceof Uint8Array?a:typeof a=="string"?new TextEncoder().encode(a):null,u=c?await Mt(c,e.headers["content-type"]??null,i.parseResponse,i.parseFailure,e.headers,"url"in e?e.url:t.url):null,l=N()-o,h="url"in e?e.url:t.url,d="redirected"in e?e.redirected:!1,p="httpVersion"in e?e.httpVersion:"HTTP/1.1";return{status:e.status,statusText:e.statusText,headers:e.headers,body:c,data:u,rawBody:c,url:h,cached:n,redirected:d,httpVersion:p,durationMs:l,request:t,attempt:s}}_hookCtx(e){return{request:e.request,response:e.response,error:e.error,startedAt:e.startedAt,attempt:e.attempt,meta:e.request.meta}}_trace(e,t,n,s,o,i){if(this.cfg.onPipelineTrace)try{console.debug("[kinetex:trace]",e,t,n,o),this.cfg.onPipelineTrace({requestId:e,stage:t,event:n,elapsedMs:typeof performance<"u"?performance.now()-s:Date.now()-s,attempt:o,...i})}catch{}}get(e,t){return this.send(e,"GET",t)}post(e,t,n){return this.send(e,"POST",{...n,...t!==void 0?{body:t}:{}})}put(e,t,n){return this.send(e,"PUT",{...n,...t!==void 0?{body:t}:{}})}patch(e,t,n){return this.send(e,"PATCH",{...n,...t!==void 0?{body:t}:{}})}delete(e,t){return this.send(e,"DELETE",t)}head(e,t){return this.send(e,"HEAD",t)}options(e,t){return this.send(e,"OPTIONS",t)}request(e,t){return new Cr(this,e,t)}GET(e){return this.request("GET",e)}POST(e){return this.request("POST",e)}PUT(e){return this.request("PUT",e)}PATCH(e){return this.request("PATCH",e)}DELETE(e){return this.request("DELETE",e)}async sse(e,t={}){let{SSEClient:n}=await Promise.resolve().then(()=>(Er(),No)),s=Qt(this.cfg.headers,t.headers),o=kr(this.cfg.baseURL,e,this.cfg.params,void 0,this.cfg.allowPrivateNetwork),i=async(a,c)=>{let u=typeof a=="string"?a:a.url,l=c,h=await this.send(u,l.method??"GET",{headers:l.headers,body:l.body,signal:l.signal,throwOnError:!1,parseResponse:p=>p}),d={...h.headers};return delete d["content-encoding"],delete d["Content-Encoding"],new Response(h.rawBody?.buffer??null,{status:h.status,headers:d})};return new n({url:o,headers:s,fetch:i,...t})}async graphql(e,t={}){let{GraphQLClient:n}=await Promise.resolve().then(()=>(Dn(),qc)),s=Qt(this.cfg.headers,t.headers),o=kr(this.cfg.baseURL,e,this.cfg.params,void 0,this.cfg.allowPrivateNetwork),i=async(a,c)=>{let u=typeof a=="string"?a:a.url,l=c,h=await this.send(u,l.method??"POST",{headers:l.headers,body:l.body,signal:l.signal,throwOnError:!1,parseResponse:p=>p}),d={...h.headers};return delete d["content-encoding"],delete d["Content-Encoding"],new Response(h.rawBody?.buffer??null,{status:h.status,headers:d})};return new n({url:o,headers:s,fetch:i,...t})}async paginate(e,t){let{createPagePaginator:n}=await Promise.resolve().then(()=>(Hn(),Fc)),s=kr(this.cfg.baseURL,e,this.cfg.params,void 0,this.cfg.allowPrivateNetwork);return n({url:s,fetch:async(i,a)=>{let c=typeof i=="string"?i:i.url,u=a,l=await this.send(c,u.method??"GET",{headers:u.headers,body:u.body,signal:u.signal,throwOnError:!1,parseResponse:d=>d}),h={...l.headers};return delete h["content-encoding"],delete h["Content-Encoding"],new Response(l.rawBody?.buffer??null,{status:l.status,headers:h})},headers:Qt(this.cfg.headers),...t})}destroy(){for(let e of this._wsClients)try{e.close(1e3,"Client destroyed")}catch{}return this._wsClients.clear(),ze&&this.transport&&"destroy"in this.transport&&this.transport.destroy(),this._concurrencyLimiter?.drain(),this._cookieJar=null,this._logger=null,this._dedup?.clear(),this._circuitBreakers?.clear?.(),this._otelTracer=null,this.interceptors.clear(),Promise.resolve()}},Cr=class{constructor(e,t,n){f(this,"client");f(this,"method");f(this,"_options",{});f(this,"_url");this.client=e,this.method=t,this._url=n}header(e,t){return this._options.headers={...this._options.headers,[e.toLowerCase()]:t},this}idempotencyKey(e){let t=e===void 0?rn():e;if(!nn(t))throw new TypeError(`idempotencyKey: ${typeof t=="string"?JSON.stringify(t):typeof t} is not a valid Idempotency-Key \u2014 expected 1-255 visible ASCII characters`);return this._options.headers={...this._options.headers,"idempotency-key":t},this}headers(e){return this._options.headers={...this._options.headers,...e},this}param(e,t){return this._options.params={...this._options.params,[e]:t},this}params(e){return this._options.params={...this._options.params,...e},this}withBody(e){return this._options.body=e,this}withJSON(e){return this._options.body=JSON.stringify(e),this._options.headers={...this._options.headers,"content-type":"application/json"},this}withForm(e){return this._options.body=e,this}bearer(e){return this._options.auth={type:"bearer",token:e},this}basic(e,t){return this._options.auth={type:"basic",username:e,password:t},this}apiKey(e,t){return this._options.auth={type:"apikey",header:e,key:t},this}digest(e,t){return this._options.auth={type:"digest",username:e,password:t},this}noAuth(){return this._options.auth=!1,this}retry(e,t){return this._options.retry={maxRetries:e,...t},this}noRetry(){return this._options.retry=!1,this}timeout(e){return this._options.timeout=e,this}proxy(e){return this._options.proxy=e,this}cache(e){return this._options.cache=e,this}noCache(){return this._options.cache={forceRefresh:!0},this}onUploadProgress(e){return this._options.onUploadProgress=e,this}onDownloadProgress(e){return this._options.onDownloadProgress=e,this}signal(e){return this._options.signal=e,this}maxSize(e){return this._options.maxResponseSize=e,this}http2(){return this._options.httpVersion="HTTP/2",this}http1(){return this._options.httpVersion="HTTP/1.1",this}noThrow(){return this._options.throwOnError=!1,this}tags(...e){return this._options.tags=e,this}meta(e){return this._options.meta={...this._options.meta,...e},this}send(){return this.client.send(this._url,this.method,this._options)}async data(){return(await this.client.send(this._url,this.method,this._options)).data}async json(){let e={...this._options};return e.headers={...e.headers,accept:"application/json"},(await this.client.send(this._url,this.method,e)).data}async text(){let e={...this._options};return e.parseResponse=n=>new TextDecoder("utf-8").decode(n),(await this.client.send(this._url,this.method,e)).data}async bytes(){let e={...this._options};return e.parseResponse=n=>n,(await this.client.send(this._url,this.method,e)).data}async blob(){let e=await this.bytes(),t="application/octet-stream";if(typeof Blob>"u")throw new x("Blob is not available in this runtime","EUNKNOWN");return new Blob([e.buffer],{type:t})}subscribe(e,t){this.client.send(this._url,this.method,{...this._options,onSuccess:e,...t!==void 0?{onError:t}:{}}).catch(n=>t?.(n instanceof x?n:new x(String(n),"EUNKNOWN")))}};function Cf(r,e){return r?{status:r.status,statusText:r.statusText,headers:r.headers,body:r.rawBody??null,request:e}:null}function gi(r){return new _t(r)}function vf(r,e){if(!(!r&&!e))return{...r,...e}}function fi(r,e){return new Promise((t,n)=>{if(e?.aborted){n(gi());return}let s=()=>{clearTimeout(o),n(gi())},o=setTimeout(()=>{e?.removeEventListener("abort",s),t()},r);e?.addEventListener("abort",s,{once:!0})})}function Yc(r){return r instanceof ReadableStream?!0:typeof Blob<"u"&&r instanceof Blob}function nu(r){try{return`${r.method}:${new URL(r.url).origin}`}catch{return`${r.method}:${r.url}`}}var jn=class{constructor(e,t={}){f(this,"_client");f(this,"_maxBatch");f(this,"_flushMs");f(this,"_queue",[]);f(this,"_timer",null);this._client=e;let n=t.maxBatch??100;if(!Number.isInteger(n)||n<1)throw new RangeError(`BatchQueue maxBatch must be a positive integer (got ${n})`);this._maxBatch=n;let s=t.flushMs??0;if(!Number.isFinite(s)||s<0)throw new RangeError(`BatchQueue flushMs must be a non-negative finite number (got ${s})`);this._flushMs=s}enqueue(e,t="GET",n={}){return new Promise((s,o)=>{let i={url:e,method:t,options:n,resolve:s,reject:o};this._queue.push(i);let a=n.signal;if(a){let c=()=>{let u=this._queue.indexOf(i);u!==-1&&(this._queue.splice(u,1),o(new x("Request aborted while queued","EABORT")))};if(i._abortCleanup=()=>a.removeEventListener("abort",c),a.addEventListener("abort",c,{once:!0}),a.aborted){a.removeEventListener("abort",c);let u=this._queue.indexOf(i);u!==-1&&this._queue.splice(u,1),o(new x("Request aborted before flush","EABORT"));return}}this._queue.length>=this._maxBatch?this._flushNow():this._timer||(this._flushMs===0?queueMicrotask(()=>{this._timer=null,this._flushNow()}):this._timer=setTimeout(()=>this._flushNow(),this._flushMs))})}flush(){let e=this._queue.length+1;for(;this._queue.length>0&&e-- >0;)this._flushNow()}get pendingCount(){return this._queue.length}_flushNow(){if(this._timer!==null&&(clearTimeout(this._timer),this._timer=null),this._queue.length===0)return;let e=this._queue.splice(0,this._maxBatch);for(let t of e){let n=o=>{t._abortCleanup?.(),t.resolve(o)},s=o=>{t._abortCleanup?.(),t.reject(o)};try{this._client.send(t.url,t.method,t.options).then(n,s)}catch(o){s(o)}}}};Rt();An();Nt();Dn();$e();U();var vr=class{constructor(){f(this,"listeners",new Map)}on(e,t){let n=this.listeners.get(e)??[];return n.push({fn:t,once:!1}),this.listeners.set(e,n),this}once(e,t){let n=this.listeners.get(e)??[];return n.push({fn:t,once:!0}),this.listeners.set(e,n),this}off(e,t){let n=this.listeners.get(e);return n?(this.listeners.set(e,n.filter(s=>s.fn!==t)),this):this}async emit(e,t){let n=this.listeners.get(e);if(!n||n.length===0)return;let s=[...n],o=new Set;for(let i of s){try{await i.fn(t)}catch{}i.once&&o.add(i)}if(o.size>0){let i=this.listeners.get(e)??[];this.listeners.set(e,i.filter(a=>!o.has(a)))}}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}},Pf=0;function Lf(){return`hook_${++Pf}`}function ee(r){return[...r].sort((e,t)=>e.priority-t.priority)}var Bn=class{constructor(){f(this,"beforeRequest",[]);f(this,"afterRequest",[]);f(this,"beforeResponse",[]);f(this,"afterResponse",[]);f(this,"onError",[]);f(this,"onRetry",[]);f(this,"onRedirect",[]);f(this,"onUploadProgress",[]);f(this,"onDownloadProgress",[]);f(this,"onCancel",[]);f(this,"onConnection",[]);f(this,"aroundHooks",[]);f(this,"emitter",new vr)}addBeforeRequest(e,t={}){return this._add(this.beforeRequest,e,t)}addAfterRequest(e,t={}){return this._add(this.afterRequest,e,t)}addBeforeResponse(e,t={}){return this._add(this.beforeResponse,e,t)}addAfterResponse(e,t={}){return this._add(this.afterResponse,e,t)}addOnError(e,t={}){return this._add(this.onError,e,t)}addOnRetry(e,t={}){return this._add(this.onRetry,e,t)}addOnRedirect(e,t={}){return this._add(this.onRedirect,e,t)}addOnUploadProgress(e,t={}){return this._add(this.onUploadProgress,e,t)}addOnDownloadProgress(e,t={}){return this._add(this.onDownloadProgress,e,t)}addOnCancel(e,t={}){return this._add(this.onCancel,e,t)}addOnConnection(e,t={}){return this._add(this.onConnection,e,t)}addAround(e,t={}){return this._add(this.aroundHooks,e,t)}remove(e){let t=!1,n=[this.beforeRequest,this.afterRequest,this.beforeResponse,this.afterResponse,this.onError,this.onRetry,this.onRedirect,this.onUploadProgress,this.onDownloadProgress,this.onCancel,this.onConnection,this.aroundHooks];for(let s of n){let o=s.length,i=s.filter(a=>a.id!==e);i.length<o&&(s.length=0,s.push(...i),t=!0)}return t}removeAll(){this.beforeRequest.length=0,this.afterRequest.length=0,this.beforeResponse.length=0,this.afterResponse.length=0,this.onError.length=0,this.onRetry.length=0,this.onRedirect.length=0,this.onUploadProgress.length=0,this.onDownloadProgress.length=0,this.onCancel.length=0,this.onConnection.length=0,this.aroundHooks.length=0}has(e){return[this.beforeRequest,this.afterRequest,this.beforeResponse,this.afterResponse,this.onError,this.onRetry,this.onRedirect,this.onUploadProgress,this.onDownloadProgress,this.onCancel,this.onConnection,this.aroundHooks].some(n=>n.some(s=>s.id===e))}async runBeforeRequest(e,t){let n=e;for(let s of ee(this.beforeRequest)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(n,t));o&&typeof o=="object"&&"url"in o&&(n=o),this._maybeEject(s,this.beforeRequest)}return await this.emitter.emit("before:request",n),n}async runAfterRequest(e,t){for(let n of ee(this.afterRequest))this._shouldRun(n,t)&&(await this._safeRun(n,()=>n.fn(e,t)),this._maybeEject(n,this.afterRequest));await this.emitter.emit("after:request",e)}async runBeforeResponse(e,t){let n=e;for(let s of ee(this.beforeResponse)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(n,t));o&&typeof o=="object"&&"status"in o&&(n=o),this._maybeEject(s,this.beforeResponse)}return await this.emitter.emit("before:response",n),n}async runAfterResponse(e,t){for(let n of ee(this.afterResponse))this._shouldRun(n,t)&&(await this._safeRun(n,()=>n.fn(e,t)),this._maybeEject(n,this.afterResponse));await this.emitter.emit("after:response",e)}async runOnError(e,t){let n=null;for(let s of ee(this.onError)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(e,t));if(this._maybeEject(s,this.onError),o&&typeof o=="object"&&"status"in o){n=o;break}}return await this.emitter.emit("error",e),n}async runOnRetry(e,t){for(let n of ee(this.onRetry))this._shouldRun(n,t)&&(await this._safeRun(n,()=>n.fn(e,t)),this._maybeEject(n,this.onRetry));await this.emitter.emit("retry",e)}async runOnRedirect(e,t){let n=!0;for(let s of ee(this.onRedirect)){if(!this._shouldRun(s,t))continue;let o=await this._safeRun(s,()=>s.fn(e,t));if(this._maybeEject(s,this.onRedirect),o===!1){n=!1;break}}return await this.emitter.emit("redirect",e),n}runOnUploadProgress(e,t){for(let n of ee(this.onUploadProgress))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e,t)),this._maybeEject(n,this.onUploadProgress));this.emitter.emit("upload:progress",e)}runOnDownloadProgress(e,t){for(let n of ee(this.onDownloadProgress))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e,t)),this._maybeEject(n,this.onDownloadProgress));this.emitter.emit("download:progress",e)}runOnCancel(e,t){for(let n of ee(this.onCancel))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e,t)),this._maybeEject(n,this.onCancel));this.emitter.emit("cancel",e)}runOnConnection(e,t){for(let n of ee(this.onConnection))this._shouldRun(n,t)&&(this._safeRunSync(n,()=>n.fn(e)),this._maybeEject(n,this.onConnection));this.emitter.emit("connection",e)}wrapWithAround(e,t){let n=ee(this.aroundHooks).reverse(),s=t;for(let o of n){let i=s;s=()=>{if(!this._shouldRun(o,e))return i();let a=!1,c=this._safeRunSync(o,()=>(a=!0,o.fn(e,i)));return this._maybeEject(o,this.aroundHooks),a?i():c}}return s}_add(e,t,n){let s=n.id??Lf();return e.push({id:s,priority:n.priority??0,once:n.once??!1,condition:n.condition??null,safe:n.safe??!1,fn:t}),s}_shouldRun(e,t){return e.condition?e.condition(t):!0}async _safeRun(e,t){try{return await t()}catch(n){if(!e.safe)throw n;console.error(`[lifecycle] Hook "${e.id}" threw:`,n);return}}_safeRunSync(e,t){try{return t()}catch(n){if(!e.safe)throw n;console.error(`[lifecycle] Hook "${e.id}" threw:`,n);return}}_maybeEject(e,t){if(!e.once)return;let n=t.indexOf(e);n!==-1&&t.splice(n,1)}};var zn=class{constructor(e=10){f(this,"maxRedirects");f(this,"count",0);this.maxRedirects=e}record(e,t,n,s){if(this.count++,this.count>this.maxRedirects)throw new Pr(this.count,e);return{from:e,to:t,status:n,count:this.count,request:s}}get redirectCount(){return this.count}reset(){this.count=0}},Pr=class extends Error{constructor(t,n){super(`Too many redirects (${t}) at ${n}`);f(this,"count");f(this,"url");f(this,"code","ETOOMANYREDIRECTS");this.count=t,this.url=n,this.name="TooManyRedirectsError"}};function su(r){return async e=>(await r(e),e)}function ou(r){return async e=>({...e,headers:{...e.headers,...typeof r=="function"?await r():r}})}function iu(r){return e=>{if(/^https?:\/\//i.test(e.url))return;let t=r.replace(/\/+$/,""),n=e.url.replace(/^\/+/,"");return{...e,url:`${t}/${n}`}}}function au(r=e=>e>=400){return e=>{if(e.response&&r(e.response.status))throw new Lr(e.response.status,e.response.statusText,e.response)}}function cu(r){return e=>{let t=r(e);if(t===!0)return;let n=typeof t=="string"?t:`Response validation failed (status ${e.status})`;throw new Ir(n,e)}}var Lr=class extends Error{constructor(t,n,s){super(`HTTP ${t}: ${n}`);f(this,"status");f(this,"statusText");f(this,"response");f(this,"code","EHTTPERROR");this.status=t,this.statusText=n,this.response=s,this.name="HTTPError"}},Ir=class extends Error{constructor(t,n){super(t);f(this,"response");f(this,"code","EVALIDATION");this.response=n,this.name="ResponseValidationError"}};function uu(...r){return async(e,t)=>{let n=e;for(let s of r){let o=await s(n,t);o&&typeof o=="object"&&"url"in o&&(n=o)}return n}}function lu(...r){return async(e,t)=>{let n=e;for(let s of r){let o=await s(n,t);o&&typeof o=="object"&&"status"in o&&(n=o)}return n}}function hu(...r){return(e,t)=>r.reduceRight((s,o)=>()=>o(e,s),t)()}function fu(r={}){let e=r.logger??((s,o)=>console.log(s,JSON.stringify(o))),t=new Set((r.redactHeaders??["authorization","cookie","set-cookie","proxy-authorization"]).map(s=>s.toLowerCase())),n=s=>pt(s,t,"***");return{beforeRequest:s=>{e("\u2192 request",{method:s.method,url:s.url,headers:n(s.headers)})},afterResponse:s=>{e("\u2190 response",{status:s.status,url:s.request.url,headers:n(s.headers)})},onError:s=>{e("\u2717 error",{url:s.request.url,error:s.error instanceof Error?s.error.message:String(s.error),status:s.response?.status??null})}}}function du(){let r="__kinetex_timing__";return{beforeRequest:(e,t)=>{t.meta[r]=N()},afterResponse:(e,t)=>{let n=t.meta[r],s=n!==void 0?N()-n:null;s!==null&&(t.meta.durationMs=s)}}}function pu(r="utf-8"){return e=>{if(e.body instanceof Uint8Array)return{...e,body:new TextDecoder(r).decode(e.body)}}}function mu(){return{beforeRequest:(r,e)=>{if(r.signal?.aborted)throw e.meta.aborted=!0,Zt("Request aborted before sending")},onCancel:r=>{console.debug(`[lifecycle] Request cancelled: ${r.request.url}`,r.reason)}}}function gu(r,e={}){return{request:r,response:null,error:null,startedAt:N(),attempt:1,meta:{},...e}}Ln();Hn();mr();var Xt={NoAuth:0,GSSAPI:1,UserPassword:2,NoAcceptable:255},ae={IPv4:1,Domain:3,IPv6:4},If={Connect:1,Bind:2,UdpAssociate:3},te={Succeeded:0,GeneralFailure:1,ConnNotAllowed:2,NetworkUnreachable:3,HostUnreachable:4,ConnRefused:5,TtlExpired:6,CmdNotSupported:7,AddrTypeNotSupported:8},Of={[te.Succeeded]:"Succeeded",[te.GeneralFailure]:"General SOCKS server failure",[te.ConnNotAllowed]:"Connection not allowed by ruleset",[te.NetworkUnreachable]:"Network unreachable",[te.HostUnreachable]:"Host unreachable",[te.ConnRefused]:"Connection refused",[te.TtlExpired]:"TTL expired",[te.CmdNotSupported]:"Command not supported",[te.AddrTypeNotSupported]:"Address type not supported"},I=class extends Error{constructor(t,n,s=!1){super(t);f(this,"code");f(this,"retriable");this.code=n,this.retriable=s,this.name="Socks5Error"}};function Mf(r){let e=Of[r]??`Unknown reply code 0x${r.toString(16)}`,t=r===te.NetworkUnreachable||r===te.TtlExpired;return new I(`SOCKS5 proxy error: ${e}`,`SOCKS5_REPLY_${r}`,t)}var xi=class{constructor(e,t){f(this,"conn");f(this,"timeoutMs");f(this,"buf",new Uint8Array(0));this.conn=e,this.timeoutMs=t}async readExact(e){for(;this.buf.length<e;){let n=new Uint8Array(4096),o=await yu(this.conn.read(n),this.timeoutMs,"SOCKS5 handshake read timed out");if(o===null||o===0)throw new I("Connection closed during SOCKS5 handshake","SOCKS5_EOF");let i=new Uint8Array(this.buf.length+o);i.set(this.buf),i.set(n.subarray(0,o),this.buf.length),this.buf=i}let t=this.buf.slice(0,e);return this.buf=this.buf.slice(e),t}};function yu(r,e,t){return!Number.isFinite(e)||e<=0?r:new Promise((n,s)=>{let o=setTimeout(()=>s(new I(t,"SOCKS5_TIMEOUT",!0)),e);r.then(i=>{clearTimeout(o),n(i)},i=>{clearTimeout(o),s(i)})})}function Nf(r,e){let t=r.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(t){let o=t.slice(1).map(Number);if(o.every(i=>i>=0&&i<=255))return new Uint8Array([ae.IPv4,...o])}let n=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(Df(n)){let o=$f(n);return new Uint8Array([ae.IPv6,...o])}e||console.warn("[socks5] remoteDns=false but got a hostname; sending as DOMAINNAME");let s=new TextEncoder().encode(r);if(s.length>255)throw new I("Hostname too long for SOCKS5 (max 255 bytes)","SOCKS5_ADDR_TOO_LONG");return new Uint8Array([ae.Domain,s.length,...s])}var _i=/^[0-9a-fA-F]{1,4}$/;function Df(r){if(!r.includes(":"))return!1;let e=r.split("::");if(e.length>2)return!1;let t=s=>s===void 0||s===""?[]:s.split(":"),n=t(e[0]);if(e.length===2){let s=t(e[1]);return n.length+s.length>7?!1:[...n,...s].every(o=>_i.test(o))}return n.length===8&&n.every(s=>_i.test(s))}function $f(r){let e=r.split("::"),t=o=>o?o.split(":").map(i=>_i.test(i)?parseInt(i,16):Number.NaN):[],n;if(e.length===2){let o=t(e[0]),i=t(e[1]),a=new Array(8-o.length-i.length).fill(0);n=[...o,...a,...i]}else n=t(r);if(n.length!==8)throw new I(`Invalid IPv6 address: ${r}`,"SOCKS5_INVALID_ADDR");for(let o of n)if(!Number.isFinite(o)||o<0||o>65535)throw new I(`Invalid IPv6 group: ${o} out of range (0-65535)`,"SOCKS5_INVALID_ADDR");let s=[];for(let o of n)s.push(o>>8&255,o&255);return s}function bi(r,e){if(r===ae.IPv4)return Array.from(e).join(".");if(r===ae.IPv6){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return t.join(":")}return new TextDecoder().decode(e)}async function Uf(r,e,t){let n=new xi(r,t.handshakeTimeoutMs),s=!!(t.username&&t.password),o=s?[Xt.NoAuth,Xt.UserPassword]:[Xt.NoAuth],i=new Uint8Array([5,o.length,...o]);await r.write(i);let a=await n.readExact(2);if(a[0]!==5)throw new I(`Unexpected SOCKS version in method response: ${a[0]}`,"SOCKS5_BAD_VERSION");let c=a[1];if(c===Xt.NoAcceptable)throw new I("SOCKS5 proxy rejected all authentication methods","SOCKS5_NO_ACCEPTABLE_METHOD");if(c===Xt.UserPassword){if(!s)throw new I("SOCKS5 proxy requires username/password but none provided","SOCKS5_AUTH_REQUIRED");await Hf(r,n,t.username,t.password)}else if(c!==Xt.NoAuth)throw new I(`SOCKS5 proxy chose unsupported auth method: 0x${c.toString(16)}`,"SOCKS5_UNSUPPORTED_METHOD");let u=Nf(e.host,t.remoteDns),l=e.port,h=[l>>8&255,l&255],d=new Uint8Array([5,If.Connect,0,...u,...h]);await r.write(d);let p=await n.readExact(4);if(p[0]!==5)throw new I(`Unexpected SOCKS version in reply: ${p[0]}`,"SOCKS5_BAD_VERSION");if(p[1]!==te.Succeeded)throw Mf(p[1]);let m=p[3],g,w;if(m===ae.IPv4)w=await n.readExact(4),g=bi(ae.IPv4,w);else if(m===ae.IPv6)w=await n.readExact(16),g=bi(ae.IPv6,w);else if(m===ae.Domain){let b=await n.readExact(1);w=await n.readExact(b[0]),g=bi(ae.Domain,w)}else throw new I(`Unsupported bound address type in reply: 0x${m.toString(16)}`,"SOCKS5_UNSUPPORTED_ADDR_TYPE");let y=await n.readExact(2),S=y[0]<<8|y[1];return{boundAddr:g,boundPort:S}}async function Hf(r,e,t,n){let s=new TextEncoder,o=s.encode(t),i=s.encode(n);if(o.length>255||i.length>255)throw new I("Username or password too long (max 255 bytes)","SOCKS5_AUTH_TOO_LONG");let a=new Uint8Array([1,o.length,...o,i.length,...i]);await r.write(a);let c=await e.readExact(2);if(c[0]!==1&&c[0]!==5)throw new I(`Unexpected auth sub-negotiation version: ${c[0]}`,"SOCKS5_BAD_AUTH_VERSION");if(c[1]!==0)throw new I("SOCKS5 authentication failed (invalid credentials)","SOCKS5_AUTH_FAILED")}async function jf(r,e,t){let n;for(let s=0;s<=e;s++)try{return await r()}catch(o){if(n=o,!(o instanceof I&&o.retriable)||s===e)break;await Bf(t*Math.pow(2,s))}throw n}function Bf(r){return new Promise(e=>setTimeout(e,r))}var zf=new Set(["ECONNREFUSED","ECONNRESET","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ETIMEDOUT","EPIPE","EAI_AGAIN"]);function qf(r){return{host:r.host,port:r.port??1080,username:r.username??"",password:r.password??"",remoteDns:r.remoteDns??!0,connectTimeoutMs:r.connectTimeoutMs??1e4,handshakeTimeoutMs:r.handshakeTimeoutMs??1e4,maxRetries:r.maxRetries??2,retryDelayMs:r.retryDelayMs??300}}async function Si(r,e,t){let n=qf(r);return await jf(async()=>{let s=await yu(t(n.host,n.port,n.connectTimeoutMs),n.connectTimeoutMs,`TCP connection to SOCKS5 proxy ${n.host}:${n.port} timed out`).catch(o=>{if(o instanceof I||o instanceof DOMException)throw o;let i=o?.code,a=typeof i=="string"?i:"UNKNOWN";throw new I(`Cannot reach SOCKS5 proxy ${n.host}:${n.port}: ${o instanceof Error?o.message:String(o)}`,"SOCKS5_CONNECT_FAILED",zf.has(a))});try{let{boundAddr:o,boundPort:i}=await Uf(s,e,n);return{conn:s,boundAddr:o,boundPort:i}}catch(o){throw s.close(),o}},n.maxRetries,n.retryDelayMs)}function wu(r){let e;try{Ff(r),e=new URL(r)}catch{throw new I("Invalid SOCKS5 proxy URL: malformed URL","SOCKS5_BAD_URL")}if(e.protocol!=="socks5:"&&e.protocol!=="socks5h:")throw new I(`Expected socks5:// or socks5h:// scheme, got: ${e.protocol}`,"SOCKS5_BAD_SCHEME");let t=e.protocol==="socks5h:",n=e.hostname,s=e.port?parseInt(e.port,10):1080;if(!Number.isFinite(s)||s<1||s>65535)throw new I("Invalid SOCKS5 proxy URL: port must be between 1 and 65535","SOCKS5_BAD_URL");if(!n)throw new I("Invalid SOCKS5 proxy URL: no hostname specified (e.g., socks5://host:port)","SOCKS5_BAD_URL");let o={host:n,port:s,remoteDns:t},i=(a,c)=>{try{return decodeURIComponent(a)}catch{throw new I(`Invalid SOCKS5 proxy URL: malformed percent-encoding in the ${c}`,"SOCKS5_BAD_URL")}};return e.username&&(o.username=i(e.username,"username")),e.password&&(o.password=i(e.password,"password")),o}function Ff(r){try{let e=new URL(r);return`${e.protocol}//${e.host}${e.pathname}${e.search}${e.hash}`}catch{return"[redacted]"}}var bu=async(r,e,t)=>{let n=globalThis,s=async(a,c)=>{if(!t||t<=0)return a;let u;try{return await Promise.race([a,new Promise((l,h)=>{u=setTimeout(()=>h(new I(c,"SOCKS5_TIMEOUT",!0)),t)})])}finally{u!==void 0&&clearTimeout(u)}},o=await s(n.Deno.connect({hostname:r,port:e,transport:"tcp"}),"TCP connect to proxy timed out");return{read:a=>{let c=o.read(a).catch(()=>null);return s(c,"TCP read timed out")},write:a=>o.write(a),close:()=>{try{o.close()}catch{}}}},xu=(r,e,t)=>new Promise((n,s)=>{import("node:net").then(({createConnection:o})=>{let i=o({host:r,port:e}),a;Number.isFinite(t)&&t>0&&(a=setTimeout(()=>{i.destroy(),s(new I("TCP connect to proxy timed out","SOCKS5_TIMEOUT",!0))},t));let c=()=>{a!==void 0&&clearTimeout(a)},u=new Uint8Array(0),l=null,h=null,d=null,p=null;function m(){if(!l||!d||u.length===0)return;let y=Math.min(u.length,d.length);d.set(u.subarray(0,y)),u=u.slice(y);let S=l;l=null,h=null,d=null,S(y)}function g(y){if(h){let S=h;l=null,h=null,d=null,S(y)}}i.on("data",y=>{let S=new Uint8Array(u.length+y.length);S.set(u),S.set(y,u.length),u=S,m()});let w=!1;i.on("end",()=>{w=!0,l&&(l(null),l=null,h=null,d=null)}),i.on("close",()=>{w=!0}),i.once("error",y=>{c(),p=y,g(y),s(y)}),i.once("connect",()=>{c(),i.on("error",y=>{p=y,g(y)}),n({read:y=>new Promise((S,b)=>{if(p){b(p);return}if(w&&u.length===0){S(null);return}if(u.length>0){let E=Math.min(u.length,y.length);y.set(u.subarray(0,E)),u=u.slice(E),S(E);return}l=S,h=b,d=y}),write:y=>new Promise((S,b)=>{i.write(y,E=>E?b(E):S(y.length))}),close:()=>i.destroy()})})}).catch(s)});function _u(r,e){return async(t,n,s)=>{let o=Number.isFinite(s)&&s>0?s:void 0,i=o??r.connectTimeoutMs;return(await Si({...r,...i!==void 0?{connectTimeoutMs:i}:{},...o!==void 0?{handshakeTimeoutMs:o}:{}},{host:t,port:n},e)).conn}}Er();Re();Re();Nt();Rt();Eo();Er();Dn();Hn();Ln();mr();$e();U();var qn=class extends Error{constructor(t){super(t);f(this,"code","URL_VALIDATION_ERROR");this.name="URLValidationError"}},Wf=/^[A-Za-z0-9\-._~]$/,Kf=/^[:/?#\[\]@!$&'()*+,;=]$/;function Fn(r,e=!1){return Array.from(r).map(t=>{if(Wf.test(t)||e&&Kf.test(t))return t;let n=t.codePointAt(0);if(n>65535){let s=new TextEncoder().encode(t);return Array.from(s).map(o=>"%"+o.toString(16).toUpperCase().padStart(2,"0")).join("")}if(n>127){let s=new TextEncoder().encode(t);return Array.from(s).map(o=>"%"+o.toString(16).toUpperCase().padStart(2,"0")).join("")}return"%"+n.toString(16).toUpperCase().padStart(2,"0")}).join("")}function ce(r){try{return decodeURIComponent(r.replace(/\+/g,"%20"))}catch{return r.replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}}function Ti(r){return encodeURIComponent(r).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function ut(r){return encodeURIComponent(r).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function Ru(r,e={}){let{sort:t=!1,arrayFormat:n="repeat"}=e,s=[];for(let[o,i]of Object.entries(r)){if(i==null)continue;let a=ut(o);if(Array.isArray(i)){let c=i.filter(u=>u!=null);if(c.length===0)continue;if(n==="comma")s.push([a,c.map(u=>ut(String(u))).join(",")]);else if(n==="bracket")for(let u of c)s.push([`${a}[]`,ut(String(u))]);else for(let u of c)s.push([a,ut(String(u))])}else s.push([a,ut(String(i))])}return t&&s.sort(([o],[i])=>o<i?-1:o>i?1:0),s.map(([o,i])=>`${o}=${i}`).join("&")}function Ei(r){let e=r.startsWith("?")?r.slice(1):r,t={};if(!e)return t;let n=(o,i)=>Object.prototype.hasOwnProperty.call(o,i),s=(o,i)=>{o==="__proto__"?Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):t[o]=i};for(let o of e.split("&")){if(!o)continue;let i=o.indexOf("="),a=ce(i===-1?o:o.slice(0,i)),c=i===-1?"":ce(o.slice(i+1));if(!n(t,a))s(a,c);else{let u=t[a];Array.isArray(u)?u.push(c):s(a,[u,c])}}return t}function ku(r,e){let t={...r};for(let[n,s]of Object.entries(e))s==null?delete t[n]:t[n]=s;return t}function Au(r,...e){let t={};for(let n of e)n in r&&(t[n]=r[n]);return t}function Cu(r,...e){let t=new Set(e),n={};for(let[s,o]of Object.entries(r))t.has(s)||(n[s]=o);return n}function Ri(...r){if(r.length===0)return"/";let e=[];for(let i of r)i&&e.push(...i.split("/").filter((a,c)=>a!==""||c===0));let n=vu(e).join("/"),o=r[r.length-1]?.endsWith("/")&&n!=="/"?"/":"";return(n.startsWith("/")?"":"/")+n+o}function vu(r){let e=[];for(let t of r)t!=="."&&(t===".."?e.pop():e.push(t));return e}function ki(r,e={}){let{trailingSlash:t="preserve"}=e,n=r.endsWith("/")&&r!=="/",s=r.split("/").filter(Boolean),i="/"+vu(s).join("/");return t==="add"&&i!=="/"?i+="/":t==="remove"||t==="preserve"&&n&&i!=="/"&&(i+="/"),i}function Pu(r){return r.split("/").filter(Boolean).map(ce)}function Ai(r,e){return r.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g,(t,n)=>{let s=e[n];if(s===void 0)throw new qn(`Missing path param: "${n}"`);return Ti(String(s))})}var Vf={"http:":"80","https:":"443","ftp:":"21","ws:":"80","wss:":"443"};function Lu(r,e={}){let t=Je(r);if(!t)throw new TypeError(`Invalid URL: ${r}`);let n=Vf[t.protocol],s=t.port===n?"":t.port,o=ki(t.pathname,{trailingSlash:e.trailingSlash??"preserve"});e.sortParams&&t.searchParams.sort();let i=t.searchParams.toString()?`?${t.searchParams}`:"",a=e.removeFragment?"":t.hash,c=t.username?`${encodeURIComponent(t.username)}${t.password?":"+encodeURIComponent(t.password):""}@`:"",u=s?`${t.hostname}:${s}`:t.hostname;return`${t.protocol}//${c}${u}${o}${i}${a}`}var Ve=class r{constructor(e,t){f(this,"_url");try{this._url=new URL(String(e),t)}catch{throw new TypeError(`Invalid URL: "${e}"${t?` (base: "${t}")`:""}`)}}static from(e,t){return new r(e,t)}static https(e,t){return new r(`https://${e}${t??"/"}`)}static http(e,t){return new r(`http://${e}${t??"/"}`)}withProtocol(e){let t=this._clone();return t._url.protocol=e.endsWith(":")?e:e+":",t}withHostname(e){let t=this._clone();return t._url.hostname=e,t}withHost(e){let t=this._clone();return t._url.host=e,t}withPort(e){let t=this._clone();return t._url.port=String(e),t}withUsername(e){let t=this._clone();return t._url.username=encodeURIComponent(e),t}withPassword(e){let t=this._clone();return t._url.password=encodeURIComponent(e),t}withPathname(e){let t=this._clone();return t._url.pathname=e,t}appendPath(...e){let t=this._clone(),n=t._url.pathname.replace(/\/$/,""),s=e.map(o=>o.replace(/^\/|\/$/g,"")).filter(Boolean);return t._url.pathname=n+"/"+s.join("/"),t}path(...e){let t=this._clone();return t._url.pathname=Ri(...e),t}params(e){let t=this._clone();t._url.pathname=Ai(t._url.pathname,e);for(let[n,s]of Object.entries(e))t._url.searchParams.set(n,String(s));return t}addTrailingSlash(){let e=this._clone();return e._url.pathname.endsWith("/")||(e._url.pathname+="/"),e}removeTrailingSlash(){let e=this._clone();return e._url.pathname!=="/"&&e._url.pathname.endsWith("/")&&(e._url.pathname=e._url.pathname.slice(0,-1)),e}setParam(e,t){let n=this._clone();return t==null?n._url.searchParams.delete(e):n._url.searchParams.set(e,String(t)),n}appendParam(e,t){if(t==null)return this;let n=this._clone();return n._url.searchParams.append(e,String(t)),n}deleteParam(e){let t=this._clone();return t._url.searchParams.delete(e),t}query(e){let t=this._clone();for(let[n,s]of Object.entries(e))if(s==null)t._url.searchParams.delete(n);else if(Array.isArray(s)){t._url.searchParams.delete(n);for(let o of s)o!=null&&t._url.searchParams.append(n,String(o))}else t._url.searchParams.set(n,String(s));return t}setQuery(e){let t=this._clone();return t._url.search="",t.query(e)}pickParams(...e){let t=this._clone(),n=new Set(e),s=[];for(let[o,i]of t._url.searchParams.entries())n.has(o)&&s.push([o,i]);t._url.search="";for(let[o,i]of s)t._url.searchParams.append(o,i);return t}omitParams(...e){let t=this._clone(),n=new Set(e);for(let s of n)t._url.searchParams.delete(s);return t}sortParams(){let e=this._clone();return e._url.searchParams.sort(),e}redactParams(...e){let t=this._clone();for(let n of e)t._url.searchParams.has(n)&&(t=t.setParam(n,"REDACTED"));return t}withHash(e){let t=this._clone();return t._url.hash=e.startsWith("#")?e:"#"+e,t}removeHash(){let e=this._clone();return e._url.hash="",e}toString(){return this._url.toString()}toURL(){return new URL(this._url.toString())}get href(){return this._url.href}get protocol(){return this._url.protocol}get hostname(){return this._url.hostname}get host(){return this._url.host}get port(){return this._url.port}get pathname(){return this._url.pathname}get search(){return this._url.search}get hash(){return this._url.hash}get origin(){return this._url.origin}get searchParams(){return new URLSearchParams(this._url.searchParams)}get queryObject(){return Ei(this._url.search)}_clone(){return new r(this._url.toString())}};function Iu(r,e){return r.replace(/\{([^}]+)\}/g,(t,n)=>{let s=n[0],o="+#./;?&".includes(s),i=(o?n.slice(1):n).split(",");return Jf(o?s:"",i,e)})}function Jf(r,e,t){let n=Xf(r),s=Yf(r),o=Zf(r),i=ed(r),a=r==="+"||r==="#",c=[];for(let u of e){let{name:l,explode:h,maxLength:d}=Qf(u.trim()),p=t[l];if(p==null)continue;let m=Gf(p,l,o,h,d,a,n,i);m!==null&&c.push(m)}return c.length===0?"":s+c.join(n)}function Qf(r){if(r.endsWith("*"))return{name:r.slice(0,-1),explode:!0,maxLength:null};let e=r.lastIndexOf(":");if(e!==-1){let t=parseInt(r.slice(e+1),10);return{name:r.slice(0,e),explode:!1,maxLength:isNaN(t)?null:t}}return{name:r,explode:!1,maxLength:null}}function Gf(r,e,t,n,s,o,i,a){let c=u=>o?Fn(u,!0):Fn(u);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"){let u=String(r);s!==null&&(u=u.slice(0,s));let l=c(u);return t?`${e}${l===""?a:"="+l}`:l}if(Array.isArray(r)){if(r.length===0)return null;if(n)return r.map(l=>{let h=c(String(l));return t?`${e}=${h}`:h}).join(i);let u=r.map(l=>c(String(l))).join(",");return t?`${e}=${u}`:u}if(typeof r=="object"&&r!==null){let u=Object.entries(r);if(u.length===0)return null;if(n)return u.map(([h,d])=>`${c(h)}=${c(d)}`).join(i);let l=u.flatMap(([h,d])=>[c(h),c(d)]).join(",");return t?`${e}=${l}`:l}return null}function Xf(r){switch(r){case".":return".";case"/":return"/";case";":return";";case"?":case"&":return"&";default:return","}}function Yf(r){switch(r){case"#":return"#";case".":return".";case"/":return"/";case";":return";";case"?":return"?";case"&":return"&";default:return""}}function Zf(r){return r===";"||r==="?"||r==="&"}function ed(r){return r===";"?"":"="}function Su(r){return r.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function Ou(r){let e=[],t=/:([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]+)\))?|\*\*|\*/g,n="",s=0;for(let i of r.matchAll(t))n+=Su(r.slice(s,i.index)),s=i.index+i[0].length,i[1]!==void 0?(e.push({kind:"param",name:i[1]}),n+=`(${i[2]??"[^/]+"})`):i[0]==="**"?(e.push({kind:"wildcard",greedy:!0}),n+="(.+?)"):(e.push({kind:"wildcard",greedy:!1}),n+="([^/]+)");n+=Su(r.slice(s));let o=new RegExp(`^${n}\\/?$`);return{match(i){let a=Tu(i),c=o.exec(a);if(!c)return null;let u={},l=[],h={};for(let d=0;d<e.length;d++){let p=e[d],m=c[d+1]??"";if(p.kind==="param"){let g=ce(m);u[p.name]=g,h[p.name]=g;continue}if(p.greedy)for(let g of m.split("/").filter(Boolean))l.push(ce(g));else l.push(ce(m));h[String(d+1)]=ce(m)}return{params:u,wildcards:l,groups:h}},test(i){return o.test(Tu(i))}}}function Tu(r){try{return new URL(r).pathname}catch{return r}}function Wn(r){let e=Je(r);return e?["file:","data:","blob:"].includes(e.protocol)?"null":e.origin:null}function Mu(r,e){let t=Wn(r),n=Wn(e);return!t||!n?!1:t===n}function Nu(r,e){let t=Je(r),n=Je(e);return!t||!n||t.protocol!==n.protocol?!1:Eu(t.hostname)===Eu(n.hostname)}function Eu(r){let e=new Set(["co.uk","co.jp","co.kr","co.nz","co.za","co.in","com.au","com.br","com.mx","com.cn","com.tw","com.hk","com.sg","com.my","com.ph","com.vn","com.tr","net.au","net.uk","net.br","org.uk","org.au","org.nz","org.cn","org.in","ac.uk","gov.uk","gov.au","gov.cn","or.kr","pe.kr","go.jp","ne.jp","ac.jp","github.io","herokuapp.com","cloudfront.net"]),t=r.split(".");if(t.length>=3){let n=t.slice(-2).join(".");if(e.has(n))return t.slice(-3).join(".")}return t.slice(-2).join(".")}function Du(r,e){try{return new URL(r,e).toString()}catch{throw new TypeError(`Cannot resolve "${r}" against base "${e}"`)}}function $u(r,e){try{let t=new URL(r),n=new URL(e);return t.origin!==n.origin||!t.pathname.startsWith(n.pathname)||t.pathname.length>n.pathname.length&&!n.pathname.endsWith("/")&&t.pathname[n.pathname.length]!=="/"?null:t.pathname.slice(n.pathname.length)+t.search+t.hash}catch{return null}}function Ci(r){try{if(/^[A-Za-z][A-Za-z0-9+\-.]*:\/\//.test(r))return!0;let e=new URL(r);return e.protocol!==""&&e.protocol!=="file:"}catch{return!1}}function Uu(r){return!Ci(r)}function Hu(r){try{return new URL(r).protocol==="https:"}catch{return!1}}function ju(r){try{let e=new URL(r).protocol;return e==="http:"||e==="https:"}catch{return!1}}function Bu(r){return r.trimStart().startsWith("data:")}function zu(r){return r.trimStart().startsWith("blob:")}function qu(r){try{let e=new URL(r).hostname;return e==="localhost"||e==="127.0.0.1"||e==="::1"||e.endsWith(".localhost")}catch{return!1}}function Fu(r){if(!r.startsWith("data:"))return null;let e=r.indexOf(",");if(e===-1)return null;let t=r.slice(5,e),n=r.slice(e+1),s=t.lastIndexOf(";"),o=!1;return s!==-1&&t.slice(s+1).toLowerCase()==="base64"&&(o=!0,t=t.slice(0,s)),t=t.replace(/^;+/,""),{mediaType:t.includes("/")?t:t===""?"text/plain":`text/plain;${t}`,isBase64:o,data:n}}function Wu(r,e,t=!0){if(/[,;]/.test(e))throw new qn(`Invalid media type for a data URL: ${JSON.stringify(e)} (it must not contain "," or ";")`);return typeof r=="string"?t?`data:${e};base64,${se(new TextEncoder().encode(r))}`:`data:${e},${encodeURIComponent(r)}`:`data:${e};base64,${se(r)}`}function Ku(r,e){let t=Je(r),n=Je(e);if(!t||!n)throw new TypeError(`Cannot diff invalid URLs: "${r}" vs "${e}"`);let s={addedParams:{},removedParams:{},changedParams:{}};t.protocol!==n.protocol&&(s.protocol=[t.protocol,n.protocol]),t.hostname!==n.hostname&&(s.hostname=[t.hostname,n.hostname]),t.port!==n.port&&(s.port=[t.port,n.port]),t.pathname!==n.pathname&&(s.pathname=[t.pathname,n.pathname]),t.hash!==n.hash&&(s.hash=[t.hash,n.hash]);for(let[o,i]of t.searchParams.entries()){let a=n.searchParams.get(o);a===null?s.removedParams[o]=i:a!==i&&(s.changedParams[o]=[i,a])}for(let[o,i]of n.searchParams.entries())t.searchParams.has(o)||(s.addedParams[o]=i);return t.search!==n.search&&!Object.keys(s.changedParams).length&&!Object.keys(s.addedParams).length&&!Object.keys(s.removedParams).length&&(s.search=[t.search,n.search]),s}function Je(r){try{return new URL(r)}catch{return null}}function Vu(r){return Ve.from(r).addTrailingSlash().toString()}function Ju(r){return Ve.from(r).removeTrailingSlash().toString()}function Qu(r){try{return Ve.from(r).removeHash().toString()}catch{return r}}function Gu(r){try{let e=new URL(r);return e.search="",e.toString()}catch{return r}}function Xu(r){try{let t=new URL(r).pathname.split("/").pop()??"",n=t.lastIndexOf(".");return n===-1?"":t.slice(n+1).toLowerCase()}catch{return""}}function Yu(r){try{let e=new URL(r).pathname;return ce(e.split("/").filter(Boolean).pop()??"")}catch{return""}}function Zu(r,...e){try{return Ve.from(r).redactParams(...e).toString()}catch{return td(r,e)}}function td(r,e){if(e.length===0)return r;let t=r.indexOf("#"),n=t===-1?r:r.slice(0,t),s=t===-1?"":r.slice(t),o=n.indexOf("?");if(o===-1)return r;let i=n.slice(0,o),a=n.slice(o+1).split("&").map(c=>{let u=c.indexOf("="),l=u===-1?c:c.slice(0,u);return e.includes(l)||e.includes(ce(l))?`${l}=REDACTED`:c});return`${i}?${a.join("&")}${s}`}$e();U();function el(r={}){return new Gt(r)}var rd=el;return hl(nd);})();