try{var e,t;(t=(new(e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{}).Error).stack)&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9ca6faeb-2a80-4fdb-baf1-690fd24532c1",e._sentryDebugIdIdentifier="sentry-dbid-9ca6faeb-2a80-4fdb-baf1-690fd24532c1")}catch(e){}try{("u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{}).SENTRY_RELEASE={id:"1.26.1"}}catch(e){}var r={47055(e,t,r){"use strict";var i;let n;Object.defineProperty(t,"__esModule",{value:!0}),t.AuthRejectedError=void 0,t.sendAuthCode=y,t.loginWithCode=_,t.logOut=m,t.getLastUserData=function(){try{var e;let t=localStorage.getItem("last_jwt"),r=(e=t)?(0,s.decodeJwt)(e):null;if(r){if(!r.exp)throw Error("Missing expiry in JWT data");if(1e3*r.exp<Date.now())throw Error("Last JWT expired");E(t,"app").catch(e=>{localStorage.removeItem("last_jwt"),console.log("Last JWT no longer valid - now cleared",e)})}return P(r)}catch(e){return console.warn("Couldn't parse saved user data",e),w()}},t.getLatestUserData=v,t.getBillingData=g,t.getUserFromAppJwt=S,t.updateTeamMembers=C,t.cancelSubscription=W;let o=r(64578),a=r(1681),s=r(60257),c=r(97489),l=r(71097),d=(null==(i=null==globalThis?void 0:globalThis.crypto)?void 0:i.subtle)?(0,s.importSPKI)(`
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzRLZvRoiWBQS8Fdqqh/h
xVDI+ogFZ2LdIiMOQmkq2coYNvBXGX016Uw9KNlweUlCXUaQZkDuQBmwxcs80PEn
IliLvJnOcIA9bAJFEF36uIwSI/ZRj0faExanLO78cdIx+B+p69kFGlohQGzJmS1S
v/IYYu032hO+F5ypR+AoXn6qtGGLVN0zAvsvLEF3urY5jHiVbgk2FWD3FWMU3oBF
jEEjeSlAFnwJZgeEMFeYni7W/rQ8seU8y3YMIg2UyHpeVNnuWbJFFwGq8Aumg4SC
mCVpul3MYubdv034/ipGZSKJTwgubiHocrSBdeImNe3xdxOw/Mo04r0kcZBg2l/b
7QIDAQAB
-----END PUBLIC KEY-----
`.trim(),"RS256"):Promise.reject(Error("WebCrypto not available in your browser. Auth is only possible in secure contexts (HTTPS).")),u=new o.Mutex;if("u">typeof localStorage)try{n=JSON.parse(localStorage.getItem("tokens"))}catch(e){n=null,console.log("Invalid token",localStorage.getItem("tokens"),e)}function p(e){return u.runExclusive(()=>{n=e,localStorage.setItem("tokens",JSON.stringify(e))})}function h(){return u.runExclusive(()=>{if(!n)return;let e=n.accessTokenExpiry.valueOf()-Date.now(),t=e<6e5&&n.refreshToken?b(n.refreshToken):null;return e>5e3?n.accessToken:t?t:void m()})}class f extends a.CustomError{constructor(){super("Authentication failed")}}async function y(e,t){try{let r=await fetch(`${c.ACCOUNTS_API_BASE}/auth/send-code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,source:t})});if(!r.ok){let e=await r.text().catch(e=>`[Response body unavailable: ${(0,a.asErrorLike)(e).message||e}]`);throw Error(`Unexpected ${r.status} response: ${e}`)}}catch(e){throw Error(`Failed to send auth code: ${(0,a.asErrorLike)(e).message||e}`)}}async function _(e,t){try{let r=await fetch(`${c.ACCOUNTS_API_BASE}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,code:t})});if(!r.ok)if(403===r.status)throw new f;else{let e=await r.text().catch(e=>`[Response body unavailable: ${(0,a.asErrorLike)(e).message||e}]`);throw Error(`Unexpected ${r.status} response: ${e}`)}let i=await r.json();await p({accessToken:i.accessToken,refreshToken:i.refreshToken,accessTokenExpiry:i.expiresAt})}catch(e){if(e instanceof f)throw e;throw Error(`Failed to login with code: ${(0,a.asErrorLike)(e).message||e}`)}}function m(){p(null)}async function b(e){try{let t=await fetch(`${c.ACCOUNTS_API_BASE}/auth/refresh-token`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!t.ok)if(403===t.status)throw new f;else throw Error(`Unexpected ${t.status} response when refreshing token`);let r=await t.json();return n.accessToken=r.accessToken,n.accessTokenExpiry=r.expiresAt,localStorage.setItem("tokens",JSON.stringify(n)),r.accessToken}catch(e){if(e instanceof f)throw e;throw Error(`Failed to refresh token: ${(0,a.asErrorLike)(e).message||e}`)}}t.AuthRejectedError=f;let w=()=>k({featureFlags:[],banned:!1});async function v(){try{let e=await T("app"),t=await E(e,"app"),r=P(t);return localStorage.setItem("last_jwt",e),r}catch(e){try{let e=localStorage.getItem("last_jwt"),t=await E(e,"app");return P(t)}catch(e){return console.warn("Failed to validate last user JWT when updating",e),w()}}}async function g(){let e=await T("billing");return O(await E(e,"billing"))}async function S(e){return P(await E(e,"app"))}async function E(e,t){return e?(await (0,s.jwtVerify)(e,await d,{algorithms:["RS256"],audience:`https://httptoolkit.tech/${t}_data`,issuer:"https://httptoolkit.tech/"})).payload:null}function P(e){return e?k({userId:e.user_id,email:e.email,subscription:A(e),teamSubscription:e.team_subscription?A(e.team_subscription):void 0,featureFlags:e.feature_flags||[],banned:!!e.banned}):w()}function k(e){let t=Object.assign(Object.assign({},e),{isStatusUnexpired(){var e,r;let i=null==(e=t.subscription)?void 0:e.expiry,n=null==(r=t.subscription)?void 0:r.status;return!!i&&i.valueOf()+6048e5*("active"===n)>Date.now()},isPaidUser(){var e;return(null==(e=t.subscription)?void 0:e.status)!=="past_due"&&t.isStatusUnexpired()},isPastDueUser(){var e;return(null==(e=t.subscription)?void 0:e.status)==="past_due"&&t.isStatusUnexpired()},userHasSubscription(){return this.isPaidUser()||this.isPastDueUser()}});return t}async function O(e){var t,r;if(!e)return{transactions:[],banned:!1};let i=null!=(r=null==(t=e.transactions)?void 0:t.map(e=>({orderId:e.order_id,receiptUrl:e.receipt_url,sku:e.sku,createdAt:e.created_at,status:e.status,amount:e.amount,currency:e.currency})))?r:null;return{email:e.email,subscription:A(e),transactions:i,teamMembers:e.team_members,teamOwner:e.team_owner,lockedLicenseExpiries:e.locked_license_expiries,banned:!!e.banned}}function A(e){var t,r;let i=null!=(t=e.subscription_sku)?t:(0,l.getSKUForPaddleId)(e.subscription_plan_id),[n,o]=i?i.split("-"):[],s={status:e.subscription_status,plan:i,sku:i,tierCode:n,interval:o,quantity:e.subscription_quantity,expiry:e.subscription_expiry?new Date(e.subscription_expiry):void 0,updateBillingDetailsUrl:e.update_url,cancelSubscriptionUrl:e.cancel_url,lastReceiptUrl:e.last_receipt_url,canManageSubscription:!!e.can_manage_subscription};if(Object.values(s).some(Boolean)&&!s.plan)throw console.warn("Invalid raw subscription data",e),new a.CustomError("Invalid subscription data");return(r=["lastReceiptUrl","updateBillingDetailsUrl","cancelSubscriptionUrl"],Object.entries(s).filter(([e])=>!r.includes(e)).every(([e,t])=>null!=t))?s:void 0}async function T(e,t={}){let r=await h();if(!r)return"";let i=await fetch(`${c.ACCOUNTS_API_BASE}/get-${e}-data`,{method:"GET",headers:{Authorization:`Bearer ${r}`}});if(!i.ok){if(console.log(`Received ${i.status} loading ${e} data, with body: ${await i.text()}`),401===i.status)return u.runExclusive(()=>{if(t.isRetry||!(null==n?void 0:n.refreshToken))throw new f;return b(n.refreshToken)}).then(()=>T(e,{isRetry:!0}));throw Error(`Failed to load ${e} data`)}return i.text()}async function C(e,t){let r=await h();if(!r)throw Error("Can't update team without an auth token");let i=await fetch(`${c.ACCOUNTS_API_BASE}/update-team`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({idsToRemove:e,emailsToAdd:t})});if(!i.ok){let e=await i.text();throw console.log(`Received ${i.status} updating team members: ${e}`),Error(e||"Failed to update team members")}}async function W(){let e=await h();if(!e)throw Error("Can't cancel account without an auth token");let t=await fetch(`${c.ACCOUNTS_API_BASE}/cancel-subscription`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Unexpected ${t.status} response cancelling subscription`)}},14025(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepareCheckout=function(e,t,r){fetch(n(e,t,r),{redirect:"manual"}).catch(()=>{})},t.prefetchCheckout=function(e,t,r){!function(e){if(document.head.querySelector(`link[href='${e}'][rel=prefetch]`))return;let t=document.createElement("link");t.setAttribute("rel","prefetch"),t.setAttribute("href",e),document.head.appendChild(t)}(n(e,t,r))},t.goToCheckout=o,t.openNewCheckoutWindow=function(e,t,r){window.open(n(e,t,r),"_blank")};let i=r(97489),n=(e,t,r)=>`${i.ACCOUNTS_API_BASE}/redirect-to-checkout?email=${encodeURIComponent(e)}&sku=${t}&source=${window.location.hostname}&returnUrl=${encodeURIComponent(`https://httptoolkit.com/${r}-purchase-thank-you/`)}`;async function o(e,t,r){window.location.assign(n(e,t,r))}},10185(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.updateTeamMembers=t.getBillingData=t.cancelSubscription=t.getUserFromAppJwt=t.getLastUserData=t.getLatestUserData=t.AuthRejectedError=t.logOut=t.sendAuthCode=t.loginWithCode=t.openNewCheckoutWindow=t.goToCheckout=t.prefetchCheckout=t.prepareCheckout=t.loadPlanPricesUntilSuccess=t.getPlanByCode=t.getSKUForPaddleId=t.SubscriptionPlans=void 0,n(r(17752),t);var o=r(71097);Object.defineProperty(t,"SubscriptionPlans",{enumerable:!0,get:function(){return o.SubscriptionPlans}}),Object.defineProperty(t,"getSKUForPaddleId",{enumerable:!0,get:function(){return o.getSKUForPaddleId}}),Object.defineProperty(t,"getPlanByCode",{enumerable:!0,get:function(){return o.getPlanByCode}}),Object.defineProperty(t,"loadPlanPricesUntilSuccess",{enumerable:!0,get:function(){return o.loadPlanPricesUntilSuccess}});var a=r(14025);Object.defineProperty(t,"prepareCheckout",{enumerable:!0,get:function(){return a.prepareCheckout}}),Object.defineProperty(t,"prefetchCheckout",{enumerable:!0,get:function(){return a.prefetchCheckout}}),Object.defineProperty(t,"goToCheckout",{enumerable:!0,get:function(){return a.goToCheckout}}),Object.defineProperty(t,"openNewCheckoutWindow",{enumerable:!0,get:function(){return a.openNewCheckoutWindow}});var s=r(47055);Object.defineProperty(t,"loginWithCode",{enumerable:!0,get:function(){return s.loginWithCode}}),Object.defineProperty(t,"sendAuthCode",{enumerable:!0,get:function(){return s.sendAuthCode}}),Object.defineProperty(t,"logOut",{enumerable:!0,get:function(){return s.logOut}}),Object.defineProperty(t,"AuthRejectedError",{enumerable:!0,get:function(){return s.AuthRejectedError}}),Object.defineProperty(t,"getLatestUserData",{enumerable:!0,get:function(){return s.getLatestUserData}}),Object.defineProperty(t,"getLastUserData",{enumerable:!0,get:function(){return s.getLastUserData}}),Object.defineProperty(t,"getUserFromAppJwt",{enumerable:!0,get:function(){return s.getUserFromAppJwt}}),Object.defineProperty(t,"cancelSubscription",{enumerable:!0,get:function(){return s.cancelSubscription}}),Object.defineProperty(t,"getBillingData",{enumerable:!0,get:function(){return s.getBillingData}}),Object.defineProperty(t,"updateTeamMembers",{enumerable:!0,get:function(){return s.updateTeamMembers}})},71097(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSKUForPaddleId=t.getPlanByCode=t.SubscriptionPlans=void 0,t.loadPlanPricesUntilSuccess=a;let i=r(1681),n=r(97489);async function o(){let e=await fetch(`${n.ACCOUNTS_API_BASE}/get-prices`);if(!e.ok)throw console.log(e),Error(`Failed to look up prices, got ${e.status}: ${e.statusText}`);let r=await e.json();if(!r.success)throw console.log(r),Error("Price lookup request was unsuccessful");return r.response.products.forEach(e=>{let r=Object.values(t.SubscriptionPlans).find(t=>t.paddleId===e.product_id);if(!r)return;let i=e.currency,n=e.price.net,o="year"===e.subscription.interval?n/12:n;r.prices={rawTotal:n,currency:i,total:s(i,n),monthly:s(i,o)}}),t.SubscriptionPlans}async function a(){return await (0,i.doWhile)(()=>Promise.race([o().catch(console.warn),(0,i.delay)(5e3)]).then(()=>(0,i.delay)(1e3)),()=>Object.values(t.SubscriptionPlans).some(e=>!e.prices)),t.SubscriptionPlans}function s(e,t){return Number(t).toLocaleString(void 0,{style:"currency",currency:e,minimumFractionDigits:2*(Math.round(t)!==t),maximumFractionDigits:2})}t.SubscriptionPlans={"pro-monthly":{paddleId:550380,name:"Pro (monthly)"},"pro-annual":{paddleId:550382,name:"Pro (annual)"},"team-monthly":{paddleId:550789,name:"Team (monthly)"},"team-annual":{paddleId:550788,name:"Team (annual)"},"pro-perpetual":{paddleId:599788,name:"Pro (perpetual)",prices:"priceless"}},t.getPlanByCode=e=>t.SubscriptionPlans[e],t.getSKUForPaddleId=e=>Object.keys(t.SubscriptionPlans).find(r=>t.SubscriptionPlans[r].paddleId===e)},17752(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},97489(e,t){"use strict";var r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.ACCOUNTS_API_BASE=void 0,t.ACCOUNTS_API_BASE=null!=(i=null!=(r=process.env.ACCOUNTS_API)?r:process.env.GATSBY_ACCOUNTS_API)?i:"https://accounts.httptoolkit.tech/api"},53705(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(8674),n=r(45312);t.default=function(){function e(){this._semaphore=new n.default(1)}return e.prototype.acquire=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return[4,this._semaphore.acquire()];case 1:return[2,e.sent()[1]]}})})},e.prototype.runExclusive=function(e){return this._semaphore.runExclusive(function(){return e()})},e.prototype.isLocked=function(){return this._semaphore.isLocked()},e.prototype.release=function(){this._semaphore.release()},e}()},45312(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(8674);t.default=function(){function e(e){if(this._maxConcurrency=e,this._queue=[],e<=0)throw Error("semaphore must be initialized to a positive value");this._value=e}return e.prototype.acquire=function(){var e=this,t=this.isLocked(),r=new Promise(function(t){return e._queue.push(t)});return t||this._dispatch(),r},e.prototype.runExclusive=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,r,n;return i.__generator(this,function(i){switch(i.label){case 0:return[4,this.acquire()];case 1:r=(t=i.sent())[0],n=t[1],i.label=2;case 2:return i.trys.push([2,,4,5]),[4,e(r)];case 3:return[2,i.sent()];case 4:return n(),[7];case 5:return[2]}})})},e.prototype.isLocked=function(){return this._value<=0},e.prototype.release=function(){if(this._maxConcurrency>1)throw Error("this method is unavailabel on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){var e=this._currentReleaser;this._currentReleaser=void 0,e()}},e.prototype._dispatch=function(){var e=this,t=this._queue.shift();if(t){var r=!1;this._currentReleaser=function(){r||(r=!0,e._value++,e._dispatch())},t([this._value--,this._currentReleaser])}},e}()},64578(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.Semaphore=t.Mutex=void 0;var i=r(53705);Object.defineProperty(t,"Mutex",{enumerable:!0,get:function(){return i.default}});var n=r(45312);Object.defineProperty(t,"Semaphore",{enumerable:!0,get:function(){return n.default}});var o=r(21977);Object.defineProperty(t,"withTimeout",{enumerable:!0,get:function(){return o.withTimeout}})},21977(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=void 0;var i=r(8674);t.withTimeout=function(e,t,r){var n=this;return void 0===r&&(r=Error("timeout")),{acquire:function(){return new Promise(function(o,a){return i.__awaiter(n,void 0,void 0,function(){var n,s;return i.__generator(this,function(i){switch(i.label){case 0:return n=!1,setTimeout(function(){n=!0,a(r)},t),[4,e.acquire()];case 1:return s=i.sent(),n?(Array.isArray(s)?s[1]:s)():o(s),[2]}})})})},runExclusive:function(e){return i.__awaiter(this,void 0,void 0,function(){var t,r;return i.__generator(this,function(i){switch(i.label){case 0:t=function(){},i.label=1;case 1:return i.trys.push([1,,7,8]),[4,this.acquire()];case 2:if(!Array.isArray(r=i.sent()))return[3,4];return t=r[1],[4,e(r[0])];case 3:case 5:return[2,i.sent()];case 4:return t=r,[4,e()];case 6:return[3,8];case 7:return t(),[7];case 8:return[2]}})})},release:function(){e.release()},isLocked:function(){return e.isLocked()}}}},17318(e,t){"use strict";function r(e){return e&&"object"==typeof e&&(e instanceof Error||e.message||e.code||e.stack)}Object.defineProperty(t,"__esModule",{value:!0}),t.unreachableCheck=t.UnreachableCheck=t.StatusError=t.CustomError=t.asErrorLike=t.isErrorLike=void 0,t.isErrorLike=r,t.asErrorLike=function(e){return r(e)?e:e?Error(e.message||e.toString()||"[Unknown error]"):Error("[Undefined error]")};class i extends Error{constructor(e,t={}){super(e),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype),void 0!==t.code&&(this.code=t.code),void 0!==t.statusCode&&(this.statusCode=t.statusCode),void 0!==t.cause&&(this.cause=t.cause)}}t.CustomError=i,t.StatusError=class extends i{constructor(e,t,r={}){super(t,{...r,statusCode:e})}};class n extends i{constructor(e,t=e=>e){super(`Unhandled case value: ${t(e)}`)}}t.UnreachableCheck=n,t.unreachableCheck=(e,t=e=>e)=>{throw new n(e,t)}},1681(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(37991),t),n(r(17318),t),n(r(71530),t)},37991(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.combineParallelCalls=t.getDeferred=t.doWhile=t.delay=void 0,t.delay=(e,t={})=>new Promise(r=>{let i=setTimeout(r,e);t.unref&&i.unref&&i.unref()}),t.doWhile=async function(e,t){do await e();while(await t())},t.getDeferred=function(){let e,t,r=new Promise((r,i)=>{e=r,t=i});return Object.assign(r,{resolve:e,reject:t,promise:r})},t.combineParallelCalls=function(e){let t;return()=>(void 0===t&&(t=e().finally(()=>{t=void 0})),t)}},71530(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aOrAn=t.joinAnd=t.truncateWithEllipsis=void 0,t.truncateWithEllipsis=function(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."},t.joinAnd=function(e,t={}){if(1===e.length)return e[0];let r=t.separator??", ",i=t.finalSeparator??"and ",n=t.oxfordComma??!1;return e.slice(0,-1).join(r)+(n?r:" ")+i+e[e.length-1]};let r=["a","e","i","o","u","y"];t.aOrAn=function(e){return r.includes(e[0].toLowerCase())?"an":"a"}},60257(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cryptoRuntime=t.base64url=t.generateSecret=t.generateKeyPair=t.errors=t.decodeJwt=t.decodeProtectedHeader=t.importJWK=t.importX509=t.importPKCS8=t.importSPKI=t.exportJWK=t.exportSPKI=t.exportPKCS8=t.UnsecuredJWT=t.experimental_jwksCache=t.jwksCache=t.createRemoteJWKSet=t.createLocalJWKSet=t.EmbeddedJWK=t.calculateJwkThumbprintUri=t.calculateJwkThumbprint=t.EncryptJWT=t.SignJWT=t.GeneralSign=t.FlattenedSign=t.CompactSign=t.FlattenedEncrypt=t.CompactEncrypt=t.jwtDecrypt=t.jwtVerify=t.generalVerify=t.flattenedVerify=t.compactVerify=t.GeneralEncrypt=t.generalDecrypt=t.flattenedDecrypt=t.compactDecrypt=void 0;var i=r(66923);Object.defineProperty(t,"compactDecrypt",{enumerable:!0,get:function(){return i.compactDecrypt}});var n=r(54533);Object.defineProperty(t,"flattenedDecrypt",{enumerable:!0,get:function(){return n.flattenedDecrypt}});var o=r(10774);Object.defineProperty(t,"generalDecrypt",{enumerable:!0,get:function(){return o.generalDecrypt}});var a=r(40782);Object.defineProperty(t,"GeneralEncrypt",{enumerable:!0,get:function(){return a.GeneralEncrypt}});var s=r(51427);Object.defineProperty(t,"compactVerify",{enumerable:!0,get:function(){return s.compactVerify}});var c=r(96833);Object.defineProperty(t,"flattenedVerify",{enumerable:!0,get:function(){return c.flattenedVerify}});var l=r(49060);Object.defineProperty(t,"generalVerify",{enumerable:!0,get:function(){return l.generalVerify}});var d=r(43082);Object.defineProperty(t,"jwtVerify",{enumerable:!0,get:function(){return d.jwtVerify}});var u=r(83814);Object.defineProperty(t,"jwtDecrypt",{enumerable:!0,get:function(){return u.jwtDecrypt}});var p=r(47815);Object.defineProperty(t,"CompactEncrypt",{enumerable:!0,get:function(){return p.CompactEncrypt}});var h=r(9805);Object.defineProperty(t,"FlattenedEncrypt",{enumerable:!0,get:function(){return h.FlattenedEncrypt}});var f=r(79851);Object.defineProperty(t,"CompactSign",{enumerable:!0,get:function(){return f.CompactSign}});var y=r(94329);Object.defineProperty(t,"FlattenedSign",{enumerable:!0,get:function(){return y.FlattenedSign}});var _=r(77440);Object.defineProperty(t,"GeneralSign",{enumerable:!0,get:function(){return _.GeneralSign}});var m=r(42230);Object.defineProperty(t,"SignJWT",{enumerable:!0,get:function(){return m.SignJWT}});var b=r(76638);Object.defineProperty(t,"EncryptJWT",{enumerable:!0,get:function(){return b.EncryptJWT}});var w=r(82599);Object.defineProperty(t,"calculateJwkThumbprint",{enumerable:!0,get:function(){return w.calculateJwkThumbprint}}),Object.defineProperty(t,"calculateJwkThumbprintUri",{enumerable:!0,get:function(){return w.calculateJwkThumbprintUri}});var v=r(87897);Object.defineProperty(t,"EmbeddedJWK",{enumerable:!0,get:function(){return v.EmbeddedJWK}});var g=r(26980);Object.defineProperty(t,"createLocalJWKSet",{enumerable:!0,get:function(){return g.createLocalJWKSet}});var S=r(29877);Object.defineProperty(t,"createRemoteJWKSet",{enumerable:!0,get:function(){return S.createRemoteJWKSet}}),Object.defineProperty(t,"jwksCache",{enumerable:!0,get:function(){return S.jwksCache}}),Object.defineProperty(t,"experimental_jwksCache",{enumerable:!0,get:function(){return S.experimental_jwksCache}});var E=r(50049);Object.defineProperty(t,"UnsecuredJWT",{enumerable:!0,get:function(){return E.UnsecuredJWT}});var P=r(50068);Object.defineProperty(t,"exportPKCS8",{enumerable:!0,get:function(){return P.exportPKCS8}}),Object.defineProperty(t,"exportSPKI",{enumerable:!0,get:function(){return P.exportSPKI}}),Object.defineProperty(t,"exportJWK",{enumerable:!0,get:function(){return P.exportJWK}});var k=r(87364);Object.defineProperty(t,"importSPKI",{enumerable:!0,get:function(){return k.importSPKI}}),Object.defineProperty(t,"importPKCS8",{enumerable:!0,get:function(){return k.importPKCS8}}),Object.defineProperty(t,"importX509",{enumerable:!0,get:function(){return k.importX509}}),Object.defineProperty(t,"importJWK",{enumerable:!0,get:function(){return k.importJWK}});var O=r(14443);Object.defineProperty(t,"decodeProtectedHeader",{enumerable:!0,get:function(){return O.decodeProtectedHeader}});var A=r(38396);Object.defineProperty(t,"decodeJwt",{enumerable:!0,get:function(){return A.decodeJwt}}),t.errors=r(36247);var T=r(30409);Object.defineProperty(t,"generateKeyPair",{enumerable:!0,get:function(){return T.generateKeyPair}});var C=r(16502);Object.defineProperty(t,"generateSecret",{enumerable:!0,get:function(){return C.generateSecret}}),t.base64url=r(18462);var W=r(4166);Object.defineProperty(t,"cryptoRuntime",{enumerable:!0,get:function(){return W.default}})},66923(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compactDecrypt=a;let i=r(54533),n=r(36247),o=r(35821);async function a(e,t,r){if(e instanceof Uint8Array&&(e=o.decoder.decode(e)),"string"!=typeof e)throw new n.JWEInvalid("Compact JWE must be a string or Uint8Array");let{0:a,1:s,2:c,3:l,4:d,length:u}=e.split(".");if(5!==u)throw new n.JWEInvalid("Invalid Compact JWE");let p=await (0,i.flattenedDecrypt)({ciphertext:l,iv:c||void 0,protected:a,tag:d||void 0,encrypted_key:s||void 0},t,r),h={plaintext:p.plaintext,protectedHeader:p.protectedHeader};return"function"==typeof t?{...h,key:p.key}:h}},47815(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CompactEncrypt=void 0;let i=r(9805);t.CompactEncrypt=class{_flattened;constructor(e){this._flattened=new i.FlattenedEncrypt(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){let r=await this._flattened.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}},54533(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenedDecrypt=h;let i=r(40082),n=r(54799),o=r(36247),a=r(49476),s=r(41855),c=r(24760),l=r(35821),d=r(51784),u=r(82458),p=r(68604);async function h(e,t,r){let h,f,y,_,m,b,w;if(!(0,s.default)(e))throw new o.JWEInvalid("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new o.JWEInvalid("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new o.JWEInvalid("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new o.JWEInvalid("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new o.JWEInvalid("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new o.JWEInvalid("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new o.JWEInvalid("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new o.JWEInvalid("JWE AAD incorrect type");if(void 0!==e.header&&!(0,s.default)(e.header))throw new o.JWEInvalid("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!(0,s.default)(e.unprotected))throw new o.JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");if(e.protected)try{let t=(0,i.decode)(e.protected);h=JSON.parse(l.decoder.decode(t))}catch{throw new o.JWEInvalid("JWE Protected Header is invalid")}if(!(0,a.default)(h,e.header,e.unprotected))throw new o.JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let v={...h,...e.header,...e.unprotected};if((0,u.default)(o.JWEInvalid,new Map,r?.crit,h,v),void 0!==v.zip)throw new o.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');let{alg:g,enc:S}=v;if("string"!=typeof g||!g)throw new o.JWEInvalid("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof S||!S)throw new o.JWEInvalid("missing JWE Encryption Algorithm (enc) in JWE Header");let E=r&&(0,p.default)("keyManagementAlgorithms",r.keyManagementAlgorithms),P=r&&(0,p.default)("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(E&&!E.has(g)||!E&&g.startsWith("PBES2"))throw new o.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(P&&!P.has(S))throw new o.JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter value not allowed');if(void 0!==e.encrypted_key)try{f=(0,i.decode)(e.encrypted_key)}catch{throw new o.JWEInvalid("Failed to base64url decode the encrypted_key")}let k=!1;"function"==typeof t&&(t=await t(h,e),k=!0);try{y=await (0,c.default)(g,t,f,v,r)}catch(e){if(e instanceof TypeError||e instanceof o.JWEInvalid||e instanceof o.JOSENotSupported)throw e;y=(0,d.default)(S)}if(void 0!==e.iv)try{_=(0,i.decode)(e.iv)}catch{throw new o.JWEInvalid("Failed to base64url decode the iv")}if(void 0!==e.tag)try{m=(0,i.decode)(e.tag)}catch{throw new o.JWEInvalid("Failed to base64url decode the tag")}let O=l.encoder.encode(e.protected??"");b=void 0!==e.aad?(0,l.concat)(O,l.encoder.encode("."),l.encoder.encode(e.aad)):O;try{w=(0,i.decode)(e.ciphertext)}catch{throw new o.JWEInvalid("Failed to base64url decode the ciphertext")}let A={plaintext:await (0,n.default)(S,y,w,_,m,b)};if(void 0!==e.protected&&(A.protectedHeader=h),void 0!==e.aad)try{A.additionalAuthenticatedData=(0,i.decode)(e.aad)}catch{throw new o.JWEInvalid("Failed to base64url decode the aad")}return(void 0!==e.unprotected&&(A.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(A.unprotectedHeader=e.header),k)?{...A,key:t}:A}},9805(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlattenedEncrypt=void 0;let i=r(40082),n=r(93688),o=r(82027),a=r(90508),s=r(36247),c=r(49476),l=r(35821),d=r(82458);t.FlattenedEncrypt=class{_plaintext;_protectedHeader;_sharedUnprotectedHeader;_unprotectedHeader;_aad;_cek;_iv;_keyManagementParameters;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw 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 TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,t){let r,u,p,h,f;if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new s.JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!(0,c.default)(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new s.JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let y={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if((0,d.default)(s.JWEInvalid,new Map,t?.crit,this._protectedHeader,y),void 0!==y.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');let{alg:_,enc:m}=y;if("string"!=typeof _||!_)throw new s.JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof m||!m)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(this._cek&&("dir"===_||"ECDH-ES"===_))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${_}`);{let i;({cek:u,encryptedKey:r,parameters:i}=await (0,a.default)(_,m,e,this._cek,this._keyManagementParameters)),i&&(t&&n.unprotected in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...i}:this.setUnprotectedHeader(i):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...i}:this.setProtectedHeader(i))}h=this._protectedHeader?l.encoder.encode((0,i.encode)(JSON.stringify(this._protectedHeader))):l.encoder.encode(""),this._aad?(f=(0,i.encode)(this._aad),p=(0,l.concat)(h,l.encoder.encode("."),l.encoder.encode(f))):p=h;let{ciphertext:b,tag:w,iv:v}=await (0,o.default)(m,this._plaintext,u,this._iv,p),g={ciphertext:(0,i.encode)(b)};return v&&(g.iv=(0,i.encode)(v)),w&&(g.tag=(0,i.encode)(w)),r&&(g.encrypted_key=(0,i.encode)(r)),f&&(g.aad=f),this._protectedHeader&&(g.protected=l.decoder.decode(h)),this._sharedUnprotectedHeader&&(g.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(g.header=this._unprotectedHeader),g}}},10774(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generalDecrypt=a;let i=r(54533),n=r(36247),o=r(41855);async function a(e,t,r){if(!(0,o.default)(e))throw new n.JWEInvalid("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(o.default))throw new n.JWEInvalid("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new n.JWEInvalid("JWE Recipients has no members");for(let n of e.recipients)try{return await (0,i.flattenedDecrypt)({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{}throw new n.JWEDecryptionFailed}},40782(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GeneralEncrypt=void 0;let i=r(9805),n=r(93688),o=r(36247),a=r(51784),s=r(49476),c=r(90508),l=r(40082),d=r(82458);class u{parent;unprotectedHeader;key;options;constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setUnprotectedHeader(e){if(this.unprotectedHeader)throw 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}}t.GeneralEncrypt=class{_plaintext;_recipients=[];_protectedHeader;_unprotectedHeader;_aad;constructor(e){this._plaintext=e}addRecipient(e,t){let r=new u(this,e,{crit:t?.crit});return this._recipients.push(r),r}setProtectedHeader(e){if(this._protectedHeader)throw TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(){let e;if(!this._recipients.length)throw new o.JWEInvalid("at least one recipient must be added");if(1===this._recipients.length){let[e]=this._recipients,t=await new i.FlattenedEncrypt(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(e.unprotectedHeader).encrypt(e.key,{...e.options}),r={ciphertext:t.ciphertext,iv:t.iv,recipients:[{}],tag:t.tag};return t.aad&&(r.aad=t.aad),t.protected&&(r.protected=t.protected),t.unprotected&&(r.unprotected=t.unprotected),t.encrypted_key&&(r.recipients[0].encrypted_key=t.encrypted_key),t.header&&(r.recipients[0].header=t.header),r}for(let t=0;t<this._recipients.length;t++){let r=this._recipients[t];if(!(0,s.default)(this._protectedHeader,this._unprotectedHeader,r.unprotectedHeader))throw new o.JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let i={...this._protectedHeader,...this._unprotectedHeader,...r.unprotectedHeader},{alg:n}=i;if("string"!=typeof n||!n)throw new o.JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===n||"ECDH-ES"===n)throw new o.JWEInvalid('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof i.enc||!i.enc)throw new o.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(e){if(e!==i.enc)throw new o.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else e=i.enc;if((0,d.default)(o.JWEInvalid,new Map,r.options.crit,this._protectedHeader,i),void 0!==i.zip)throw new o.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.')}let t=(0,a.default)(e),r={ciphertext:"",iv:"",recipients:[],tag:""};for(let o=0;o<this._recipients.length;o++){let a=this._recipients[o],s={};r.recipients.push(s);let d=({...this._protectedHeader,...this._unprotectedHeader,...a.unprotectedHeader}).alg.startsWith("PBES2")?2048+o:void 0;if(0===o){let e=await new i.FlattenedEncrypt(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(t).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(a.unprotectedHeader).setKeyManagementParameters({p2c:d}).encrypt(a.key,{...a.options,[n.unprotected]:!0});r.ciphertext=e.ciphertext,r.iv=e.iv,r.tag=e.tag,e.aad&&(r.aad=e.aad),e.protected&&(r.protected=e.protected),e.unprotected&&(r.unprotected=e.unprotected),s.encrypted_key=e.encrypted_key,e.header&&(s.header=e.header);continue}let{encryptedKey:u,parameters:p}=await (0,c.default)(a.unprotectedHeader?.alg||this._protectedHeader?.alg||this._unprotectedHeader?.alg,e,a.key,t,{p2c:d});s.encrypted_key=(0,l.encode)(u),(a.unprotectedHeader||p)&&(s.header={...a.unprotectedHeader,...p})}return r}}},87897(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmbeddedJWK=a;let i=r(87364),n=r(41855),o=r(36247);async function a(e,t){let r={...e,...t?.header};if(!(0,n.default)(r.jwk))throw new o.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let a=await (0,i.importJWK)({...r.jwk,ext:!0},r.alg);if(a instanceof Uint8Array||"public"!==a.type)throw new o.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');return a}},82599(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calculateJwkThumbprint=l,t.calculateJwkThumbprintUri=d;let i=r(76332),n=r(40082),o=r(36247),a=r(35821),s=r(41855),c=(e,t)=>{if("string"!=typeof e||!e)throw new o.JWKInvalid(`${t} missing or invalid`)};async function l(e,t){let r;if(!(0,s.default)(e))throw TypeError("JWK must be an object");if("sha256"!==(t??="sha256")&&"sha384"!==t&&"sha512"!==t)throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');switch(e.kty){case"EC":c(e.crv,'"crv" (Curve) Parameter'),c(e.x,'"x" (X Coordinate) Parameter'),c(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":c(e.crv,'"crv" (Subtype of Key Pair) Parameter'),c(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":c(e.e,'"e" (Exponent) Parameter'),c(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":c(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new o.JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported')}let l=a.encoder.encode(JSON.stringify(r));return(0,n.encode)(await (0,i.default)(t,l))}async function d(e,t){t??="sha256";let r=await l(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}},26980(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createLocalJWKSet=function(e){let t=new c(e),r=async(e,r)=>t.getKey(e,r);return Object.defineProperties(r,{jwks:{value:()=>s(t._jwks),enumerable:!0,configurable:!1,writable:!1}}),r};let i=r(87364),n=r(36247),o=r(41855);function a(e){return(0,o.default)(e)}function s(e){return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}class c{_jwks;_cached=new WeakMap;constructor(e){if(!(e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(a)))throw new n.JWKSInvalid("JSON Web Key Set malformed");this._jwks=s(e)}async getKey(e,t){let{alg:r,kid:i}={...e,...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 n.JOSENotSupported('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 i&&(t=i===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)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;break;case"Ed25519":t="Ed25519"===e.crv;break;case"EdDSA":t="Ed25519"===e.crv||"Ed448"===e.crv}return t}),{0:s,length:c}=a;if(0===c)throw new n.JWKSNoMatchingKey;if(1!==c){let e=new n.JWKSMultipleMatchingKeys,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(let e of a)try{yield await l(t,e,r)}catch{}},e}return l(this._cached,s,r)}}async function l(e,t,r){let o=e.get(t)||e.set(t,{}).get(t);if(void 0===o[r]){let e=await (0,i.importJWK)({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new n.JWKSInvalid("JSON Web Key Set members must be public keys");o[r]=e}return o[r]}},29877(e,t,r){"use strict";let i;Object.defineProperty(t,"__esModule",{value:!0}),t.experimental_jwksCache=t.jwksCache=void 0,t.createRemoteJWKSet=function(e,t){let r=new c(e,t),i=async(e,t)=>r.getKey(e,t);return Object.defineProperties(i,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!r._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>r._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),i};let n=r(28832),o=r(36247),a=r(26980),s=r(41855);("u"<typeof navigator||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(i="jose/v5.10.0"),t.jwksCache=Symbol();class c{_url;_timeoutDuration;_cooldownDuration;_cacheMaxAge;_jwksTimestamp;_pendingFetch;_options;_local;_cache;constructor(e,r){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");if(this._url=new URL(e.href),this._options={agent:r?.agent,headers:r?.headers},this._timeoutDuration="number"==typeof r?.timeoutDuration?r?.timeoutDuration:5e3,this._cooldownDuration="number"==typeof r?.cooldownDuration?r?.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof r?.cacheMaxAge?r?.cacheMaxAge:6e5,r?.[t.jwksCache]!==void 0){var i,n;this._cache=r?.[t.jwksCache],i=r?.[t.jwksCache],n=this._cacheMaxAge,!("object"!=typeof i||null===i||!("uat"in i)||"number"!=typeof i.uat||Date.now()-i.uat>=n)&&"jwks"in i&&(0,s.default)(i.jwks)&&Array.isArray(i.jwks.keys)&&Array.prototype.every.call(i.jwks.keys,s.default)&&1&&(this._jwksTimestamp=this._cache.uat,this._local=(0,a.createLocalJWKSet)(this._cache.jwks))}}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._local&&this.fresh()||await this.reload();try{return await this._local(e,t)}catch(r){if(r instanceof o.JWKSNoMatchingKey&&!1===this.coolingDown())return await this.reload(),this._local(e,t);throw r}}async reload(){this._pendingFetch&&("u">typeof WebSocketPair||"u">typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"u">typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0);let e=new Headers(this._options.headers);i&&!e.has("User-Agent")&&(e.set("User-Agent",i),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||=(0,n.default)(this._url,this._timeoutDuration,this._options).then(e=>{this._local=(0,a.createLocalJWKSet)(e),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=e),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e}),await this._pendingFetch}}t.experimental_jwksCache=t.jwksCache},79851(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CompactSign=void 0;let i=r(94329);t.CompactSign=class{_flattened;constructor(e){this._flattened=new i.FlattenedSign(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){let r=await this._flattened.sign(e,t);if(void 0===r.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}},51427(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compactVerify=a;let i=r(96833),n=r(36247),o=r(35821);async function a(e,t,r){if(e instanceof Uint8Array&&(e=o.decoder.decode(e)),"string"!=typeof e)throw new n.JWSInvalid("Compact JWS must be a string or Uint8Array");let{0:a,1:s,2:c,length:l}=e.split(".");if(3!==l)throw new n.JWSInvalid("Invalid Compact JWS");let d=await (0,i.flattenedVerify)({payload:s,protected:a,signature:c},t,r),u={payload:d.payload,protectedHeader:d.protectedHeader};return"function"==typeof t?{...u,key:d.key}:u}},94329(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlattenedSign=void 0;let i=r(40082),n=r(47965),o=r(49476),a=r(36247),s=r(35821),c=r(11688),l=r(82458);t.FlattenedSign=class{_payload;_protectedHeader;_unprotectedHeader;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){let r;if(!this._protectedHeader&&!this._unprotectedHeader)throw new a.JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!(0,o.default)(this._protectedHeader,this._unprotectedHeader))throw new a.JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let d={...this._protectedHeader,...this._unprotectedHeader},u=(0,l.default)(a.JWSInvalid,new Map([["b64",!0]]),t?.crit,this._protectedHeader,d),p=!0;if(u.has("b64")&&"boolean"!=typeof(p=this._protectedHeader.b64))throw new a.JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:h}=d;if("string"!=typeof h||!h)throw new a.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');(0,c.checkKeyTypeWithJwk)(h,e,"sign");let f=this._payload;p&&(f=s.encoder.encode((0,i.encode)(f))),r=this._protectedHeader?s.encoder.encode((0,i.encode)(JSON.stringify(this._protectedHeader))):s.encoder.encode("");let y=(0,s.concat)(r,s.encoder.encode("."),f),_=await (0,n.default)(h,e,y),m={signature:(0,i.encode)(_),payload:""};return p&&(m.payload=s.decoder.decode(f)),this._unprotectedHeader&&(m.header=this._unprotectedHeader),this._protectedHeader&&(m.protected=s.decoder.decode(r)),m}}},96833(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenedVerify=f;let i=r(40082),n=r(33117),o=r(36247),a=r(35821),s=r(49476),c=r(41855),l=r(11688),d=r(82458),u=r(68604),p=r(26990),h=r(87364);async function f(e,t,r){let f,y;if(!(0,c.default)(e))throw new o.JWSInvalid("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new o.JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new o.JWSInvalid("JWS Protected Header incorrect type");if(void 0===e.payload)throw new o.JWSInvalid("JWS Payload missing");if("string"!=typeof e.signature)throw new o.JWSInvalid("JWS Signature missing or incorrect type");if(void 0!==e.header&&!(0,c.default)(e.header))throw new o.JWSInvalid("JWS Unprotected Header incorrect type");let _={};if(e.protected)try{let t=(0,i.decode)(e.protected);_=JSON.parse(a.decoder.decode(t))}catch{throw new o.JWSInvalid("JWS Protected Header is invalid")}if(!(0,s.default)(_,e.header))throw new o.JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let m={..._,...e.header},b=(0,d.default)(o.JWSInvalid,new Map([["b64",!0]]),r?.crit,_,m),w=!0;if(b.has("b64")&&"boolean"!=typeof(w=_.b64))throw new o.JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:v}=m;if("string"!=typeof v||!v)throw new o.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');let g=r&&(0,u.default)("algorithms",r.algorithms);if(g&&!g.has(v))throw new o.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(w){if("string"!=typeof e.payload)throw new o.JWSInvalid("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new o.JWSInvalid("JWS Payload must be a string or an Uint8Array instance");let S=!1;"function"==typeof t?(t=await t(_,e),S=!0,(0,l.checkKeyTypeWithJwk)(v,t,"verify"),(0,p.isJWK)(t)&&(t=await (0,h.importJWK)(t,v))):(0,l.checkKeyTypeWithJwk)(v,t,"verify");let E=(0,a.concat)(a.encoder.encode(e.protected??""),a.encoder.encode("."),"string"==typeof e.payload?a.encoder.encode(e.payload):e.payload);try{f=(0,i.decode)(e.signature)}catch{throw new o.JWSInvalid("Failed to base64url decode the signature")}if(!await (0,n.default)(v,t,f,E))throw new o.JWSSignatureVerificationFailed;if(w)try{y=(0,i.decode)(e.payload)}catch{throw new o.JWSInvalid("Failed to base64url decode the payload")}else y="string"==typeof e.payload?a.encoder.encode(e.payload):e.payload;let P={payload:y};return(void 0!==e.protected&&(P.protectedHeader=_),void 0!==e.header&&(P.unprotectedHeader=e.header),S)?{...P,key:t}:P}},77440(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GeneralSign=void 0;let i=r(94329),n=r(36247);class o{parent;protectedHeader;unprotectedHeader;options;key;constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setProtectedHeader(e){if(this.protectedHeader)throw TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw 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}}t.GeneralSign=class{_payload;_signatures=[];constructor(e){this._payload=e}addSignature(e,t){let r=new o(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new n.JWSInvalid("at least one signature must be added");let e={signatures:[],payload:""};for(let t=0;t<this._signatures.length;t++){let r=this._signatures[t],o=new i.FlattenedSign(this._payload);o.setProtectedHeader(r.protectedHeader),o.setUnprotectedHeader(r.unprotectedHeader);let{payload:a,...s}=await o.sign(r.key,r.options);if(0===t)e.payload=a;else if(e.payload!==a)throw new n.JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(s)}return e}}},49060(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generalVerify=a;let i=r(96833),n=r(36247),o=r(41855);async function a(e,t,r){if(!(0,o.default)(e))throw new n.JWSInvalid("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(o.default))throw new n.JWSInvalid("JWS Signatures missing or incorrect type");for(let n of e.signatures)try{return await (0,i.flattenedVerify)({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new n.JWSSignatureVerificationFailed}},83814(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.jwtDecrypt=a;let i=r(66923),n=r(70493),o=r(36247);async function a(e,t,r){let a=await (0,i.compactDecrypt)(e,t,r),s=(0,n.default)(a.protectedHeader,a.plaintext,r),{protectedHeader:c}=a;if(void 0!==c.iss&&c.iss!==s.iss)throw new o.JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch',s,"iss","mismatch");if(void 0!==c.sub&&c.sub!==s.sub)throw new o.JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch',s,"sub","mismatch");if(void 0!==c.aud&&JSON.stringify(c.aud)!==JSON.stringify(s.aud))throw new o.JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch',s,"aud","mismatch");let l={payload:s,protectedHeader:c};return"function"==typeof t?{...l,key:a.key}:l}},76638(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EncryptJWT=void 0;let i=r(47815),n=r(35821),o=r(10751);class a extends o.ProduceJWT{_cek;_iv;_keyManagementParameters;_protectedHeader;_replicateIssuerAsHeader;_replicateSubjectAsHeader;_replicateAudienceAsHeader;setProtectedHeader(e){if(this._protectedHeader)throw TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw 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){let r=new i.CompactEncrypt(n.encoder.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)}}t.EncryptJWT=a},10751(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProduceJWT=void 0;let i=r(70936),n=r(41855),o=r(49743);function a(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}t.ProduceJWT=class{_payload;constructor(e={}){if(!(0,n.default)(e))throw 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"number"==typeof e?this._payload={...this._payload,nbf:a("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:a("setNotBefore",(0,i.default)(e))}:this._payload={...this._payload,nbf:(0,i.default)(new Date)+(0,o.default)(e)},this}setExpirationTime(e){return"number"==typeof e?this._payload={...this._payload,exp:a("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:a("setExpirationTime",(0,i.default)(e))}:this._payload={...this._payload,exp:(0,i.default)(new Date)+(0,o.default)(e)},this}setIssuedAt(e){return void 0===e?this._payload={...this._payload,iat:(0,i.default)(new Date)}:e instanceof Date?this._payload={...this._payload,iat:a("setIssuedAt",(0,i.default)(e))}:"string"==typeof e?this._payload={...this._payload,iat:a("setIssuedAt",(0,i.default)(new Date)+(0,o.default)(e))}:this._payload={...this._payload,iat:a("setIssuedAt",e)},this}}},42230(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SignJWT=void 0;let i=r(79851),n=r(36247),o=r(35821),a=r(10751);class s extends a.ProduceJWT{_protectedHeader;setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){let r=new i.CompactSign(o.encoder.encode(JSON.stringify(this._payload)));if(r.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new n.JWTInvalid("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}t.SignJWT=s},50049(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnsecuredJWT=void 0;let i=r(40082),n=r(35821),o=r(36247),a=r(70493),s=r(10751);class c extends s.ProduceJWT{encode(){let e=i.encode(JSON.stringify({alg:"none"})),t=i.encode(JSON.stringify(this._payload));return`${e}.${t}.`}static decode(e,t){let r;if("string"!=typeof e)throw new o.JWTInvalid("Unsecured JWT must be a string");let{0:s,1:c,2:l,length:d}=e.split(".");if(3!==d||""!==l)throw new o.JWTInvalid("Invalid Unsecured JWT");try{if(r=JSON.parse(n.decoder.decode(i.decode(s))),"none"!==r.alg)throw Error()}catch{throw new o.JWTInvalid("Invalid Unsecured JWT")}return{payload:(0,a.default)(r,i.decode(c),t),header:r}}}t.UnsecuredJWT=c},43082(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.jwtVerify=a;let i=r(51427),n=r(70493),o=r(36247);async function a(e,t,r){let a=await (0,i.compactVerify)(e,t,r);if(a.protectedHeader.crit?.includes("b64")&&!1===a.protectedHeader.b64)throw new o.JWTInvalid("JWTs MUST NOT use unencoded payload");let s={payload:(0,n.default)(a.protectedHeader,a.payload,r),protectedHeader:a.protectedHeader};return"function"==typeof t?{...s,key:a.key}:s}},50068(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exportSPKI=a,t.exportPKCS8=s,t.exportJWK=c;let i=r(60293),n=r(60293),o=r(99590);async function a(e){return(0,i.toSPKI)(e)}async function s(e){return(0,n.toPKCS8)(e)}async function c(e){return(0,o.default)(e)}},30409(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateKeyPair=n;let i=r(87975);async function n(e,t){return(0,i.generateKeyPair)(e,t)}},16502(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateSecret=n;let i=r(87975);async function n(e,t){return(0,i.generateSecret)(e,t)}},87364(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.importSPKI=c,t.importX509=l,t.importPKCS8=d,t.importJWK=u;let i=r(40082),n=r(60293),o=r(84660),a=r(36247),s=r(41855);async function c(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw TypeError('"spki" must be SPKI formatted string');return(0,n.fromSPKI)(e,t,r)}async function l(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw TypeError('"x509" must be X.509 formatted string');return(0,n.fromX509)(e,t,r)}async function d(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return(0,n.fromPKCS8)(e,t,r)}async function u(e,t){if(!(0,s.default)(e))throw TypeError("JWK must be an object");switch(t||=e.alg,e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return(0,i.decode)(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new a.JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return(0,o.default)({...e,alg:t});default:throw new a.JOSENotSupported('Unsupported "kty" (Key Type) Parameter value')}}},47031(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrap=a,t.unwrap=s;let i=r(82027),n=r(54799),o=r(40082);async function a(e,t,r,n){let a=e.slice(0,7),s=await (0,i.default)(a,r,t,n,new Uint8Array(0));return{encryptedKey:s.ciphertext,iv:(0,o.encode)(s.iv),tag:(0,o.encode)(s.tag)}}async function s(e,t,r,i,o){let a=e.slice(0,7);return(0,n.default)(a,t,r,i,o,new Uint8Array(0))}},35821(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decoder=t.encoder=void 0,t.concat=n,t.p2s=function(e,r){return n(t.encoder.encode(e),new Uint8Array([0]),r)},t.uint64be=function(e){let t=Math.floor(e/0x100000000),r=new Uint8Array(8);return o(r,t,0),o(r,e%0x100000000,4),r},t.uint32be=a,t.lengthAndInput=function(e){return n(a(e.length),e)},t.concatKdf=s;let i=r(76332);function n(...e){let t=new Uint8Array(e.reduce((e,{length:t})=>e+t,0)),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}function o(e,t,r){if(t<0||t>=0x100000000)throw RangeError(`value must be >= 0 and <= ${0x100000000-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function a(e){let t=new Uint8Array(4);return o(t,e),t}async function s(e,t,r){let n=Math.ceil((t>>3)/32),o=new Uint8Array(32*n);for(let t=0;t<n;t++){let n=new Uint8Array(4+e.length+r.length);n.set(a(t+1)),n.set(e,4),n.set(r,4+e.length),o.set(await (0,i.default)("sha256",n),32*t)}return o.slice(0,t>>3)}t.encoder=new TextEncoder,t.decoder=new TextDecoder},51784(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bitLength=o;let i=r(36247),n=r(20927);function o(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 i.JOSENotSupported(`Unsupported JWE Algorithm: ${e}`)}}t.default=e=>(0,n.default)(new Uint8Array(o(e)>>3))},1146(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(36247),n=r(97974);t.default=(e,t)=>{if(t.length<<3!==(0,n.bitLength)(e))throw new i.JWEInvalid("Invalid Initialization Vector length")}},11688(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkKeyTypeWithJwk=void 0;let i=r(38737),n=r(20740),o=r(26990),a=e=>e?.[Symbol.toStringTag],s=(e,t,r)=>{if(void 0!==t.use&&"sig"!==t.use)throw TypeError("Invalid key for this operation, when present its use must be sig");if(void 0!==t.key_ops&&t.key_ops.includes?.(r)!==!0)throw TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(void 0!==t.alg&&t.alg!==e)throw TypeError(`Invalid key for this operation, when present its alg must be ${e}`);return!0};function c(e,t,r,c){t.startsWith("HS")||"dir"===t||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?((e,t,r,c)=>{if(!(t instanceof Uint8Array)){if(c&&o.isJWK(t)){if(o.isSecretJWK(t)&&s(e,t,r))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!(0,n.default)(t))throw TypeError((0,i.withAlg)(e,t,...n.types,"Uint8Array",c?"JSON Web Key":null));if("secret"!==t.type)throw TypeError(`${a(t)} instances for symmetric algorithms must be of type "secret"`)}})(t,r,c,e):((e,t,r,c)=>{if(c&&o.isJWK(t))switch(r){case"sign":if(o.isPrivateJWK(t)&&s(e,t,r))return;throw TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(o.isPublicJWK(t)&&s(e,t,r))return;throw TypeError("JSON Web Key for this operation be a public JWK")}if(!(0,n.default)(t))throw TypeError((0,i.withAlg)(e,t,...n.types,c?"JSON Web Key":null));if("secret"===t.type)throw TypeError(`${a(t)} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw TypeError(`${a(t)} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw TypeError(`${a(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw TypeError(`${a(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw TypeError(`${a(t)} instances for asymmetric algorithm encryption must be of type "public"`)})(t,r,c,e)}t.default=c.bind(void 0,!1),t.checkKeyTypeWithJwk=c.bind(void 0,!0)},28405(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(!(e instanceof Uint8Array)||e.length<8)throw new i.JWEInvalid("PBES2 Salt Input must be 8 or more octets")};let i=r(36247)},12484(e,t){"use strict";function r(e,t="algorithm.name"){return TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function i(e,t){return e.name===t}function n(e){return parseInt(e.name.slice(4),10)}function o(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){let 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 TypeError(e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.checkSigCryptoKey=function(e,t,...a){switch(t){case"HS256":case"HS384":case"HS512":{if(!i(e.algorithm,"HMAC"))throw r("HMAC");let o=parseInt(t.slice(2),10);if(n(e.algorithm.hash)!==o)throw r(`SHA-${o}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!i(e.algorithm,"RSASSA-PKCS1-v1_5"))throw r("RSASSA-PKCS1-v1_5");let o=parseInt(t.slice(2),10);if(n(e.algorithm.hash)!==o)throw r(`SHA-${o}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!i(e.algorithm,"RSA-PSS"))throw r("RSA-PSS");let o=parseInt(t.slice(2),10);if(n(e.algorithm.hash)!==o)throw r(`SHA-${o}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw r("Ed25519 or Ed448");break;case"Ed25519":if(!i(e.algorithm,"Ed25519"))throw r("Ed25519");break;case"ES256":case"ES384":case"ES512":{if(!i(e.algorithm,"ECDSA"))throw r("ECDSA");let n=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}(t);if(e.algorithm.namedCurve!==n)throw r(n,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}o(e,a)},t.checkEncCryptoKey=function(e,t,...a){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!i(e.algorithm,"AES-GCM"))throw r("AES-GCM");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw r(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!i(e.algorithm,"AES-KW"))throw r("AES-KW");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw r(n,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw r("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!i(e.algorithm,"PBKDF2"))throw r("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!i(e.algorithm,"RSA-OAEP"))throw r("RSA-OAEP");let o=parseInt(t.slice(9),10)||1;if(n(e.algorithm.hash)!==o)throw r(`SHA-${o}`,"algorithm.hash");break}default:throw TypeError("CryptoKey does not support this operation")}o(e,a)}},24760(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(82395),n=r(96112),o=r(25904),a=r(73020),s=r(40082),c=r(17889),l=r(36247),d=r(51784),u=r(87364),p=r(11688),h=r(41855),f=r(47031);t.default=async function(e,t,r,y,_){switch((0,p.default)(e,t,"decrypt"),t=await c.default.normalizePrivateKey?.(t,e)||t,e){case"dir":if(void 0!==r)throw new l.JWEInvalid("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new l.JWEInvalid("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let o,a;if(!(0,h.default)(y.epk))throw new l.JWEInvalid('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!n.ecdhAllowed(t))throw new l.JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");let c=await (0,u.importJWK)(y.epk,e);if(void 0!==y.apu){if("string"!=typeof y.apu)throw new l.JWEInvalid('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{o=(0,s.decode)(y.apu)}catch{throw new l.JWEInvalid("Failed to base64url decode the apu")}}if(void 0!==y.apv){if("string"!=typeof y.apv)throw new l.JWEInvalid('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{a=(0,s.decode)(y.apv)}catch{throw new l.JWEInvalid("Failed to base64url decode the apv")}}let p=await n.deriveKey(c,t,"ECDH-ES"===e?y.enc:e,"ECDH-ES"===e?(0,d.bitLength)(y.enc):parseInt(e.slice(-5,-2),10),o,a);if("ECDH-ES"===e)return p;if(void 0===r)throw new l.JWEInvalid("JWE Encrypted Key missing");return(0,i.unwrap)(e.slice(-6),p,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 l.JWEInvalid("JWE Encrypted Key missing");return(0,a.decrypt)(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let i;if(void 0===r)throw new l.JWEInvalid("JWE Encrypted Key missing");if("number"!=typeof y.p2c)throw new l.JWEInvalid('JOSE Header "p2c" (PBES2 Count) missing or invalid');let n=_?.maxPBES2Count||1e4;if(y.p2c>n)throw new l.JWEInvalid('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof y.p2s)throw new l.JWEInvalid('JOSE Header "p2s" (PBES2 Salt) missing or invalid');try{i=(0,s.decode)(y.p2s)}catch{throw new l.JWEInvalid("Failed to base64url decode the p2s")}return(0,o.decrypt)(e,t,r,y.p2c,i)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new l.JWEInvalid("JWE Encrypted Key missing");return(0,i.unwrap)(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{let i,n;if(void 0===r)throw new l.JWEInvalid("JWE Encrypted Key missing");if("string"!=typeof y.iv)throw new l.JWEInvalid('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof y.tag)throw new l.JWEInvalid('JOSE Header "tag" (Authentication Tag) missing or invalid');try{i=(0,s.decode)(y.iv)}catch{throw new l.JWEInvalid("Failed to base64url decode the iv")}try{n=(0,s.decode)(y.tag)}catch{throw new l.JWEInvalid("Failed to base64url decode the tag")}return(0,f.unwrap)(e,t,r,i,n)}default:throw new l.JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value')}}},90508(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(82395),n=r(96112),o=r(25904),a=r(73020),s=r(40082),c=r(17889),l=r(51784),d=r(36247),u=r(50068),p=r(11688),h=r(47031);t.default=async function(e,t,r,f,y={}){let _,m,b;switch((0,p.default)(e,r,"encrypt"),r=await c.default.normalizePublicKey?.(r,e)||r,e){case"dir":b=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!n.ecdhAllowed(r))throw new d.JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:o,apv:a}=y,{epk:c}=y;c||=(await n.generateEpk(r)).privateKey;let{x:p,y:h,crv:w,kty:v}=await (0,u.exportJWK)(c),g=await n.deriveKey(r,c,"ECDH-ES"===e?t:e,"ECDH-ES"===e?(0,l.bitLength)(t):parseInt(e.slice(-5,-2),10),o,a);if(m={epk:{x:p,crv:w,kty:v}},"EC"===v&&(m.epk.y=h),o&&(m.apu=(0,s.encode)(o)),a&&(m.apv=(0,s.encode)(a)),"ECDH-ES"===e){b=g;break}b=f||(0,l.default)(t);let S=e.slice(-6);_=await (0,i.wrap)(S,g,b);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":b=f||(0,l.default)(t),_=await (0,a.encrypt)(e,r,b);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{b=f||(0,l.default)(t);let{p2c:i,p2s:n}=y;({encryptedKey:_,...m}=await (0,o.encrypt)(e,r,b,i,n));break}case"A128KW":case"A192KW":case"A256KW":b=f||(0,l.default)(t),_=await (0,i.wrap)(e,r,b);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{b=f||(0,l.default)(t);let{iv:i}=y;({encryptedKey:_,...m}=await (0,h.wrap)(e,r,b,i));break}default:throw new d.JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:b,encryptedKey:_,parameters:m}}},70936(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=e=>Math.floor(e.getTime()/1e3)},38737(e,t){"use strict";function r(e,t,...i){if((i=i.filter(Boolean)).length>2){let t=i.pop();e+=`one of type ${i.join(", ")}, or ${t}.`}else 2===i.length?e+=`one of type ${i[0]} or ${i[1]}.`:e+=`of type ${i[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}Object.defineProperty(t,"__esModule",{value:!0}),t.withAlg=function(e,t,...i){return r(`Key for the ${e} algorithm must be `,t,...i)},t.default=(e,...t)=>r("Key must be ",e,...t)},49476(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=(...e)=>{let t,r=e.filter(Boolean);if(0===r.length||1===r.length)return!0;for(let e of r){let r=Object.keys(e);if(!t||0===t.size){t=new Set(r);continue}for(let e of r){if(t.has(e))return!1;t.add(e)}}return!0}},26990(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJWK=n,t.isPrivateJWK=function(e){return"oct"!==e.kty&&"string"==typeof e.d},t.isPublicJWK=function(e){return"oct"!==e.kty&&void 0===e.d},t.isSecretJWK=function(e){return n(e)&&"oct"===e.kty&&"string"==typeof e.k};let i=r(41855);function n(e){return(0,i.default)(e)&&"string"==typeof e.kty}},41855(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}},97974(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bitLength=o;let i=r(36247),n=r(20927);function o(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 i.JOSENotSupported(`Unsupported JWE Algorithm: ${e}`)}}t.default=e=>(0,n.default)(new Uint8Array(o(e)>>3))},70493(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(36247),n=r(35821),o=r(70936),a=r(49743),s=r(41855),c=e=>e.toLowerCase().replace(/^application\//,"");t.default=(e,t,r={})=>{var l,d;let u,p;try{u=JSON.parse(n.decoder.decode(t))}catch{}if(!(0,s.default)(u))throw new i.JWTInvalid("JWT Claims Set must be a top-level JSON object");let{typ:h}=r;if(h&&("string"!=typeof e.typ||c(e.typ)!==c(h)))throw new i.JWTClaimValidationFailed('unexpected "typ" JWT header value',u,"typ","check_failed");let{requiredClaims:f=[],issuer:y,subject:_,audience:m,maxTokenAge:b}=r,w=[...f];for(let e of(void 0!==b&&w.push("iat"),void 0!==m&&w.push("aud"),void 0!==_&&w.push("sub"),void 0!==y&&w.push("iss"),new Set(w.reverse())))if(!(e in u))throw new i.JWTClaimValidationFailed(`missing required "${e}" claim`,u,e,"missing");if(y&&!(Array.isArray(y)?y:[y]).includes(u.iss))throw new i.JWTClaimValidationFailed('unexpected "iss" claim value',u,"iss","check_failed");if(_&&u.sub!==_)throw new i.JWTClaimValidationFailed('unexpected "sub" claim value',u,"sub","check_failed");if(m&&(l=u.aud,d="string"==typeof m?[m]:m,"string"==typeof l?!d.includes(l):!(Array.isArray(l)&&d.some(Set.prototype.has.bind(new Set(l))))))throw new i.JWTClaimValidationFailed('unexpected "aud" claim value',u,"aud","check_failed");switch(typeof r.clockTolerance){case"string":p=(0,a.default)(r.clockTolerance);break;case"number":p=r.clockTolerance;break;case"undefined":p=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:v}=r,g=(0,o.default)(v||new Date);if((void 0!==u.iat||b)&&"number"!=typeof u.iat)throw new i.JWTClaimValidationFailed('"iat" claim must be a number',u,"iat","invalid");if(void 0!==u.nbf){if("number"!=typeof u.nbf)throw new i.JWTClaimValidationFailed('"nbf" claim must be a number',u,"nbf","invalid");if(u.nbf>g+p)throw new i.JWTClaimValidationFailed('"nbf" claim timestamp check failed',u,"nbf","check_failed")}if(void 0!==u.exp){if("number"!=typeof u.exp)throw new i.JWTClaimValidationFailed('"exp" claim must be a number',u,"exp","invalid");if(u.exp<=g-p)throw new i.JWTExpired('"exp" claim timestamp check failed',u,"exp","check_failed")}if(b){let e=g-u.iat;if(e-p>("number"==typeof b?b:(0,a.default)(b)))throw new i.JWTExpired('"iat" claim timestamp check failed (too far in the past)',u,"iat","check_failed");if(e<0-p)throw new i.JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)',u,"iat","check_failed")}return u}},93688(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unprotected=void 0,t.unprotected=Symbol()},49743(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;t.default=e=>{let t,i=r.exec(e);if(!i||i[4]&&i[1])throw TypeError("Invalid time period format");let n=parseFloat(i[2]);switch(i[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":t=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":t=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":t=Math.round(3600*n);break;case"day":case"days":case"d":t=Math.round(86400*n);break;case"week":case"weeks":case"w":t=Math.round(604800*n);break;default:t=Math.round(0x1e187e0*n)}return"-"===i[1]||"ago"===i[4]?-t:t}},68604(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}},82458(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(36247);t.default=function(e,t,r,n,o){let a;if(void 0!==o.crit&&n?.crit===void 0)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');for(let s of(a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t,n.crit)){if(!a.has(s))throw new i.JOSENotSupported(`Extension Header Parameter "${s}" is not recognized`);if(void 0===o[s])throw new e(`Extension Header Parameter "${s}" is missing`);if(a.get(s)&&void 0===n[s])throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}},82395(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unwrap=t.wrap=void 0;let i=r(4573),n=r(77598),o=r(36247),a=r(35821),s=r(78993),c=r(12484),l=r(44512),d=r(38737),u=r(63022),p=r(20740);function h(e,t){if(e.symmetricKeySize<<3!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function f(e,t,r){if((0,l.default)(e))return e;if(e instanceof Uint8Array)return(0,n.createSecretKey)(e);if((0,s.isCryptoKey)(e))return(0,c.checkEncCryptoKey)(e,t,r),n.KeyObject.from(e);throw TypeError((0,d.default)(e,...p.types,"Uint8Array"))}t.wrap=(e,t,r)=>{let s=parseInt(e.slice(1,4),10),c=`aes${s}-wrap`;if(!(0,u.default)(c))throw new o.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`);let l=f(t,e,"wrapKey");h(l,e);let d=(0,n.createCipheriv)(c,l,i.Buffer.alloc(8,166));return(0,a.concat)(d.update(r),d.final())},t.unwrap=(e,t,r)=>{let s=parseInt(e.slice(1,4),10),c=`aes${s}-wrap`;if(!(0,u.default)(c))throw new o.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`);let l=f(t,e,"unwrapKey");h(l,e);let d=(0,n.createDecipheriv)(c,l,i.Buffer.alloc(8,166));return(0,a.concat)(d.update(r),d.final())}},60293(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromX509=t.fromSPKI=t.fromPKCS8=t.toPKCS8=t.toSPKI=void 0;let i=r(77598),n=r(4573),o=r(78993),a=r(44512),s=r(38737),c=r(20740),l=(e,t,r)=>{let n;if((0,o.isCryptoKey)(r)){if(!r.extractable)throw TypeError("CryptoKey is not extractable");n=i.KeyObject.from(r)}else if((0,a.default)(r))n=r;else throw TypeError((0,s.default)(r,...c.types));if(n.type!==e)throw TypeError(`key is not a ${e} key`);return n.export({format:"pem",type:t})};t.toSPKI=e=>l("public","spki",e),t.toPKCS8=e=>l("private","pkcs8",e),t.fromPKCS8=e=>(0,i.createPrivateKey)({key:n.Buffer.from(e.replace(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,""),"base64"),type:"pkcs8",format:"der"}),t.fromSPKI=e=>(0,i.createPublicKey)({key:n.Buffer.from(e.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,""),"base64"),type:"spki",format:"der"}),t.fromX509=e=>(0,i.createPublicKey)({key:e,type:"spki",format:"pem"})},40082(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=t.encodeBase64=t.decodeBase64=void 0;let i=r(4573),n=r(35821);t.encode=e=>i.Buffer.from(e).toString("base64url"),t.decodeBase64=e=>new Uint8Array(i.Buffer.from(e,"base64")),t.encodeBase64=e=>i.Buffer.from(e).toString("base64"),t.decode=e=>{let t;return new Uint8Array(i.Buffer.from(((t=e)instanceof Uint8Array&&(t=n.decoder.decode(t)),t),"base64url"))}},37184(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,o,a,s){let c=(0,n.concat)(e,t,r,(0,n.uint64be)(e.length<<3)),l=(0,i.createHmac)(`sha${o}`,a);return l.update(c),l.digest().slice(0,s>>3)};let i=r(77598),n=r(35821)},72319(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(36247),n=r(44512);t.default=(e,t)=>{let r;switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":r=parseInt(e.slice(-3),10);break;case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10);break;default:throw new i.JOSENotSupported(`Content Encryption Algorithm ${e} is not supported either by JOSE or your javascript runtime`)}if(t instanceof Uint8Array){let e=t.byteLength<<3;if(e!==r)throw new i.JWEInvalid(`Invalid Content Encryption Key length. Expected ${r} bits, got ${e} bits`);return}if((0,n.default)(t)&&"secret"===t.type){let e=t.symmetricKeySize<<3;if(e!==r)throw new i.JWEInvalid(`Invalid Content Encryption Key length. Expected ${r} bits, got ${e} bits`);return}throw TypeError("Invalid Content Encryption Key type")}},18257(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598);t.default=(e,t)=>{let r;try{r=e instanceof i.KeyObject?e.asymmetricKeyDetails?.modulusLength:Buffer.from(e.n,"base64url").byteLength<<3}catch{}if("number"!=typeof r||r<2048)throw TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}},63022(e,t,r){"use strict";let i;Object.defineProperty(t,"__esModule",{value:!0});let n=r(77598);t.default=e=>(i||=new Set((0,n.getCiphers)())).has(e)},54799(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598),n=r(1146),o=r(72319),a=r(35821),s=r(36247),c=r(12167),l=r(37184),d=r(78993),u=r(12484),p=r(44512),h=r(38737),f=r(63022),y=r(20740);t.default=(e,t,r,_,m,b)=>{let w;if((0,d.isCryptoKey)(t))(0,u.checkEncCryptoKey)(t,e,"decrypt"),w=i.KeyObject.from(t);else if(t instanceof Uint8Array||(0,p.default)(t))w=t;else throw TypeError((0,h.default)(t,...y.types,"Uint8Array"));if(!_)throw new s.JWEInvalid("JWE Initialization Vector missing");if(!m)throw new s.JWEInvalid("JWE Authentication Tag missing");switch((0,o.default)(e,w),(0,n.default)(e,_),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return function(e,t,r,n,o,d){let u,h,y=parseInt(e.slice(1,4),10);(0,p.default)(t)&&(t=t.export());let _=t.subarray(y>>3),m=t.subarray(0,y>>3),b=parseInt(e.slice(-3),10),w=`aes-${y}-cbc`;if(!(0,f.default)(w))throw new s.JOSENotSupported(`alg ${e} is not supported by your javascript runtime`);let v=(0,l.default)(d,n,r,b,m,y);try{u=(0,c.default)(o,v)}catch{}if(!u)throw new s.JWEDecryptionFailed;try{let e=(0,i.createDecipheriv)(w,_,n);h=(0,a.concat)(e.update(r),e.final())}catch{}if(!h)throw new s.JWEDecryptionFailed;return h}(e,w,r,_,m,b);case"A128GCM":case"A192GCM":case"A256GCM":var v=w;let g=parseInt(e.slice(1,4),10),S=`aes-${g}-gcm`;if(!(0,f.default)(S))throw new s.JOSENotSupported(`alg ${e} is not supported by your javascript runtime`);try{let e=(0,i.createDecipheriv)(S,v,_,{authTagLength:16});e.setAuthTag(m),b.byteLength&&e.setAAD(b,{plaintextLength:r.length});let t=e.update(r);return e.final(),t}catch{throw new s.JWEDecryptionFailed}default:throw new s.JOSENotSupported("Unsupported JWE Content Encryption Algorithm")}}},76332(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598);t.default=(e,t)=>(0,i.createHash)(e).update(t).digest()},75945(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){switch(e){case"PS256":case"RS256":case"ES256":case"ES256K":return"sha256";case"PS384":case"RS384":case"ES384":return"sha384";case"PS512":case"RS512":case"ES512":return"sha512";case"Ed25519":case"EdDSA":return;default:throw new i.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};let i=r(36247)},96112(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ecdhAllowed=void 0,t.deriveKey=f,t.generateEpk=y;let i=r(77598),n=r(57975),o=r(38960),a=r(35821),s=r(36247),c=r(78993),l=r(12484),d=r(44512),u=r(38737),p=r(20740),h=(0,n.promisify)(i.generateKeyPair);async function f(e,t,r,n,o=new Uint8Array(0),s=new Uint8Array(0)){let h,y;if((0,c.isCryptoKey)(e))(0,l.checkEncCryptoKey)(e,"ECDH"),h=i.KeyObject.from(e);else if((0,d.default)(e))h=e;else throw TypeError((0,u.default)(e,...p.types));if((0,c.isCryptoKey)(t))(0,l.checkEncCryptoKey)(t,"ECDH","deriveBits"),y=i.KeyObject.from(t);else if((0,d.default)(t))y=t;else throw TypeError((0,u.default)(t,...p.types));let _=(0,a.concat)((0,a.lengthAndInput)(a.encoder.encode(r)),(0,a.lengthAndInput)(o),(0,a.lengthAndInput)(s),(0,a.uint32be)(n)),m=(0,i.diffieHellman)({privateKey:y,publicKey:h});return(0,a.concatKdf)(m,n,_)}async function y(e){let t;if((0,c.isCryptoKey)(e))t=i.KeyObject.from(e);else if((0,d.default)(e))t=e;else throw TypeError((0,u.default)(e,...p.types));switch(t.asymmetricKeyType){case"x25519":return h("x25519");case"x448":return h("x448");case"ec":return h("ec",{namedCurve:(0,o.default)(t)});default:throw new s.JOSENotSupported("Invalid or unsupported EPK")}}t.ecdhAllowed=e=>["P-256","P-384","P-521","X25519","X448"].includes((0,o.default)(e))},82027(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598),n=r(1146),o=r(72319),a=r(35821),s=r(37184),c=r(78993),l=r(12484),d=r(44512),u=r(38737),p=r(97974),h=r(36247),f=r(63022),y=r(20740);t.default=(e,t,r,_,m)=>{let b;if((0,c.isCryptoKey)(r))(0,l.checkEncCryptoKey)(r,e,"encrypt"),b=i.KeyObject.from(r);else if(r instanceof Uint8Array||(0,d.default)(r))b=r;else throw TypeError((0,u.default)(r,...y.types,"Uint8Array"));switch((0,o.default)(e,b),_?(0,n.default)(e,_):_=(0,p.default)(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return function(e,t,r,n,o){let c=parseInt(e.slice(1,4),10);(0,d.default)(r)&&(r=r.export());let l=r.subarray(c>>3),u=r.subarray(0,c>>3),p=`aes-${c}-cbc`;if(!(0,f.default)(p))throw new h.JOSENotSupported(`alg ${e} is not supported by your javascript runtime`);let y=(0,i.createCipheriv)(p,l,n),_=(0,a.concat)(y.update(t),y.final()),m=parseInt(e.slice(-3),10),b=(0,s.default)(o,n,_,m,u,c);return{ciphertext:_,tag:b,iv:n}}(e,t,b,_,m);case"A128GCM":case"A192GCM":case"A256GCM":var w=b,v=_;let g=parseInt(e.slice(1,4),10),S=`aes-${g}-gcm`;if(!(0,f.default)(S))throw new h.JOSENotSupported(`alg ${e} is not supported by your javascript runtime`);let E=(0,i.createCipheriv)(S,w,v,{authTagLength:16});m.byteLength&&E.setAAD(m,{plaintextLength:t.length});let P=E.update(t);return E.final(),{ciphertext:P,tag:E.getAuthTag(),iv:v};default:throw new h.JOSENotSupported("Unsupported JWE Content Encryption Algorithm")}}},28832(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(37067),n=r(44708),o=r(78474),a=r(36247),s=r(35821);t.default=async(e,t,r)=>{let c;switch(e.protocol){case"https:":c=n.get;break;case"http:":c=i.get;break;default:throw TypeError("Unsupported URL protocol.")}let{agent:l,headers:d}=r,u=c(e.href,{agent:l,timeout:t,headers:d}),[p]=await Promise.race([(0,o.once)(u,"response"),(0,o.once)(u,"timeout")]);if(!p)throw u.destroy(),new a.JWKSTimeout;if(200!==p.statusCode)throw new a.JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");let h=[];for await(let e of p)h.push(e);try{return JSON.parse(s.decoder.decode((0,s.concat)(...h)))}catch{throw new a.JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON")}}},87975(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateSecret=c,t.generateKeyPair=l;let i=r(77598),n=r(57975),o=r(20927),a=r(36247),s=(0,n.promisify)(i.generateKeyPair);async function c(e,t){let r;switch(e){case"HS256":case"HS384":case"HS512":case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":r=parseInt(e.slice(-3),10);break;case"A128KW":case"A192KW":case"A256KW":case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10);break;default:throw new a.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return(0,i.createSecretKey)((0,o.default)(new Uint8Array(r>>3)))}async function l(e,t){switch(e){case"RS256":case"RS384":case"RS512":case"PS256":case"PS384":case"PS512":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":case"RSA1_5":{let e=t?.modulusLength??2048;if("number"!=typeof e||e<2048)throw new a.JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return await s("rsa",{modulusLength:e,publicExponent:65537})}case"ES256":return s("ec",{namedCurve:"P-256"});case"ES256K":return s("ec",{namedCurve:"secp256k1"});case"ES384":return s("ec",{namedCurve:"P-384"});case"ES512":return s("ec",{namedCurve:"P-521"});case"Ed25519":return s("ed25519");case"EdDSA":switch(t?.crv){case void 0:case"Ed25519":return s("ed25519");case"Ed448":return s("ed448");default:throw new a.JOSENotSupported("Invalid or unsupported crv option provided, supported values are Ed25519 and Ed448")}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let e=t?.crv??"P-256";switch(e){case void 0:case"P-256":case"P-384":case"P-521":return s("ec",{namedCurve:e});case"X25519":return s("x25519");case"X448":return s("x448");default:throw new a.JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}}default:throw new a.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}}},38960(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.weakMap=void 0;let i=r(77598),n=r(36247),o=r(78993),a=r(44512),s=r(38737),c=r(20740),l=r(26990);t.weakMap=new WeakMap,t.default=(e,t)=>{let r;if((0,o.isCryptoKey)(e))r=i.KeyObject.from(e);else if((0,a.default)(e))r=e;else if((0,l.isJWK)(e))return e.crv;else throw TypeError((0,s.default)(e,...c.types));if("secret"===r.type)throw TypeError('only "private" or "public" type keys can be used for this operation');switch(r.asymmetricKeyType){case"ed25519":case"ed448":return`Ed${r.asymmetricKeyType.slice(2)}`;case"x25519":case"x448":return`X${r.asymmetricKeyType.slice(1)}`;case"ec":{let e=r.asymmetricKeyDetails.namedCurve;if(t)return e;switch(e){case"prime256v1":return"P-256";case"secp384r1":return"P-384";case"secp521r1":return"P-521";case"secp256k1":return"secp256k1";default:throw new n.JOSENotSupported("Unsupported key curve for this operation")}}default:throw TypeError("Invalid asymmetric key type for this operation")}}},15206(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError((0,a.default)(t,...s.types));return(0,i.createSecretKey)(t)}if(t instanceof i.KeyObject)return t;if((0,n.isCryptoKey)(t))return(0,o.checkSigCryptoKey)(t,e,r),i.KeyObject.from(t);if(c.isJWK(t))return e.startsWith("HS")?(0,i.createSecretKey)(Buffer.from(t.k,"base64url")):t;throw TypeError((0,a.default)(t,...s.types,"Uint8Array","JSON Web Key"))};let i=r(77598),n=r(78993),o=r(12484),a=r(38737),s=r(20740),c=r(26990)},63254(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){switch(e){case"HS256":return"sha256";case"HS384":return"sha384";case"HS512":return"sha512";default:throw new i.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};let i=r(36247)},20740(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0;let i=r(78993),n=r(44512);t.default=e=>(0,n.default)(e)||(0,i.isCryptoKey)(e);let o=["KeyObject"];t.types=o,(globalThis.CryptoKey||i.default?.CryptoKey)&&o.push("CryptoKey")},44512(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(57975);t.default=e=>i.types.isKeyObject(e)},84660(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598);t.default=e=>e.d?(0,i.createPrivateKey)({format:"jwk",key:e}):(0,i.createPublicKey)({format:"jwk",key:e})},99590(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598),n=r(40082),o=r(36247),a=r(78993),s=r(44512),c=r(38737),l=r(20740);t.default=e=>{let t;if((0,a.isCryptoKey)(e)){if(!e.extractable)throw TypeError("CryptoKey is not extractable");t=i.KeyObject.from(e)}else if((0,s.default)(e))t=e;else if(e instanceof Uint8Array)return{kty:"oct",k:(0,n.encode)(e)};else throw TypeError((0,c.default)(e,...l.types,"Uint8Array"));if("secret"!==t.type&&!["rsa","ec","ed25519","x25519","ed448","x448"].includes(t.asymmetricKeyType))throw new o.JOSENotSupported("Unsupported key asymmetricKeyType");return t.export({format:"jwk"})}},87980(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){let r,c,l,d;if(t instanceof i.KeyObject)r=t.asymmetricKeyType,c=t.asymmetricKeyDetails;else switch(l=!0,t.kty){case"RSA":r="rsa";break;case"EC":r="ec";break;case"OKP":if("Ed25519"===t.crv){r="ed25519";break}if("Ed448"===t.crv){r="ed448";break}throw TypeError("Invalid key for this operation, its crv must be Ed25519 or Ed448");default:throw TypeError("Invalid key for this operation, its kty must be RSA, OKP, or EC")}switch(e){case"Ed25519":if("ed25519"!==r)throw TypeError("Invalid key for this operation, its asymmetricKeyType must be ed25519");break;case"EdDSA":if(!["ed25519","ed448"].includes(r))throw TypeError("Invalid key for this operation, its asymmetricKeyType must be ed25519 or ed448");break;case"RS256":case"RS384":case"RS512":if("rsa"!==r)throw TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa");(0,a.default)(t,e);break;case"PS256":case"PS384":case"PS512":if("rsa-pss"===r){let{hashAlgorithm:t,mgf1HashAlgorithm:r,saltLength:i}=c,n=parseInt(e.slice(-3),10);if(void 0!==t&&(t!==`sha${n}`||r!==t))throw TypeError(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}`);if(void 0!==i&&i>n>>3)throw TypeError(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}`)}else if("rsa"!==r)throw TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa or rsa-pss");(0,a.default)(t,e),d={padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST};break;case"ES256":case"ES256K":case"ES384":case"ES512":{if("ec"!==r)throw TypeError("Invalid key for this operation, its asymmetricKeyType must be ec");let i=(0,n.default)(t),o=s.get(e);if(i!==o)throw TypeError(`Invalid key curve for the algorithm, its curve must be ${o}, got ${i}`);d={dsaEncoding:"ieee-p1363"};break}default:throw new o.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}return l?{format:"jwk",key:t,...d}:d?{...d,key:t}:t};let i=r(77598),n=r(38960),o=r(36247),a=r(18257),s=new Map([["ES256","P-256"],["ES256K","secp256k1"],["ES384","P-384"],["ES512","P-521"]])},17889(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={}},25904(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=void 0;let i=r(57975),n=r(77598),o=r(20927),a=r(35821),s=r(40082),c=r(82395),l=r(28405),d=r(78993),u=r(12484),p=r(44512),h=r(38737),f=r(20740),y=(0,i.promisify)(n.pbkdf2);function _(e,t){if((0,p.default)(e))return e.export();if(e instanceof Uint8Array)return e;if((0,d.isCryptoKey)(e))return(0,u.checkEncCryptoKey)(e,t,"deriveBits","deriveKey"),n.KeyObject.from(e).export();throw TypeError((0,h.default)(e,...f.types,"Uint8Array"))}t.encrypt=async(e,t,r,i=2048,n=(0,o.default)(new Uint8Array(16)))=>{(0,l.default)(n);let d=(0,a.p2s)(e,n),u=parseInt(e.slice(13,16),10)>>3,p=_(t,e),h=await y(p,d,i,u,`sha${e.slice(8,11)}`);return{encryptedKey:await (0,c.wrap)(e.slice(-6),h,r),p2c:i,p2s:(0,s.encode)(n)}},t.decrypt=async(e,t,r,i,n)=>{(0,l.default)(n);let o=(0,a.p2s)(e,n),s=parseInt(e.slice(13,16),10)>>3,d=_(t,e),u=await y(d,o,i,s,`sha${e.slice(8,11)}`);return(0,c.unwrap)(e.slice(-6),u,r)}},20927(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=r(77598);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.randomFillSync}})},73020(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=void 0;let i=r(77598),n=r(57975),o=r(18257),a=r(78993),s=r(12484),c=r(44512),l=r(38737),d=r(20740),u=(e,t)=>{if("rsa"!==e.asymmetricKeyType)throw TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa");(0,o.default)(e,t)},p=(0,n.deprecate)(()=>i.constants.RSA_PKCS1_PADDING,'The RSA1_5 "alg" (JWE Algorithm) is deprecated and will be removed in the next major revision.'),h=e=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return i.constants.RSA_PKCS1_OAEP_PADDING;case"RSA1_5":return p();default:return}},f=e=>{switch(e){case"RSA-OAEP":return"sha1";case"RSA-OAEP-256":return"sha256";case"RSA-OAEP-384":return"sha384";case"RSA-OAEP-512":return"sha512";default:return}};function y(e,t,...r){if((0,c.default)(e))return e;if((0,a.isCryptoKey)(e))return(0,s.checkEncCryptoKey)(e,t,...r),i.KeyObject.from(e);throw TypeError((0,l.default)(e,...d.types))}t.encrypt=(e,t,r)=>{let n=h(e),o=f(e),a=y(t,e,"wrapKey","encrypt");return u(a,e),(0,i.publicEncrypt)({key:a,oaepHash:o,padding:n},r)},t.decrypt=(e,t,r)=>{let n=h(e),o=f(e),a=y(t,e,"unwrapKey","decrypt");return u(a,e),(0,i.privateDecrypt)({key:a,oaepHash:o,padding:n},r)}},59754(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default="node:crypto"},47965(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598),n=r(57975),o=r(75945),a=r(63254),s=r(87980),c=r(15206),l=(0,n.promisify)(i.sign);t.default=async(e,t,r)=>{let n=(0,c.default)(e,t,"sign");if(e.startsWith("HS")){let t=i.createHmac((0,a.default)(e),n);return t.update(r),t.digest()}return l((0,o.default)(e),r,(0,s.default)(e,n))}},12167(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=r(77598).timingSafeEqual},33117(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let i=r(77598),n=r(57975),o=r(75945),a=r(87980),s=r(47965),c=r(15206),l=(0,n.promisify)(i.verify);t.default=async(e,t,r,n)=>{let d=(0,c.default)(e,t,"verify");if(e.startsWith("HS")){let t=await (0,s.default)(e,d,n);try{return i.timingSafeEqual(r,t)}catch{return!1}}let u=(0,o.default)(e),p=(0,a.default)(e,d);try{return await l(u,n,p,r)}catch{return!1}}},78993(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isCryptoKey=void 0;let i=r(77598),n=r(57975);t.default=i.webcrypto,t.isCryptoKey=e=>n.types.isCryptoKey(e)},18462(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;let i=r(40082);t.encode=i.encode,t.decode=i.decode},38396(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodeJwt=function(e){let t,r;if("string"!=typeof e)throw new a.JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");let{1:s,length:c}=e.split(".");if(5===c)throw new a.JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");if(3!==c)throw new a.JWTInvalid("Invalid JWT");if(!s)throw new a.JWTInvalid("JWTs must contain a payload");try{t=(0,i.decode)(s)}catch{throw new a.JWTInvalid("Failed to base64url decode the payload")}try{r=JSON.parse(n.decoder.decode(t))}catch{throw new a.JWTInvalid("Failed to parse the decoded payload as JSON")}if(!(0,o.default)(r))throw new a.JWTInvalid("Invalid JWT Claims Set");return r};let i=r(18462),n=r(35821),o=r(41855),a=r(36247)},14443(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodeProtectedHeader=function(e){let t;if("string"==typeof e){let r=e.split(".");(3===r.length||5===r.length)&&([t]=r)}else if("object"==typeof e&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");try{if("string"!=typeof t||!t)throw Error();let e=JSON.parse(n.decoder.decode((0,i.decode)(t)));if(!(0,o.default)(e))throw Error();return e}catch{throw TypeError("Invalid Token or Protected Header formatting")}};let i=r(18462),n=r(35821),o=r(41855)},36247(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JWSSignatureVerificationFailed=t.JWKSTimeout=t.JWKSMultipleMatchingKeys=t.JWKSNoMatchingKey=t.JWKSInvalid=t.JWKInvalid=t.JWTInvalid=t.JWSInvalid=t.JWEInvalid=t.JWEDecryptionFailed=t.JOSENotSupported=t.JOSEAlgNotAllowed=t.JWTExpired=t.JWTClaimValidationFailed=t.JOSEError=void 0;class r extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}t.JOSEError=r,t.JWTClaimValidationFailed=class extends r{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",i="unspecified"){super(e,{cause:{claim:r,reason:i,payload:t}}),this.claim=r,this.reason=i,this.payload=t}},t.JWTExpired=class extends r{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",i="unspecified"){super(e,{cause:{claim:r,reason:i,payload:t}}),this.claim=r,this.reason=i,this.payload=t}},t.JOSEAlgNotAllowed=class extends r{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"},t.JOSENotSupported=class extends r{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"},t.JWEDecryptionFailed=class extends r{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}},t.JWEInvalid=class extends r{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"},t.JWSInvalid=class extends r{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"},t.JWTInvalid=class extends r{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"},t.JWKInvalid=class extends r{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"},t.JWKSInvalid=class extends r{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"},t.JWKSNoMatchingKey=class extends r{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}};class i extends r{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}t.JWKSMultipleMatchingKeys=i,t.JWKSTimeout=class extends r{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}},t.JWSSignatureVerificationFailed=class extends r{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}},4166(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=r(59754).default},50205(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},a=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))(function(n,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,i,n,o,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){var c=[o,s];if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,i&&(n=2&c[0]?i.return:c[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,c[1])).done)return n;switch(i=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,i=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(n=(n=a.trys).length>0&&n[n.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){a.label=c[1];break}if(6===c[0]&&a.label<n[1]){a.label=n[1],n=c;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(c);break}n[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],i=0}finally{r=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}};Object.defineProperty(t,"__esModule",{value:!0}),t.lookpath=void 0;var c=o(r(79896)),l=o(r(16928)),d=/^win/i.test(process.platform),u=function(e){return a(void 0,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,Promise.all((process.env.PATHEXT||"").split(l.delimiter).concat("").map(function(t){var r;return r=e+t,new Promise(function(e){return c.access(r,c.constants.X_OK,function(t){return e(t?void 0:r)})})}))];case 1:return[2,t.sent().find(function(e){return!!e})]}})})};t.lookpath=function(e,t){return void 0===t&&(t={}),a(this,void 0,void 0,function(){var r;return s(this,function(i){switch(i.label){case 0:var n;if(r=e.includes(l.sep)?l.resolve(e):void 0)return[2,u(r)];return n=t,[4,Promise.all((process.env[d?"Path":"PATH"]||"").split(l.delimiter).concat(n.include||[]).filter(function(e){return!(n.exclude||[]).includes(e)}).map(function(t){return u(l.join(t,e))}))];case 1:return[2,i.sent().find(function(e){return!!e})]}})})}},35083(e,t,r){let i=r(79896),n=r(70857),o=r(16928),a=r(76982),s={fs:i.constants,os:n.constants},c=(s.O_CREAT||s.fs.O_CREAT,s.O_EXCL||s.fs.O_EXCL,s.O_RDWR||s.fs.O_RDWR,"win32"===n.platform()),l=s.EBADF||s.os.errno.EBADF,d=s.ENOENT||s.os.errno.ENOENT,u=[],p=i.rmdirSync.bind(i);process.addListener("exit",function(){var e;0})},8674(e,t,r){"use strict";r.r(t),r.d(t,{__addDisposableResource:()=>K,__assign:()=>o,__asyncDelegator:()=>k,__asyncGenerator:()=>P,__asyncValues:()=>O,__await:()=>E,__awaiter:()=>f,__classPrivateFieldGet:()=>J,__classPrivateFieldIn:()=>j,__classPrivateFieldSet:()=>I,__createBinding:()=>_,__decorate:()=>s,__disposeResources:()=>N,__esDecorate:()=>l,__exportStar:()=>m,__extends:()=>n,__generator:()=>y,__importDefault:()=>x,__importStar:()=>W,__makeTemplateObject:()=>A,__metadata:()=>h,__param:()=>c,__propKey:()=>u,__read:()=>w,__rest:()=>a,__rewriteRelativeImportExtension:()=>M,__runInitializers:()=>d,__setFunctionName:()=>p,__spread:()=>v,__spreadArray:()=>S,__spreadArrays:()=>g,__values:()=>b,default:()=>R});var i=function(e,t){return(i=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])})(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return(o=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function a(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)0>t.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r}function s(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,i){t(r,i,e)}}function l(e,t,r,i,n,o){function a(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var s,c=i.kind,l="getter"===c?"get":"setter"===c?"set":"value",d=!t&&e?i.static?e:e.prototype:null,u=t||(d?Object.getOwnPropertyDescriptor(d,i.name):{}),p=!1,h=r.length-1;h>=0;h--){var f={};for(var y in i)f[y]="access"===y?{}:i[y];for(var y in i.access)f.access[y]=i.access[y];f.addInitializer=function(e){if(p)throw TypeError("Cannot add initializers after decoration has completed");o.push(a(e||null))};var _=(0,r[h])("accessor"===c?{get:u.get,set:u.set}:u[l],f);if("accessor"===c){if(void 0===_)continue;if(null===_||"object"!=typeof _)throw TypeError("Object expected");(s=a(_.get))&&(u.get=s),(s=a(_.set))&&(u.set=s),(s=a(_.init))&&n.unshift(s)}else(s=a(_))&&("field"===c?n.unshift(s):u[l]=s)}d&&Object.defineProperty(d,i.name,u),p=!0}function d(e,t,r){for(var i=arguments.length>2,n=0;n<t.length;n++)r=i?t[n].call(e,r):t[n].call(e);return i?r:void 0}function u(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,i){return new(r||(r=Promise))(function(n,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})}function y(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){var l=[s,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&l[0]?i.return:l[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,l[1])).done)return n;switch(i=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,i=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){o=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){o.label=l[1];break}if(6===l[0]&&o.label<n[1]){o.label=n[1],n=l;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(l);break}n[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],i=0}finally{r=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var _=Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]};function m(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||_(t,e,r)}function b(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return a}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(w(arguments[t]));return e}function g(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var i=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,n++)i[n]=o[a];return i}function S(e,t,r){if(r||2==arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}function E(e){return this instanceof E?(this.v=e,this):new E(e)}function P(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,n=r.apply(e,t||[]),o=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),i[Symbol.asyncIterator]=function(){return this},i;function a(e,t){n[e]&&(i[e]=function(t){return new Promise(function(r,i){o.push([e,t,r,i])>1||s(e,t)})},t&&(i[e]=t(i[e])))}function s(e,t){try{var r;(r=n[e](t)).value instanceof E?Promise.resolve(r.value.v).then(c,l):d(o[0][2],r)}catch(e){d(o[0][3],e)}}function c(e){s("next",e)}function l(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function k(e){var t,r;return t={},i("next"),i("throw",function(e){throw e}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,n){t[i]=e[i]?function(t){return(r=!r)?{value:E(e[i](t)),done:!1}:n?n(t):t}:n}}function O(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=b(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(r){t[r]=e[r]&&function(t){return new Promise(function(i,n){var o,a,s;o=i,a=n,s=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){o({value:e,done:s})},a)})}}}function A(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},C=function(e){return(C=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function W(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=C(e),i=0;i<r.length;i++)"default"!==r[i]&&_(t,e,r[i]);return T(t,e),t}function x(e){return e&&e.__esModule?e:{default:e}}function J(e,t,r,i){if("a"===r&&!i)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)}function I(e,t,r,i,n){if("m"===i)throw TypeError("Private method is not writable");if("a"===i&&!n)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r}function j(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function K(e,t,r){if(null!=t){var i,n;if("object"!=typeof t&&"function"!=typeof t)throw TypeError("Object expected.");if(r){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");i=t[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");i=t[Symbol.dispose],r&&(n=i)}if("function"!=typeof i)throw TypeError("Object not disposable.");n&&(i=function(){try{n.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:i,async:r})}else r&&e.stack.push({async:!0});return t}var H="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var i=Error(r);return i.name="SuppressedError",i.error=e,i.suppressed=t,i};function N(e){function t(t){e.error=e.hasError?new H(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,i=0;return function n(){for(;r=e.stack.pop();)try{if(!r.async&&1===i)return i=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(o).then(n,function(e){return t(e),n()})}else i|=1}catch(e){t(e)}if(1===i)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function M(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,i,n,o){return r?t?".jsx":".js":!i||n&&o?i+n+"."+o.toLowerCase()+"js":e}):e}let R={__extends:n,__assign:o,__rest:a,__decorate:s,__param:c,__esDecorate:l,__runInitializers:d,__propKey:u,__setFunctionName:p,__metadata:h,__awaiter:f,__generator:y,__createBinding:_,__exportStar:m,__values:b,__read:w,__spread:v,__spreadArrays:g,__spreadArray:S,__await:E,__asyncGenerator:P,__asyncDelegator:k,__asyncValues:O,__makeTemplateObject:A,__importStar:W,__importDefault:x,__classPrivateFieldGet:J,__classPrivateFieldSet:I,__classPrivateFieldIn:j,__addDisposableResource:K,__disposeResources:N,__rewriteRelativeImportExtension:M}},93338(e,t,r){"use strict";let{EMPTY_BUFFER:i}=r(32614),n=Buffer[Symbol.species];function o(e,t,r,i,n){for(let o=0;o<n;o++)r[i+o]=e[o]^t[3&o]}function a(e,t){for(let r=0;r<e.length;r++)e[r]^=t[3&r]}function s(e){let t;return(s.readOnly=!0,Buffer.isBuffer(e))?e:(e instanceof ArrayBuffer?t=new n(e):ArrayBuffer.isView(e)?t=new n(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),s.readOnly=!1),t)}if(e.exports={concat:function(e,t){if(0===e.length)return i;if(1===e.length)return e[0];let r=Buffer.allocUnsafe(t),o=0;for(let t=0;t<e.length;t++){let i=e[t];r.set(i,o),o+=i.length}return o<t?new n(r.buffer,r.byteOffset,o):r},mask:o,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:s,unmask:a},!process.env.WS_NO_BUFFER_UTIL)try{let t=r(Object(function(){var e=Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.mask=function(e,r,i,n,a){a<48?o(e,r,i,n,a):t.mask(e,r,i,n,a)},e.exports.unmask=function(e,r){e.length<32?a(e,r):t.unmask(e,r)}}catch(e){}},32614(e){"use strict";let t=["nodebuffer","arraybuffer","fragments"],r="u">typeof Blob;r&&t.push("blob"),e.exports={BINARY_TYPES:t,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:r,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},90597(e,t,r){"use strict";let{kForOnEventAttribute:i,kListener:n}=r(32614),o=Symbol("kCode"),a=Symbol("kData"),s=Symbol("kError"),c=Symbol("kMessage"),l=Symbol("kReason"),d=Symbol("kTarget"),u=Symbol("kType"),p=Symbol("kWasClean");class h{constructor(e){this[d]=null,this[u]=e}get target(){return this[d]}get type(){return this[u]}}Object.defineProperty(h.prototype,"target",{enumerable:!0}),Object.defineProperty(h.prototype,"type",{enumerable:!0});class f extends h{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[l]=void 0===t.reason?"":t.reason,this[p]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[l]}get wasClean(){return this[p]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class y extends h{constructor(e,t={}){super(e),this[s]=void 0===t.error?null:t.error,this[c]=void 0===t.message?"":t.message}get error(){return this[s]}get message(){return this[c]}}Object.defineProperty(y.prototype,"error",{enumerable:!0}),Object.defineProperty(y.prototype,"message",{enumerable:!0});class _ extends h{constructor(e,t={}){super(e),this[a]=void 0===t.data?null:t.data}get data(){return this[a]}}function m(e,t,r){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}Object.defineProperty(_.prototype,"data",{enumerable:!0}),e.exports={CloseEvent:f,ErrorEvent:y,Event:h,EventTarget:{addEventListener(e,t,r={}){let o;for(let o of this.listeners(e))if(!r[i]&&o[n]===t&&!o[i])return;if("message"===e)o=function(e,r){let i=new _("message",{data:r?e:e.toString()});i[d]=this,m(t,this,i)};else if("close"===e)o=function(e,r){let i=new f("close",{code:e,reason:r.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});i[d]=this,m(t,this,i)};else if("error"===e)o=function(e){let r=new y("error",{error:e,message:e.message});r[d]=this,m(t,this,r)};else{if("open"!==e)return;o=function(){let e=new h("open");e[d]=this,m(t,this,e)}}o[i]=!!r[i],o[n]=t,r.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[n]===t&&!r[i]){this.removeListener(e,r);break}}},MessageEvent:_}},55926(e,t,r){"use strict";let{tokenChars:i}=r(95880);function n(e,t,r){void 0===e[t]?e[t]=[r]:e[t].push(r)}e.exports={format:function(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(e=>[t].concat(Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){let t,r,o=Object.create(null),a=Object.create(null),s=!1,c=!1,l=!1,d=-1,u=-1,p=-1,h=0;for(;h<e.length;h++)if(u=e.charCodeAt(h),void 0===t)if(-1===p&&1===i[u])-1===d&&(d=h);else if(0!==h&&(32===u||9===u))-1===p&&-1!==d&&(p=h);else if(59===u||44===u){if(-1===d)throw SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h);let r=e.slice(d,p);44===u?(n(o,r,a),a=Object.create(null)):t=r,d=p=-1}else throw SyntaxError(`Unexpected character at index ${h}`);else if(void 0===r)if(-1===p&&1===i[u])-1===d&&(d=h);else if(32===u||9===u)-1===p&&-1!==d&&(p=h);else if(59===u||44===u){if(-1===d)throw SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h),n(a,e.slice(d,p),!0),44===u&&(n(o,t,a),a=Object.create(null),t=void 0),d=p=-1}else if(61===u&&-1!==d&&-1===p)r=e.slice(d,h),d=p=-1;else throw SyntaxError(`Unexpected character at index ${h}`);else if(c){if(1!==i[u])throw SyntaxError(`Unexpected character at index ${h}`);-1===d?d=h:s||(s=!0),c=!1}else if(l)if(1===i[u])-1===d&&(d=h);else if(34===u&&-1!==d)l=!1,p=h;else if(92===u)c=!0;else throw SyntaxError(`Unexpected character at index ${h}`);else if(34===u&&61===e.charCodeAt(h-1))l=!0;else if(-1===p&&1===i[u])-1===d&&(d=h);else if(-1!==d&&(32===u||9===u))-1===p&&(p=h);else if(59===u||44===u){if(-1===d)throw SyntaxError(`Unexpected character at index ${h}`);-1===p&&(p=h);let i=e.slice(d,p);s&&(i=i.replace(/\\/g,""),s=!1),n(a,r,i),44===u&&(n(o,t,a),a=Object.create(null),t=void 0),r=void 0,d=p=-1}else throw SyntaxError(`Unexpected character at index ${h}`);if(-1===d||l||32===u||9===u)throw SyntaxError("Unexpected end of input");-1===p&&(p=h);let f=e.slice(d,p);return void 0===t?n(o,f,a):(void 0===r?n(a,f,!0):s?n(a,r,f.replace(/\\/g,"")):n(a,r,f),n(o,t,a)),o}}},4759(e){"use strict";let t=Symbol("kDone"),r=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[t])}}}},42971(e,t,r){"use strict";let i,n=r(43106),o=r(93338),a=r(4759),{kStatusCode:s}=r(32614),c=Buffer[Symbol.species],l=Buffer.from([0,0,255,255]),d=Symbol("permessage-deflate"),u=Symbol("total-length"),p=Symbol("callback"),h=Symbol("buffers"),f=Symbol("error");function y(e){this[h].push(e),this[u]+=e.length}function _(e){(this[u]+=e.length,this[d]._maxPayload<1||this[u]<=this[d]._maxPayload)?this[h].push(e):(this[f]=RangeError("Max payload size exceeded"),this[f].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[f][s]=1009,this.removeListener("data",_),this.reset())}function m(e){(this[d]._inflate=null,this[f])?this[p](this[f]):(e[s]=1007,this[p](e))}e.exports=class{constructor(e){this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._maxPayload=0|this._options.maxPayload,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,i||(i=new a(void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10))}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[p];this._deflate.close(),this._deflate=null,e&&e(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(e=>(!1!==t.serverNoContextTakeover||!e.server_no_context_takeover)&&(!e.server_max_window_bits||!1!==t.serverMaxWindowBits&&("number"!=typeof t.serverMaxWindowBits||!(t.serverMaxWindowBits>e.server_max_window_bits)))&&("number"!=typeof t.clientMaxWindowBits||!!e.client_max_window_bits));if(!r)throw Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(r.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?r.client_max_window_bits=t.clientMaxWindowBits:(!0===r.client_max_window_bits||!1===t.clientMaxWindowBits)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let r=e[t];if(r.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(r=r[0],"client_max_window_bits"===t){if(!0!==r){let e=+r;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${r}`)}else if("server_max_window_bits"===t){let e=+r;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if("client_no_context_takeover"===t||"server_no_context_takeover"===t){if(!0!==r)throw TypeError(`Invalid value for parameter "${t}": ${r}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=r})}),e}decompress(e,t,r){i.add(i=>{this._decompress(e,t,(e,t)=>{i(),r(e,t)})})}compress(e,t,r){i.add(i=>{this._compress(e,t,(e,t)=>{i(),r(e,t)})})}_decompress(e,t,r){let i=this._isServer?"client":"server";if(!this._inflate){let e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?n.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[d]=this,this._inflate[u]=0,this._inflate[h]=[],this._inflate.on("error",m),this._inflate.on("data",_)}this._inflate[p]=r,this._inflate.write(e),t&&this._inflate.write(l),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,r(e);return}let n=o.concat(this._inflate[h],this._inflate[u]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[u]=0,this._inflate[h]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,n)})}_compress(e,t,r){let i=this._isServer?"server":"client";if(!this._deflate){let e=`${i}_max_window_bits`,t="number"!=typeof this.params[e]?n.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[u]=0,this._deflate[h]=[],this._deflate.on("data",y)}this._deflate[p]=r,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=o.concat(this._deflate[h],this._deflate[u]);t&&(e=new c(e.buffer,e.byteOffset,e.length-4)),this._deflate[p]=null,this._deflate[u]=0,this._deflate[h]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,e)})}}},46286(e,t,r){"use strict";let{Writable:i}=r(2203),n=r(42971),{BINARY_TYPES:o,EMPTY_BUFFER:a,kStatusCode:s,kWebSocket:c}=r(32614),{concat:l,toArrayBuffer:d,unmask:u}=r(93338),{isValidStatusCode:p,isValidUTF8:h}=r(95880),f=Buffer[Symbol.species];e.exports=class extends i{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,r){if(8===this._opcode&&0==this._state)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new f(t.buffer,t.byteOffset+e,t.length-e),new f(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=t.length-e;e>=r.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new f(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((48&t[0])!=0)return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"));let r=(64&t[0])==64;if(r&&!this._extensions[n.extensionName])return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._fin=(128&t[0])==128,this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(r)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(!this._fragmented)return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"));this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));this._compressed=r}else{if(!(this._opcode>7)||!(this._opcode<11))return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));if(!this._fin)return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"));if(r)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=(128&t[1])==128,this._isServer){if(!this._masked)return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}else if(this._masked)return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"));126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);r>2097151?e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=0x100000000*r+t.readUInt32BE(4),this.haveLength(e))}haveLength(e){this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)?e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")):this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!=0&&u(t,this._mask)}if(this._opcode>7)return void this.controlMessage(t,e);if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[n.extensionName].decompress(e,this._fin,(e,r)=>{if(e)return t(e);if(r.length){if(this._messageLength+=r.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return void t(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(r)}this.dataMessage(t),0===this._state&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let i;i="nodebuffer"===this._binaryType?l(r,t):"arraybuffer"===this._binaryType?d(l(r,t)):"blob"===this._binaryType?new Blob(r):r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",i,!0),this._state=0,this.startLoop(e)}))}else{let i=l(r,t);if(!this._skipUTF8Validation&&!h(i))return void e(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));5===this._state||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",i,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(8===this._opcode){if(0===e.length)this._loop=!1,this.emit("conclude",1005,a),this.end();else{let r=e.readUInt16BE(0);if(!p(r))return void t(this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE"));let i=new f(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!h(i))return void t(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)}))}createError(e,t,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=n,o[s]=i,o}}},80914(e,t,r){"use strict";let i,{Duplex:n}=r(2203),{randomFillSync:o}=r(76982),a=r(42971),{EMPTY_BUFFER:s,kWebSocket:c,NOOP:l}=r(32614),{isBlob:d,isValidStatusCode:u}=r(95880),{mask:p,toBuffer:h}=r(93338),f=Symbol("kByteLength"),y=Buffer.alloc(4),_=8192;class m{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=l,this[c]=void 0}static frame(e,t){let r,n,a=!1,s=2,c=!1;t.mask&&(r=t.maskBuffer||y,t.generateMask?t.generateMask(r):(8192===_&&(void 0===i&&(i=Buffer.alloc(8192)),o(i,0,8192),_=0),r[0]=i[_++],r[1]=i[_++],r[2]=i[_++],r[3]=i[_++]),c=(r[0]|r[1]|r[2]|r[3])==0,s=6),"string"==typeof e?n=(!t.mask||c)&&void 0!==t[f]?t[f]:(e=Buffer.from(e)).length:(n=e.length,a=t.mask&&t.readOnly&&!c);let l=n;n>=65536?(s+=8,l=127):n>125&&(s+=2,l=126);let d=Buffer.allocUnsafe(a?n+s:s);return(d[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(d[0]|=64),d[1]=l,126===l?d.writeUInt16BE(n,2):127===l&&(d[2]=d[3]=0,d.writeUIntBE(n,4,6)),t.mask)?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=r[2],d[s-1]=r[3],c)?[d,e]:a?(p(e,r,d,s,n),[d]):(p(e,r,e,0,n),[d,e]):[d,e]}close(e,t,r,i){let n;if(void 0===e)n=s;else if("number"==typeof e&&u(e))if(void 0!==t&&t.length){let r=Buffer.byteLength(t);if(r>123)throw RangeError("The message must not be greater than 123 bytes");(n=Buffer.allocUnsafe(2+r)).writeUInt16BE(e,0),"string"==typeof t?n.write(t,2):n.set(t,2)}else(n=Buffer.allocUnsafe(2)).writeUInt16BE(e,0);else throw TypeError("First argument must be a valid error code number");let o={[f]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(m.frame(n,o),i)}ping(e,t,r){let i,n;if("string"==typeof e?(i=Buffer.byteLength(e),n=!1):d(e)?(i=e.size,n=!1):(i=(e=h(e)).length,n=h.readOnly),i>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):0!==this._state?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(m.frame(e,o),r)}pong(e,t,r){let i,n;if("string"==typeof e?(i=Buffer.byteLength(e),n=!1):d(e)?(i=e.size,n=!1):(i=(e=h(e)).length,n=h.readOnly),i>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):0!==this._state?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(m.frame(e,o),r)}send(e,t,r){let i,n,o=this._extensions[a.extensionName],s=t.binary?2:1,c=t.compress;"string"==typeof e?(i=Buffer.byteLength(e),n=!1):d(e)?(i=e.size,n=!1):(i=(e=h(e)).length,n=h.readOnly),this._firstFragment?(this._firstFragment=!1,c&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(c=i>=o._threshold),this._compress=c):(c=!1,s=0),t.fin&&(this._firstFragment=!0);let l={[f]:i,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:n,rsv1:c};d(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,l,r]):this.getBlobData(e,this._compress,l,r):0!==this._state?this.enqueue([this.dispatch,e,this._compress,l,r]):this.dispatch(e,this._compress,l,r)}getBlobData(e,t,r,i){this._bufferedBytes+=r[f],this._state=2,e.arrayBuffer().then(e=>{if(this._socket.destroyed){let e=Error("The socket was closed while the blob was being read");process.nextTick(b,this,e,i);return}this._bufferedBytes-=r[f];let n=h(e);t?this.dispatch(n,t,r,i):(this._state=0,this.sendFrame(m.frame(n,r),i),this.dequeue())}).catch(e=>{process.nextTick(w,this,e,i)})}dispatch(e,t,r,i){if(!t)return void this.sendFrame(m.frame(e,r),i);let n=this._extensions[a.extensionName];this._bufferedBytes+=r[f],this._state=1,n.compress(e,r.fin,(e,t)=>{this._socket.destroyed?b(this,Error("The socket was closed while data was being compressed"),i):(this._bufferedBytes-=r[f],this._state=0,r.readOnly=!1,this.sendFrame(m.frame(t,r),i),this.dequeue())})}dequeue(){for(;0===this._state&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][f],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function b(e,t,r){"function"==typeof r&&r(t);for(let r=0;r<e._queue.length;r++){let i=e._queue[r],n=i[i.length-1];"function"==typeof n&&n(t)}}function w(e,t,r){b(e,t,r),e.onerror(t)}e.exports=m},3719(e,t,r){"use strict";r(91060);let{Duplex:i}=r(2203);function n(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener("error",a),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let r=!0,s=new i({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(t,r){let i=!r&&s._readableState.objectMode?t.toString():t;s.push(i)||e.pause()}),e.once("error",function(e){s.destroyed||(r=!1,s.destroy(e))}),e.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(t,i){if(e.readyState===e.CLOSED){i(t),process.nextTick(n,s);return}let o=!1;e.once("error",function(e){o=!0,i(e)}),e.once("close",function(){o||i(t),process.nextTick(n,s)}),r&&e.terminate()},s._final=function(t){e.readyState===e.CONNECTING?e.once("open",function(){s._final(t)}):null!==e._socket&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once("finish",function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,r,i){e.readyState===e.CONNECTING?e.once("open",function(){s._write(t,r,i)}):e.send(t,i)},s.on("end",o),s.on("error",a),s}},28237(e,t,r){"use strict";let{tokenChars:i}=r(95880);e.exports={parse:function(e){let t=new Set,r=-1,n=-1,o=0;for(;o<e.length;o++){let a=e.charCodeAt(o);if(-1===n&&1===i[a])-1===r&&(r=o);else if(0!==o&&(32===a||9===a))-1===n&&-1!==r&&(n=o);else if(44===a){if(-1===r)throw SyntaxError(`Unexpected character at index ${o}`);-1===n&&(n=o);let i=e.slice(r,n);if(t.has(i))throw SyntaxError(`The "${i}" subprotocol is duplicated`);t.add(i),r=n=-1}else throw SyntaxError(`Unexpected character at index ${o}`)}if(-1===r||-1!==n)throw SyntaxError("Unexpected end of input");let a=e.slice(r,o);if(t.has(a))throw SyntaxError(`The "${a}" subprotocol is duplicated`);return t.add(a),t}}},95880(e,t,r){"use strict";let{isUtf8:i}=r(20181),{hasBlob:n}=r(32614);function o(e){let t=e.length,r=0;for(;r<t;)if((128&e[r])==0)r++;else if((224&e[r])==192){if(r+1===t||(192&e[r+1])!=128||(254&e[r])==192)return!1;r+=2}else if((240&e[r])==224){if(r+2>=t||(192&e[r+1])!=128||(192&e[r+2])!=128||224===e[r]&&(224&e[r+1])==128||237===e[r]&&(224&e[r+1])==160)return!1;r+=3}else{if((248&e[r])!=240||r+3>=t||(192&e[r+1])!=128||(192&e[r+2])!=128||(192&e[r+3])!=128||240===e[r]&&(240&e[r+1])==128||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}return!0}if(e.exports={isBlob:function(e){return n&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:o,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},i)e.exports.isValidUTF8=function(e){return e.length<24?o(e):i(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=r(Object(function(){var e=Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.isValidUTF8=function(e){return e.length<32?o(e):t(e)}}catch(e){}},61722(e,t,r){"use strict";let i=r(24434),n=r(58611),{Duplex:o}=r(2203),{createHash:a}=r(76982),s=r(55926),c=r(42971),l=r(28237),d=r(91060),{CLOSE_TIMEOUT:u,GUID:p,kWebSocket:h}=r(32614),f=/^[+/0-9A-Za-z]{22}==$/;function y(e){e._state=2,e.emit("close")}function _(){this.destroy()}function m(e,t,r,i){r=r||n.STATUS_CODES[t],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${n.STATUS_CODES[t]}\r
`+Object.keys(i).map(e=>`${e}: ${i[e]}`).join("\r\n")+"\r\n\r\n"+r)}function b(e,t,r,i,n,o){if(e.listenerCount("wsClientError")){let i=Error(n);Error.captureStackTrace(i,b),e.emit("wsClientError",i,r,t)}else m(r,i,n,o)}e.exports=class extends i{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:u,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:d,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=n.createServer((e,t)=>{let r=n.STATUS_CODES[426];t.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),t.end(r)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return function(){for(let r of Object.keys(t))e.removeListener(r,t[r])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,r,i)=>{this.handleUpgrade(t,r,i,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state){e&&this.once("close",()=>{e(Error("The server is not running"))}),process.nextTick(y,this);return}if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(y,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{y(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,i){t.on("error",_);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if("GET"!==e.method)return void b(this,e,t,405,"Invalid HTTP method");if(void 0===o||"websocket"!==o.toLowerCase())return void b(this,e,t,400,"Invalid Upgrade header");if(void 0===n||!f.test(n))return void b(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");if(13!==a&&8!==a)return void b(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});if(!this.shouldHandle(e))return void m(t,400);let d=e.headers["sec-websocket-protocol"],u=new Set;if(void 0!==d)try{u=l.parse(d)}catch(r){b(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&void 0!==p){let r=new c({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=s.parse(p);e[c.extensionName]&&(r.accept(e[c.extensionName]),h[c.extensionName]=r)}catch(r){b(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let o={origin:e.headers[`${8===a?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,(o,a,s,c)=>{if(!o)return m(t,a||401,s,c);this.completeUpgrade(h,n,u,e,t,r,i)});if(!this.options.verifyClient(o))return m(t,401)}this.completeUpgrade(h,n,u,e,t,r,i)}completeUpgrade(e,t,r,i,n,o,l){if(!n.readable||!n.writable)return n.destroy();if(n[h])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return m(n,503);let d=a("sha1").update(t+p).digest("base64"),u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${d}`],f=new this.options.WebSocket(null,void 0,this.options);if(r.size){let e=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),f._protocol=e)}if(e[c.extensionName]){let t=e[c.extensionName].params,r=s.format({[c.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${r}`),f._extensions=e}this.emit("headers",u,i),n.write(u.concat("\r\n").join("\r\n")),n.removeListener("error",_),f.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(y,this)})),l(f,i)}}},91060(e,t,r){"use strict";let i=r(24434),n=r(65692),o=r(58611),a=r(69278),s=r(64756),{randomBytes:c,createHash:l}=r(76982),{Duplex:d,Readable:u}=r(2203),{URL:p}=r(87016),h=r(42971),f=r(46286),y=r(80914),{isBlob:_}=r(95880),{BINARY_TYPES:m,CLOSE_TIMEOUT:b,EMPTY_BUFFER:w,GUID:v,kForOnEventAttribute:g,kListener:S,kStatusCode:E,kWebSocket:P,NOOP:k}=r(32614),{EventTarget:{addEventListener:O,removeEventListener:A}}=r(90597),{format:T,parse:C}=r(55926),{toBuffer:W}=r(93338),x=Symbol("kAborted"),J=[8,13],I=["CONNECTING","OPEN","CLOSING","CLOSED"],j=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class K extends i{constructor(e,t,r){super(),this._binaryType=m[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=w,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=K.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(r=t,t=[]):t=[t]),function e(t,r,i,a){let s,d,u,f,y={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:b,protocolVersion:J[1],maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=y.autoPong,t._closeTimeout=y.closeTimeout,!J.includes(y.protocolVersion))throw RangeError(`Unsupported protocol version: ${y.protocolVersion} (supported versions: ${J.join(", ")})`);if(r instanceof p)s=r;else try{s=new p(r)}catch{throw SyntaxError(`Invalid URL: ${r}`)}"http:"===s.protocol?s.protocol="ws:":"https:"===s.protocol&&(s.protocol="wss:"),t._url=s.href;let _="wss:"===s.protocol,m="ws+unix:"===s.protocol;if("ws:"===s.protocol||_||m?m&&!s.pathname?d="The URL's pathname is empty":s.hash&&(d="The URL contains a fragment identifier"):d='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',d){let e=SyntaxError(d);if(0!==t._redirects)return void H(t,e);throw e}let w=_?443:80,g=c(16).toString("base64"),S=_?n.request:o.request,E=new Set;if(y.createConnection=y.createConnection||(_?M:N),y.defaultPort=y.defaultPort||w,y.port=s.port||w,y.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,y.headers={...y.headers,"Sec-WebSocket-Version":y.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},y.path=s.pathname+s.search,y.timeout=y.handshakeTimeout,y.perMessageDeflate&&(u=new h({...y.perMessageDeflate,isServer:!1,maxPayload:y.maxPayload}),y.headers["Sec-WebSocket-Extensions"]=T({[h.extensionName]:u.offer()})),i.length){for(let e of i){if("string"!=typeof e||!j.test(e)||E.has(e))throw SyntaxError("An invalid or duplicated subprotocol was specified");E.add(e)}y.headers["Sec-WebSocket-Protocol"]=i.join(",")}if(y.origin&&(y.protocolVersion<13?y.headers["Sec-WebSocket-Origin"]=y.origin:y.headers.Origin=y.origin),(s.username||s.password)&&(y.auth=`${s.username}:${s.password}`),m){let e=y.path.split(":");y.socketPath=e[0],y.path=e[1]}if(y.followRedirects){if(0===t._redirects){t._originalIpc=m,t._originalSecure=_,t._originalHostOrSocketPath=m?y.socketPath:s.host;let e=a&&a.headers;if(a={...a,headers:{}},e)for(let[t,r]of Object.entries(e))a.headers[t.toLowerCase()]=r}else if(0===t.listenerCount("redirect")){let e=m?!!t._originalIpc&&y.socketPath===t._originalHostOrSocketPath:!t._originalIpc&&s.host===t._originalHostOrSocketPath;e&&(!t._originalSecure||_)||(delete y.headers.authorization,delete y.headers.cookie,e||delete y.headers.host,y.auth=void 0)}y.auth&&!a.headers.authorization&&(a.headers.authorization="Basic "+Buffer.from(y.auth).toString("base64")),f=t._req=S(y),t._redirects&&t.emit("redirect",t.url,f)}else f=t._req=S(y);y.timeout&&f.on("timeout",()=>{R(t,f,"Opening handshake has timed out")}),f.on("error",e=>{null===f||f[x]||(f=t._req=null,H(t,e))}),f.on("response",n=>{let o=n.headers.location,s=n.statusCode;if(o&&y.followRedirects&&s>=300&&s<400){let n;if(++t._redirects>y.maxRedirects)return void R(t,f,"Maximum redirects exceeded");f.abort();try{n=new p(o,r)}catch(e){H(t,SyntaxError(`Invalid URL: ${o}`));return}e(t,n,i,a)}else t.emit("unexpected-response",f,n)||R(t,f,`Unexpected server response: ${n.statusCode}`)}),f.on("upgrade",(e,r,i)=>{let n;if(t.emit("upgrade",e),t.readyState!==K.CONNECTING)return;f=t._req=null;let o=e.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void R(t,r,"Invalid Upgrade header");let a=l("sha1").update(g+v).digest("base64");if(e.headers["sec-websocket-accept"]!==a)return void R(t,r,"Invalid Sec-WebSocket-Accept header");let s=e.headers["sec-websocket-protocol"];if(void 0!==s?E.size?E.has(s)||(n="Server sent an invalid subprotocol"):n="Server sent a subprotocol but none was requested":E.size&&(n="Server sent no subprotocol"),n)return void R(t,r,n);s&&(t._protocol=s);let c=e.headers["sec-websocket-extensions"];if(void 0!==c){let e;if(!u)return void R(t,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");try{e=C(c)}catch(e){R(t,r,"Invalid Sec-WebSocket-Extensions header");return}let i=Object.keys(e);if(1!==i.length||i[0]!==h.extensionName)return void R(t,r,"Server indicated an extension that was not requested");try{u.accept(e[h.extensionName])}catch(e){R(t,r,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[h.extensionName]=u}t.setSocket(r,i,{allowSynchronousEvents:y.allowSynchronousEvents,generateMask:y.generateMask,maxPayload:y.maxPayload,skipUTF8Validation:y.skipUTF8Validation})}),y.finishRequest?y.finishRequest(f,t):f.end()}(this,e,t,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){m.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let i=new f({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new y(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[P]=this,n[P]=this,e[P]=this,i.on("conclude",D),i.on("drain",L),i.on("error",B),i.on("message",$),i.on("ping",G),i.on("pong",V),n.onerror=z,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Y),e.on("data",Z),e.on("end",Q),e.on("error",ee),this._readyState=K.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=K.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[h.extensionName]&&this._extensions[h.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=K.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==K.CLOSED){if(this.readyState===K.CONNECTING)return void R(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===K.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=K.CLOSING,this._sender.close(e,t,!this._isServer,e=>{!e&&(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),X(this)}}pause(){this.readyState!==K.CONNECTING&&this.readyState!==K.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===K.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==K.OPEN)?U(this,e,r):(void 0===t&&(t=!this._isServer),this._sender.ping(e||w,t,r))}pong(e,t,r){if(this.readyState===K.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==K.OPEN)?U(this,e,r):(void 0===t&&(t=!this._isServer),this._sender.pong(e||w,t,r))}resume(){this.readyState!==K.CONNECTING&&this.readyState!==K.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===K.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(r=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==K.OPEN)return void U(this,e,r);let i={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[h.extensionName]||(i.compress=!1),this._sender.send(e||w,i,r)}terminate(){if(this.readyState!==K.CLOSED){if(this.readyState===K.CONNECTING)return void R(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=K.CLOSING,this._socket.destroy())}}}function H(e,t){e._readyState=K.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function N(e){return e.path=e.socketPath,a.connect(e)}function M(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=a.isIP(e.host)?"":e.host),s.connect(e)}function R(e,t,r){e._readyState=K.CLOSING;let i=Error(r);Error.captureStackTrace(i,R),t.setHeader?(t[x]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(H,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function U(e,t,r){if(t){let r=_(t)?t.size:W(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(r){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${I[e.readyState]})`);process.nextTick(r,t)}}function D(e,t){let r=this[P];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,void 0!==r._socket[P]&&(r._socket.removeListener("data",Z),process.nextTick(q,r._socket),1005===e?r.close():r.close(e,t))}function L(){let e=this[P];e.isPaused||e._socket.resume()}function B(e){let t=this[P];void 0!==t._socket[P]&&(t._socket.removeListener("data",Z),process.nextTick(q,t._socket),t.close(e[E])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function F(){this[P].emitClose()}function $(e,t){this[P].emit("message",e,t)}function G(e){let t=this[P];t._autoPong&&t.pong(e,!this._isServer,k),t.emit("ping",e)}function V(e){this[P].emit("pong",e)}function q(e){e.resume()}function z(e){let t=this[P];t.readyState!==K.CLOSED&&(t.readyState===K.OPEN&&(t._readyState=K.CLOSING,X(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function X(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function Y(){let e=this[P];if(this.removeListener("close",Y),this.removeListener("data",Z),this.removeListener("end",Q),e._readyState=K.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&0!==this._readableState.length){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[P]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",F),e._receiver.on("finish",F))}function Z(e){this[P]._receiver.write(e)||this.pause()}function Q(){let e=this[P];e._readyState=K.CLOSING,e._receiver.end(),this.end()}function ee(){let e=this[P];this.removeListener("error",ee),this.on("error",k),e&&(e._readyState=K.CLOSING,this.destroy())}Object.defineProperty(K,"CONNECTING",{enumerable:!0,value:I.indexOf("CONNECTING")}),Object.defineProperty(K.prototype,"CONNECTING",{enumerable:!0,value:I.indexOf("CONNECTING")}),Object.defineProperty(K,"OPEN",{enumerable:!0,value:I.indexOf("OPEN")}),Object.defineProperty(K.prototype,"OPEN",{enumerable:!0,value:I.indexOf("OPEN")}),Object.defineProperty(K,"CLOSING",{enumerable:!0,value:I.indexOf("CLOSING")}),Object.defineProperty(K.prototype,"CLOSING",{enumerable:!0,value:I.indexOf("CLOSING")}),Object.defineProperty(K,"CLOSED",{enumerable:!0,value:I.indexOf("CLOSED")}),Object.defineProperty(K.prototype,"CLOSED",{enumerable:!0,value:I.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(K.prototype,e,{enumerable:!0})}),["open","error","close","message"].forEach(e=>{Object.defineProperty(K.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[g])return t[S];return null},set(t){for(let t of this.listeners(e))if(t[g]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[g]:!0})}})}),K.prototype.addEventListener=O,K.prototype.removeEventListener=A,e.exports=K},20181(e){"use strict";e.exports=require("buffer")},76982(e){"use strict";e.exports=require("crypto")},24434(e){"use strict";e.exports=require("events")},79896(e){"use strict";e.exports=require("fs")},58611(e){"use strict";e.exports=require("http")},65692(e){"use strict";e.exports=require("https")},69278(e){"use strict";e.exports=require("net")},4573(e){"use strict";e.exports=require("node:buffer")},77598(e){"use strict";e.exports=require("node:crypto")},78474(e){"use strict";e.exports=require("node:events")},37067(e){"use strict";e.exports=require("node:http")},44708(e){"use strict";e.exports=require("node:https")},57975(e){"use strict";e.exports=require("node:util")},70857(e){"use strict";e.exports=require("os")},16928(e){"use strict";e.exports=require("path")},2203(e){"use strict";e.exports=require("stream")},64756(e){"use strict";e.exports=require("tls")},87016(e){"use strict";e.exports=require("url")},43106(e){"use strict";e.exports=require("zlib")}},i={};function n(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return r[e].call(o.exports,o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{apiRequest:()=>d});var e=n(58611),t=n(1681);n(76982);var r=n(79896),i=n(16928);n(35083),n(50205),r.promises.stat,r.promises.readFile,r.promises.readdir,r.promises.readlink,r.promises.unlink,r.promises.access,r.promises.chmod;var a=r.promises.mkdir;r.promises.writeFile,r.promises.copyFile,r.promises.appendFile,r.createReadStream,r.createWriteStream;var s=n(70857);function c(e,t,r,i,n,o,a){try{var s=e[o](a),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(i,n)}function l(e,t,r,i,n,o,a){try{var s=e[o](a),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(i,n)}function d(r,n,o){var d;return(d=function(){var l,d,u;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(a,"next",{value:c(0)}),s(a,"throw",{value:c(1)}),s(a,"return",{value:c(2)}),"function"==typeof Symbol&&s(a,Symbol.iterator,{value:function(){return this}}),a;function c(s){return function(c){var l=[s,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&l[0]?i.return:l[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,l[1])).done)return n;switch(i=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,i=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){o=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){o.label=l[1];break}if(6===l[0]&&o.label<n[1]){o.label=n[1],n=l;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(l);break}n[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],i=0}finally{r=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(p){switch(p.label){case 0:var h;return l=(0,t.getDeferred)(),[4,(h=function(){var e,t;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(a,"next",{value:c(0)}),s(a,"throw",{value:c(1)}),s(a,"return",{value:c(2)}),"function"==typeof Symbol&&s(a,Symbol.iterator,{value:function(){return this}}),a;function c(s){return function(c){var l=[s,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&l[0]?i.return:l[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,l[1])).done)return n;switch(i=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,i=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){o=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){o.label=l[1];break}if(6===l[0]&&o.label<n[1]){o.label=n[1],n=l;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(l);break}n[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],i=0}finally{r=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:if("win32"===process.platform)return[2,"\\\\.\\pipe\\httptoolkit-ctl"];if(!("linux"===process.platform&&process.env.XDG_RUNTIME_DIR))return[3,1];return e=process.env.XDG_RUNTIME_DIR,[3,4];case 1:if("/tmp"!==(t=s.tmpdir())&&"/var/tmp"!==t)return[3,3];return[4,a(e=i.join(t,"httptoolkit-".concat(process.getuid())),{mode:448,recursive:!0})];case 2:return r.sent(),[3,4];case 3:e=t,r.label=4;case 4:return[2,i.join(e,"httptoolkit-ctl.sock")]}})},function(){var e=this,t=arguments;return new Promise(function(r,i){var n=h.apply(e,t);function o(e){c(n,r,i,o,a,"next",e)}function a(e){c(n,r,i,o,a,"throw",e)}o(void 0)})})()];case 1:return d=p.sent(),(u=e.request({method:r,path:n,socketPath:d,headers:{"Content-Type":"application/json"},timeout:2e3},function(e){var t=[];e.on("error",function(e){return l.reject(e)}),e.on("data",function(e){return t.push(e)}),e.on("end",function(){var r=Buffer.concat(t).toString("utf-8");if(e.statusCode&&e.statusCode>=400){try{var i,n=JSON.parse(r),o=n.message||("string"==typeof n.error?n.error:null==(i=n.error)?void 0:i.message)||"HTTP ".concat(e.statusCode);l.reject(Error(o))}catch(t){l.reject(Error("HTTP ".concat(e.statusCode,": ").concat(r)))}return}try{l.resolve(JSON.parse(r))}catch(e){l.reject(Error("Unparseable response: ".concat(r)))}})})).on("timeout",function(){u.destroy(Error("Request timed out"))}),u.on("error",function(e){"ECONNREFUSED"===e.code||"ENOENT"===e.code?l.reject(Error("HTTP Toolkit is not running. Start HTTP Toolkit first.")):l.reject(e)}),o&&u.write(JSON.stringify(o)),u.end(),[2,l]}})},function(){var e=this,t=arguments;return new Promise(function(r,i){var n=d.apply(e,t);function o(e){l(n,r,i,o,a,"next",e)}function a(e){l(n,r,i,o,a,"throw",e)}o(void 0)})})()}n(24434),n(3719),n(55926),n(42971),n(46286),n(80914),n(28237),n(91060),n(61722),n(10185)})(),module.exports=o;
//# sourceMappingURL=bridge-client.js.map