@selfcommunity/api-services 0.7.0-mui7.31 → 0.7.0-mui7.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umd/194.js +1 -1
- package/lib/umd/194.js.LICENSE.txt +1 -1
- package/lib/umd/api-services.js +1 -1
- package/package.json +4 -4
package/lib/umd/194.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 194.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.webpackChunkSelfCommunityApiServices=self.webpackChunkSelfCommunityApiServices||[]).push([[194],{5478:(e,t,r)=>{r.r(t),r.d(t,{CompactEncrypt:()=>st,CompactSign:()=>dt,EmbeddedJWK:()=>gt,EncryptJWT:()=>ft,FlattenedEncrypt:()=>$e,FlattenedSign:()=>ct,GeneralEncrypt:()=>ze,GeneralSign:()=>lt,SignJWT:()=>ht,UnsecuredJWT:()=>Ct,base64url:()=>o,calculateJwkThumbprint:()=>wt,calculateJwkThumbprintUri:()=>mt,compactDecrypt:()=>De,compactVerify:()=>Qe,createLocalJWKSet:()=>vt,createRemoteJWKSet:()=>Pt,cryptoRuntime:()=>Ut,decodeJwt:()=>Tt,decodeProtectedHeader:()=>Ot,errors:()=>n,exportJWK:()=>Fe,exportPKCS8:()=>Me,exportSPKI:()=>Ne,flattenedDecrypt:()=>Je,flattenedVerify:()=>Ye,generalDecrypt:()=>je,generalVerify:()=>Ze,generateKeyPair:()=>Kt,generateSecret:()=>Wt,importJWK:()=>Te,importPKCS8:()=>Oe,importSPKI:()=>He,importX509:()=>Re,jwtDecrypt:()=>it,jwtVerify:()=>at});var n={};r.r(n),r.d(n,{JOSEAlgNotAllowed:()=>v,JOSEError:()=>b,JOSENotSupported:()=>_,JWEDecompressionFailed:()=>C,JWEDecryptionFailed:()=>P,JWEInvalid:()=>H,JWKInvalid:()=>T,JWKSInvalid:()=>k,JWKSMultipleMatchingKeys:()=>W,JWKSNoMatchingKey:()=>K,JWKSTimeout:()=>U,JWSInvalid:()=>R,JWSSignatureVerificationFailed:()=>x,JWTClaimValidationFailed:()=>S,JWTExpired:()=>A,JWTInvalid:()=>O});var o={};r.r(o),r.d(o,{decode:()=>Rt,encode:()=>Ht});const a=crypto,i=e=>e instanceof CryptoKey,s=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await a.subtle.digest(r,t))},c=new TextEncoder,d=new TextDecoder,u=2**32;function l(...e){const t=e.reduce((e,{length:t})=>e+t,0),r=new Uint8Array(t);let n=0;return e.forEach(e=>{r.set(e,n),n+=e.length}),r}function p(e,t,r){if(t<0||t>=u)throw new RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function h(e){const t=Math.floor(e/u),r=e%u,n=new Uint8Array(8);return p(n,t,0),p(n,r,4),n}function f(e){const t=new Uint8Array(4);return p(t,e),t}function y(e){return l(f(e.length),e)}const w=e=>{let t=e;"string"==typeof t&&(t=c.encode(t));const r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))},m=e=>w(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),g=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},E=e=>{let t=e;t instanceof Uint8Array&&(t=d.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return g(t)}catch(e){throw new TypeError("The input to be decoded is not correctly encoded.")}};class b extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(e){var t;super(e),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor)}}class S extends b{static get code(){return"ERR_JWT_CLAIM_VALIDATION_FAILED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=t,this.reason=r}}class A extends b{static get code(){return"ERR_JWT_EXPIRED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_EXPIRED",this.claim=t,this.reason=r}}class v extends b{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}static get code(){return"ERR_JOSE_ALG_NOT_ALLOWED"}}class _ extends b{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class P extends b{constructor(){super(...arguments),this.code="ERR_JWE_DECRYPTION_FAILED",this.message="decryption operation failed"}static get code(){return"ERR_JWE_DECRYPTION_FAILED"}}class C extends b{constructor(){super(...arguments),this.code="ERR_JWE_DECOMPRESSION_FAILED",this.message="decompression operation failed"}static get code(){return"ERR_JWE_DECOMPRESSION_FAILED"}}class H extends b{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}class R extends b{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}}class O extends b{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}}class T extends b{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}static get code(){return"ERR_JWK_INVALID"}}class k extends b{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}static get code(){return"ERR_JWKS_INVALID"}}class K extends b{constructor(){super(...arguments),this.code="ERR_JWKS_NO_MATCHING_KEY",this.message="no applicable key found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_NO_MATCHING_KEY"}}class W extends b{constructor(){super(...arguments),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS",this.message="multiple matching keys found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Symbol.asyncIterator;class U extends b{constructor(){super(...arguments),this.code="ERR_JWKS_TIMEOUT",this.message="request timed out"}static get code(){return"ERR_JWKS_TIMEOUT"}}class x extends b{constructor(){super(...arguments),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED",this.message="signature verification failed"}static get code(){return"ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}const J=a.getRandomValues.bind(a);function D(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new _(`Unsupported JWE Algorithm: ${e}`)}}const j=e=>J(new Uint8Array(D(e)>>3)),I=(e,t)=>{if(t.length<<3!==D(e))throw new H("Invalid Initialization Vector length")},N=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new H(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function M(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function F(e,t){return e.name===t}function B(e){return parseInt(e.name.slice(4),10)}function L(e,t){if(t.length&&!t.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const r=t.pop();e+=`one of ${t.join(", ")}, or ${r}.`}else 2===t.length?e+=`one of ${t[0]} or ${t[1]}.`:e+=`${t[0]}.`;throw new TypeError(e)}}function $(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!F(e.algorithm,"AES-GCM"))throw M("AES-GCM");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw M(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!F(e.algorithm,"AES-KW"))throw M("AES-KW");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw M(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw M("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!F(e.algorithm,"PBKDF2"))throw M("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!F(e.algorithm,"RSA-OAEP"))throw M("RSA-OAEP");const r=parseInt(t.slice(9),10)||1;if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}L(e,r)}function G(e,t,...r){if(r.length>2){const t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const z=(e,...t)=>G("Key must be ",e,...t);function V(e,t,...r){return G(`Key for the ${e} algorithm must be `,t,...r)}const q=e=>i(e),X=["CryptoKey"],Y=async(e,t,r,n,o,s)=>{if(!(i(t)||t instanceof Uint8Array))throw new TypeError(z(t,...X,"Uint8Array"));switch(I(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&N(t,parseInt(e.slice(-3),10)),async function(e,t,r,n,o,i){if(!(t instanceof Uint8Array))throw new TypeError(z(t,"Uint8Array"));const s=parseInt(e.slice(1,4),10),c=await a.subtle.importKey("raw",t.subarray(s>>3),"AES-CBC",!1,["decrypt"]),d=await a.subtle.importKey("raw",t.subarray(0,s>>3),{hash:"SHA-"+(s<<1),name:"HMAC"},!1,["sign"]),u=l(i,n,r,h(i.length<<3)),p=new Uint8Array((await a.subtle.sign("HMAC",d,u)).slice(0,s>>3));let f,y;try{f=((e,t)=>{if(!(e instanceof Uint8Array))throw new TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw new TypeError("Second argument must be a buffer");if(e.length!==t.length)throw new TypeError("Input buffers must have the same length");const r=e.length;let n=0,o=-1;for(;++o<r;)n|=e[o]^t[o];return 0===n})(o,p)}catch(e){}if(!f)throw new P;try{y=new Uint8Array(await a.subtle.decrypt({iv:n,name:"AES-CBC"},c,r))}catch(e){}if(!y)throw new P;return y}(e,t,r,n,o,s);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&N(t,parseInt(e.slice(1,4),10)),async function(e,t,r,n,o,i){let s;t instanceof Uint8Array?s=await a.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):($(t,e,"decrypt"),s=t);try{return new Uint8Array(await a.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},s,l(r,o)))}catch(e){throw new P}}(e,t,r,n,o,s);default:throw new _("Unsupported JWE Content Encryption Algorithm")}},Q=async()=>{throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `inflateRaw` decrypt option to provide Inflate Raw implementation.')},Z=async()=>{throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `deflateRaw` encrypt option to provide Deflate Raw implementation.')},ee=(...e)=>{const t=e.filter(Boolean);if(0===t.length||1===t.length)return!0;let r;for(const e of t){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return!1;r.add(e)}else r=new Set(t)}return!0};function te(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let r=e;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}const re=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function ne(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function oe(e,t,r){if(i(e))return $(e,t,r),e;if(e instanceof Uint8Array)return a.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(z(e,...X,"Uint8Array"))}const ae=async(e,t,r)=>{const n=await oe(t,e,"wrapKey");ne(n,e);const o=await a.subtle.importKey("raw",r,...re);return new Uint8Array(await a.subtle.wrapKey("raw",o,n,"AES-KW"))},ie=async(e,t,r)=>{const n=await oe(t,e,"unwrapKey");ne(n,e);const o=await a.subtle.unwrapKey("raw",r,n,"AES-KW",...re);return new Uint8Array(await a.subtle.exportKey("raw",o))};async function se(e,t,r,n,o=new Uint8Array(0),d=new Uint8Array(0)){if(!i(e))throw new TypeError(z(e,...X));if($(e,"ECDH"),!i(t))throw new TypeError(z(t,...X));$(t,"ECDH","deriveBits");const u=l(y(c.encode(r)),y(o),y(d),f(n));let p;return p="X25519"===e.algorithm.name?256:"X448"===e.algorithm.name?448:Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3,async function(e,t,r){const n=Math.ceil((t>>3)/32),o=new Uint8Array(32*n);for(let t=0;t<n;t++){const n=new Uint8Array(4+e.length+r.length);n.set(f(t+1)),n.set(e,4),n.set(r,4+e.length),o.set(await s("sha256",n),32*t)}return o.slice(0,t>>3)}(new Uint8Array(await a.subtle.deriveBits({name:e.algorithm.name,public:e},t,p)),n,u)}function ce(e){if(!i(e))throw new TypeError(z(e,...X));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||"X25519"===e.algorithm.name||"X448"===e.algorithm.name}async function de(e,t,r,n){!function(e){if(!(e instanceof Uint8Array)||e.length<8)throw new H("PBES2 Salt Input must be 8 or more octets")}(e);const o=function(e,t){return l(c.encode(e),new Uint8Array([0]),t)}(t,e),s=parseInt(t.slice(13,16),10),d={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:o},u={length:s,name:"AES-KW"},p=await function(e,t){if(e instanceof Uint8Array)return a.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(i(e))return $(e,t,"deriveBits","deriveKey"),e;throw new TypeError(z(e,...X,"Uint8Array"))}(n,t);if(p.usages.includes("deriveBits"))return new Uint8Array(await a.subtle.deriveBits(d,p,s));if(p.usages.includes("deriveKey"))return a.subtle.deriveKey(d,p,u,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}function ue(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const le=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};function pe(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new _(`Unsupported JWE Algorithm: ${e}`)}}const he=e=>J(new Uint8Array(pe(e)>>3)),fe=(e,t)=>`-----BEGIN ${t}-----\n${(e.match(/.{1,64}/g)||[]).join("\n")}\n-----END ${t}-----`,ye=async(e,t,r)=>{if(!i(r))throw new TypeError(z(r,...X));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==e)throw new TypeError(`key is not a ${e} key`);return fe(w(new Uint8Array(await a.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},we=e=>ye("public","spki",e),me=e=>ye("private","pkcs8",e),ge=(e,t,r=0)=>{0===r&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(-1===n)return!1;const o=e.subarray(n,n+t.length);return o.length===t.length&&(o.every((e,r)=>e===t[r])||ge(e,t,n+1))},Ee=e=>{switch(!0){case ge(e,[42,134,72,206,61,3,1,7]):return"P-256";case ge(e,[43,129,4,0,34]):return"P-384";case ge(e,[43,129,4,0,35]):return"P-521";case ge(e,[43,101,110]):return"X25519";case ge(e,[43,101,111]):return"X448";case ge(e,[43,101,112]):return"Ed25519";case ge(e,[43,101,113]):return"Ed448";default:throw new _("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},be=async(e,t,r,n,o)=>{var i;let s,c;const d=new Uint8Array(atob(r.replace(e,"")).split("").map(e=>e.charCodeAt(0))),u="spki"===t;switch(n){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},c=u?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},c=u?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},c=u?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},c=u?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},c=u?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},c=u?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const e=Ee(d);s=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},c=u?[]:["deriveBits"];break}case"EdDSA":s={name:Ee(d)},c=u?["verify"]:["sign"];break;default:throw new _('Invalid or unsupported "alg" (Algorithm) value')}return a.subtle.importKey(t,d,s,null!==(i=null==o?void 0:o.extractable)&&void 0!==i&&i,c)},Se=(e,t,r)=>be(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r),Ae=(e,t,r)=>be(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r);function ve(e){let t=[],r=0;for(;r<e.length;){let n=_e(e.subarray(r));t.push(n),r+=n.byteLength}return t}function _e(e){let t=0,r=31&e[0];if(t++,31===r){for(r=0;e[t]>=128;)r=128*r+e[t]-128,t++;r=128*r+e[t]-128,t++}let n=0;if(e[t]<128)n=e[t],t++;else{if(128===n){for(n=0;0!==e[t+n]||0!==e[t+n+1];){if(n>e.byteLength)throw new TypeError("invalid indefinite form length");n++}const r=t+n+2;return{byteLength:r,contents:e.subarray(t,t+n),raw:e.subarray(0,r)}}{let r=127&e[t];t++,n=0;for(let o=0;o<r;o++)n=256*n+e[t],t++}}const o=t+n;return{byteLength:o,contents:e.subarray(t,o),raw:e.subarray(0,o)}}const Pe=(e,t,r)=>{let n;try{n=function(e){const t=e.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g,""),r=g(t);return fe(function(e){const t=ve(ve(_e(e).contents)[0].contents);return w(t[160===t[0].raw[0]?6:5].raw)}(r),"PUBLIC KEY")}(e)}catch(e){throw new TypeError("Failed to parse the X.509 certificate",{cause:e})}return Ae(n,t,r)},Ce=async e=>{var t,r;if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:n,keyUsages:o}=function(e){let t,r;switch(e.kty){case"oct":switch(e.alg){case"HS256":case"HS384":case"HS512":t={name:"HMAC",hash:`SHA-${e.alg.slice(-3)}`},r=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":throw new _(`${e.alg} keys cannot be imported as CryptoKey instances`);case"A128GCM":case"A192GCM":case"A256GCM":case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":t={name:"AES-GCM"},r=["encrypt","decrypt"];break;case"A128KW":case"A192KW":case"A256KW":t={name:"AES-KW"},r=["wrapKey","unwrapKey"];break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":t={name:"PBKDF2"},r=["deriveBits"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new _('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),i=[n,null!==(t=e.ext)&&void 0!==t&&t,null!==(r=e.key_ops)&&void 0!==r?r:o];if("PBKDF2"===n.name)return a.subtle.importKey("raw",E(e.k),...i);const s={...e};return delete s.alg,delete s.use,a.subtle.importKey("jwk",s,...i)};async function He(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw new TypeError('"spki" must be SPKI formatted string');return Ae(e,t,r)}async function Re(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw new TypeError('"x509" must be X.509 formatted string');return Pe(e,t,r)}async function Oe(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return Se(e,t,r)}async function Te(e,t,r){var n;if(!te(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return null!=r||(r=!0!==e.ext),r?Ce({...e,alg:t,ext:null!==(n=e.ext)&&void 0!==n&&n}):E(e.k);case"RSA":if(void 0!==e.oth)throw new _('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Ce({...e,alg:t});default:throw new _('Unsupported "kty" (Key Type) Parameter value')}}const ke=(e,t,r)=>{e.startsWith("HS")||"dir"===e||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?((e,t)=>{if(!(t instanceof Uint8Array)){if(!q(t))throw new TypeError(V(e,t,...X,"Uint8Array"));if("secret"!==t.type)throw new TypeError(`${X.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}})(e,t):((e,t,r)=>{if(!q(t))throw new TypeError(V(e,t,...X));if("secret"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)})(e,t,r)},Ke=async(e,t,r,n,o)=>{if(!(i(r)||r instanceof Uint8Array))throw new TypeError(z(r,...X,"Uint8Array"));switch(I(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&N(r,parseInt(e.slice(-3),10)),async function(e,t,r,n,o){if(!(r instanceof Uint8Array))throw new TypeError(z(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),s=await a.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),c=await a.subtle.importKey("raw",r.subarray(0,i>>3),{hash:"SHA-"+(i<<1),name:"HMAC"},!1,["sign"]),d=new Uint8Array(await a.subtle.encrypt({iv:n,name:"AES-CBC"},s,t)),u=l(o,n,d,h(o.length<<3));return{ciphertext:d,tag:new Uint8Array((await a.subtle.sign("HMAC",c,u)).slice(0,i>>3))}}(e,t,r,n,o);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&N(r,parseInt(e.slice(1,4),10)),async function(e,t,r,n,o){let i;r instanceof Uint8Array?i=await a.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):($(r,e,"encrypt"),i=r);const s=new Uint8Array(await a.subtle.encrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},i,t)),c=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:c}}(e,t,r,n,o);default:throw new _("Unsupported JWE Content Encryption Algorithm")}},We=async function(e,t,r,n,o){switch(ke(e,t,"decrypt"),e){case"dir":if(void 0!==r)throw new H("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new H("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!te(n.epk))throw new H('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!ce(t))throw new _("ECDH with the provided key is not allowed or not supported by your javascript runtime");const o=await Te(n.epk,e);let a,i;if(void 0!==n.apu){if("string"!=typeof n.apu)throw new H('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{a=E(n.apu)}catch(e){throw new H("Failed to base64url decode the apu")}}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new H('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{i=E(n.apv)}catch(e){throw new H("Failed to base64url decode the apv")}}const s=await se(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?pe(n.enc):parseInt(e.slice(-5,-2),10),a,i);if("ECDH-ES"===e)return s;if(void 0===r)throw new H("JWE Encrypted Key missing");return ie(e.slice(-6),s,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if(void 0===r)throw new H("JWE Encrypted Key missing");return(async(e,t,r)=>{if(!i(t))throw new TypeError(z(t,...X));if($(t,e,"decrypt","unwrapKey"),le(e,t),t.usages.includes("decrypt"))return new Uint8Array(await a.subtle.decrypt(ue(e),t,r));if(t.usages.includes("unwrapKey")){const n=await a.subtle.unwrapKey("raw",r,t,ue(e),...re);return new Uint8Array(await a.subtle.exportKey("raw",n))}throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')})(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(void 0===r)throw new H("JWE Encrypted Key missing");if("number"!=typeof n.p2c)throw new H('JOSE Header "p2c" (PBES2 Count) missing or invalid');const a=(null==o?void 0:o.maxPBES2Count)||1e4;if(n.p2c>a)throw new H('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new H('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let i;try{i=E(n.p2s)}catch(e){throw new H("Failed to base64url decode the p2s")}return(async(e,t,r,n,o)=>{const a=await de(o,e,n,t);return ie(e.slice(-6),a,r)})(e,t,r,n.p2c,i)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new H("JWE Encrypted Key missing");return ie(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(void 0===r)throw new H("JWE Encrypted Key missing");if("string"!=typeof n.iv)throw new H('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new H('JOSE Header "tag" (Authentication Tag) missing or invalid');let o,a;try{o=E(n.iv)}catch(e){throw new H("Failed to base64url decode the iv")}try{a=E(n.tag)}catch(e){throw new H("Failed to base64url decode the tag")}return async function(e,t,r,n,o){const a=e.slice(0,7);return Y(a,t,r,n,o,new Uint8Array(0))}(e,t,r,o,a)}default:throw new _('Invalid or unsupported "alg" (JWE Algorithm) header value')}},Ue=function(e,t,r,n,o){if(void 0!==o.crit&&void 0===n.crit)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||void 0===n.crit)return new Set;if(!Array.isArray(n.crit)||0===n.crit.length||n.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t;for(const t of n.crit){if(!a.has(t))throw new _(`Extension Header Parameter "${t}" is not recognized`);if(void 0===o[t])throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&void 0===n[t])throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(n.crit)},xe=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};async function Je(e,t,r){var n;if(!te(e))throw new H("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new H("JOSE Header missing");if("string"!=typeof e.iv)throw new H("JWE Initialization Vector missing or incorrect type");if("string"!=typeof e.ciphertext)throw new H("JWE Ciphertext missing or incorrect type");if("string"!=typeof e.tag)throw new H("JWE Authentication Tag missing or incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new H("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new H("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new H("JWE AAD incorrect type");if(void 0!==e.header&&!te(e.header))throw new H("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!te(e.unprotected))throw new H("JWE Per-Recipient Unprotected Header incorrect type");let o;if(e.protected)try{const t=E(e.protected);o=JSON.parse(d.decode(t))}catch(e){throw new H("JWE Protected Header is invalid")}if(!ee(o,e.header,e.unprotected))throw new H("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");const a={...o,...e.header,...e.unprotected};if(Ue(H,new Map,null==r?void 0:r.crit,o,a),void 0!==a.zip){if(!o||!o.zip)throw new H('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');if("DEF"!==a.zip)throw new _('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value')}const{alg:i,enc:s}=a;if("string"!=typeof i||!i)throw new H("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof s||!s)throw new H("missing JWE Encryption Algorithm (enc) in JWE Header");const u=r&&xe("keyManagementAlgorithms",r.keyManagementAlgorithms),p=r&&xe("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(u&&!u.has(i))throw new v('"alg" (Algorithm) Header Parameter not allowed');if(p&&!p.has(s))throw new v('"enc" (Encryption Algorithm) Header Parameter not allowed');let h;if(void 0!==e.encrypted_key)try{h=E(e.encrypted_key)}catch(e){throw new H("Failed to base64url decode the encrypted_key")}let f,y,w,m=!1;"function"==typeof t&&(t=await t(o,e),m=!0);try{f=await We(i,t,h,a,r)}catch(e){if(e instanceof TypeError||e instanceof H||e instanceof _)throw e;f=he(s)}try{y=E(e.iv)}catch(e){throw new H("Failed to base64url decode the iv")}try{w=E(e.tag)}catch(e){throw new H("Failed to base64url decode the tag")}const g=c.encode(null!==(n=e.protected)&&void 0!==n?n:"");let b,S;b=void 0!==e.aad?l(g,c.encode("."),c.encode(e.aad)):g;try{S=E(e.ciphertext)}catch(e){throw new H("Failed to base64url decode the ciphertext")}let A=await Y(s,f,S,y,w,b);"DEF"===a.zip&&(A=await((null==r?void 0:r.inflateRaw)||Q)(A));const P={plaintext:A};if(void 0!==e.protected&&(P.protectedHeader=o),void 0!==e.aad)try{P.additionalAuthenticatedData=E(e.aad)}catch(e){throw new H("Failed to base64url decode the aad")}return void 0!==e.unprotected&&(P.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(P.unprotectedHeader=e.header),m?{...P,key:t}:P}async function De(e,t,r){if(e instanceof Uint8Array&&(e=d.decode(e)),"string"!=typeof e)throw new H("Compact JWE must be a string or Uint8Array");const{0:n,1:o,2:a,3:i,4:s,length:c}=e.split(".");if(5!==c)throw new H("Invalid Compact JWE");const u=await Je({ciphertext:i,iv:a||void 0,protected:n||void 0,tag:s||void 0,encrypted_key:o||void 0},t,r),l={plaintext:u.plaintext,protectedHeader:u.protectedHeader};return"function"==typeof t?{...l,key:u.key}:l}async function je(e,t,r){if(!te(e))throw new H("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(te))throw new H("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new H("JWE Recipients has no members");for(const n of e.recipients)try{return await Je({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch(e){}throw new P}const Ie=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:m(e)};if(!i(e))throw new TypeError(z(e,...X,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:o,...s}=await a.subtle.exportKey("jwk",e);return s};async function Ne(e){return we(e)}async function Me(e){return me(e)}async function Fe(e){return Ie(e)}const Be=async function(e,t,r,n,o={}){let s,c,d;switch(ke(e,r,"encrypt"),e){case"dir":d=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!ce(r))throw new _("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:l}=o;let{epk:p}=o;p||(p=(await async function(e){if(!i(e))throw new TypeError(z(e,...X));return a.subtle.generateKey(e.algorithm,!0,["deriveBits"])}(r)).privateKey);const{x:h,y:f,crv:y,kty:w}=await Fe(p),g=await se(r,p,"ECDH-ES"===e?t:e,"ECDH-ES"===e?pe(t):parseInt(e.slice(-5,-2),10),u,l);if(c={epk:{x:h,crv:y,kty:w}},"EC"===w&&(c.epk.y=f),u&&(c.apu=m(u)),l&&(c.apv=m(l)),"ECDH-ES"===e){d=g;break}d=n||he(t);const E=e.slice(-6);s=await ae(E,g,d);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":d=n||he(t),s=await(async(e,t,r)=>{if(!i(t))throw new TypeError(z(t,...X));if($(t,e,"encrypt","wrapKey"),le(e,t),t.usages.includes("encrypt"))return new Uint8Array(await a.subtle.encrypt(ue(e),t,r));if(t.usages.includes("wrapKey")){const n=await a.subtle.importKey("raw",r,...re);return new Uint8Array(await a.subtle.wrapKey("raw",n,t,ue(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')})(e,r,d);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{d=n||he(t);const{p2c:a,p2s:i}=o;({encryptedKey:s,...c}=await(async(e,t,r,n=2048,o=J(new Uint8Array(16)))=>{const a=await de(o,e,n,t);return{encryptedKey:await ae(e.slice(-6),a,r),p2c:n,p2s:m(o)}})(e,r,d,a,i));break}case"A128KW":case"A192KW":case"A256KW":d=n||he(t),s=await ae(e,r,d);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{d=n||he(t);const{iv:a}=o;({encryptedKey:s,...c}=await async function(e,t,r,n){const o=e.slice(0,7);n||(n=j(o));const{ciphertext:a,tag:i}=await Ke(o,r,t,n,new Uint8Array(0));return{encryptedKey:a,iv:m(n),tag:m(i)}}(e,r,d,a));break}default:throw new _('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:d,encryptedKey:s,parameters:c}},Le=Symbol();class $e{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,t){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new H("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!ee(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new H("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(Ue(H,new Map,null==t?void 0:t.crit,this._protectedHeader,r),void 0!==r.zip){if(!this._protectedHeader||!this._protectedHeader.zip)throw new H('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');if("DEF"!==r.zip)throw new _('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value')}const{alg:n,enc:o}=r;if("string"!=typeof n||!n)throw new H('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof o||!o)throw new H('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a,i,s,u,p,h,f;if("dir"===n){if(this._cek)throw new TypeError("setContentEncryptionKey cannot be called when using Direct Encryption")}else if("ECDH-ES"===n&&this._cek)throw new TypeError("setContentEncryptionKey cannot be called when using Direct Key Agreement");{let r;({cek:i,encryptedKey:a,parameters:r}=await Be(n,o,e,this._cek,this._keyManagementParameters)),r&&(t&&Le in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...r}:this.setUnprotectedHeader(r):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...r}:this.setProtectedHeader(r))}if(this._iv||(this._iv=j(o)),u=this._protectedHeader?c.encode(m(JSON.stringify(this._protectedHeader))):c.encode(""),this._aad?(p=m(this._aad),s=l(u,c.encode("."),c.encode(p))):s=u,"DEF"===r.zip){const e=await((null==t?void 0:t.deflateRaw)||Z)(this._plaintext);({ciphertext:h,tag:f}=await Ke(o,e,i,this._iv,s))}else({ciphertext:h,tag:f}=await Ke(o,this._plaintext,i,this._iv,s));const y={ciphertext:m(h),iv:m(this._iv),tag:m(f)};return a&&(y.encrypted_key=m(a)),p&&(y.aad=p),this._protectedHeader&&(y.protected=d.decode(u)),this._sharedUnprotectedHeader&&(y.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(y.header=this._unprotectedHeader),y}}class Ge{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addRecipient(...e){return this.parent.addRecipient(...e)}encrypt(...e){return this.parent.encrypt(...e)}done(){return this.parent}}class ze{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,t){const r=new Ge(this,e,{crit:null==t?void 0:t.crit});return this._recipients.push(r),r}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(e){var t,r,n;if(!this._recipients.length)throw new H("at least one recipient must be added");if(e={deflateRaw:null==e?void 0:e.deflateRaw},1===this._recipients.length){const[t]=this._recipients,r=await new $e(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(t.unprotectedHeader).encrypt(t.key,{...t.options,...e});let n={ciphertext:r.ciphertext,iv:r.iv,recipients:[{}],tag:r.tag};return r.aad&&(n.aad=r.aad),r.protected&&(n.protected=r.protected),r.unprotected&&(n.unprotected=r.unprotected),r.encrypted_key&&(n.recipients[0].encrypted_key=r.encrypted_key),r.header&&(n.recipients[0].header=r.header),n}let o;for(let e=0;e<this._recipients.length;e++){const t=this._recipients[e];if(!ee(this._protectedHeader,this._unprotectedHeader,t.unprotectedHeader))throw new H("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...t.unprotectedHeader},{alg:n}=r;if("string"!=typeof n||!n)throw new H('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===n||"ECDH-ES"===n)throw new H('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof r.enc||!r.enc)throw new H('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(o){if(o!==r.enc)throw new H('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else o=r.enc;if(Ue(H,new Map,t.options.crit,this._protectedHeader,r),!(void 0===r.zip||this._protectedHeader&&this._protectedHeader.zip))throw new H('JWE "zip" (Compression Algorithm) Header MUST be integrity protected')}const a=he(o);let i={ciphertext:"",iv:"",recipients:[],tag:""};for(let s=0;s<this._recipients.length;s++){const c=this._recipients[s],d={};i.recipients.push(d);const u={...this._protectedHeader,...this._unprotectedHeader,...c.unprotectedHeader}.alg.startsWith("PBES2")?2048+s:void 0;if(0===s){const t=await new $e(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(a).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(c.unprotectedHeader).setKeyManagementParameters({p2c:u}).encrypt(c.key,{...c.options,...e,[Le]:!0});i.ciphertext=t.ciphertext,i.iv=t.iv,i.tag=t.tag,t.aad&&(i.aad=t.aad),t.protected&&(i.protected=t.protected),t.unprotected&&(i.unprotected=t.unprotected),d.encrypted_key=t.encrypted_key,t.header&&(d.header=t.header);continue}const{encryptedKey:l,parameters:p}=await Be((null===(t=c.unprotectedHeader)||void 0===t?void 0:t.alg)||(null===(r=this._protectedHeader)||void 0===r?void 0:r.alg)||(null===(n=this._unprotectedHeader)||void 0===n?void 0:n.alg),o,c.key,a,{p2c:u});d.encrypted_key=m(l),(c.unprotectedHeader||p)&&(d.header={...c.unprotectedHeader,...p})}return i}}function Ve(e,t){const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function qe(e,t,r){if(i(t))return function(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!F(e.algorithm,"HMAC"))throw M("HMAC");const r=parseInt(t.slice(2),10);if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!F(e.algorithm,"RSASSA-PKCS1-v1_5"))throw M("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!F(e.algorithm,"RSA-PSS"))throw M("RSA-PSS");const r=parseInt(t.slice(2),10);if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw M("Ed25519 or Ed448");break;case"ES256":case"ES384":case"ES512":{if(!F(e.algorithm,"ECDSA"))throw M("ECDSA");const r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw M(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}L(e,r)}(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(z(t,...X));return a.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(z(t,...X,"Uint8Array"))}const Xe=async(e,t,r,n)=>{const o=await qe(e,t,"verify");le(e,o);const i=Ve(e,o.algorithm);try{return await a.subtle.verify(i,o,r,n)}catch(e){return!1}};async function Ye(e,t,r){var n;if(!te(e))throw new R("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new R('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new R("JWS Protected Header incorrect type");if(void 0===e.payload)throw new R("JWS Payload missing");if("string"!=typeof e.signature)throw new R("JWS Signature missing or incorrect type");if(void 0!==e.header&&!te(e.header))throw new R("JWS Unprotected Header incorrect type");let o={};if(e.protected)try{const t=E(e.protected);o=JSON.parse(d.decode(t))}catch(e){throw new R("JWS Protected Header is invalid")}if(!ee(o,e.header))throw new R("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const a={...o,...e.header};let i=!0;if(Ue(R,new Map([["b64",!0]]),null==r?void 0:r.crit,o,a).has("b64")&&(i=o.b64,"boolean"!=typeof i))throw new R('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:s}=a;if("string"!=typeof s||!s)throw new R('JWS "alg" (Algorithm) Header Parameter missing or invalid');const u=r&&xe("algorithms",r.algorithms);if(u&&!u.has(s))throw new v('"alg" (Algorithm) Header Parameter not allowed');if(i){if("string"!=typeof e.payload)throw new R("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new R("JWS Payload must be a string or an Uint8Array instance");let p=!1;"function"==typeof t&&(t=await t(o,e),p=!0),ke(s,t,"verify");const h=l(c.encode(null!==(n=e.protected)&&void 0!==n?n:""),c.encode("."),"string"==typeof e.payload?c.encode(e.payload):e.payload);let f,y;try{f=E(e.signature)}catch(e){throw new R("Failed to base64url decode the signature")}if(!await Xe(s,t,f,h))throw new x;if(i)try{y=E(e.payload)}catch(e){throw new R("Failed to base64url decode the payload")}else y="string"==typeof e.payload?c.encode(e.payload):e.payload;const w={payload:y};return void 0!==e.protected&&(w.protectedHeader=o),void 0!==e.header&&(w.unprotectedHeader=e.header),p?{...w,key:t}:w}async function Qe(e,t,r){if(e instanceof Uint8Array&&(e=d.decode(e)),"string"!=typeof e)throw new R("Compact JWS must be a string or Uint8Array");const{0:n,1:o,2:a,length:i}=e.split(".");if(3!==i)throw new R("Invalid Compact JWS");const s=await Ye({payload:o,protected:n,signature:a},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...c,key:s.key}:c}async function Ze(e,t,r){if(!te(e))throw new R("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(te))throw new R("JWS Signatures missing or incorrect type");for(const n of e.signatures)try{return await Ye({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch(e){}throw new x}const et=e=>Math.floor(e.getTime()/1e3),tt=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,rt=e=>{const t=tt.exec(e);if(!t)throw new TypeError("Invalid time period format");const r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(60*r);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(3600*r);case"day":case"days":case"d":return Math.round(86400*r);case"week":case"weeks":case"w":return Math.round(604800*r);default:return Math.round(31557600*r)}},nt=e=>e.toLowerCase().replace(/^application\//,""),ot=(e,t,r={})=>{const{typ:n}=r;if(n&&("string"!=typeof e.typ||nt(e.typ)!==nt(n)))throw new S('unexpected "typ" JWT header value',"typ","check_failed");let o;try{o=JSON.parse(d.decode(t))}catch(e){}if(!te(o))throw new O("JWT Claims Set must be a top-level JSON object");const{requiredClaims:a=[],issuer:i,subject:s,audience:c,maxTokenAge:u}=r;void 0!==u&&a.push("iat"),void 0!==c&&a.push("aud"),void 0!==s&&a.push("sub"),void 0!==i&&a.push("iss");for(const e of new Set(a.reverse()))if(!(e in o))throw new S(`missing required "${e}" claim`,e,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(o.iss))throw new S('unexpected "iss" claim value',"iss","check_failed");if(s&&o.sub!==s)throw new S('unexpected "sub" claim value',"sub","check_failed");if(c&&(p="string"==typeof c?[c]:c,!("string"==typeof(l=o.aud)?p.includes(l):Array.isArray(l)&&p.some(Set.prototype.has.bind(new Set(l))))))throw new S('unexpected "aud" claim value',"aud","check_failed");var l,p;let h;switch(typeof r.clockTolerance){case"string":h=rt(r.clockTolerance);break;case"number":h=r.clockTolerance;break;case"undefined":h=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:f}=r,y=et(f||new Date);if((void 0!==o.iat||u)&&"number"!=typeof o.iat)throw new S('"iat" claim must be a number',"iat","invalid");if(void 0!==o.nbf){if("number"!=typeof o.nbf)throw new S('"nbf" claim must be a number',"nbf","invalid");if(o.nbf>y+h)throw new S('"nbf" claim timestamp check failed',"nbf","check_failed")}if(void 0!==o.exp){if("number"!=typeof o.exp)throw new S('"exp" claim must be a number',"exp","invalid");if(o.exp<=y-h)throw new A('"exp" claim timestamp check failed',"exp","check_failed")}if(u){const e=y-o.iat;if(e-h>("number"==typeof u?u:rt(u)))throw new A('"iat" claim timestamp check failed (too far in the past)',"iat","check_failed");if(e<0-h)throw new S('"iat" claim timestamp check failed (it should be in the past)',"iat","check_failed")}return o};async function at(e,t,r){var n;const o=await Qe(e,t,r);if((null===(n=o.protectedHeader.crit)||void 0===n?void 0:n.includes("b64"))&&!1===o.protectedHeader.b64)throw new O("JWTs MUST NOT use unencoded payload");const a={payload:ot(o.protectedHeader,o.payload,r),protectedHeader:o.protectedHeader};return"function"==typeof t?{...a,key:o.key}:a}async function it(e,t,r){const n=await De(e,t,r),o=ot(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(void 0!==a.iss&&a.iss!==o.iss)throw new S('replicated "iss" claim header parameter mismatch',"iss","mismatch");if(void 0!==a.sub&&a.sub!==o.sub)throw new S('replicated "sub" claim header parameter mismatch',"sub","mismatch");if(void 0!==a.aud&&JSON.stringify(a.aud)!==JSON.stringify(o.aud))throw new S('replicated "aud" claim header parameter mismatch',"aud","mismatch");const i={payload:o,protectedHeader:a};return"function"==typeof t?{...i,key:n.key}:i}class st{constructor(e){this._flattened=new $e(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,t){const r=await this._flattened.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}class ct{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader)throw new R("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ee(this._protectedHeader,this._unprotectedHeader))throw new R("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader};let n=!0;if(Ue(R,new Map([["b64",!0]]),null==t?void 0:t.crit,this._protectedHeader,r).has("b64")&&(n=this._protectedHeader.b64,"boolean"!=typeof n))throw new R('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:o}=r;if("string"!=typeof o||!o)throw new R('JWS "alg" (Algorithm) Header Parameter missing or invalid');ke(o,e,"sign");let i,s=this._payload;n&&(s=c.encode(m(s))),i=this._protectedHeader?c.encode(m(JSON.stringify(this._protectedHeader))):c.encode("");const u=l(i,c.encode("."),s),p=await(async(e,t,r)=>{const n=await qe(e,t,"sign");le(e,n);const o=await a.subtle.sign(Ve(e,n.algorithm),n,r);return new Uint8Array(o)})(o,e,u),h={signature:m(p),payload:""};return n&&(h.payload=d.decode(s)),this._unprotectedHeader&&(h.header=this._unprotectedHeader),this._protectedHeader&&(h.protected=d.decode(i)),h}}class dt{constructor(e){this._flattened=new ct(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){const r=await this._flattened.sign(e,t);if(void 0===r.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class ut{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setProtectedHeader(e){if(this.protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addSignature(...e){return this.parent.addSignature(...e)}sign(...e){return this.parent.sign(...e)}done(){return this.parent}}class lt{constructor(e){this._signatures=[],this._payload=e}addSignature(e,t){const r=new ut(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new R("at least one signature must be added");const e={signatures:[],payload:""};for(let t=0;t<this._signatures.length;t++){const r=this._signatures[t],n=new ct(this._payload);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);const{payload:o,...a}=await n.sign(r.key,r.options);if(0===t)e.payload=o;else if(e.payload!==o)throw new R("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(a)}return e}}class pt{constructor(e){if(!te(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return this._payload="number"==typeof e?{...this._payload,nbf:e}:{...this._payload,nbf:et(new Date)+rt(e)},this}setExpirationTime(e){return this._payload="number"==typeof e?{...this._payload,exp:e}:{...this._payload,exp:et(new Date)+rt(e)},this}setIssuedAt(e){return this._payload=void 0===e?{...this._payload,iat:et(new Date)}:{...this._payload,iat:e},this}}class ht extends pt{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){var r;const n=new dt(c.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(null===(r=this._protectedHeader)||void 0===r?void 0:r.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new O("JWTs MUST NOT use unencoded payload");return n.sign(e,t)}}class ft extends pt{setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}replicateIssuerAsHeader(){return this._replicateIssuerAsHeader=!0,this}replicateSubjectAsHeader(){return this._replicateSubjectAsHeader=!0,this}replicateAudienceAsHeader(){return this._replicateAudienceAsHeader=!0,this}async encrypt(e,t){const r=new st(c.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),r.setProtectedHeader(this._protectedHeader),this._iv&&r.setInitializationVector(this._iv),this._cek&&r.setContentEncryptionKey(this._cek),this._keyManagementParameters&&r.setKeyManagementParameters(this._keyManagementParameters),r.encrypt(e,t)}}const yt=(e,t)=>{if("string"!=typeof e||!e)throw new T(`${t} missing or invalid`)};async function wt(e,t){if(!te(e))throw new TypeError("JWK must be an object");if(null!=t||(t="sha256"),"sha256"!==t&&"sha384"!==t&&"sha512"!==t)throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let r;switch(e.kty){case"EC":yt(e.crv,'"crv" (Curve) Parameter'),yt(e.x,'"x" (X Coordinate) Parameter'),yt(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":yt(e.crv,'"crv" (Subtype of Key Pair) Parameter'),yt(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":yt(e.e,'"e" (Exponent) Parameter'),yt(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":yt(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new _('"kty" (Key Type) Parameter missing or unsupported')}const n=c.encode(JSON.stringify(r));return m(await s(t,n))}async function mt(e,t){null!=t||(t="sha256");const r=await wt(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function gt(e,t){const r={...e,...null==t?void 0:t.header};if(!te(r.jwk))throw new R('"jwk" (JSON Web Key) Header Parameter must be a JSON object');const n=await Te({...r.jwk,ext:!0},r.alg,!0);if(n instanceof Uint8Array||"public"!==n.type)throw new R('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function Et(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(bt)}function bt(e){return te(e)}class St{constructor(e){if(this._cached=new WeakMap,!Et(e))throw new k("JSON Web Key Set malformed");var t;this._jwks=(t=e,"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t)))}async getKey(e,t){const{alg:r,kid:n}={...e,...null==t?void 0:t.header},o=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new _('Unsupported "alg" value for a JSON Web Key Set')}}(r),a=this._jwks.keys.filter(e=>{let t=o===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t&&"EdDSA"===r&&(t="Ed25519"===e.crv||"Ed448"===e.crv),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv}return t}),{0:i,length:s}=a;if(0===s)throw new K;if(1!==s){const e=new W,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(const e of a)try{yield await At(t,e,r)}catch(e){continue}},e}return At(this._cached,i,r)}}async function At(e,t,r){const n=e.get(t)||e.set(t,{}).get(t);if(void 0===n[r]){const e=await Te({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new k("JSON Web Key Set members must be public keys");n[r]=e}return n[r]}function vt(e){const t=new St(e);return async function(e,r){return t.getKey(e,r)}}class _t extends St{constructor(e,t){if(super({keys:[]}),this._jwks=void 0,!(e instanceof URL))throw new TypeError("url must be an instance of URL");this._url=new URL(e.href),this._options={agent:null==t?void 0:t.agent,headers:null==t?void 0:t.headers},this._timeoutDuration="number"==typeof(null==t?void 0:t.timeoutDuration)?null==t?void 0:t.timeoutDuration:5e3,this._cooldownDuration="number"==typeof(null==t?void 0:t.cooldownDuration)?null==t?void 0:t.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof(null==t?void 0:t.cacheMaxAge)?null==t?void 0:t.cacheMaxAge:6e5}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._jwks&&this.fresh()||await this.reload();try{return await super.getKey(e,t)}catch(r){if(r instanceof K&&!1===this.coolingDown())return await this.reload(),super.getKey(e,t);throw r}}async reload(){this._pendingFetch&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0),this._pendingFetch||(this._pendingFetch=(async(e,t,r)=>{let n,o,a=!1;"function"==typeof AbortController&&(n=new AbortController,o=setTimeout(()=>{a=!0,n.abort()},t));const i=await fetch(e.href,{signal:n?n.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{if(a)throw new U;throw e});if(void 0!==o&&clearTimeout(o),200!==i.status)throw new b("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch(e){throw new b("Failed to parse the JSON Web Key Set HTTP response as JSON")}})(this._url,this._timeoutDuration,this._options).then(e=>{if(!Et(e))throw new k("JSON Web Key Set malformed");this._jwks={keys:e.keys},this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e})),await this._pendingFetch}}function Pt(e,t){const r=new _t(e,t);return async function(e,t){return r.getKey(e,t)}}class Ct extends pt{encode(){return`${m(JSON.stringify({alg:"none"}))}.${m(JSON.stringify(this._payload))}.`}static decode(e,t){if("string"!=typeof e)throw new O("Unsecured JWT must be a string");const{0:r,1:n,2:o,length:a}=e.split(".");if(3!==a||""!==o)throw new O("Invalid Unsecured JWT");let i;try{if(i=JSON.parse(d.decode(E(r))),"none"!==i.alg)throw new Error}catch(e){throw new O("Invalid Unsecured JWT")}return{payload:ot(i,E(n),t),header:i}}}const Ht=m,Rt=E;function Ot(e){let t;if("string"==typeof e){const r=e.split(".");3!==r.length&&5!==r.length||([t]=r)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(d.decode(Rt(t)));if(!te(e))throw new Error;return e}catch(e){throw new TypeError("Invalid Token or Protected Header formatting")}}function Tt(e){if("string"!=typeof e)throw new O("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:r}=e.split(".");if(5===r)throw new O("Only JWTs using Compact JWS serialization can be decoded");if(3!==r)throw new O("Invalid JWT");if(!t)throw new O("JWTs must contain a payload");let n,o;try{n=Rt(t)}catch(e){throw new O("Failed to base64url decode the payload")}try{o=JSON.parse(d.decode(n))}catch(e){throw new O("Failed to parse the decoded payload as JSON")}if(!te(o))throw new O("Invalid JWT Claims Set");return o}function kt(e){var t;const r=null!==(t=null==e?void 0:e.modulusLength)&&void 0!==t?t:2048;if("number"!=typeof r||r<2048)throw new _("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return r}async function Kt(e,t){return async function(e,t){var r,n,o;let i,s;switch(e){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:kt(t)},s=["sign","verify"];break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:kt(t)},s=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:kt(t)},s=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":i={name:"ECDSA",namedCurve:"P-256"},s=["sign","verify"];break;case"ES384":i={name:"ECDSA",namedCurve:"P-384"},s=["sign","verify"];break;case"ES512":i={name:"ECDSA",namedCurve:"P-521"},s=["sign","verify"];break;case"EdDSA":s=["sign","verify"];const o=null!==(r=null==t?void 0:t.crv)&&void 0!==r?r:"Ed25519";switch(o){case"Ed25519":case"Ed448":i={name:o};break;default:throw new _("Invalid or unsupported crv option provided")}break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{s=["deriveKey","deriveBits"];const e=null!==(n=null==t?void 0:t.crv)&&void 0!==n?n:"P-256";switch(e){case"P-256":case"P-384":case"P-521":i={name:"ECDH",namedCurve:e};break;case"X25519":case"X448":i={name:e};break;default:throw new _("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return a.subtle.generateKey(i,null!==(o=null==t?void 0:t.extractable)&&void 0!==o&&o,s)}(e,t)}async function Wt(e,t){return async function(e,t){var r;let n,o,i;switch(e){case"HS256":case"HS384":case"HS512":n=parseInt(e.slice(-3),10),o={name:"HMAC",hash:`SHA-${n}`,length:n},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return n=parseInt(e.slice(-3),10),J(new Uint8Array(n>>3));case"A128KW":case"A192KW":case"A256KW":n=parseInt(e.slice(1,4),10),o={name:"AES-KW",length:n},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":n=parseInt(e.slice(1,4),10),o={name:"AES-GCM",length:n},i=["encrypt","decrypt"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return a.subtle.generateKey(o,null!==(r=null==t?void 0:t.extractable)&&void 0!==r&&r,i)}(e,t)}const Ut="WebCryptoAPI"},5608:(e,t,r)=>{r.r(t),r.d(t,{__addDisposableResource:()=>x,__assign:()=>a,__asyncDelegator:()=>P,__asyncGenerator:()=>_,__asyncValues:()=>C,__await:()=>v,__awaiter:()=>f,__classPrivateFieldGet:()=>K,__classPrivateFieldIn:()=>U,__classPrivateFieldSet:()=>W,__createBinding:()=>w,__decorate:()=>s,__disposeResources:()=>D,__esDecorate:()=>d,__exportStar:()=>m,__extends:()=>o,__generator:()=>y,__importDefault:()=>k,__importStar:()=>T,__makeTemplateObject:()=>H,__metadata:()=>h,__param:()=>c,__propKey:()=>l,__read:()=>E,__rest:()=>i,__rewriteRelativeImportExtension:()=>j,__runInitializers:()=>u,__setFunctionName:()=>p,__spread:()=>b,__spreadArray:()=>A,__spreadArrays:()=>S,__values:()=>g,default:()=>I});var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function i(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function c(e,t){return function(r,n){t(r,n,e)}}function d(e,t,r,n,o,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var s,c=n.kind,d="getter"===c?"get":"setter"===c?"set":"value",u=!t&&e?n.static?e:e.prototype:null,l=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),p=!1,h=r.length-1;h>=0;h--){var f={};for(var y in n)f[y]="access"===y?{}:n[y];for(var y in n.access)f.access[y]=n.access[y];f.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var w=(0,r[h])("accessor"===c?{get:l.get,set:l.set}:l[d],f);if("accessor"===c){if(void 0===w)continue;if(null===w||"object"!=typeof w)throw new TypeError("Object expected");(s=i(w.get))&&(l.get=s),(s=i(w.set))&&(l.set=s),(s=i(w.init))&&o.unshift(s)}else(s=i(w))&&("field"===c?o.unshift(s):l[d]=s)}u&&Object.defineProperty(u,n.name,l),p=!0}function u(e,t,r){for(var n=arguments.length>2,o=0;o<t.length;o++)r=n?t[o].call(e,r):t[o].call(e);return n?r:void 0}function l(e){return"symbol"==typeof e?e:"".concat(e)}function p(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}c((n=n.apply(e,t||[])).next())})}function y(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}var w=Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function m(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||w(t,e,r)}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function E(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(E(arguments[t]));return e}function S(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)n[o]=a[i];return n}function A(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function v(e){return this instanceof v?(this.v=e,this):new v(e)}function _(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),a=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",function(e){return function(t){return Promise.resolve(t).then(e,d)}}),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise(function(r,n){a.push([e,t,r,n])>1||s(e,t)})},t&&(n[e]=t(n[e])))}function s(e,t){try{(r=o[e](t)).value instanceof v?Promise.resolve(r.value.v).then(c,d):u(a[0][2],r)}catch(e){u(a[0][3],e)}var r}function c(e){s("next",e)}function d(e){s("throw",e)}function u(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function P(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:v(e[n](t)),done:!1}:o?o(t):t}:o}}function C(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){!function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)}(n,o,(t=e[r](t)).done,t.value)})}}}function H(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var R=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},O=function(e){return O=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},O(e)};function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=O(e),n=0;n<r.length;n++)"default"!==r[n]&&w(t,e,r[n]);return R(t,e),t}function k(e){return e&&e.__esModule?e:{default:e}}function K(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function W(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}function U(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function x(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(o=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");o&&(n=function(){try{o.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var J="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function D(e){function t(t){e.error=e.hasError?new J(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function o(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(a).then(o,function(e){return t(e),o()})}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function j(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,n,o,a){return r?t?".jsx":".js":!n||o&&a?n+o+"."+a.toLowerCase()+"js":e}):e}const I={__extends:o,__assign:a,__rest:i,__decorate:s,__param:c,__esDecorate:d,__runInitializers:u,__propKey:l,__setFunctionName:p,__metadata:h,__awaiter:f,__generator:y,__createBinding:w,__exportStar:m,__values:g,__read:E,__spread:b,__spreadArrays:S,__spreadArray:A,__await:v,__asyncGenerator:_,__asyncDelegator:P,__asyncValues:C,__makeTemplateObject:H,__importStar:T,__importDefault:k,__classPrivateFieldGet:K,__classPrivateFieldSet:W,__classPrivateFieldIn:U,__addDisposableResource:x,__disposeResources:D,__rewriteRelativeImportExtension:j}},7764:(e,t,r)=>{function n(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:a}=Object,{iterator:i,toStringTag:s}=Symbol,c=(d=Object.create(null),e=>{const t=o.call(e);return d[t]||(d[t]=t.slice(8,-1).toLowerCase())});var d;const u=e=>(e=e.toLowerCase(),t=>c(t)===e),l=e=>t=>typeof t===e,{isArray:p}=Array,h=l("undefined");function f(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const y=u("ArrayBuffer"),w=l("string"),m=l("function"),g=l("number"),E=e=>null!==e&&"object"==typeof e,b=e=>{if("object"!==c(e))return!1;const t=a(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||s in e||i in e)},S=u("Date"),A=u("File"),v=u("Blob"),_=u("FileList"),P=u("URLSearchParams"),[C,H,R,O]=["ReadableStream","Request","Response","Headers"].map(u);function T(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),p(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(f(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),a=o.length;let i;for(n=0;n<a;n++)i=o[n],t.call(null,e[i],i,e)}}function k(e,t){if(f(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const K="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:r.g,W=e=>!h(e)&&e!==K,U=(x="undefined"!=typeof Uint8Array&&a(Uint8Array),e=>x&&e instanceof x);var x;const J=u("HTMLFormElement"),D=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),j=u("RegExp"),I=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};T(r,(r,o)=>{let a;!1!==(a=t(r,o,e))&&(n[o]=a||r)}),Object.defineProperties(e,n)},N=u("AsyncFunction"),M=(F="function"==typeof setImmediate,B=m(K.postMessage),F?setImmediate:B?(L=`axios@${Math.random()}`,$=[],K.addEventListener("message",({source:e,data:t})=>{e===K&&t===L&&$.length&&$.shift()()},!1),e=>{$.push(e),K.postMessage(L,"*")}):e=>setTimeout(e));var F,B,L,$;const G="undefined"!=typeof queueMicrotask?queueMicrotask.bind(K):"undefined"!=typeof process&&process.nextTick||M;var z={isArray:p,isArrayBuffer:y,isBuffer:f,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||m(e.append)&&("formdata"===(t=c(e))||"object"===t&&m(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&y(e.buffer),t},isString:w,isNumber:g,isBoolean:e=>!0===e||!1===e,isObject:E,isPlainObject:b,isEmptyObject:e=>{if(!E(e)||f(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:C,isRequest:H,isResponse:R,isHeaders:O,isUndefined:h,isDate:S,isFile:A,isBlob:v,isRegExp:j,isFunction:m,isStream:e=>E(e)&&m(e.pipe),isURLSearchParams:P,isTypedArray:U,isFileList:_,forEach:T,merge:function e(){const{caseless:t,skipUndefined:r}=W(this)&&this||{},n={},o=(o,a)=>{const i=t&&k(n,a)||a;b(n[i])&&b(o)?n[i]=e(n[i],o):b(o)?n[i]=e({},o):p(o)?n[i]=o.slice():r&&h(o)||(n[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&T(arguments[e],o);return n},extend:(e,t,r,{allOwnKeys:o}={})=>(T(t,(t,o)=>{r&&m(t)?e[o]=n(t,r):e[o]=t},{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,i,s;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],n&&!n(s,e,t)||c[s]||(t[s]=e[s],c[s]=!0);e=!1!==r&&a(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:c,kindOfTest:u,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(p(e))return e;let t=e.length;if(!g(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[i]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:J,hasOwnProperty:D,hasOwnProp:D,reduceDescriptors:I,freezeMethods:e=>{I(e,(t,r)=>{if(m(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];m(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return p(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:k,global:K,isContextDefined:W,isSpecCompliantForm:function(e){return!!(e&&m(e.append)&&"FormData"===e[s]&&e[i])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(E(e)){if(t.indexOf(e)>=0)return;if(f(e))return e;if(!("toJSON"in e)){t[n]=e;const o=p(e)?[]:{};return T(e,(e,t)=>{const a=r(e,n+1);!h(a)&&(o[t]=a)}),t[n]=void 0,o}}return e};return r(e,0)},isAsyncFn:N,isThenable:e=>e&&(E(e)||m(e))&&m(e.then)&&m(e.catch),setImmediate:M,asap:G,isIterable:e=>null!=e&&m(e[i])};function V(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}z.inherits(V,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:z.toJSONObject(this.config),code:this.code,status:this.status}}});const q=V.prototype,X={};function Y(e){return z.isPlainObject(e)||z.isArray(e)}function Q(e){return z.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,r){return e?e.concat(t).map(function(e,t){return e=Q(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{X[e]={value:e}}),Object.defineProperties(V,X),Object.defineProperty(q,"isAxiosError",{value:!0}),V.from=(e,t,r,n,o,a)=>{const i=Object.create(q);z.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const s=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return V.call(i,s,c,r,n,o),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",a&&Object.assign(i,a),i};const ee=z.toFlatObject(z,{},null,function(e){return/^is[A-Z]/.test(e)});function te(e,t,r){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=z.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!z.isUndefined(t[e])})).metaTokens,o=r.visitor||d,a=r.dots,i=r.indexes,s=(r.Blob||"undefined"!=typeof Blob&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(z.isDate(e))return e.toISOString();if(z.isBoolean(e))return e.toString();if(!s&&z.isBlob(e))throw new V("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(e)||z.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,r,o){let s=e;if(e&&!o&&"object"==typeof e)if(z.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(z.isArray(e)&&function(e){return z.isArray(e)&&!e.some(Y)}(e)||(z.isFileList(e)||z.endsWith(r,"[]"))&&(s=z.toArray(e)))return r=Q(r),s.forEach(function(e,n){!z.isUndefined(e)&&null!==e&&t.append(!0===i?Z([r],n,a):null===i?r:r+"[]",c(e))}),!1;return!!Y(e)||(t.append(Z(o,r,a),c(e)),!1)}const u=[],l=Object.assign(ee,{defaultVisitor:d,convertValue:c,isVisitable:Y});if(!z.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!z.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),z.forEach(r,function(r,a){!0===(!(z.isUndefined(r)||null===r)&&o.call(t,r,z.isString(a)?a.trim():a,n,l))&&e(r,n?n.concat(a):[a])}),u.pop()}}(e),t}function re(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ne(e,t){this._pairs=[],e&&te(e,this,t)}const oe=ne.prototype;function ae(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ie(e,t,r){if(!t)return e;const n=r&&r.encode||ae;z.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let a;if(a=o?o(t,r):z.isURLSearchParams(t)?t.toString():new ne(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}oe.append=function(e,t){this._pairs.push([e,t])},oe.toString=function(e){const t=e?function(t){return e.call(this,t,re)}:re;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var se=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){z.forEach(this.handlers,function(t){null!==t&&e(t)})}},ce={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},de={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ne,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ue="undefined"!=typeof window&&"undefined"!=typeof document,le="object"==typeof navigator&&navigator||void 0,pe=ue&&(!le||["ReactNative","NativeScript","NS"].indexOf(le.product)<0),he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,fe=ue&&window.location.href||"http://localhost";var ye={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:he,hasStandardBrowserEnv:pe,navigator:le,origin:fe}),...de};function we(e){function t(e,r,n,o){let a=e[o++];if("__proto__"===a)return!0;const i=Number.isFinite(+a),s=o>=e.length;return a=!a&&z.isArray(n)?n.length:a,s?(z.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!i):(n[a]&&z.isObject(n[a])||(n[a]=[]),t(e,r,n[a],o)&&z.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let a;for(n=0;n<o;n++)a=r[n],t[a]=e[a];return t}(n[a])),!i)}if(z.isFormData(e)&&z.isFunction(e.entries)){const r={};return z.forEachEntry(e,(e,n)=>{t(function(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,r,0)}),r}return null}const me={transitional:ce,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=z.isObject(e);if(o&&z.isHTMLForm(e)&&(e=new FormData(e)),z.isFormData(e))return n?JSON.stringify(we(e)):e;if(z.isArrayBuffer(e)||z.isBuffer(e)||z.isStream(e)||z.isFile(e)||z.isBlob(e)||z.isReadableStream(e))return e;if(z.isArrayBufferView(e))return e.buffer;if(z.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new ye.classes.URLSearchParams,{visitor:function(e,t,r,n){return ye.isNode&&z.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((a=z.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e){if(z.isString(e))try{return(0,JSON.parse)(e),z.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||me.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(z.isResponse(e)||z.isReadableStream(e))return e;if(e&&z.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(e){if(r){if("SyntaxError"===e.name)throw V.from(e,V.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ye.classes.FormData,Blob:ye.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{me.headers[e]={}});var ge=me;const Ee=z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),be=Symbol("internals");function Se(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:z.isArray(e)?e.map(Ae):String(e)}function ve(e,t,r,n,o){return z.isFunction(n)?n.call(this,t,r):(o&&(t=r),z.isString(t)?z.isString(n)?-1!==t.indexOf(n):z.isRegExp(n)?n.test(t):void 0:void 0)}class _e{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=Se(t);if(!o)throw new Error("header name must be a non-empty string");const a=z.findKey(n,o);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=Ae(e))}const a=(e,t)=>z.forEach(e,(e,r)=>o(e,r,t));if(z.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(z.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))a((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&Ee[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(z.isObject(e)&&z.isIterable(e)){let r,n,o={};for(const t of e){if(!z.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[n=t[0]]=(r=o[n])?z.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(o,t)}else null!=e&&o(t,e,r);return this}get(e,t){if(e=Se(e)){const r=z.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(z.isFunction(t))return t.call(this,e,r);if(z.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Se(e)){const r=z.findKey(this,e);return!(!r||void 0===this[r]||t&&!ve(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=Se(e)){const o=z.findKey(r,e);!o||t&&!ve(0,r[o],o,t)||(delete r[o],n=!0)}}return z.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!ve(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return z.forEach(this,(n,o)=>{const a=z.findKey(r,o);if(a)return t[a]=Ae(n),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Ae(n),r[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return z.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&z.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[be]=this[be]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Se(e);t[n]||(function(e,t){const r=z.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})})}(r,e),t[n]=!0)}return z.isArray(e)?e.forEach(n):n(e),this}}_e.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors(_e.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),z.freezeMethods(_e);var Pe=_e;function Ce(e,t){const r=this||ge,n=t||r,o=Pe.from(n.headers);let a=n.data;return z.forEach(e,function(e){a=e.call(r,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function He(e){return!(!e||!e.__CANCEL__)}function Re(e,t,r){V.call(this,null==e?"canceled":e,V.ERR_CANCELED,t,r),this.name="CanceledError"}function Oe(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new V("Request failed with status code "+r.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}z.inherits(Re,V,{__CANCEL__:!0});const Te=(e,t,r=3)=>{let n=0;const o=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,a=0,i=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),d=n[i];o||(o=c),r[a]=s,n[a]=c;let u=i,l=0;for(;u!==a;)l+=r[u++],u%=e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),c-o<t)return;const p=d&&c-d;return p?Math.round(1e3*l/p):void 0}}(50,250);return function(r,a){let i,s,c=0,d=1e3/a;const u=(r,a=Date.now())=>{c=a,i=null,s&&(clearTimeout(s),s=null),(r=>{const a=r.loaded,i=r.lengthComputable?r.total:void 0,s=a-n,c=o(s);n=a,e({loaded:a,total:i,progress:i?a/i:void 0,bytes:s,rate:c||void 0,estimated:c&&i&&a<=i?(i-a)/c:void 0,event:r,lengthComputable:null!=i,[t?"download":"upload"]:!0})})(...r)};return[(...e)=>{const t=Date.now(),r=t-c;r>=d?u(e,t):(i=e,s||(s=setTimeout(()=>{s=null,u(i)},d-r)))},()=>i&&u(i)]}(0,r)},ke=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Ke=e=>(...t)=>z.asap(()=>e(...t));var We=ye.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ye.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ye.origin),ye.navigator&&/(msie|trident)/i.test(ye.navigator.userAgent)):()=>!0,Ue=ye.hasStandardBrowserEnv?{write(e,t,r,n,o,a,i){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];z.isNumber(r)&&s.push(`expires=${new Date(r).toUTCString()}`),z.isString(n)&&s.push(`path=${n}`),z.isString(o)&&s.push(`domain=${o}`),!0===a&&s.push("secure"),z.isString(i)&&s.push(`SameSite=${i}`),document.cookie=s.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function xe(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Je=e=>e instanceof Pe?{...e}:e;function De(e,t){t=t||{};const r={};function n(e,t,r,n){return z.isPlainObject(e)&&z.isPlainObject(t)?z.merge.call({caseless:n},e,t):z.isPlainObject(t)?z.merge({},t):z.isArray(t)?t.slice():t}function o(e,t,r,o){return z.isUndefined(t)?z.isUndefined(e)?void 0:n(void 0,e,0,o):n(e,t,0,o)}function a(e,t){if(!z.isUndefined(t))return n(void 0,t)}function i(e,t){return z.isUndefined(t)?z.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,o,a){return a in t?n(r,o):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:s,headers:(e,t,r)=>o(Je(e),Je(t),0,!0)};return z.forEach(Object.keys({...e,...t}),function(n){const a=c[n]||o,i=a(e[n],t[n],n);z.isUndefined(i)&&a!==s||(r[n]=i)}),r}var je=e=>{const t=De({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:s}=t;if(t.headers=i=Pe.from(i),t.url=ie(xe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&i.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):""))),z.isFormData(r))if(ye.hasStandardBrowserEnv||ye.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(r.getHeaders)){const e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,r])=>{t.includes(e.toLowerCase())&&i.set(e,r)})}if(ye.hasStandardBrowserEnv&&(n&&z.isFunction(n)&&(n=n(t)),n||!1!==n&&We(t.url))){const e=o&&a&&Ue.read(a);e&&i.set(o,e)}return t},Ie="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=je(e);let o=n.data;const a=Pe.from(n.headers).normalize();let i,s,c,d,u,{responseType:l,onUploadProgress:p,onDownloadProgress:h}=n;function f(){d&&d(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(i),n.signal&&n.signal.removeEventListener("abort",i)}let y=new XMLHttpRequest;function w(){if(!y)return;const n=Pe.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders());Oe(function(e){t(e),f()},function(e){r(e),f()},{data:l&&"text"!==l&&"json"!==l?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:n,config:e,request:y}),y=null}y.open(n.method.toUpperCase(),n.url,!0),y.timeout=n.timeout,"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(w)},y.onabort=function(){y&&(r(new V("Request aborted",V.ECONNABORTED,e,y)),y=null)},y.onerror=function(t){const n=new V(t&&t.message?t.message:"Network Error",V.ERR_NETWORK,e,y);n.event=t||null,r(n),y=null},y.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const o=n.transitional||ce;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new V(t,o.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,e,y)),y=null},void 0===o&&a.setContentType(null),"setRequestHeader"in y&&z.forEach(a.toJSON(),function(e,t){y.setRequestHeader(t,e)}),z.isUndefined(n.withCredentials)||(y.withCredentials=!!n.withCredentials),l&&"json"!==l&&(y.responseType=n.responseType),h&&([c,u]=Te(h,!0),y.addEventListener("progress",c)),p&&y.upload&&([s,d]=Te(p),y.upload.addEventListener("progress",s),y.upload.addEventListener("loadend",d)),(n.cancelToken||n.signal)&&(i=t=>{y&&(r(!t||t.type?new Re(null,e,y):t),y.abort(),y=null)},n.cancelToken&&n.cancelToken.subscribe(i),n.signal&&(n.signal.aborted?i():n.signal.addEventListener("abort",i)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);m&&-1===ye.protocols.indexOf(m)?r(new V("Unsupported protocol "+m+":",V.ERR_BAD_REQUEST,e)):y.send(o||null)})},Ne=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const o=function(e){if(!r){r=!0,i();const t=e instanceof Error?e:this.reason;n.abort(t instanceof V?t:new Re(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,o(new V(`timeout ${t} of ms exceeded`,V.ETIMEDOUT))},t);const i=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:s}=n;return s.unsubscribe=()=>z.asap(i),s}};const Me=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,o=0;for(;o<r;)n=o+t,yield e.slice(o,n),o=n},Fe=(e,t,r,n)=>{const o=async function*(e,t){for await(const r of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}}(e))yield*Me(r,t)}(e,t);let a,i=0,s=e=>{a||(a=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await o.next();if(t)return s(),void e.close();let a=n.byteLength;if(r){let e=i+=a;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw s(e),e}},cancel:e=>(s(e),o.return())},{highWaterMark:2})},{isFunction:Be}=z,Le=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:$e,TextEncoder:Ge}=z.global,ze=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ve=e=>{e=z.merge.call({skipUndefined:!0},Le,e);const{fetch:t,Request:r,Response:n}=e,o=t?Be(t):"function"==typeof fetch,a=Be(r),i=Be(n);if(!o)return!1;const s=o&&Be($e),c=o&&("function"==typeof Ge?(d=new Ge,e=>d.encode(e)):async e=>new Uint8Array(await new r(e).arrayBuffer()));var d;const u=a&&s&&ze(()=>{let e=!1;const t=new r(ye.origin,{body:new $e,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),l=i&&s&&ze(()=>z.isReadableStream(new n("").body)),p={stream:l&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!p[e]&&(p[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,r)})});return async e=>{let{url:o,method:i,data:s,signal:d,cancelToken:h,timeout:f,onDownloadProgress:y,onUploadProgress:w,responseType:m,headers:g,withCredentials:E="same-origin",fetchOptions:b}=je(e),S=t||fetch;m=m?(m+"").toLowerCase():"text";let A=Ne([d,h&&h.toAbortSignal()],f),v=null;const _=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let P;try{if(w&&u&&"get"!==i&&"head"!==i&&0!==(P=await(async(e,t)=>{const n=z.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(z.isBlob(e))return e.size;if(z.isSpecCompliantForm(e)){const t=new r(ye.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return z.isArrayBufferView(e)||z.isArrayBuffer(e)?e.byteLength:(z.isURLSearchParams(e)&&(e+=""),z.isString(e)?(await c(e)).byteLength:void 0)})(t):n})(g,s))){let e,t=new r(o,{method:"POST",body:s,duplex:"half"});if(z.isFormData(s)&&(e=t.headers.get("content-type"))&&g.setContentType(e),t.body){const[e,r]=ke(P,Te(Ke(w)));s=Fe(t.body,65536,e,r)}}z.isString(E)||(E=E?"include":"omit");const t=a&&"credentials"in r.prototype,d={...b,signal:A,method:i.toUpperCase(),headers:g.normalize().toJSON(),body:s,duplex:"half",credentials:t?E:void 0};v=a&&new r(o,d);let h=await(a?S(v,b):S(o,d));const f=l&&("stream"===m||"response"===m);if(l&&(y||f&&_)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=h[t]});const t=z.toFiniteNumber(h.headers.get("content-length")),[r,o]=y&&ke(t,Te(Ke(y),!0))||[];h=new n(Fe(h.body,65536,r,()=>{o&&o(),_&&_()}),e)}m=m||"text";let C=await p[z.findKey(p,m)||"text"](h,e);return!f&&_&&_(),await new Promise((t,r)=>{Oe(t,r,{data:C,headers:Pe.from(h.headers),status:h.status,statusText:h.statusText,config:e,request:v})})}catch(t){if(_&&_(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new V("Network Error",V.ERR_NETWORK,e,v),{cause:t.cause||t});throw V.from(t,t&&t.code,e,v)}}},qe=new Map,Xe=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,a=[n,o,r];let i,s,c=a.length,d=qe;for(;c--;)i=a[c],s=d.get(i),void 0===s&&d.set(i,s=c?new Map:Ve(t)),d=s;return s};Xe();const Ye={http:null,xhr:Ie,fetch:{get:Xe}};z.forEach(Ye,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Qe=e=>`- ${e}`,Ze=e=>z.isFunction(e)||null===e||!1===e;var et=function(e,t){e=z.isArray(e)?e:[e];const{length:r}=e;let n,o;const a={};for(let i=0;i<r;i++){let r;if(n=e[i],o=n,!Ze(n)&&(o=Ye[(r=String(n)).toLowerCase()],void 0===o))throw new V(`Unknown adapter '${r}'`);if(o&&(z.isFunction(o)||(o=o.get(t))))break;a[r||"#"+i]=o}if(!o){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new V("There is no suitable adapter to dispatch the request "+(r?e.length>1?"since :\n"+e.map(Qe).join("\n"):" "+Qe(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function tt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Re(null,e)}function rt(e){return tt(e),e.headers=Pe.from(e.headers),e.data=Ce.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et(e.adapter||ge.adapter,e)(e).then(function(t){return tt(e),t.data=Ce.call(e,e.transformResponse,t),t.headers=Pe.from(t.headers),t},function(t){return He(t)||(tt(e),t&&t.response&&(t.response.data=Ce.call(e,e.transformResponse,t.response),t.response.headers=Pe.from(t.response.headers))),Promise.reject(t)})}const nt="1.13.1",ot={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ot[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const at={};ot.transitional=function(e,t,r){function n(e,t){return"[Axios v"+nt+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,a)=>{if(!1===e)throw new V(n(o," has been removed"+(t?" in "+t:"")),V.ERR_DEPRECATED);return t&&!at[o]&&(at[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,a)}},ot.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var it={assertOptions:function(e,t,r){if("object"!=typeof e)throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const a=n[o],i=t[a];if(i){const t=e[a],r=void 0===t||i(t,a,e);if(!0!==r)throw new V("option "+a+" must be "+r,V.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new V("Unknown option "+a,V.ERR_BAD_OPTION)}},validators:ot};const st=it.validators;class ct{constructor(e){this.defaults=e||{},this.interceptors={request:new se,response:new se}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=De(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;void 0!==r&&it.assertOptions(r,{silentJSONParsing:st.transitional(st.boolean),forcedJSONParsing:st.transitional(st.boolean),clarifyTimeoutError:st.transitional(st.boolean)},!1),null!=n&&(z.isFunction(n)?t.paramsSerializer={serialize:n}:it.assertOptions(n,{encode:st.function,serialize:st.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),it.assertOptions(t,{baseUrl:st.spelling("baseURL"),withXsrfToken:st.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=o&&z.merge(o.common,o[t.method]);o&&z.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Pe.concat(a,o);const i=[];let s=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const c=[];let d;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,l=0;if(!s){const e=[rt.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,d=Promise.resolve(t);l<u;)d=d.then(e[l++],e[l++]);return d}u=i.length;let p=t;for(;l<u;){const e=i[l++],t=i[l++];try{p=e(p)}catch(e){t.call(this,e);break}}try{d=rt.call(this,p)}catch(e){return Promise.reject(e)}for(l=0,u=c.length;l<u;)d=d.then(c[l++],c[l++]);return d}getUri(e){return ie(xe((e=De(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}z.forEach(["delete","get","head","options"],function(e){ct.prototype[e]=function(t,r){return this.request(De(r||{},{method:e,url:t,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,o){return this.request(De(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ct.prototype[e]=t(),ct.prototype[e+"Form"]=t(!0)});var dt=ct;class ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,o){r.reason||(r.reason=new Re(e,n,o),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ut(function(t){e=t}),cancel:e}}}var lt=ut;const pt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(pt).forEach(([e,t])=>{pt[t]=e});var ht=pt;const ft=function e(t){const r=new dt(t),o=n(dt.prototype.request,r);return z.extend(o,dt.prototype,r,{allOwnKeys:!0}),z.extend(o,r,null,{allOwnKeys:!0}),o.create=function(r){return e(De(t,r))},o}(ge);ft.Axios=dt,ft.CanceledError=Re,ft.CancelToken=lt,ft.isCancel=He,ft.VERSION=nt,ft.toFormData=te,ft.AxiosError=V,ft.Cancel=ft.CanceledError,ft.all=function(e){return Promise.all(e)},ft.spread=function(e){return function(t){return e.apply(null,t)}},ft.isAxiosError=function(e){return z.isObject(e)&&!0===e.isAxiosError},ft.mergeConfig=De,ft.AxiosHeaders=Pe,ft.formToJSON=e=>we(z.isHTMLForm(e)?new FormData(e):e),ft.getAdapter=et,ft.HttpStatusCode=ht,ft.default=ft,e.exports=ft}}]);
|
|
2
|
+
"use strict";(self.webpackChunkSelfCommunityApiServices=self.webpackChunkSelfCommunityApiServices||[]).push([[194],{5478(e,t,r){r.r(t),r.d(t,{CompactEncrypt:()=>et,CompactSign:()=>rt,EmbeddedJWK:()=>lt,EncryptJWT:()=>st,FlattenedEncrypt:()=>Ie,FlattenedSign:()=>tt,GeneralEncrypt:()=>Me,GeneralSign:()=>ot,SignJWT:()=>it,UnsecuredJWT:()=>Et,base64url:()=>o,calculateJwkThumbprint:()=>dt,calculateJwkThumbprintUri:()=>ut,compactDecrypt:()=>Ke,compactVerify:()=>$e,createLocalJWKSet:()=>wt,createRemoteJWKSet:()=>gt,cryptoRuntime:()=>Ht,decodeJwt:()=>vt,decodeProtectedHeader:()=>At,errors:()=>n,exportJWK:()=>Je,exportPKCS8:()=>xe,exportSPKI:()=>Ue,flattenedDecrypt:()=>ke,flattenedVerify:()=>Le,generalDecrypt:()=>We,generalVerify:()=>Ge,generateKeyPair:()=>Pt,generateSecret:()=>Ct,importJWK:()=>Ce,importPKCS8:()=>Pe,importSPKI:()=>ve,importX509:()=>_e,jwtDecrypt:()=>Ze,jwtVerify:()=>Qe});var n={};r.r(n),r.d(n,{JOSEAlgNotAllowed:()=>v,JOSEError:()=>b,JOSENotSupported:()=>_,JWEDecompressionFailed:()=>C,JWEDecryptionFailed:()=>P,JWEInvalid:()=>H,JWKInvalid:()=>T,JWKSInvalid:()=>k,JWKSMultipleMatchingKeys:()=>W,JWKSNoMatchingKey:()=>K,JWKSTimeout:()=>U,JWSInvalid:()=>R,JWSSignatureVerificationFailed:()=>x,JWTClaimValidationFailed:()=>S,JWTExpired:()=>A,JWTInvalid:()=>O});var o={};r.r(o),r.d(o,{decode:()=>St,encode:()=>bt});const a=crypto,i=e=>e instanceof CryptoKey,s=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await a.subtle.digest(r,t))},c=new TextEncoder,d=new TextDecoder,u=2**32;function l(...e){const t=e.reduce((e,{length:t})=>e+t,0),r=new Uint8Array(t);let n=0;return e.forEach(e=>{r.set(e,n),n+=e.length}),r}function p(e,t,r){if(t<0||t>=u)throw new RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function h(e){const t=Math.floor(e/u),r=e%u,n=new Uint8Array(8);return p(n,t,0),p(n,r,4),n}function f(e){const t=new Uint8Array(4);return p(t,e),t}function y(e){return l(f(e.length),e)}const w=e=>{let t=e;"string"==typeof t&&(t=c.encode(t));const r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))},m=e=>w(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),g=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},E=e=>{let t=e;t instanceof Uint8Array&&(t=d.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return g(t)}catch(e){throw new TypeError("The input to be decoded is not correctly encoded.")}};class b extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(e){var t;super(e),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor)}}class S extends b{static get code(){return"ERR_JWT_CLAIM_VALIDATION_FAILED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=t,this.reason=r}}class A extends b{static get code(){return"ERR_JWT_EXPIRED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_EXPIRED",this.claim=t,this.reason=r}}class v extends b{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}static get code(){return"ERR_JOSE_ALG_NOT_ALLOWED"}}class _ extends b{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class P extends b{constructor(){super(...arguments),this.code="ERR_JWE_DECRYPTION_FAILED",this.message="decryption operation failed"}static get code(){return"ERR_JWE_DECRYPTION_FAILED"}}class C extends b{constructor(){super(...arguments),this.code="ERR_JWE_DECOMPRESSION_FAILED",this.message="decompression operation failed"}static get code(){return"ERR_JWE_DECOMPRESSION_FAILED"}}class H extends b{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}class R extends b{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}}class O extends b{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}}class T extends b{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}static get code(){return"ERR_JWK_INVALID"}}class k extends b{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}static get code(){return"ERR_JWKS_INVALID"}}class K extends b{constructor(){super(...arguments),this.code="ERR_JWKS_NO_MATCHING_KEY",this.message="no applicable key found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_NO_MATCHING_KEY"}}class W extends b{constructor(){super(...arguments),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS",this.message="multiple matching keys found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Symbol.asyncIterator;class U extends b{constructor(){super(...arguments),this.code="ERR_JWKS_TIMEOUT",this.message="request timed out"}static get code(){return"ERR_JWKS_TIMEOUT"}}class x extends b{constructor(){super(...arguments),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED",this.message="signature verification failed"}static get code(){return"ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}const J=a.getRandomValues.bind(a);function D(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new _(`Unsupported JWE Algorithm: ${e}`)}}const j=e=>J(new Uint8Array(D(e)>>3)),I=(e,t)=>{if(t.length<<3!==D(e))throw new H("Invalid Initialization Vector length")},N=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new H(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function M(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function F(e,t){return e.name===t}function B(e){return parseInt(e.name.slice(4),10)}function L(e,t){if(t.length&&!t.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const r=t.pop();e+=`one of ${t.join(", ")}, or ${r}.`}else 2===t.length?e+=`one of ${t[0]} or ${t[1]}.`:e+=`${t[0]}.`;throw new TypeError(e)}}function $(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!F(e.algorithm,"AES-GCM"))throw M("AES-GCM");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw M(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!F(e.algorithm,"AES-KW"))throw M("AES-KW");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw M(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw M("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!F(e.algorithm,"PBKDF2"))throw M("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!F(e.algorithm,"RSA-OAEP"))throw M("RSA-OAEP");const r=parseInt(t.slice(9),10)||1;if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}L(e,r)}function G(e,t,...r){if(r.length>2){const t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const z=(e,...t)=>G("Key must be ",e,...t);function V(e,t,...r){return G(`Key for the ${e} algorithm must be `,t,...r)}const q=e=>i(e),X=["CryptoKey"],Y=async(e,t,r,n,o,s)=>{if(!(i(t)||t instanceof Uint8Array))throw new TypeError(z(t,...X,"Uint8Array"));switch(I(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&N(t,parseInt(e.slice(-3),10)),async function(e,t,r,n,o,i){if(!(t instanceof Uint8Array))throw new TypeError(z(t,"Uint8Array"));const s=parseInt(e.slice(1,4),10),c=await a.subtle.importKey("raw",t.subarray(s>>3),"AES-CBC",!1,["decrypt"]),d=await a.subtle.importKey("raw",t.subarray(0,s>>3),{hash:"SHA-"+(s<<1),name:"HMAC"},!1,["sign"]),u=l(i,n,r,h(i.length<<3)),p=new Uint8Array((await a.subtle.sign("HMAC",d,u)).slice(0,s>>3));let f,y;try{f=((e,t)=>{if(!(e instanceof Uint8Array))throw new TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw new TypeError("Second argument must be a buffer");if(e.length!==t.length)throw new TypeError("Input buffers must have the same length");const r=e.length;let n=0,o=-1;for(;++o<r;)n|=e[o]^t[o];return 0===n})(o,p)}catch(e){}if(!f)throw new P;try{y=new Uint8Array(await a.subtle.decrypt({iv:n,name:"AES-CBC"},c,r))}catch(e){}if(!y)throw new P;return y}(e,t,r,n,o,s);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&N(t,parseInt(e.slice(1,4),10)),async function(e,t,r,n,o,i){let s;t instanceof Uint8Array?s=await a.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):($(t,e,"decrypt"),s=t);try{return new Uint8Array(await a.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},s,l(r,o)))}catch(e){throw new P}}(e,t,r,n,o,s);default:throw new _("Unsupported JWE Content Encryption Algorithm")}},Q=async()=>{throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `inflateRaw` decrypt option to provide Inflate Raw implementation.')},Z=async()=>{throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `deflateRaw` encrypt option to provide Deflate Raw implementation.')},ee=(...e)=>{const t=e.filter(Boolean);if(0===t.length||1===t.length)return!0;let r;for(const e of t){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return!1;r.add(e)}else r=new Set(t)}return!0};function te(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let r=e;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}const re=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function ne(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function oe(e,t,r){if(i(e))return $(e,t,r),e;if(e instanceof Uint8Array)return a.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(z(e,...X,"Uint8Array"))}const ae=async(e,t,r)=>{const n=await oe(t,e,"wrapKey");ne(n,e);const o=await a.subtle.importKey("raw",r,...re);return new Uint8Array(await a.subtle.wrapKey("raw",o,n,"AES-KW"))},ie=async(e,t,r)=>{const n=await oe(t,e,"unwrapKey");ne(n,e);const o=await a.subtle.unwrapKey("raw",r,n,"AES-KW",...re);return new Uint8Array(await a.subtle.exportKey("raw",o))};async function se(e,t,r,n,o=new Uint8Array(0),d=new Uint8Array(0)){if(!i(e))throw new TypeError(z(e,...X));if($(e,"ECDH"),!i(t))throw new TypeError(z(t,...X));$(t,"ECDH","deriveBits");const u=l(y(c.encode(r)),y(o),y(d),f(n));let p;return p="X25519"===e.algorithm.name?256:"X448"===e.algorithm.name?448:Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3,async function(e,t,r){const n=Math.ceil((t>>3)/32),o=new Uint8Array(32*n);for(let t=0;t<n;t++){const n=new Uint8Array(4+e.length+r.length);n.set(f(t+1)),n.set(e,4),n.set(r,4+e.length),o.set(await s("sha256",n),32*t)}return o.slice(0,t>>3)}(new Uint8Array(await a.subtle.deriveBits({name:e.algorithm.name,public:e},t,p)),n,u)}function ce(e){if(!i(e))throw new TypeError(z(e,...X));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||"X25519"===e.algorithm.name||"X448"===e.algorithm.name}async function de(e,t,r,n){!function(e){if(!(e instanceof Uint8Array)||e.length<8)throw new H("PBES2 Salt Input must be 8 or more octets")}(e);const o=function(e,t){return l(c.encode(e),new Uint8Array([0]),t)}(t,e),s=parseInt(t.slice(13,16),10),d={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:o},u={length:s,name:"AES-KW"},p=await function(e,t){if(e instanceof Uint8Array)return a.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(i(e))return $(e,t,"deriveBits","deriveKey"),e;throw new TypeError(z(e,...X,"Uint8Array"))}(n,t);if(p.usages.includes("deriveBits"))return new Uint8Array(await a.subtle.deriveBits(d,p,s));if(p.usages.includes("deriveKey"))return a.subtle.deriveKey(d,p,u,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}function ue(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const le=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};function pe(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new _(`Unsupported JWE Algorithm: ${e}`)}}const he=e=>J(new Uint8Array(pe(e)>>3)),fe=(e,t)=>`-----BEGIN ${t}-----\n${(e.match(/.{1,64}/g)||[]).join("\n")}\n-----END ${t}-----`,ye=async(e,t,r)=>{if(!i(r))throw new TypeError(z(r,...X));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==e)throw new TypeError(`key is not a ${e} key`);return fe(w(new Uint8Array(await a.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},we=(e,t,r=0)=>{0===r&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(-1===n)return!1;const o=e.subarray(n,n+t.length);return o.length===t.length&&(o.every((e,r)=>e===t[r])||we(e,t,n+1))},me=e=>{switch(!0){case we(e,[42,134,72,206,61,3,1,7]):return"P-256";case we(e,[43,129,4,0,34]):return"P-384";case we(e,[43,129,4,0,35]):return"P-521";case we(e,[43,101,110]):return"X25519";case we(e,[43,101,111]):return"X448";case we(e,[43,101,112]):return"Ed25519";case we(e,[43,101,113]):return"Ed448";default:throw new _("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},ge=async(e,t,r,n,o)=>{var i;let s,c;const d=new Uint8Array(atob(r.replace(e,"")).split("").map(e=>e.charCodeAt(0))),u="spki"===t;switch(n){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},c=u?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},c=u?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},c=u?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},c=u?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},c=u?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},c=u?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const e=me(d);s=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},c=u?[]:["deriveBits"];break}case"EdDSA":s={name:me(d)},c=u?["verify"]:["sign"];break;default:throw new _('Invalid or unsupported "alg" (Algorithm) value')}return a.subtle.importKey(t,d,s,null!==(i=null==o?void 0:o.extractable)&&void 0!==i&&i,c)},Ee=(e,t,r)=>ge(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r);function be(e){let t=[],r=0;for(;r<e.length;){let n=Se(e.subarray(r));t.push(n),r+=n.byteLength}return t}function Se(e){let t=0,r=31&e[0];if(t++,31===r){for(r=0;e[t]>=128;)r=128*r+e[t]-128,t++;r=128*r+e[t]-128,t++}let n=0;if(e[t]<128)n=e[t],t++;else{if(128===n){for(n=0;0!==e[t+n]||0!==e[t+n+1];){if(n>e.byteLength)throw new TypeError("invalid indefinite form length");n++}const r=t+n+2;return{byteLength:r,contents:e.subarray(t,t+n),raw:e.subarray(0,r)}}{let r=127&e[t];t++,n=0;for(let o=0;o<r;o++)n=256*n+e[t],t++}}const o=t+n;return{byteLength:o,contents:e.subarray(t,o),raw:e.subarray(0,o)}}const Ae=async e=>{var t,r;if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:n,keyUsages:o}=function(e){let t,r;switch(e.kty){case"oct":switch(e.alg){case"HS256":case"HS384":case"HS512":t={name:"HMAC",hash:`SHA-${e.alg.slice(-3)}`},r=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":throw new _(`${e.alg} keys cannot be imported as CryptoKey instances`);case"A128GCM":case"A192GCM":case"A256GCM":case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":t={name:"AES-GCM"},r=["encrypt","decrypt"];break;case"A128KW":case"A192KW":case"A256KW":t={name:"AES-KW"},r=["wrapKey","unwrapKey"];break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":t={name:"PBKDF2"},r=["deriveBits"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new _('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),i=[n,null!==(t=e.ext)&&void 0!==t&&t,null!==(r=e.key_ops)&&void 0!==r?r:o];if("PBKDF2"===n.name)return a.subtle.importKey("raw",E(e.k),...i);const s={...e};return delete s.alg,delete s.use,a.subtle.importKey("jwk",s,...i)};async function ve(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw new TypeError('"spki" must be SPKI formatted string');return Ee(e,t,r)}async function _e(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw new TypeError('"x509" must be X.509 formatted string');return((e,t,r)=>{let n;try{n=function(e){const t=e.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g,""),r=g(t);return fe(function(e){const t=be(be(Se(e).contents)[0].contents);return w(t[160===t[0].raw[0]?6:5].raw)}(r),"PUBLIC KEY")}(e)}catch(e){throw new TypeError("Failed to parse the X.509 certificate",{cause:e})}return Ee(n,t,r)})(e,t,r)}async function Pe(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return((e,t,r)=>ge(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r))(e,t,r)}async function Ce(e,t,r){var n;if(!te(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return null!=r||(r=!0!==e.ext),r?Ae({...e,alg:t,ext:null!==(n=e.ext)&&void 0!==n&&n}):E(e.k);case"RSA":if(void 0!==e.oth)throw new _('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Ae({...e,alg:t});default:throw new _('Unsupported "kty" (Key Type) Parameter value')}}const He=(e,t,r)=>{e.startsWith("HS")||"dir"===e||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?((e,t)=>{if(!(t instanceof Uint8Array)){if(!q(t))throw new TypeError(V(e,t,...X,"Uint8Array"));if("secret"!==t.type)throw new TypeError(`${X.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}})(e,t):((e,t,r)=>{if(!q(t))throw new TypeError(V(e,t,...X));if("secret"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw new TypeError(`${X.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)})(e,t,r)},Re=async(e,t,r,n,o)=>{if(!(i(r)||r instanceof Uint8Array))throw new TypeError(z(r,...X,"Uint8Array"));switch(I(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&N(r,parseInt(e.slice(-3),10)),async function(e,t,r,n,o){if(!(r instanceof Uint8Array))throw new TypeError(z(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),s=await a.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),c=await a.subtle.importKey("raw",r.subarray(0,i>>3),{hash:"SHA-"+(i<<1),name:"HMAC"},!1,["sign"]),d=new Uint8Array(await a.subtle.encrypt({iv:n,name:"AES-CBC"},s,t)),u=l(o,n,d,h(o.length<<3));return{ciphertext:d,tag:new Uint8Array((await a.subtle.sign("HMAC",c,u)).slice(0,i>>3))}}(e,t,r,n,o);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&N(r,parseInt(e.slice(1,4),10)),async function(e,t,r,n,o){let i;r instanceof Uint8Array?i=await a.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):($(r,e,"encrypt"),i=r);const s=new Uint8Array(await a.subtle.encrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},i,t)),c=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:c}}(e,t,r,n,o);default:throw new _("Unsupported JWE Content Encryption Algorithm")}},Oe=function(e,t,r,n,o){if(void 0!==o.crit&&void 0===n.crit)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||void 0===n.crit)return new Set;if(!Array.isArray(n.crit)||0===n.crit.length||n.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t;for(const t of n.crit){if(!a.has(t))throw new _(`Extension Header Parameter "${t}" is not recognized`);if(void 0===o[t])throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&void 0===n[t])throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(n.crit)},Te=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};async function ke(e,t,r){var n;if(!te(e))throw new H("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new H("JOSE Header missing");if("string"!=typeof e.iv)throw new H("JWE Initialization Vector missing or incorrect type");if("string"!=typeof e.ciphertext)throw new H("JWE Ciphertext missing or incorrect type");if("string"!=typeof e.tag)throw new H("JWE Authentication Tag missing or incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new H("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new H("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new H("JWE AAD incorrect type");if(void 0!==e.header&&!te(e.header))throw new H("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!te(e.unprotected))throw new H("JWE Per-Recipient Unprotected Header incorrect type");let o;if(e.protected)try{const t=E(e.protected);o=JSON.parse(d.decode(t))}catch(e){throw new H("JWE Protected Header is invalid")}if(!ee(o,e.header,e.unprotected))throw new H("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");const s={...o,...e.header,...e.unprotected};if(Oe(H,new Map,null==r?void 0:r.crit,o,s),void 0!==s.zip){if(!o||!o.zip)throw new H('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');if("DEF"!==s.zip)throw new _('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value')}const{alg:u,enc:p}=s;if("string"!=typeof u||!u)throw new H("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof p||!p)throw new H("missing JWE Encryption Algorithm (enc) in JWE Header");const h=r&&Te("keyManagementAlgorithms",r.keyManagementAlgorithms),f=r&&Te("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(h&&!h.has(u))throw new v('"alg" (Algorithm) Header Parameter not allowed');if(f&&!f.has(p))throw new v('"enc" (Encryption Algorithm) Header Parameter not allowed');let y;if(void 0!==e.encrypted_key)try{y=E(e.encrypted_key)}catch(e){throw new H("Failed to base64url decode the encrypted_key")}let w,m,g,b=!1;"function"==typeof t&&(t=await t(o,e),b=!0);try{w=await async function(e,t,r,n,o){switch(He(e,t,"decrypt"),e){case"dir":if(void 0!==r)throw new H("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new H("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!te(n.epk))throw new H('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!ce(t))throw new _("ECDH with the provided key is not allowed or not supported by your javascript runtime");const o=await Ce(n.epk,e);let a,i;if(void 0!==n.apu){if("string"!=typeof n.apu)throw new H('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{a=E(n.apu)}catch(e){throw new H("Failed to base64url decode the apu")}}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new H('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{i=E(n.apv)}catch(e){throw new H("Failed to base64url decode the apv")}}const s=await se(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?pe(n.enc):parseInt(e.slice(-5,-2),10),a,i);if("ECDH-ES"===e)return s;if(void 0===r)throw new H("JWE Encrypted Key missing");return ie(e.slice(-6),s,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if(void 0===r)throw new H("JWE Encrypted Key missing");return(async(e,t,r)=>{if(!i(t))throw new TypeError(z(t,...X));if($(t,e,"decrypt","unwrapKey"),le(e,t),t.usages.includes("decrypt"))return new Uint8Array(await a.subtle.decrypt(ue(e),t,r));if(t.usages.includes("unwrapKey")){const n=await a.subtle.unwrapKey("raw",r,t,ue(e),...re);return new Uint8Array(await a.subtle.exportKey("raw",n))}throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')})(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(void 0===r)throw new H("JWE Encrypted Key missing");if("number"!=typeof n.p2c)throw new H('JOSE Header "p2c" (PBES2 Count) missing or invalid');const a=(null==o?void 0:o.maxPBES2Count)||1e4;if(n.p2c>a)throw new H('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new H('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let i;try{i=E(n.p2s)}catch(e){throw new H("Failed to base64url decode the p2s")}return(async(e,t,r,n,o)=>{const a=await de(o,e,n,t);return ie(e.slice(-6),a,r)})(e,t,r,n.p2c,i)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new H("JWE Encrypted Key missing");return ie(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(void 0===r)throw new H("JWE Encrypted Key missing");if("string"!=typeof n.iv)throw new H('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new H('JOSE Header "tag" (Authentication Tag) missing or invalid');let o,a;try{o=E(n.iv)}catch(e){throw new H("Failed to base64url decode the iv")}try{a=E(n.tag)}catch(e){throw new H("Failed to base64url decode the tag")}return async function(e,t,r,n,o){const a=e.slice(0,7);return Y(a,t,r,n,o,new Uint8Array(0))}(e,t,r,o,a)}default:throw new _('Invalid or unsupported "alg" (JWE Algorithm) header value')}}(u,t,y,s,r)}catch(e){if(e instanceof TypeError||e instanceof H||e instanceof _)throw e;w=he(p)}try{m=E(e.iv)}catch(e){throw new H("Failed to base64url decode the iv")}try{g=E(e.tag)}catch(e){throw new H("Failed to base64url decode the tag")}const S=c.encode(null!==(n=e.protected)&&void 0!==n?n:"");let A,P;A=void 0!==e.aad?l(S,c.encode("."),c.encode(e.aad)):S;try{P=E(e.ciphertext)}catch(e){throw new H("Failed to base64url decode the ciphertext")}let C=await Y(p,w,P,m,g,A);"DEF"===s.zip&&(C=await((null==r?void 0:r.inflateRaw)||Q)(C));const R={plaintext:C};if(void 0!==e.protected&&(R.protectedHeader=o),void 0!==e.aad)try{R.additionalAuthenticatedData=E(e.aad)}catch(e){throw new H("Failed to base64url decode the aad")}return void 0!==e.unprotected&&(R.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(R.unprotectedHeader=e.header),b?{...R,key:t}:R}async function Ke(e,t,r){if(e instanceof Uint8Array&&(e=d.decode(e)),"string"!=typeof e)throw new H("Compact JWE must be a string or Uint8Array");const{0:n,1:o,2:a,3:i,4:s,length:c}=e.split(".");if(5!==c)throw new H("Invalid Compact JWE");const u=await ke({ciphertext:i,iv:a||void 0,protected:n||void 0,tag:s||void 0,encrypted_key:o||void 0},t,r),l={plaintext:u.plaintext,protectedHeader:u.protectedHeader};return"function"==typeof t?{...l,key:u.key}:l}async function We(e,t,r){if(!te(e))throw new H("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(te))throw new H("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new H("JWE Recipients has no members");for(const n of e.recipients)try{return await ke({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch(e){}throw new P}async function Ue(e){return(e=>ye("public","spki",e))(e)}async function xe(e){return(e=>ye("private","pkcs8",e))(e)}async function Je(e){return(async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:m(e)};if(!i(e))throw new TypeError(z(e,...X,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:o,...s}=await a.subtle.exportKey("jwk",e);return s})(e)}const De=async function(e,t,r,n,o={}){let s,c,d;switch(He(e,r,"encrypt"),e){case"dir":d=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!ce(r))throw new _("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:l}=o;let{epk:p}=o;p||(p=(await async function(e){if(!i(e))throw new TypeError(z(e,...X));return a.subtle.generateKey(e.algorithm,!0,["deriveBits"])}(r)).privateKey);const{x:h,y:f,crv:y,kty:w}=await Je(p),g=await se(r,p,"ECDH-ES"===e?t:e,"ECDH-ES"===e?pe(t):parseInt(e.slice(-5,-2),10),u,l);if(c={epk:{x:h,crv:y,kty:w}},"EC"===w&&(c.epk.y=f),u&&(c.apu=m(u)),l&&(c.apv=m(l)),"ECDH-ES"===e){d=g;break}d=n||he(t);const E=e.slice(-6);s=await ae(E,g,d);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":d=n||he(t),s=await(async(e,t,r)=>{if(!i(t))throw new TypeError(z(t,...X));if($(t,e,"encrypt","wrapKey"),le(e,t),t.usages.includes("encrypt"))return new Uint8Array(await a.subtle.encrypt(ue(e),t,r));if(t.usages.includes("wrapKey")){const n=await a.subtle.importKey("raw",r,...re);return new Uint8Array(await a.subtle.wrapKey("raw",n,t,ue(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')})(e,r,d);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{d=n||he(t);const{p2c:a,p2s:i}=o;({encryptedKey:s,...c}=await(async(e,t,r,n=2048,o=J(new Uint8Array(16)))=>{const a=await de(o,e,n,t);return{encryptedKey:await ae(e.slice(-6),a,r),p2c:n,p2s:m(o)}})(e,r,d,a,i));break}case"A128KW":case"A192KW":case"A256KW":d=n||he(t),s=await ae(e,r,d);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{d=n||he(t);const{iv:a}=o;({encryptedKey:s,...c}=await async function(e,t,r,n){const o=e.slice(0,7);n||(n=j(o));const{ciphertext:a,tag:i}=await Re(o,r,t,n,new Uint8Array(0));return{encryptedKey:a,iv:m(n),tag:m(i)}}(e,r,d,a));break}default:throw new _('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:d,encryptedKey:s,parameters:c}},je=Symbol();class Ie{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,t){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new H("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!ee(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new H("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(Oe(H,new Map,null==t?void 0:t.crit,this._protectedHeader,r),void 0!==r.zip){if(!this._protectedHeader||!this._protectedHeader.zip)throw new H('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');if("DEF"!==r.zip)throw new _('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value')}const{alg:n,enc:o}=r;if("string"!=typeof n||!n)throw new H('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof o||!o)throw new H('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a,i,s,u,p,h,f;if("dir"===n){if(this._cek)throw new TypeError("setContentEncryptionKey cannot be called when using Direct Encryption")}else if("ECDH-ES"===n&&this._cek)throw new TypeError("setContentEncryptionKey cannot be called when using Direct Key Agreement");{let r;({cek:i,encryptedKey:a,parameters:r}=await De(n,o,e,this._cek,this._keyManagementParameters)),r&&(t&&je in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...r}:this.setUnprotectedHeader(r):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...r}:this.setProtectedHeader(r))}if(this._iv||(this._iv=j(o)),u=this._protectedHeader?c.encode(m(JSON.stringify(this._protectedHeader))):c.encode(""),this._aad?(p=m(this._aad),s=l(u,c.encode("."),c.encode(p))):s=u,"DEF"===r.zip){const e=await((null==t?void 0:t.deflateRaw)||Z)(this._plaintext);({ciphertext:h,tag:f}=await Re(o,e,i,this._iv,s))}else({ciphertext:h,tag:f}=await Re(o,this._plaintext,i,this._iv,s));const y={ciphertext:m(h),iv:m(this._iv),tag:m(f)};return a&&(y.encrypted_key=m(a)),p&&(y.aad=p),this._protectedHeader&&(y.protected=d.decode(u)),this._sharedUnprotectedHeader&&(y.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(y.header=this._unprotectedHeader),y}}class Ne{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addRecipient(...e){return this.parent.addRecipient(...e)}encrypt(...e){return this.parent.encrypt(...e)}done(){return this.parent}}class Me{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,t){const r=new Ne(this,e,{crit:null==t?void 0:t.crit});return this._recipients.push(r),r}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(e){var t,r,n;if(!this._recipients.length)throw new H("at least one recipient must be added");if(e={deflateRaw:null==e?void 0:e.deflateRaw},1===this._recipients.length){const[t]=this._recipients,r=await new Ie(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(t.unprotectedHeader).encrypt(t.key,{...t.options,...e});let n={ciphertext:r.ciphertext,iv:r.iv,recipients:[{}],tag:r.tag};return r.aad&&(n.aad=r.aad),r.protected&&(n.protected=r.protected),r.unprotected&&(n.unprotected=r.unprotected),r.encrypted_key&&(n.recipients[0].encrypted_key=r.encrypted_key),r.header&&(n.recipients[0].header=r.header),n}let o;for(let e=0;e<this._recipients.length;e++){const t=this._recipients[e];if(!ee(this._protectedHeader,this._unprotectedHeader,t.unprotectedHeader))throw new H("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...t.unprotectedHeader},{alg:n}=r;if("string"!=typeof n||!n)throw new H('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===n||"ECDH-ES"===n)throw new H('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof r.enc||!r.enc)throw new H('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(o){if(o!==r.enc)throw new H('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else o=r.enc;if(Oe(H,new Map,t.options.crit,this._protectedHeader,r),!(void 0===r.zip||this._protectedHeader&&this._protectedHeader.zip))throw new H('JWE "zip" (Compression Algorithm) Header MUST be integrity protected')}const a=he(o);let i={ciphertext:"",iv:"",recipients:[],tag:""};for(let s=0;s<this._recipients.length;s++){const c=this._recipients[s],d={};i.recipients.push(d);const u={...this._protectedHeader,...this._unprotectedHeader,...c.unprotectedHeader}.alg.startsWith("PBES2")?2048+s:void 0;if(0===s){const t=await new Ie(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(a).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(c.unprotectedHeader).setKeyManagementParameters({p2c:u}).encrypt(c.key,{...c.options,...e,[je]:!0});i.ciphertext=t.ciphertext,i.iv=t.iv,i.tag=t.tag,t.aad&&(i.aad=t.aad),t.protected&&(i.protected=t.protected),t.unprotected&&(i.unprotected=t.unprotected),d.encrypted_key=t.encrypted_key,t.header&&(d.header=t.header);continue}const{encryptedKey:l,parameters:p}=await De((null===(t=c.unprotectedHeader)||void 0===t?void 0:t.alg)||(null===(r=this._protectedHeader)||void 0===r?void 0:r.alg)||(null===(n=this._unprotectedHeader)||void 0===n?void 0:n.alg),o,c.key,a,{p2c:u});d.encrypted_key=m(l),(c.unprotectedHeader||p)&&(d.header={...c.unprotectedHeader,...p})}return i}}function Fe(e,t){const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function Be(e,t,r){if(i(t))return function(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!F(e.algorithm,"HMAC"))throw M("HMAC");const r=parseInt(t.slice(2),10);if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!F(e.algorithm,"RSASSA-PKCS1-v1_5"))throw M("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!F(e.algorithm,"RSA-PSS"))throw M("RSA-PSS");const r=parseInt(t.slice(2),10);if(B(e.algorithm.hash)!==r)throw M(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw M("Ed25519 or Ed448");break;case"ES256":case"ES384":case"ES512":{if(!F(e.algorithm,"ECDSA"))throw M("ECDSA");const r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw M(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}L(e,r)}(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(z(t,...X));return a.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(z(t,...X,"Uint8Array"))}async function Le(e,t,r){var n;if(!te(e))throw new R("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new R('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new R("JWS Protected Header incorrect type");if(void 0===e.payload)throw new R("JWS Payload missing");if("string"!=typeof e.signature)throw new R("JWS Signature missing or incorrect type");if(void 0!==e.header&&!te(e.header))throw new R("JWS Unprotected Header incorrect type");let o={};if(e.protected)try{const t=E(e.protected);o=JSON.parse(d.decode(t))}catch(e){throw new R("JWS Protected Header is invalid")}if(!ee(o,e.header))throw new R("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const i={...o,...e.header};let s=!0;if(Oe(R,new Map([["b64",!0]]),null==r?void 0:r.crit,o,i).has("b64")&&(s=o.b64,"boolean"!=typeof s))throw new R('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:u}=i;if("string"!=typeof u||!u)throw new R('JWS "alg" (Algorithm) Header Parameter missing or invalid');const p=r&&Te("algorithms",r.algorithms);if(p&&!p.has(u))throw new v('"alg" (Algorithm) Header Parameter not allowed');if(s){if("string"!=typeof e.payload)throw new R("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new R("JWS Payload must be a string or an Uint8Array instance");let h=!1;"function"==typeof t&&(t=await t(o,e),h=!0),He(u,t,"verify");const f=l(c.encode(null!==(n=e.protected)&&void 0!==n?n:""),c.encode("."),"string"==typeof e.payload?c.encode(e.payload):e.payload);let y,w;try{y=E(e.signature)}catch(e){throw new R("Failed to base64url decode the signature")}if(!await(async(e,t,r,n)=>{const o=await Be(e,t,"verify");le(e,o);const i=Fe(e,o.algorithm);try{return await a.subtle.verify(i,o,r,n)}catch(e){return!1}})(u,t,y,f))throw new x;if(s)try{w=E(e.payload)}catch(e){throw new R("Failed to base64url decode the payload")}else w="string"==typeof e.payload?c.encode(e.payload):e.payload;const m={payload:w};return void 0!==e.protected&&(m.protectedHeader=o),void 0!==e.header&&(m.unprotectedHeader=e.header),h?{...m,key:t}:m}async function $e(e,t,r){if(e instanceof Uint8Array&&(e=d.decode(e)),"string"!=typeof e)throw new R("Compact JWS must be a string or Uint8Array");const{0:n,1:o,2:a,length:i}=e.split(".");if(3!==i)throw new R("Invalid Compact JWS");const s=await Le({payload:o,protected:n,signature:a},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...c,key:s.key}:c}async function Ge(e,t,r){if(!te(e))throw new R("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(te))throw new R("JWS Signatures missing or incorrect type");for(const n of e.signatures)try{return await Le({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch(e){}throw new x}const ze=e=>Math.floor(e.getTime()/1e3),Ve=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,qe=e=>{const t=Ve.exec(e);if(!t)throw new TypeError("Invalid time period format");const r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(60*r);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(3600*r);case"day":case"days":case"d":return Math.round(86400*r);case"week":case"weeks":case"w":return Math.round(604800*r);default:return Math.round(31557600*r)}},Xe=e=>e.toLowerCase().replace(/^application\//,""),Ye=(e,t,r={})=>{const{typ:n}=r;if(n&&("string"!=typeof e.typ||Xe(e.typ)!==Xe(n)))throw new S('unexpected "typ" JWT header value',"typ","check_failed");let o;try{o=JSON.parse(d.decode(t))}catch(e){}if(!te(o))throw new O("JWT Claims Set must be a top-level JSON object");const{requiredClaims:a=[],issuer:i,subject:s,audience:c,maxTokenAge:u}=r;void 0!==u&&a.push("iat"),void 0!==c&&a.push("aud"),void 0!==s&&a.push("sub"),void 0!==i&&a.push("iss");for(const e of new Set(a.reverse()))if(!(e in o))throw new S(`missing required "${e}" claim`,e,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(o.iss))throw new S('unexpected "iss" claim value',"iss","check_failed");if(s&&o.sub!==s)throw new S('unexpected "sub" claim value',"sub","check_failed");if(c&&(p="string"==typeof c?[c]:c,!("string"==typeof(l=o.aud)?p.includes(l):Array.isArray(l)&&p.some(Set.prototype.has.bind(new Set(l))))))throw new S('unexpected "aud" claim value',"aud","check_failed");var l,p;let h;switch(typeof r.clockTolerance){case"string":h=qe(r.clockTolerance);break;case"number":h=r.clockTolerance;break;case"undefined":h=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:f}=r,y=ze(f||new Date);if((void 0!==o.iat||u)&&"number"!=typeof o.iat)throw new S('"iat" claim must be a number',"iat","invalid");if(void 0!==o.nbf){if("number"!=typeof o.nbf)throw new S('"nbf" claim must be a number',"nbf","invalid");if(o.nbf>y+h)throw new S('"nbf" claim timestamp check failed',"nbf","check_failed")}if(void 0!==o.exp){if("number"!=typeof o.exp)throw new S('"exp" claim must be a number',"exp","invalid");if(o.exp<=y-h)throw new A('"exp" claim timestamp check failed',"exp","check_failed")}if(u){const e=y-o.iat;if(e-h>("number"==typeof u?u:qe(u)))throw new A('"iat" claim timestamp check failed (too far in the past)',"iat","check_failed");if(e<0-h)throw new S('"iat" claim timestamp check failed (it should be in the past)',"iat","check_failed")}return o};async function Qe(e,t,r){var n;const o=await $e(e,t,r);if((null===(n=o.protectedHeader.crit)||void 0===n?void 0:n.includes("b64"))&&!1===o.protectedHeader.b64)throw new O("JWTs MUST NOT use unencoded payload");const a={payload:Ye(o.protectedHeader,o.payload,r),protectedHeader:o.protectedHeader};return"function"==typeof t?{...a,key:o.key}:a}async function Ze(e,t,r){const n=await Ke(e,t,r),o=Ye(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(void 0!==a.iss&&a.iss!==o.iss)throw new S('replicated "iss" claim header parameter mismatch',"iss","mismatch");if(void 0!==a.sub&&a.sub!==o.sub)throw new S('replicated "sub" claim header parameter mismatch',"sub","mismatch");if(void 0!==a.aud&&JSON.stringify(a.aud)!==JSON.stringify(o.aud))throw new S('replicated "aud" claim header parameter mismatch',"aud","mismatch");const i={payload:o,protectedHeader:a};return"function"==typeof t?{...i,key:n.key}:i}class et{constructor(e){this._flattened=new Ie(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,t){const r=await this._flattened.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}class tt{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader)throw new R("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ee(this._protectedHeader,this._unprotectedHeader))throw new R("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader};let n=!0;if(Oe(R,new Map([["b64",!0]]),null==t?void 0:t.crit,this._protectedHeader,r).has("b64")&&(n=this._protectedHeader.b64,"boolean"!=typeof n))throw new R('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:o}=r;if("string"!=typeof o||!o)throw new R('JWS "alg" (Algorithm) Header Parameter missing or invalid');He(o,e,"sign");let i,s=this._payload;n&&(s=c.encode(m(s))),i=this._protectedHeader?c.encode(m(JSON.stringify(this._protectedHeader))):c.encode("");const u=l(i,c.encode("."),s),p=await(async(e,t,r)=>{const n=await Be(e,t,"sign");le(e,n);const o=await a.subtle.sign(Fe(e,n.algorithm),n,r);return new Uint8Array(o)})(o,e,u),h={signature:m(p),payload:""};return n&&(h.payload=d.decode(s)),this._unprotectedHeader&&(h.header=this._unprotectedHeader),this._protectedHeader&&(h.protected=d.decode(i)),h}}class rt{constructor(e){this._flattened=new tt(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){const r=await this._flattened.sign(e,t);if(void 0===r.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class nt{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setProtectedHeader(e){if(this.protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addSignature(...e){return this.parent.addSignature(...e)}sign(...e){return this.parent.sign(...e)}done(){return this.parent}}class ot{constructor(e){this._signatures=[],this._payload=e}addSignature(e,t){const r=new nt(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new R("at least one signature must be added");const e={signatures:[],payload:""};for(let t=0;t<this._signatures.length;t++){const r=this._signatures[t],n=new tt(this._payload);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);const{payload:o,...a}=await n.sign(r.key,r.options);if(0===t)e.payload=o;else if(e.payload!==o)throw new R("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(a)}return e}}class at{constructor(e){if(!te(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return this._payload="number"==typeof e?{...this._payload,nbf:e}:{...this._payload,nbf:ze(new Date)+qe(e)},this}setExpirationTime(e){return this._payload="number"==typeof e?{...this._payload,exp:e}:{...this._payload,exp:ze(new Date)+qe(e)},this}setIssuedAt(e){return this._payload=void 0===e?{...this._payload,iat:ze(new Date)}:{...this._payload,iat:e},this}}class it extends at{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){var r;const n=new rt(c.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(null===(r=this._protectedHeader)||void 0===r?void 0:r.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new O("JWTs MUST NOT use unencoded payload");return n.sign(e,t)}}class st extends at{setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}replicateIssuerAsHeader(){return this._replicateIssuerAsHeader=!0,this}replicateSubjectAsHeader(){return this._replicateSubjectAsHeader=!0,this}replicateAudienceAsHeader(){return this._replicateAudienceAsHeader=!0,this}async encrypt(e,t){const r=new et(c.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),r.setProtectedHeader(this._protectedHeader),this._iv&&r.setInitializationVector(this._iv),this._cek&&r.setContentEncryptionKey(this._cek),this._keyManagementParameters&&r.setKeyManagementParameters(this._keyManagementParameters),r.encrypt(e,t)}}const ct=(e,t)=>{if("string"!=typeof e||!e)throw new T(`${t} missing or invalid`)};async function dt(e,t){if(!te(e))throw new TypeError("JWK must be an object");if(null!=t||(t="sha256"),"sha256"!==t&&"sha384"!==t&&"sha512"!==t)throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let r;switch(e.kty){case"EC":ct(e.crv,'"crv" (Curve) Parameter'),ct(e.x,'"x" (X Coordinate) Parameter'),ct(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":ct(e.crv,'"crv" (Subtype of Key Pair) Parameter'),ct(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":ct(e.e,'"e" (Exponent) Parameter'),ct(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":ct(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new _('"kty" (Key Type) Parameter missing or unsupported')}const n=c.encode(JSON.stringify(r));return m(await s(t,n))}async function ut(e,t){null!=t||(t="sha256");const r=await dt(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function lt(e,t){const r={...e,...null==t?void 0:t.header};if(!te(r.jwk))throw new R('"jwk" (JSON Web Key) Header Parameter must be a JSON object');const n=await Ce({...r.jwk,ext:!0},r.alg,!0);if(n instanceof Uint8Array||"public"!==n.type)throw new R('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function pt(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(ht)}function ht(e){return te(e)}class ft{constructor(e){if(this._cached=new WeakMap,!pt(e))throw new k("JSON Web Key Set malformed");var t;this._jwks=(t=e,"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t)))}async getKey(e,t){const{alg:r,kid:n}={...e,...null==t?void 0:t.header},o=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new _('Unsupported "alg" value for a JSON Web Key Set')}}(r),a=this._jwks.keys.filter(e=>{let t=o===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t&&"EdDSA"===r&&(t="Ed25519"===e.crv||"Ed448"===e.crv),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv}return t}),{0:i,length:s}=a;if(0===s)throw new K;if(1!==s){const e=new W,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(const e of a)try{yield await yt(t,e,r)}catch(e){continue}},e}return yt(this._cached,i,r)}}async function yt(e,t,r){const n=e.get(t)||e.set(t,{}).get(t);if(void 0===n[r]){const e=await Ce({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new k("JSON Web Key Set members must be public keys");n[r]=e}return n[r]}function wt(e){const t=new ft(e);return async function(e,r){return t.getKey(e,r)}}class mt extends ft{constructor(e,t){if(super({keys:[]}),this._jwks=void 0,!(e instanceof URL))throw new TypeError("url must be an instance of URL");this._url=new URL(e.href),this._options={agent:null==t?void 0:t.agent,headers:null==t?void 0:t.headers},this._timeoutDuration="number"==typeof(null==t?void 0:t.timeoutDuration)?null==t?void 0:t.timeoutDuration:5e3,this._cooldownDuration="number"==typeof(null==t?void 0:t.cooldownDuration)?null==t?void 0:t.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof(null==t?void 0:t.cacheMaxAge)?null==t?void 0:t.cacheMaxAge:6e5}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._jwks&&this.fresh()||await this.reload();try{return await super.getKey(e,t)}catch(r){if(r instanceof K&&!1===this.coolingDown())return await this.reload(),super.getKey(e,t);throw r}}async reload(){this._pendingFetch&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0),this._pendingFetch||(this._pendingFetch=(async(e,t,r)=>{let n,o,a=!1;"function"==typeof AbortController&&(n=new AbortController,o=setTimeout(()=>{a=!0,n.abort()},t));const i=await fetch(e.href,{signal:n?n.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{if(a)throw new U;throw e});if(void 0!==o&&clearTimeout(o),200!==i.status)throw new b("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch(e){throw new b("Failed to parse the JSON Web Key Set HTTP response as JSON")}})(this._url,this._timeoutDuration,this._options).then(e=>{if(!pt(e))throw new k("JSON Web Key Set malformed");this._jwks={keys:e.keys},this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e})),await this._pendingFetch}}function gt(e,t){const r=new mt(e,t);return async function(e,t){return r.getKey(e,t)}}class Et extends at{encode(){return`${m(JSON.stringify({alg:"none"}))}.${m(JSON.stringify(this._payload))}.`}static decode(e,t){if("string"!=typeof e)throw new O("Unsecured JWT must be a string");const{0:r,1:n,2:o,length:a}=e.split(".");if(3!==a||""!==o)throw new O("Invalid Unsecured JWT");let i;try{if(i=JSON.parse(d.decode(E(r))),"none"!==i.alg)throw new Error}catch(e){throw new O("Invalid Unsecured JWT")}return{payload:Ye(i,E(n),t),header:i}}}const bt=m,St=E;function At(e){let t;if("string"==typeof e){const r=e.split(".");3!==r.length&&5!==r.length||([t]=r)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(d.decode(St(t)));if(!te(e))throw new Error;return e}catch(e){throw new TypeError("Invalid Token or Protected Header formatting")}}function vt(e){if("string"!=typeof e)throw new O("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:r}=e.split(".");if(5===r)throw new O("Only JWTs using Compact JWS serialization can be decoded");if(3!==r)throw new O("Invalid JWT");if(!t)throw new O("JWTs must contain a payload");let n,o;try{n=St(t)}catch(e){throw new O("Failed to base64url decode the payload")}try{o=JSON.parse(d.decode(n))}catch(e){throw new O("Failed to parse the decoded payload as JSON")}if(!te(o))throw new O("Invalid JWT Claims Set");return o}function _t(e){var t;const r=null!==(t=null==e?void 0:e.modulusLength)&&void 0!==t?t:2048;if("number"!=typeof r||r<2048)throw new _("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return r}async function Pt(e,t){return async function(e,t){var r,n,o;let i,s;switch(e){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:_t(t)},s=["sign","verify"];break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:_t(t)},s=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:_t(t)},s=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":i={name:"ECDSA",namedCurve:"P-256"},s=["sign","verify"];break;case"ES384":i={name:"ECDSA",namedCurve:"P-384"},s=["sign","verify"];break;case"ES512":i={name:"ECDSA",namedCurve:"P-521"},s=["sign","verify"];break;case"EdDSA":s=["sign","verify"];const o=null!==(r=null==t?void 0:t.crv)&&void 0!==r?r:"Ed25519";switch(o){case"Ed25519":case"Ed448":i={name:o};break;default:throw new _("Invalid or unsupported crv option provided")}break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{s=["deriveKey","deriveBits"];const e=null!==(n=null==t?void 0:t.crv)&&void 0!==n?n:"P-256";switch(e){case"P-256":case"P-384":case"P-521":i={name:"ECDH",namedCurve:e};break;case"X25519":case"X448":i={name:e};break;default:throw new _("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return a.subtle.generateKey(i,null!==(o=null==t?void 0:t.extractable)&&void 0!==o&&o,s)}(e,t)}async function Ct(e,t){return async function(e,t){var r;let n,o,i;switch(e){case"HS256":case"HS384":case"HS512":n=parseInt(e.slice(-3),10),o={name:"HMAC",hash:`SHA-${n}`,length:n},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return n=parseInt(e.slice(-3),10),J(new Uint8Array(n>>3));case"A128KW":case"A192KW":case"A256KW":n=parseInt(e.slice(1,4),10),o={name:"AES-KW",length:n},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":n=parseInt(e.slice(1,4),10),o={name:"AES-GCM",length:n},i=["encrypt","decrypt"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return a.subtle.generateKey(o,null!==(r=null==t?void 0:t.extractable)&&void 0!==r&&r,i)}(e,t)}const Ht="WebCryptoAPI"},5608(e,t,r){r.r(t),r.d(t,{__addDisposableResource:()=>x,__assign:()=>a,__asyncDelegator:()=>P,__asyncGenerator:()=>_,__asyncValues:()=>C,__await:()=>v,__awaiter:()=>f,__classPrivateFieldGet:()=>K,__classPrivateFieldIn:()=>U,__classPrivateFieldSet:()=>W,__createBinding:()=>w,__decorate:()=>s,__disposeResources:()=>D,__esDecorate:()=>d,__exportStar:()=>m,__extends:()=>o,__generator:()=>y,__importDefault:()=>k,__importStar:()=>T,__makeTemplateObject:()=>H,__metadata:()=>h,__param:()=>c,__propKey:()=>l,__read:()=>E,__rest:()=>i,__rewriteRelativeImportExtension:()=>j,__runInitializers:()=>u,__setFunctionName:()=>p,__spread:()=>b,__spreadArray:()=>A,__spreadArrays:()=>S,__values:()=>g,default:()=>I});var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)};function i(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function c(e,t){return function(r,n){t(r,n,e)}}function d(e,t,r,n,o,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var s,c=n.kind,d="getter"===c?"get":"setter"===c?"set":"value",u=!t&&e?n.static?e:e.prototype:null,l=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),p=!1,h=r.length-1;h>=0;h--){var f={};for(var y in n)f[y]="access"===y?{}:n[y];for(var y in n.access)f.access[y]=n.access[y];f.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var w=(0,r[h])("accessor"===c?{get:l.get,set:l.set}:l[d],f);if("accessor"===c){if(void 0===w)continue;if(null===w||"object"!=typeof w)throw new TypeError("Object expected");(s=i(w.get))&&(l.get=s),(s=i(w.set))&&(l.set=s),(s=i(w.init))&&o.unshift(s)}else(s=i(w))&&("field"===c?o.unshift(s):l[d]=s)}u&&Object.defineProperty(u,n.name,l),p=!0}function u(e,t,r){for(var n=arguments.length>2,o=0;o<t.length;o++)r=n?t[o].call(e,r):t[o].call(e);return n?r:void 0}function l(e){return"symbol"==typeof e?e:"".concat(e)}function p(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}c((n=n.apply(e,t||[])).next())})}function y(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}var w=Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function m(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||w(t,e,r)}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function E(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(E(arguments[t]));return e}function S(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)n[o]=a[i];return n}function A(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function v(e){return this instanceof v?(this.v=e,this):new v(e)}function _(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),a=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",function(e){return function(t){return Promise.resolve(t).then(e,d)}}),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise(function(r,n){a.push([e,t,r,n])>1||s(e,t)})},t&&(n[e]=t(n[e])))}function s(e,t){try{(r=o[e](t)).value instanceof v?Promise.resolve(r.value.v).then(c,d):u(a[0][2],r)}catch(e){u(a[0][3],e)}var r}function c(e){s("next",e)}function d(e){s("throw",e)}function u(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function P(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:v(e[n](t)),done:!1}:o?o(t):t}:o}}function C(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){!function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)}(n,o,(t=e[r](t)).done,t.value)})}}}function H(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var R=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},O=function(e){return O=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},O(e)};function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=O(e),n=0;n<r.length;n++)"default"!==r[n]&&w(t,e,r[n]);return R(t,e),t}function k(e){return e&&e.__esModule?e:{default:e}}function K(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function W(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}function U(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function x(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(o=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");o&&(n=function(){try{o.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var J="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function D(e){function t(t){e.error=e.hasError?new J(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function o(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(a).then(o,function(e){return t(e),o()})}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function j(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,n,o,a){return r?t?".jsx":".js":!n||o&&a?n+o+"."+a.toLowerCase()+"js":e}):e}const I={__extends:o,__assign:a,__rest:i,__decorate:s,__param:c,__esDecorate:d,__runInitializers:u,__propKey:l,__setFunctionName:p,__metadata:h,__awaiter:f,__generator:y,__createBinding:w,__exportStar:m,__values:g,__read:E,__spread:b,__spreadArrays:S,__spreadArray:A,__await:v,__asyncGenerator:_,__asyncDelegator:P,__asyncValues:C,__makeTemplateObject:H,__importStar:T,__importDefault:k,__classPrivateFieldGet:K,__classPrivateFieldSet:W,__classPrivateFieldIn:U,__addDisposableResource:x,__disposeResources:D,__rewriteRelativeImportExtension:j}},7764(e,t,r){function n(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:a}=Object,{iterator:i,toStringTag:s}=Symbol,c=(d=Object.create(null),e=>{const t=o.call(e);return d[t]||(d[t]=t.slice(8,-1).toLowerCase())});var d;const u=e=>(e=e.toLowerCase(),t=>c(t)===e),l=e=>t=>typeof t===e,{isArray:p}=Array,h=l("undefined");function f(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const y=u("ArrayBuffer"),w=l("string"),m=l("function"),g=l("number"),E=e=>null!==e&&"object"==typeof e,b=e=>{if("object"!==c(e))return!1;const t=a(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||s in e||i in e)},S=u("Date"),A=u("File"),v=u("Blob"),_=u("FileList"),P=u("URLSearchParams"),[C,H,R,O]=["ReadableStream","Request","Response","Headers"].map(u);function T(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),p(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(f(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),a=o.length;let i;for(n=0;n<a;n++)i=o[n],t.call(null,e[i],i,e)}}function k(e,t){if(f(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const K="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:r.g,W=e=>!h(e)&&e!==K,U=(x="undefined"!=typeof Uint8Array&&a(Uint8Array),e=>x&&e instanceof x);var x;const J=u("HTMLFormElement"),D=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),j=u("RegExp"),I=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};T(r,(r,o)=>{let a;!1!==(a=t(r,o,e))&&(n[o]=a||r)}),Object.defineProperties(e,n)},N=u("AsyncFunction"),M=(F="function"==typeof setImmediate,B=m(K.postMessage),F?setImmediate:B?(L=`axios@${Math.random()}`,$=[],K.addEventListener("message",({source:e,data:t})=>{e===K&&t===L&&$.length&&$.shift()()},!1),e=>{$.push(e),K.postMessage(L,"*")}):e=>setTimeout(e));var F,B,L,$;const G="undefined"!=typeof queueMicrotask?queueMicrotask.bind(K):"undefined"!=typeof process&&process.nextTick||M;var z={isArray:p,isArrayBuffer:y,isBuffer:f,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||m(e.append)&&("formdata"===(t=c(e))||"object"===t&&m(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&y(e.buffer),t},isString:w,isNumber:g,isBoolean:e=>!0===e||!1===e,isObject:E,isPlainObject:b,isEmptyObject:e=>{if(!E(e)||f(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:C,isRequest:H,isResponse:R,isHeaders:O,isUndefined:h,isDate:S,isFile:A,isBlob:v,isRegExp:j,isFunction:m,isStream:e=>E(e)&&m(e.pipe),isURLSearchParams:P,isTypedArray:U,isFileList:_,forEach:T,merge:function e(){const{caseless:t,skipUndefined:r}=W(this)&&this||{},n={},o=(o,a)=>{const i=t&&k(n,a)||a;b(n[i])&&b(o)?n[i]=e(n[i],o):b(o)?n[i]=e({},o):p(o)?n[i]=o.slice():r&&h(o)||(n[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&T(arguments[e],o);return n},extend:(e,t,r,{allOwnKeys:o}={})=>(T(t,(t,o)=>{r&&m(t)?e[o]=n(t,r):e[o]=t},{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,i,s;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],n&&!n(s,e,t)||c[s]||(t[s]=e[s],c[s]=!0);e=!1!==r&&a(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:c,kindOfTest:u,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(p(e))return e;let t=e.length;if(!g(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[i]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:J,hasOwnProperty:D,hasOwnProp:D,reduceDescriptors:I,freezeMethods:e=>{I(e,(t,r)=>{if(m(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];m(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return p(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:k,global:K,isContextDefined:W,isSpecCompliantForm:function(e){return!!(e&&m(e.append)&&"FormData"===e[s]&&e[i])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(E(e)){if(t.indexOf(e)>=0)return;if(f(e))return e;if(!("toJSON"in e)){t[n]=e;const o=p(e)?[]:{};return T(e,(e,t)=>{const a=r(e,n+1);!h(a)&&(o[t]=a)}),t[n]=void 0,o}}return e};return r(e,0)},isAsyncFn:N,isThenable:e=>e&&(E(e)||m(e))&&m(e.then)&&m(e.catch),setImmediate:M,asap:G,isIterable:e=>null!=e&&m(e[i])};function V(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}z.inherits(V,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:z.toJSONObject(this.config),code:this.code,status:this.status}}});const q=V.prototype,X={};function Y(e){return z.isPlainObject(e)||z.isArray(e)}function Q(e){return z.endsWith(e,"[]")?e.slice(0,-2):e}function Z(e,t,r){return e?e.concat(t).map(function(e,t){return e=Q(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{X[e]={value:e}}),Object.defineProperties(V,X),Object.defineProperty(q,"isAxiosError",{value:!0}),V.from=(e,t,r,n,o,a)=>{const i=Object.create(q);z.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const s=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return V.call(i,s,c,r,n,o),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",a&&Object.assign(i,a),i};const ee=z.toFlatObject(z,{},null,function(e){return/^is[A-Z]/.test(e)});function te(e,t,r){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=z.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!z.isUndefined(t[e])})).metaTokens,o=r.visitor||d,a=r.dots,i=r.indexes,s=(r.Blob||"undefined"!=typeof Blob&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(z.isDate(e))return e.toISOString();if(z.isBoolean(e))return e.toString();if(!s&&z.isBlob(e))throw new V("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(e)||z.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,r,o){let s=e;if(e&&!o&&"object"==typeof e)if(z.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(z.isArray(e)&&function(e){return z.isArray(e)&&!e.some(Y)}(e)||(z.isFileList(e)||z.endsWith(r,"[]"))&&(s=z.toArray(e)))return r=Q(r),s.forEach(function(e,n){!z.isUndefined(e)&&null!==e&&t.append(!0===i?Z([r],n,a):null===i?r:r+"[]",c(e))}),!1;return!!Y(e)||(t.append(Z(o,r,a),c(e)),!1)}const u=[],l=Object.assign(ee,{defaultVisitor:d,convertValue:c,isVisitable:Y});if(!z.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!z.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),z.forEach(r,function(r,a){!0===(!(z.isUndefined(r)||null===r)&&o.call(t,r,z.isString(a)?a.trim():a,n,l))&&e(r,n?n.concat(a):[a])}),u.pop()}}(e),t}function re(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ne(e,t){this._pairs=[],e&&te(e,this,t)}const oe=ne.prototype;function ae(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ie(e,t,r){if(!t)return e;const n=r&&r.encode||ae;z.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let a;if(a=o?o(t,r):z.isURLSearchParams(t)?t.toString():new ne(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}oe.append=function(e,t){this._pairs.push([e,t])},oe.toString=function(e){const t=e?function(t){return e.call(this,t,re)}:re;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var se=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){z.forEach(this.handlers,function(t){null!==t&&e(t)})}},ce={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},de={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ne,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ue="undefined"!=typeof window&&"undefined"!=typeof document,le="object"==typeof navigator&&navigator||void 0,pe=ue&&(!le||["ReactNative","NativeScript","NS"].indexOf(le.product)<0),he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,fe=ue&&window.location.href||"http://localhost";var ye={...Object.freeze({__proto__:null,hasBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:he,hasStandardBrowserEnv:pe,navigator:le,origin:fe}),...de};function we(e){function t(e,r,n,o){let a=e[o++];if("__proto__"===a)return!0;const i=Number.isFinite(+a),s=o>=e.length;return a=!a&&z.isArray(n)?n.length:a,s?(z.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!i):(n[a]&&z.isObject(n[a])||(n[a]=[]),t(e,r,n[a],o)&&z.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let a;for(n=0;n<o;n++)a=r[n],t[a]=e[a];return t}(n[a])),!i)}if(z.isFormData(e)&&z.isFunction(e.entries)){const r={};return z.forEachEntry(e,(e,n)=>{t(function(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,r,0)}),r}return null}const me={transitional:ce,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=z.isObject(e);if(o&&z.isHTMLForm(e)&&(e=new FormData(e)),z.isFormData(e))return n?JSON.stringify(we(e)):e;if(z.isArrayBuffer(e)||z.isBuffer(e)||z.isStream(e)||z.isFile(e)||z.isBlob(e)||z.isReadableStream(e))return e;if(z.isArrayBufferView(e))return e.buffer;if(z.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return te(e,new ye.classes.URLSearchParams,{visitor:function(e,t,r,n){return ye.isNode&&z.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((a=z.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return te(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e){if(z.isString(e))try{return(0,JSON.parse)(e),z.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||me.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(z.isResponse(e)||z.isReadableStream(e))return e;if(e&&z.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(e){if(r){if("SyntaxError"===e.name)throw V.from(e,V.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ye.classes.FormData,Blob:ye.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{me.headers[e]={}});var ge=me;const Ee=z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),be=Symbol("internals");function Se(e){return e&&String(e).trim().toLowerCase()}function Ae(e){return!1===e||null==e?e:z.isArray(e)?e.map(Ae):String(e)}function ve(e,t,r,n,o){return z.isFunction(n)?n.call(this,t,r):(o&&(t=r),z.isString(t)?z.isString(n)?-1!==t.indexOf(n):z.isRegExp(n)?n.test(t):void 0:void 0)}class _e{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=Se(t);if(!o)throw new Error("header name must be a non-empty string");const a=z.findKey(n,o);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=Ae(e))}const a=(e,t)=>z.forEach(e,(e,r)=>o(e,r,t));if(z.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(z.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))a((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&Ee[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(z.isObject(e)&&z.isIterable(e)){let r,n,o={};for(const t of e){if(!z.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[n=t[0]]=(r=o[n])?z.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(o,t)}else null!=e&&o(t,e,r);return this}get(e,t){if(e=Se(e)){const r=z.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(z.isFunction(t))return t.call(this,e,r);if(z.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Se(e)){const r=z.findKey(this,e);return!(!r||void 0===this[r]||t&&!ve(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=Se(e)){const o=z.findKey(r,e);!o||t&&!ve(0,r[o],o,t)||(delete r[o],n=!0)}}return z.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!ve(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return z.forEach(this,(n,o)=>{const a=z.findKey(r,o);if(a)return t[a]=Ae(n),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Ae(n),r[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return z.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&z.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[be]=this[be]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Se(e);t[n]||(function(e,t){const r=z.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})})}(r,e),t[n]=!0)}return z.isArray(e)?e.forEach(n):n(e),this}}_e.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors(_e.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),z.freezeMethods(_e);var Pe=_e;function Ce(e,t){const r=this||ge,n=t||r,o=Pe.from(n.headers);let a=n.data;return z.forEach(e,function(e){a=e.call(r,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function He(e){return!(!e||!e.__CANCEL__)}function Re(e,t,r){V.call(this,null==e?"canceled":e,V.ERR_CANCELED,t,r),this.name="CanceledError"}function Oe(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new V("Request failed with status code "+r.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}z.inherits(Re,V,{__CANCEL__:!0});const Te=(e,t,r=3)=>{let n=0;const o=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,a=0,i=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),d=n[i];o||(o=c),r[a]=s,n[a]=c;let u=i,l=0;for(;u!==a;)l+=r[u++],u%=e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),c-o<t)return;const p=d&&c-d;return p?Math.round(1e3*l/p):void 0}}(50,250);return function(r,a){let i,s,c=0,d=1e3/a;const u=(r,a=Date.now())=>{c=a,i=null,s&&(clearTimeout(s),s=null),(r=>{const a=r.loaded,i=r.lengthComputable?r.total:void 0,s=a-n,c=o(s);n=a,e({loaded:a,total:i,progress:i?a/i:void 0,bytes:s,rate:c||void 0,estimated:c&&i&&a<=i?(i-a)/c:void 0,event:r,lengthComputable:null!=i,[t?"download":"upload"]:!0})})(...r)};return[(...e)=>{const t=Date.now(),r=t-c;r>=d?u(e,t):(i=e,s||(s=setTimeout(()=>{s=null,u(i)},d-r)))},()=>i&&u(i)]}(0,r)},ke=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Ke=e=>(...t)=>z.asap(()=>e(...t));var We=ye.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ye.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ye.origin),ye.navigator&&/(msie|trident)/i.test(ye.navigator.userAgent)):()=>!0,Ue=ye.hasStandardBrowserEnv?{write(e,t,r,n,o,a,i){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];z.isNumber(r)&&s.push(`expires=${new Date(r).toUTCString()}`),z.isString(n)&&s.push(`path=${n}`),z.isString(o)&&s.push(`domain=${o}`),!0===a&&s.push("secure"),z.isString(i)&&s.push(`SameSite=${i}`),document.cookie=s.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function xe(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Je=e=>e instanceof Pe?{...e}:e;function De(e,t){t=t||{};const r={};function n(e,t,r,n){return z.isPlainObject(e)&&z.isPlainObject(t)?z.merge.call({caseless:n},e,t):z.isPlainObject(t)?z.merge({},t):z.isArray(t)?t.slice():t}function o(e,t,r,o){return z.isUndefined(t)?z.isUndefined(e)?void 0:n(void 0,e,0,o):n(e,t,0,o)}function a(e,t){if(!z.isUndefined(t))return n(void 0,t)}function i(e,t){return z.isUndefined(t)?z.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,o,a){return a in t?n(r,o):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:s,headers:(e,t,r)=>o(Je(e),Je(t),0,!0)};return z.forEach(Object.keys({...e,...t}),function(n){const a=c[n]||o,i=a(e[n],t[n],n);z.isUndefined(i)&&a!==s||(r[n]=i)}),r}var je=e=>{const t=De({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:s}=t;if(t.headers=i=Pe.from(i),t.url=ie(xe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&i.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):""))),z.isFormData(r))if(ye.hasStandardBrowserEnv||ye.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(r.getHeaders)){const e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,r])=>{t.includes(e.toLowerCase())&&i.set(e,r)})}if(ye.hasStandardBrowserEnv&&(n&&z.isFunction(n)&&(n=n(t)),n||!1!==n&&We(t.url))){const e=o&&a&&Ue.read(a);e&&i.set(o,e)}return t},Ie="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=je(e);let o=n.data;const a=Pe.from(n.headers).normalize();let i,s,c,d,u,{responseType:l,onUploadProgress:p,onDownloadProgress:h}=n;function f(){d&&d(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(i),n.signal&&n.signal.removeEventListener("abort",i)}let y=new XMLHttpRequest;function w(){if(!y)return;const n=Pe.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders());Oe(function(e){t(e),f()},function(e){r(e),f()},{data:l&&"text"!==l&&"json"!==l?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:n,config:e,request:y}),y=null}y.open(n.method.toUpperCase(),n.url,!0),y.timeout=n.timeout,"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(w)},y.onabort=function(){y&&(r(new V("Request aborted",V.ECONNABORTED,e,y)),y=null)},y.onerror=function(t){const n=new V(t&&t.message?t.message:"Network Error",V.ERR_NETWORK,e,y);n.event=t||null,r(n),y=null},y.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const o=n.transitional||ce;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new V(t,o.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,e,y)),y=null},void 0===o&&a.setContentType(null),"setRequestHeader"in y&&z.forEach(a.toJSON(),function(e,t){y.setRequestHeader(t,e)}),z.isUndefined(n.withCredentials)||(y.withCredentials=!!n.withCredentials),l&&"json"!==l&&(y.responseType=n.responseType),h&&([c,u]=Te(h,!0),y.addEventListener("progress",c)),p&&y.upload&&([s,d]=Te(p),y.upload.addEventListener("progress",s),y.upload.addEventListener("loadend",d)),(n.cancelToken||n.signal)&&(i=t=>{y&&(r(!t||t.type?new Re(null,e,y):t),y.abort(),y=null)},n.cancelToken&&n.cancelToken.subscribe(i),n.signal&&(n.signal.aborted?i():n.signal.addEventListener("abort",i)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);m&&-1===ye.protocols.indexOf(m)?r(new V("Unsupported protocol "+m+":",V.ERR_BAD_REQUEST,e)):y.send(o||null)})},Ne=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const o=function(e){if(!r){r=!0,i();const t=e instanceof Error?e:this.reason;n.abort(t instanceof V?t:new Re(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,o(new V(`timeout ${t} of ms exceeded`,V.ETIMEDOUT))},t);const i=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:s}=n;return s.unsubscribe=()=>z.asap(i),s}};const Me=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,o=0;for(;o<r;)n=o+t,yield e.slice(o,n),o=n},Fe=(e,t,r,n)=>{const o=async function*(e,t){for await(const r of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}}(e))yield*Me(r,t)}(e,t);let a,i=0,s=e=>{a||(a=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await o.next();if(t)return s(),void e.close();let a=n.byteLength;if(r){let e=i+=a;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw s(e),e}},cancel:e=>(s(e),o.return())},{highWaterMark:2})},{isFunction:Be}=z,Le=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:$e,TextEncoder:Ge}=z.global,ze=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ve=e=>{e=z.merge.call({skipUndefined:!0},Le,e);const{fetch:t,Request:r,Response:n}=e,o=t?Be(t):"function"==typeof fetch,a=Be(r),i=Be(n);if(!o)return!1;const s=o&&Be($e),c=o&&("function"==typeof Ge?(d=new Ge,e=>d.encode(e)):async e=>new Uint8Array(await new r(e).arrayBuffer()));var d;const u=a&&s&&ze(()=>{let e=!1;const t=new r(ye.origin,{body:new $e,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),l=i&&s&&ze(()=>z.isReadableStream(new n("").body)),p={stream:l&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!p[e]&&(p[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,r)})});return async e=>{let{url:o,method:i,data:s,signal:d,cancelToken:h,timeout:f,onDownloadProgress:y,onUploadProgress:w,responseType:m,headers:g,withCredentials:E="same-origin",fetchOptions:b}=je(e),S=t||fetch;m=m?(m+"").toLowerCase():"text";let A=Ne([d,h&&h.toAbortSignal()],f),v=null;const _=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let P;try{if(w&&u&&"get"!==i&&"head"!==i&&0!==(P=await(async(e,t)=>{const n=z.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(z.isBlob(e))return e.size;if(z.isSpecCompliantForm(e)){const t=new r(ye.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return z.isArrayBufferView(e)||z.isArrayBuffer(e)?e.byteLength:(z.isURLSearchParams(e)&&(e+=""),z.isString(e)?(await c(e)).byteLength:void 0)})(t):n})(g,s))){let e,t=new r(o,{method:"POST",body:s,duplex:"half"});if(z.isFormData(s)&&(e=t.headers.get("content-type"))&&g.setContentType(e),t.body){const[e,r]=ke(P,Te(Ke(w)));s=Fe(t.body,65536,e,r)}}z.isString(E)||(E=E?"include":"omit");const t=a&&"credentials"in r.prototype,d={...b,signal:A,method:i.toUpperCase(),headers:g.normalize().toJSON(),body:s,duplex:"half",credentials:t?E:void 0};v=a&&new r(o,d);let h=await(a?S(v,b):S(o,d));const f=l&&("stream"===m||"response"===m);if(l&&(y||f&&_)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=h[t]});const t=z.toFiniteNumber(h.headers.get("content-length")),[r,o]=y&&ke(t,Te(Ke(y),!0))||[];h=new n(Fe(h.body,65536,r,()=>{o&&o(),_&&_()}),e)}m=m||"text";let C=await p[z.findKey(p,m)||"text"](h,e);return!f&&_&&_(),await new Promise((t,r)=>{Oe(t,r,{data:C,headers:Pe.from(h.headers),status:h.status,statusText:h.statusText,config:e,request:v})})}catch(t){if(_&&_(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new V("Network Error",V.ERR_NETWORK,e,v),{cause:t.cause||t});throw V.from(t,t&&t.code,e,v)}}},qe=new Map,Xe=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,a=[n,o,r];let i,s,c=a.length,d=qe;for(;c--;)i=a[c],s=d.get(i),void 0===s&&d.set(i,s=c?new Map:Ve(t)),d=s;return s};Xe();const Ye={http:null,xhr:Ie,fetch:{get:Xe}};z.forEach(Ye,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Qe=e=>`- ${e}`,Ze=e=>z.isFunction(e)||null===e||!1===e;var et=function(e,t){e=z.isArray(e)?e:[e];const{length:r}=e;let n,o;const a={};for(let i=0;i<r;i++){let r;if(n=e[i],o=n,!Ze(n)&&(o=Ye[(r=String(n)).toLowerCase()],void 0===o))throw new V(`Unknown adapter '${r}'`);if(o&&(z.isFunction(o)||(o=o.get(t))))break;a[r||"#"+i]=o}if(!o){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new V("There is no suitable adapter to dispatch the request "+(r?e.length>1?"since :\n"+e.map(Qe).join("\n"):" "+Qe(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function tt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Re(null,e)}function rt(e){return tt(e),e.headers=Pe.from(e.headers),e.data=Ce.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et(e.adapter||ge.adapter,e)(e).then(function(t){return tt(e),t.data=Ce.call(e,e.transformResponse,t),t.headers=Pe.from(t.headers),t},function(t){return He(t)||(tt(e),t&&t.response&&(t.response.data=Ce.call(e,e.transformResponse,t.response),t.response.headers=Pe.from(t.response.headers))),Promise.reject(t)})}const nt="1.13.2",ot={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ot[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const at={};ot.transitional=function(e,t,r){function n(e,t){return"[Axios v"+nt+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,a)=>{if(!1===e)throw new V(n(o," has been removed"+(t?" in "+t:"")),V.ERR_DEPRECATED);return t&&!at[o]&&(at[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,a)}},ot.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var it={assertOptions:function(e,t,r){if("object"!=typeof e)throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const a=n[o],i=t[a];if(i){const t=e[a],r=void 0===t||i(t,a,e);if(!0!==r)throw new V("option "+a+" must be "+r,V.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new V("Unknown option "+a,V.ERR_BAD_OPTION)}},validators:ot};const st=it.validators;class ct{constructor(e){this.defaults=e||{},this.interceptors={request:new se,response:new se}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=De(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;void 0!==r&&it.assertOptions(r,{silentJSONParsing:st.transitional(st.boolean),forcedJSONParsing:st.transitional(st.boolean),clarifyTimeoutError:st.transitional(st.boolean)},!1),null!=n&&(z.isFunction(n)?t.paramsSerializer={serialize:n}:it.assertOptions(n,{encode:st.function,serialize:st.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),it.assertOptions(t,{baseUrl:st.spelling("baseURL"),withXsrfToken:st.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=o&&z.merge(o.common,o[t.method]);o&&z.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Pe.concat(a,o);const i=[];let s=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const c=[];let d;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,l=0;if(!s){const e=[rt.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,d=Promise.resolve(t);l<u;)d=d.then(e[l++],e[l++]);return d}u=i.length;let p=t;for(;l<u;){const e=i[l++],t=i[l++];try{p=e(p)}catch(e){t.call(this,e);break}}try{d=rt.call(this,p)}catch(e){return Promise.reject(e)}for(l=0,u=c.length;l<u;)d=d.then(c[l++],c[l++]);return d}getUri(e){return ie(xe((e=De(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}z.forEach(["delete","get","head","options"],function(e){ct.prototype[e]=function(t,r){return this.request(De(r||{},{method:e,url:t,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,o){return this.request(De(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ct.prototype[e]=t(),ct.prototype[e+"Form"]=t(!0)});var dt=ct;class ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,o){r.reason||(r.reason=new Re(e,n,o),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new ut(function(t){e=t}),cancel:e}}}var lt=ut;const pt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(pt).forEach(([e,t])=>{pt[t]=e});var ht=pt;const ft=function e(t){const r=new dt(t),o=n(dt.prototype.request,r);return z.extend(o,dt.prototype,r,{allOwnKeys:!0}),z.extend(o,r,null,{allOwnKeys:!0}),o.create=function(r){return e(De(t,r))},o}(ge);ft.Axios=dt,ft.CanceledError=Re,ft.CancelToken=lt,ft.isCancel=He,ft.VERSION=nt,ft.toFormData=te,ft.AxiosError=V,ft.Cancel=ft.CanceledError,ft.all=function(e){return Promise.all(e)},ft.spread=function(e){return function(t){return e.apply(null,t)}},ft.isAxiosError=function(e){return z.isObject(e)&&!0===e.isAxiosError},ft.mergeConfig=De,ft.AxiosHeaders=Pe,ft.formToJSON=e=>we(z.isHTMLForm(e)?new FormData(e):e),ft.getAdapter=et,ft.HttpStatusCode=ht,ft.default=ft,e.exports=ft}}]);
|