PageSourceSearch

https://httptoolkit.com/_next/static/chunks/6651-6b500fcdb7bf9a4f.js

js httptoolkit.com collected 2026-10-02 05:49:12 UTC 94,964 bytes, 14 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6651],{8039:(e,t,r)=>{e.exports=r(65538)},18398:(e,t,r)=>{r.d(t,{nu:()=>S,PA:()=>b});var n,a,i,o=r(88074),s=r(12115);if(!s.useState)throw Error("mobx-react-lite requires React with Hooks support");if(!o.Gn)throw Error("mobx-react-lite@3 requires mobx at least version 6 to be available");var c=r(47650);function u(e){return(0,o.yl)(e)}var l=function(){function e(e){var t=this;Object.defineProperty(this,"finalize",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"registrations",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"sweepTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sweep",{enumerable:!0,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=1e4),clearTimeout(t.sweepTimeout),t.sweepTimeout=void 0;var r=Date.now();t.registrations.forEach(function(n,a){r-n.registeredAt>=e&&(t.finalize(n.value),t.registrations.delete(a))}),t.registrations.size>0&&t.scheduleSweep()}}),Object.defineProperty(this,"finalizeAllImmediately",{enumerable:!0,configurable:!0,writable:!0,value:function(){t.sweep(0)}})}return Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this.registrations.set(r,{value:t,registeredAt:Date.now()}),this.scheduleSweep()}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.registrations.delete(e)}}),Object.defineProperty(e.prototype,"scheduleSweep",{enumerable:!1,configurable:!0,writable:!0,value:function(){void 0===this.sweepTimeout&&(this.sweepTimeout=setTimeout(this.sweep,1e4))}}),e}(),d=new("u">typeof FinalizationRegistry?FinalizationRegistry:l)(function(e){var t;null==(t=e.reaction)||t.dispose(),e.reaction=null}),p=r(8039);function h(e){e.reaction=new o.qT("observer".concat(e.name),function(){var t;e.stateVersion=Symbol(),null==(t=e.onStoreChange)||t.call(e)})}function y(e,t){void 0===t&&(t="observed");var r,n,a=s.useRef(null);if(!a.current){var i={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(e){return d.unregister(i),i.onStoreChange=e,i.reaction||(h(i),i.stateVersion=Symbol()),function(){var e;i.onStoreChange=null,null==(e=i.reaction)||e.dispose(),i.reaction=null}},getSnapshot:function(){return i.stateVersion}};a.current=i}var o=a.current;if(o.reaction||(h(o),d.register(a,o,o)),s.useDebugValue(o.reaction,u),(0,p.useSyncExternalStore)(o.subscribe,o.getSnapshot,o.getSnapshot),o.reaction.track(function(){try{r=e()}catch(e){n=e}}),n)throw n;return r}var f="function"==typeof Symbol&&Symbol.for,w=null!=(i=null==(a=Object.getOwnPropertyDescriptor(function(){},"name"))?void 0:a.configurable)&&i,m=f?Symbol.for("react.forward_ref"):"function"==typeof s.forwardRef&&(0,s.forwardRef)(function(e){return null}).$$typeof,g=f?Symbol.for("react.memo"):"function"==typeof s.memo&&(0,s.memo)(function(e){return null}).$$typeof;function b(e,t){if(g&&e.$$typeof===g)throw Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var r,n,a,i=null!=(a=null==t?void 0:t.forwardRef)&&a,o=e,c=e.displayName||e.name;if(m&&e.$$typeof===m&&(i=!0,"function"!=typeof(o=e.render)))throw Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var u=function(e,t){return y(function(){return o(e,t)},c)};return u.displayName=e.displayName,w&&Object.defineProperty(u,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(u.contextTypes=e.contextTypes),i&&(u=(0,s.forwardRef)(u)),r=e,n=u=(0,s.memo)(u),Object.keys(r).forEach(function(e){E[e]||Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),u}var E={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function S(e){var t=e.children,r=e.render;t&&r&&console.error("MobX Observer: Do not use children and render in the same time in `Observer`");var n=t||r;return"function"!=typeof n?null:y(n)}S.displayName="Observer",(n=c.unstable_batchedUpdates)||(n=function(e){e()}),(0,o.jK)({reactionScheduler:n}),d.finalizeAllImmediately},25902:(e,t,r)=>{var n,a,i=r(41463);
1Object.defineProperty(t,"__esModule",{value:!0}),t.ACCOUNTS_API_BASE=void 0,t.ACCOUNTS_API_BASE=null!=(a=null!=(n=i.env.ACCOUNTS_API)?n:i.env.GATSBY_ACCOUNTS_API)?a:"https://accounts.httptoolkit.tech/api"},27397:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=void 0;var n=r(49303);t.withTimeout=function(e,t,r){var a=this;return void 0===r&&(r=Error("timeout")),{acquire:function(){return new Promise(function(i,o){return n.__awaiter(a,void 0,void 0,function(){var a,s;return n.__generator(this,function(n){switch(n.label){case 0:return a=!1,setTimeout(function(){a=!0,o(r)},t),[4,e.acquire()];case 1:return s=n.sent(),a?(Array.isArray(s)?s[1]:s)():i(s),[2]}})})})},runExclusive:function(e){return n.__awaiter(this,void 0,void 0,function(){var t,r;return n.__generator(this,function(n){switch(n.label){case 0:t=function(){},n.label=1;case 1:return n.trys.push([1,,7,8]),[4,this.acquire()];case 2:if(!Array.isArray(r=n.sent()))return[3,4];return t=r[1],[4,e(r[0])];case 3:case 5:return[2,n.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()}}}},31938:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(72552),t),a(r(92573),t)},37662:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.Semaphore=t.Mutex=void 0;var n=r(76173);Object.defineProperty(t,"Mutex",{enumerable:!0,get:function(){return n.default}});var a=r(44784);Object.defineProperty(t,"Semaphore",{enumerable:!0,get:function(){return a.default}});var i=r(27397);Object.defineProperty(t,"withTimeout",{enumerable:!0,get:function(){return i.withTimeout}})},43814:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.openNewCheckoutWindow=t.goToCheckout=t.prefetchCheckout=t.prepareCheckout=void 0;let n=r(25902),a=(e,t,r)=>`${n.ACCOUNTS_API_BASE}/redirect-to-checkout?email=${encodeURIComponent(e)}&sku=${t}&source=${window.location.hostname}&returnUrl=${encodeURIComponent(`https://httptoolkit.com/${r}-purchase-thank-you/`)}`;t.prepareCheckout=function(e,t,r){fetch(a(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)}(a(e,t,r))},t.goToCheckout=async function(e,t,r){window.location.assign(a(e,t,r))},t.openNewCheckoutWindow=function(e,t,r){window.open(a(e,t,r),"_blank")}},44784:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r(49303);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 n.__awaiter(this,void 0,void 0,function(){var t,r,a;return n.__generator(this,function(n){switch(n.label){case 0:return[4,this.acquire()];case 1:r=(t=n.sent())[0],a=t[1],n.label=2;case 2:return n.trys.push([2,,4,5]),[4,e(r)];case 3:return[2,n.sent()];case 4:return a(),[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}()},49303:(e,t,r)=>{r.r(t),r.d(t,{__addDisposableResource:()=>J,__assign:()=>i,__asyncDelegator:()=>P,__asyncGenerator:()=>_,__asyncValues:()=>C,__await:()=>A,__awaiter:()=>y,__classPrivateFieldGet:()=>W,__classPrivateFieldIn:()=>R,__classPrivateFieldSet:()=>I,__createBinding:()=>w,__decorate:()=>s,__disposeResources:()=>x,__esDecorate:()=>u,__exportStar:()=>m,__extends:()=>a,__generator:()=>f,__importDefault:()=>K,__importStar:()=>
1T,__makeTemplateObject:()=>k,__metadata:()=>h,__param:()=>c,__propKey:()=>d,__read:()=>b,__rest:()=>o,__rewriteRelativeImportExtension:()=>j,__runInitializers:()=>l,__setFunctionName:()=>p,__spread:()=>E,__spreadArray:()=>v,__spreadArrays:()=>S,__values:()=>g,default:()=>D});var n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function a(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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)0>t.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}function s(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t,r,n,a,i){function o(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var s,c=n.kind,u="getter"===c?"get":"setter"===c?"set":"value",l=!t&&e?n.static?e:e.prototype:null,d=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),p=!1,h=r.length-1;h>=0;h--){var y={};for(var f in n)y[f]="access"===f?{}:n[f];for(var f in n.access)y.access[f]=n.access[f];y.addInitializer=function(e){if(p)throw TypeError("Cannot add initializers after decoration has completed");i.push(o(e||null))};var w=(0,r[h])("accessor"===c?{get:d.get,set:d.set}:d[u],y);if("accessor"===c){if(void 0===w)continue;if(null===w||"object"!=typeof w)throw TypeError("Object expected");(s=o(w.get))&&(d.get=s),(s=o(w.set))&&(d.set=s),(s=o(w.init))&&a.unshift(s)}else(s=o(w))&&("field"===c?a.unshift(s):d[u]=s)}l&&Object.defineProperty(l,n.name,d),p=!0}function l(e,t,r){for(var n=arguments.length>2,a=0;a<t.length;a++)r=n?t[a].call(e,r):t[a].call(e);return n?r:void 0}function d(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 y(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?a(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})}function f(e,t){var r,n,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){var u=[s,c];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var w=Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);
vendor: 4,267 bytes, line 1
1(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function m(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||w(t,e,r)}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(a)throw a.error}}return o}function E(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function S(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),a=0,t=0;t<r;t++)for(var i=arguments[t],o=0,s=i.length;o<s;o++,a++)n[a]=i[o];return n}function v(e,t,r){if(r||2==arguments.length)for(var n,a=0,i=t.length;a<i;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}function A(e){return this instanceof A?(this.v=e,this):new A(e)}function _(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n,a=r.apply(e,t||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){a[e]&&(n[e]=function(t){return new Promise(function(r,n){i.push([e,t,r,n])>1||s(e,t)})},t&&(n[e]=t(n[e])))}function s(e,t){try{var r;(r=a[e](t)).value instanceof A?Promise.resolve(r.value.v).then(c,u):l(i[0][2],r)}catch(e){l(i[0][3],e)}}function c(e){s("next",e)}function u(e){s("throw",e)}function l(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function P(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,a){t[n]=e[n]?function(t){return(r=!r)?{value:A(e[n](t)),done:!1}:a?a(t):t}:a}}function C(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,a){var i,o,s;i=n,o=a,s=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:s})},o)})}}}function k(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var H=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},O=function(e){return(O=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=O(e),n=0;n<r.length;n++)"default"!==r[n]&&w(t,e,r[n]);return H(t,e),t}function K(e){return e&&e.__esModule?e:{default:e}}function W(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function I(e,t,r,n,a){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!a)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?a.call(e,r):a?a.value=r:t.set(e,r),r}function R(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 J(e,t,r){if(null!=t){var n,a;if("object"!=typeof t&&"function"!=typeof t)throw TypeError("Object expected.");
1if(r){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(a=n)}if("function"!=typeof n)throw TypeError("Object not disposable.");a&&(n=function(){try{a.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var U="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function x(e){function t(t){e.error=e.hasError?new U(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function a(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(a);if(r.dispose){var i=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(i).then(a,function(e){return t(e),a()})}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function j(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,n,a,i){return r?t?".jsx":".js":!n||a&&i?n+a+"."+i.toLowerCase()+"js":e}):e}let D={__extends:a,__assign:i,__rest:o,__decorate:s,__param:c,__esDecorate:u,__runInitializers:l,__propKey:d,__setFunctionName:p,__metadata:h,__awaiter:y,__generator:f,__createBinding:w,__exportStar:m,__values:g,__read:b,__spread:E,__spreadArrays:S,__spreadArray:v,__await:A,__asyncGenerator:_,__asyncDelegator:P,__asyncValues:C,__makeTemplateOb
1ject:k,__importStar:T,__importDefault:K,__classPrivateFieldGet:W,__classPrivateFieldSet:I,__classPrivateFieldIn:R,__addDisposableResource:J,__disposeResources:x,__rewriteRelativeImportExtension:j}},65287:(e,t,r)=>{let n;r.r(t),r.d(t,{CompactEncrypt:()=>e9,CompactSign:()=>tt,EmbeddedJWK:()=>td,EncryptJWT:()=>ts,FlattenedEncrypt:()=>eG,FlattenedSign:()=>te,GeneralEncrypt:()=>ez,GeneralSign:()=>tn,SignJWT:()=>to,UnsecuredJWT:()=>tE,base64url:()=>i,calculateJwkThumbprint:()=>tu,calculateJwkThumbprintUri:()=>tl,compactDecrypt:()=>ej,compactVerify:()=>eZ,createLocalJWKSet:()=>tw,createRemoteJWKSet:()=>tb,cryptoRuntime:()=>tT,decodeJwt:()=>t_,decodeProtectedHeader:()=>tA,errors:()=>a,exportJWK:()=>eB,exportPKCS8:()=>e$,exportSPKI:()=>eN,flattenedDecrypt:()=>ex,flattenedVerify:()=>eQ,generalDecrypt:()=>eD,generalVerify:()=>e0,generateKeyPair:()=>tH,generateSecret:()=>tO,importJWK:()=>ek,importPKCS8:()=>eC,importSPKI:()=>e_,importX509:()=>eP,jwtDecrypt:()=>e6,jwtVerify:()=>e3});var a={};r.r(a),r.d(a,{JOSEAlgNotAllowed:()=>A,JOSEError:()=>E,JOSENotSupported:()=>_,JWEDecryptionFailed:()=>P,JWEInvalid:()=>C,JWKInvalid:()=>O,JWKSInvalid:()=>T,JWKSMultipleMatchingKeys:()=>W,JWKSNoMatchingKey:()=>K,JWKSTimeout:()=>I,JWSInvalid:()=>k,JWSSignatureVerificationFailed:()=>R,JWTClaimValidationFailed:()=>S,JWTExpired:()=>v,JWTInvalid:()=>H});var i={};r.r(i),r.d(i,{decode:()=>tv,encode:()=>tS});let o=crypto,s=async(e,t)=>{let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await o.subtle.digest(r,t))},c=new TextEncoder,u=new TextDecoder;function l(...e){let t=new Uint8Array(e.reduce((e,{length:t})=>e+t,0)),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}function d(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 p(e){let t=Math.floor(e/0x100000000),r=new Uint8Array(8);return d(r,t,0),d(r,e%0x100000000,4),r}function h(e){let t=new Uint8Array(4);return d(t,e),t}function y(e){return l(h(e.length),e)}async function f(e,t,r){let n=Math.ceil((t>>3)/32),a=new Uint8Array(32*n);for(let t=0;t<n;t++){let n=new Uint8Array(4+e.length+r.length);n.set(h(t+1)),n.set(e,4),n.set(r,4+e.length),a.set(await s("sha256",n),32*t)}return a.slice(0,t>>3)}let w=e=>{let t=e;"string"==typeof t&&(t=c.encode(t));let r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))},m=e=>w(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),g=e=>{let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},b=e=>{let t=e;t instanceof Uint8Array&&(t=u.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return g(t)}catch{throw TypeError("The input to be decoded is not correctly encoded.")}};class E extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(e){super(e),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class S extends E{static get code(){return"ERR_JWT_CLAIM_VALIDATION_FAILED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=t,this.reason=r}}class v extends E{static get code(){return"ERR_JWT_EXPIRED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_EXPIRED",this.claim=t,this.reason=r}}class A extends E{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}static get code(){return"ERR_JOSE_ALG_NOT_ALLOWED"}}class _ extends E{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class P extends E{constructor(){super(...arguments),this.code="ERR_JWE_DECRYPTION_FAILED",this.message="decryption operation failed"}static get code(){return"ERR_JWE_DECRYPTION_FAILED"}}class C extends E{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}class k extends E{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}}
1class H extends E{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}}class O extends E{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}static get code(){return"ERR_JWK_INVALID"}}class T extends E{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}static get code(){return"ERR_JWKS_INVALID"}}class K extends E{constructor(){super(...arguments),this.code="ERR_JWKS_NO_MATCHING_KEY",this.message="no applicable key found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_NO_MATCHING_KEY"}}class W extends E{constructor(){super(...arguments),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS",this.message="multiple matching keys found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}class I extends E{constructor(){super(...arguments),this.code="ERR_JWKS_TIMEOUT",this.message="request timed out"}static get code(){return"ERR_JWKS_TIMEOUT"}}class R extends E{constructor(){super(...arguments),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED",this.message="signature verification failed"}static get code(){return"ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}let J=o.getRandomValues.bind(o);function U(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new _(`Unsupported JWE Algorithm: ${e}`)}}let x=(e,t)=>{if(t.length<<3!==U(e))throw new C("Invalid Initialization Vector length")},j=(e,t)=>{let r=e.byteLength<<3;if(r!==t)throw new C(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function D(e,t="algorithm.name"){return TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function M(e,t){return e.name===t}function N(e){return parseInt(e.name.slice(4),10)}function $(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)}}function B(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!M(e.algorithm,"AES-GCM"))throw D("AES-GCM");let r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw D(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!M(e.algorithm,"AES-KW"))throw D("AES-KW");let r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw D(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw D("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!M(e.algorithm,"PBKDF2"))throw D("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!M(e.algorithm,"RSA-OAEP"))throw D("RSA-OAEP");let r=parseInt(t.slice(9),10)||1;if(N(e.algorithm.hash)!==r)throw D(`SHA-${r}`,"algorithm.hash");break}default:throw TypeError("CryptoKey does not support this operation")}$(e,r)}function L(e,t,...r){if(r.length>2){let t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}let F=(e,...t)=>L("Key must be ",e,...t);function G(e,t,...r){return L(`Key for the ${e} algorithm must be `,t,...r)}let V=["CryptoKey"];async function z(e,t,r,n,a,i){let s,c;if(!(t instanceof Uint8Array))throw TypeError(F(t,"Uint8Array"));let u=parseInt(e.slice(1,4),10),d=await o.subtle.importKey("raw",t.subarray(u>>3),"AES-CBC",!1,["decrypt"]),h=await o.subtle.importKey("raw",t.subarray(0,u>>3),{hash:`SHA-${u<<1}`,name:"HMAC"},!1,["sign"]),y=l(i,n,r,p(i.length<<3)),f=new Uint8Array((await o.subtle.sign("HMAC",h,y)).slice(0,u>>3));try{s=((e,t)=>{if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");if(e.length!==t.length)throw TypeError("Input buffers must have the same length");let r=e.length,n=0,a=-1;for(;++a<r;)n|=e[a]^t[a];return 0===n})(a,f)}catch{}if(!s)throw new P;try{c=new Uint8Array(await o.subtle.decrypt({iv:n,name:"AES-CBC"},d,r))}catch{}if(!c)throw new P;return c}async function q(e,t,r,n,a,i){let s;t instanceof Uint8Array?s=await o.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):(B(t,e,"decrypt"),s=t);try{return new Uint8Array(await o.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},s,l(r,a)))}catch{throw new P}}let X=async(e,t,r,n,a,i)=>{if(!(t instanceof CryptoKey)&&!(t instanceof Uint8Array))throw TypeError(F(t,...V,"Uint8Array"));if(!n)throw new C("JWE Initialization Vector missing");if(!a)throw new C("JWE Authentication Tag missing");switch(x(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&j(t,parseInt(e.slice(-3),10)),z(e,t,r,n,a,i);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&j(t,parseInt(e.slice(1,4),10)),q(e,t,r,n,a,i);default:throw new _("Unsupported JWE Content Encryption Algorithm")}},Y=(...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};function Q(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}
1let Z=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function ee(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function et(e,t,r){if(e instanceof CryptoKey)return B(e,t,r),e;if(e instanceof Uint8Array)return o.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw TypeError(F(e,...V,"Uint8Array"))}let er=async(e,t,r)=>{let n=await et(t,e,"wrapKey");ee(n,e);let a=await o.subtle.importKey("raw",r,...Z);return new Uint8Array(await o.subtle.wrapKey("raw",a,n,"AES-KW"))},en=async(e,t,r)=>{let n=await et(t,e,"unwrapKey");ee(n,e);let a=await o.subtle.unwrapKey("raw",r,n,"AES-KW",...Z);return new Uint8Array(await o.subtle.exportKey("raw",a))};async function ea(e,t,r,n,a=new Uint8Array(0),i=new Uint8Array(0)){let s;if(!(e instanceof CryptoKey))throw TypeError(F(e,...V));if(B(e,"ECDH"),!(t instanceof CryptoKey))throw TypeError(F(t,...V));B(t,"ECDH","deriveBits");let u=l(y(c.encode(r)),y(a),y(i),h(n));return s="X25519"===e.algorithm.name?256:"X448"===e.algorithm.name?448:Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3,f(new Uint8Array(await o.subtle.deriveBits({name:e.algorithm.name,public:e},t,s)),n,u)}async function ei(e){if(!(e instanceof CryptoKey))throw TypeError(F(e,...V));return o.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function eo(e){if(!(e instanceof CryptoKey))throw TypeError(F(e,...V));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||"X25519"===e.algorithm.name||"X448"===e.algorithm.name}async function es(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new C("PBES2 Salt Input must be 8 or more octets");let a=l(c.encode(t),new Uint8Array([0]),e),i=parseInt(t.slice(13,16),10),s={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:a},u=await function(e,t){if(e instanceof Uint8Array)return o.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(e instanceof CryptoKey)return B(e,t,"deriveBits","deriveKey"),e;throw TypeError(F(e,...V,"Uint8Array"))}(n,t);if(u.usages.includes("deriveBits"))return new Uint8Array(await o.subtle.deriveBits(s,u,i));if(u.usages.includes("deriveKey"))return o.subtle.deriveKey(s,u,{length:i,name:"AES-KW"},!1,["wrapKey","unwrapKey"]);throw TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}let ec=async(e,t,r,n=2048,a=J(new Uint8Array(16)))=>{let i=await es(a,e,n,t);return{encryptedKey:await er(e.slice(-6),i,r),p2c:n,p2s:m(a)}},eu=async(e,t,r,n,a)=>{let i=await es(a,e,n,t);return en(e.slice(-6),i,r)};function el(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}let ed=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}},ep=async(e,t,r)=>{if(!(t instanceof CryptoKey))throw TypeError(F(t,...V));if(B(t,e,"encrypt","wrapKey"),ed(e,t),t.usages.includes("encrypt"))return new Uint8Array(await o.subtle.encrypt(el(e),t,r));if(t.usages.includes("wrapKey")){let n=await o.subtle.importKey("raw",r,...Z);return new Uint8Array(await o.subtle.wrapKey("raw",n,t,el(e)))}throw TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')},eh=async(e,t,r)=>{if(!(t instanceof CryptoKey))throw TypeError(F(t,...V));if(B(t,e,"decrypt","unwrapKey"),ed(e,t),t.usages.includes("decrypt"))return new Uint8Array(await o.subtle.decrypt(el(e),t,r));if(t.usages.includes("unwrapKey")){let n=await o.subtle.unwrapKey("raw",r,t,el(e),...Z);return new Uint8Array(await o.subtle.exportKey("raw",n))}throw TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')};function ey(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new _(`Unsupported JWE Algorithm: ${e}`)}}let ef=e=>J(new Uint8Array(ey(e)>>3)),ew=(e,t)=>{let r=(e.match(/.{1,64}/g)||[]).join("\n");return`-----BEGIN ${t}-----
2${r}
3-----END ${t}-----`},em=async(e,t,r)=>{if(!(r instanceof CryptoKey))throw TypeError(F(r,...V));if(!r.extractable)throw TypeError("CryptoKey is not extractable");if(r.type!==e)throw TypeError(`key is not a ${e} key`);return ew(w(new Uint8Array(await o.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},eg=(e,t,r=0)=>{0===r&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(-1===n)return!1;let a=e.subarray(n,n+t.length);return a.length===t.length&&(a.every((e,r)=>e===t[r])||eg(e,t,n+1))},eb=e=>{switch(!0){case eg(e,[42,134,72,206,61,3,1,7]):return"P-256";case eg(e,[43,129,4,0,34]):return"P-384";case eg(e,[43,129,4,0,35]):return"P-521";case eg(e,[43,101,110]):return"X25519";case eg(e,[43,101,111]):return"X448";case eg(e,[43,101,112]):return"Ed25519";case eg(e,[43,101,113]):return"Ed448";default:throw new _("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},eE=async(e,t,r,n,a)=>{let i,s,c=new Uint8Array(atob(r.replace(e,"")).split("").map(e=>e.charCodeAt(0))),u="spki"===t;switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},s=u?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},s=u?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},s=u?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":i={name:"ECDSA",namedCurve:"P-256"},s=u?["verify"]:["sign"];break;case"ES384":i={name:"ECDSA",namedCurve:"P-384"},s=u?["verify"]:["sign"];break;case"ES512":i={name:"ECDSA",namedCurve:"P-521"},s=u?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let e=eb(c);i=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},s=u?[]:["deriveBits"];break}
3case"EdDSA":i={name:eb(c)},s=u?["verify"]:["sign"];break;default:throw new _('Invalid or unsupported "alg" (Algorithm) value')}return o.subtle.importKey(t,c,i,a?.extractable??!1,s)};function eS(e){let t=[],r=0;for(;r<e.length;){let n=ev(e.subarray(r));t.push(n),r+=n.byteLength}return t}function ev(e){let t=0,r=31&e[0];if(t++,31===r){for(r=0;e[t]>=128;)r=128*r+e[t]-128,t++;r=128*r+e[t]-128,t++}let n=0;if(e[t]<128)n=e[t],t++;else if(128===n){for(n=0;0!==e[t+n]||0!==e[t+n+1];){if(n>e.byteLength)throw TypeError("invalid indefinite form length");n++}let r=t+n+2;return{byteLength:r,contents:e.subarray(t,t+n),raw:e.subarray(0,r)}}else{let r=127&e[t];t++,n=0;for(let a=0;a<r;a++)n=256*n+e[t],t++}let a=t+n;return{byteLength:a,contents:e.subarray(t,a),raw:e.subarray(0,a)}}let eA=async e=>{if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new _('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),n=[t,e.ext??!1,e.key_ops??r],a={...e};return delete a.alg,delete a.use,o.subtle.importKey("jwk",a,...n)};async function e_(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw TypeError('"spki" must be SPKI formatted string');return eE(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r)}async function eP(e,t,r){let n;if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw TypeError('"x509" must be X.509 formatted string');try{var a;let t;a=e,n=ew((t=eS(eS(ev(g(a.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g,""))).contents)[0].contents),w(t[160===t[0].raw[0]?6:5].raw)),"PUBLIC KEY")}catch(e){throw TypeError("Failed to parse the X.509 certificate",{cause:e})}return eE(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",n,t,r)}async function eC(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return eE(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r)}async function ek(e,t){if(!Q(e))throw TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return b(e.k);case"RSA":if(void 0!==e.oth)throw new _('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return eA({...e,alg:t});default:throw new _('Unsupported "kty" (Key Type) Parameter value')}}let eH=(e,t,r)=>{if(e.startsWith("HS")||"dir"===e||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)){if(!(t instanceof Uint8Array)){if(!(t instanceof CryptoKey))throw TypeError(G(e,t,...V,"Uint8Array"));if("secret"!==t.type)throw TypeError(`${V.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}}else{if(!(t instanceof CryptoKey))throw TypeError(G(e,t,...V));if("secret"===t.type)throw TypeError(`${V.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw TypeError(`${V.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw TypeError(`${V.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw TypeError(`${V.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);
3if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw TypeError(`${V.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)}};async function eO(e,t,r,n,a){if(!(r instanceof Uint8Array))throw TypeError(F(r,"Uint8Array"));let i=parseInt(e.slice(1,4),10),s=await o.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),c=await o.subtle.importKey("raw",r.subarray(0,i>>3),{hash:`SHA-${i<<1}`,name:"HMAC"},!1,["sign"]),u=new Uint8Array(await o.subtle.encrypt({iv:n,name:"AES-CBC"},s,t)),d=l(a,n,u,p(a.length<<3));return{ciphertext:u,tag:new Uint8Array((await o.subtle.sign("HMAC",c,d)).slice(0,i>>3)),iv:n}}async function eT(e,t,r,n,a){let i;r instanceof Uint8Array?i=await o.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(B(r,e,"encrypt"),i=r);let s=new Uint8Array(await o.subtle.encrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},i,t)),c=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:c,iv:n}}let eK=async(e,t,r,n,a)=>{if(!(r instanceof CryptoKey)&&!(r instanceof Uint8Array))throw TypeError(F(r,...V,"Uint8Array"));switch(n?x(e,n):n=J(new Uint8Array(U(e)>>3)),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&j(r,parseInt(e.slice(-3),10)),eO(e,t,r,n,a);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&j(r,parseInt(e.slice(1,4),10)),eT(e,t,r,n,a);default:throw new _("Unsupported JWE Content Encryption Algorithm")}};async function eW(e,t,r,n){let a=e.slice(0,7),i=await eK(a,r,t,n,new Uint8Array(0));return{encryptedKey:i.ciphertext,iv:m(i.iv),tag:m(i.tag)}}async function eI(e,t,r,n,a){return X(e.slice(0,7),t,r,n,a,new Uint8Array(0))}async function eR(e,t,r,n,a){switch(eH(e,t,"decrypt"),e){case"dir":if(void 0!==r)throw new C("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new C("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let a,i;if(!Q(n.epk))throw new C('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!eo(t))throw new _("ECDH with the provided key is not allowed or not supported by your javascript runtime");let o=await ek(n.epk,e);if(void 0!==n.apu){if("string"!=typeof n.apu)throw new C('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{a=b(n.apu)}catch{throw new C("Failed to base64url decode the apu")}}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new C('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{i=b(n.apv)}catch{throw new C("Failed to base64url decode the apv")}}let s=await ea(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?ey(n.enc):parseInt(e.slice(-5,-2),10),a,i);if("ECDH-ES"===e)return s;if(void 0===r)throw new C("JWE Encrypted Key missing");return en(e.slice(-6),s,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if(void 0===r)throw new C("JWE Encrypted Key missing");return eh(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let i;if(void 0===r)throw new C("JWE Encrypted Key missing");if("number"!=typeof n.p2c)throw new C('JOSE Header "p2c" (PBES2 Count) missing or invalid');let o=a?.maxPBES2Count||1e4;if(n.p2c>o)throw new C('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new C('JOSE Header "p2s" (PBES2 Salt) missing or invalid');try{i=b(n.p2s)}catch{throw new C("Failed to base64url decode the p2s")}return eu(e,t,r,n.p2c,i)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new C("JWE Encrypted Key missing");return en(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{let a,i;if(void 0===r)throw new C("JWE Encrypted Key missing");if("string"!=typeof n.iv)throw new C('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new C('JOSE Header "tag" (Authentication Tag) missing or invalid');try{a=b(n.iv)}catch{throw new C("Failed to base64url decode the iv")}try{i=b(n.tag)}catch{throw new C("Failed to base64url decode the tag")}return eI(e,t,r,a,i)}default:throw new _('Invalid or unsupported "alg" (JWE Algorithm) header value')}}let eJ=function(e,t,r,n,a){let i;if(void 0!==a.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 o of(i=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t,n.crit)){if(!i.has(o))throw new _(`Extension Header Parameter "${o}" is not recognized`);if(void 0===a[o])throw new e(`Extension Header Parameter "${o}" is missing`);if(i.get(o)&&void 0===n[o])throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`)}return new Set(n.crit)},eU=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw TypeError(`"${e}
3" option must be an array of strings`);if(t)return new Set(t)};async function ex(e,t,r){let n,a,i,o,s,d,p;if(!Q(e))throw new C("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new C("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new C("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new C("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new C("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new C("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new C("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new C("JWE AAD incorrect type");if(void 0!==e.header&&!Q(e.header))throw new C("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!Q(e.unprotected))throw new C("JWE Per-Recipient Unprotected Header incorrect type");if(e.protected)try{let t=b(e.protected);n=JSON.parse(u.decode(t))}catch{throw new C("JWE Protected Header is invalid")}if(!Y(n,e.header,e.unprotected))throw new C("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let h={...n,...e.header,...e.unprotected};if(eJ(C,new Map,r?.crit,n,h),void 0!==h.zip)throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');let{alg:y,enc:f}=h;if("string"!=typeof y||!y)throw new C("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof f||!f)throw new C("missing JWE Encryption Algorithm (enc) in JWE Header");let w=r&&eU("keyManagementAlgorithms",r.keyManagementAlgorithms),m=r&&eU("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(w&&!w.has(y)||!w&&y.startsWith("PBES2"))throw new A('"alg" (Algorithm) Header Parameter value not allowed');if(m&&!m.has(f))throw new A('"enc" (Encryption Algorithm) Header Parameter value not allowed');if(void 0!==e.encrypted_key)try{a=b(e.encrypted_key)}catch{throw new C("Failed to base64url decode the encrypted_key")}let g=!1;"function"==typeof t&&(t=await t(n,e),g=!0);try{i=await eR(y,t,a,h,r)}catch(e){if(e instanceof TypeError||e instanceof C||e instanceof _)throw e;i=ef(f)}if(void 0!==e.iv)try{o=b(e.iv)}catch{throw new C("Failed to base64url decode the iv")}if(void 0!==e.tag)try{s=b(e.tag)}catch{throw new C("Failed to base64url decode the tag")}let E=c.encode(e.protected??"");d=void 0!==e.aad?l(E,c.encode("."),c.encode(e.aad)):E;try{p=b(e.ciphertext)}catch{throw new C("Failed to base64url decode the ciphertext")}let S={plaintext:await X(f,i,p,o,s,d)};if(void 0!==e.protected&&(S.protectedHeader=n),void 0!==e.aad)try{S.additionalAuthenticatedData=b(e.aad)}catch{throw new C("Failed to base64url decode the aad")}return(void 0!==e.unprotected&&(S.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(S.unprotectedHeader=e.header),g)?{...S,key:t}:S}async function ej(e,t,r){if(e instanceof Uint8Array&&(e=u.decode(e)),"string"!=typeof e)throw new C("Compact JWE must be a string or Uint8Array");let{0:n,1:a,2:i,3:o,4:s,length:c}=e.split(".");if(5!==c)throw new C("Invalid Compact JWE");let l=await ex({ciphertext:o,iv:i||void 0,protected:n,tag:s||void 0,encrypted_key:a||void 0},t,r),d={plaintext:l.plaintext,protectedHeader:l.protectedHeader};return"function"==typeof t?{...d,key:l.key}:d}async function eD(e,t,r){if(!Q(e))throw new C("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(Q))throw new C("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new C("JWE Recipients has no members");for(let n of e.recipients)try{return await ex({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 P}let eM=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:m(e)};if(!(e instanceof CryptoKey))throw TypeError(F(e,...V,"Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:a,...i}=await o.subtle.exportKey("jwk",e);return i};async function eN(e){return em("public","spki",e)}async function e$(e){return em("private","pkcs8",e)}async function eB(e){return eM(e)}async function eL(e,t,r,n,a={}){let i,o,s;switch(eH(e,r,"encrypt"),e){case"dir":s=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!eo(r))throw new _("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:c,apv:u}=a,{epk:l}=a;l||(l=(await ei(r)).privateKey);let{x:d,y:p,crv:h,kty:y}=await eB(l),f=await ea(r,l,"ECDH-ES"===e?t:e,"ECDH-ES"===e?ey(t):parseInt(e.slice(-5,-2),10),c,u);if(o={epk:{x:d,crv:h,kty:y}},"EC"===y&&(o.epk.y=p),c&&(o.apu=m(c)),u&&(o.apv=m(u)),"ECDH-ES"===e){s=f;break}s=n||ef(t);let w=e.slice(-6);i=await er(w,f,s);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s=n||ef(t),i=await ep(e,r,s);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{s=n||ef(t);let{p2c:c,p2s:u}=a;({encryptedKey:i,...o}=await ec(e,r,s,c,u));break}
3case"A128KW":case"A192KW":case"A256KW":s=n||ef(t),i=await er(e,r,s);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{s=n||ef(t);let{iv:c}=a;({encryptedKey:i,...o}=await eW(e,r,s,c));break}default:throw new _('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:s,encryptedKey:i,parameters:o}}let eF=Symbol();class eG{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,n,a,i,o;if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new C("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Y(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new C("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let s={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(eJ(C,new Map,t?.crit,this._protectedHeader,s),void 0!==s.zip)throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');let{alg:d,enc:p}=s;if("string"!=typeof d||!d)throw new C('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof p||!p)throw new C('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(this._cek&&("dir"===d||"ECDH-ES"===d))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${d}`);{let a;({cek:n,encryptedKey:r,parameters:a}=await eL(d,p,e,this._cek,this._keyManagementParameters)),a&&(t&&eF in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...a}:this.setUnprotectedHeader(a):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...a}:this.setProtectedHeader(a))}i=this._protectedHeader?c.encode(m(JSON.stringify(this._protectedHeader))):c.encode(""),this._aad?(o=m(this._aad),a=l(i,c.encode("."),c.encode(o))):a=i;let{ciphertext:h,tag:y,iv:f}=await eK(p,this._plaintext,n,this._iv,a),w={ciphertext:m(h)};return f&&(w.iv=m(f)),y&&(w.tag=m(y)),r&&(w.encrypted_key=m(r)),o&&(w.aad=o),this._protectedHeader&&(w.protected=u.decode(i)),this._sharedUnprotectedHeader&&(w.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(w.header=this._unprotectedHeader),w}}class eV{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}}class ez{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,t){let r=new eV(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 C("at least one recipient must be added");if(1===this._recipients.length){let[e]=this._recipients,t=await new eG(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(e.unprotectedHeader).encrypt
3(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(!Y(this._protectedHeader,this._unprotectedHeader,r.unprotectedHeader))throw new C("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader,...r.unprotectedHeader},{alg:a}=n;if("string"!=typeof a||!a)throw new C('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===a||"ECDH-ES"===a)throw new C('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof n.enc||!n.enc)throw new C('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(e){if(e!==n.enc)throw new C('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else e=n.enc;if(eJ(C,new Map,r.options.crit,this._protectedHeader,n),void 0!==n.zip)throw new _('JWE "zip" (Compression Algorithm) Header Parameter is not supported.')}let t=ef(e),r={ciphertext:"",iv:"",recipients:[],tag:""};for(let n=0;n<this._recipients.length;n++){let a=this._recipients[n],i={};r.recipients.push(i);let o=({...this._protectedHeader,...this._unprotectedHeader,...a.unprotectedHeader}).alg.startsWith("PBES2")?2048+n:void 0;if(0===n){let e=await new eG(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(t).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(a.unprotectedHeader).setKeyManagementParameters({p2c:o}).encrypt(a.key,{...a.options,[eF]:!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),i.encrypted_key=e.encrypted_key,e.header&&(i.header=e.header);continue}let{encryptedKey:s,parameters:c}=await eL(a.unprotectedHeader?.alg||this._protectedHeader?.alg||this._unprotectedHeader?.alg,e,a.key,t,{p2c:o});i.encrypted_key=m(s),(a.unprotectedHeader||c)&&(i.header={...a.unprotectedHeader,...c})}return r}}function eq(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new _(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function eX(e,t,r){if(t instanceof CryptoKey)return!function(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!M(e.algorithm,"HMAC"))throw D("HMAC");let r=parseInt(t.slice(2),10);if(N(e.algorithm.hash)!==r)throw D(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!M(e.algorithm,"RSASSA-PKCS1-v1_5"))throw D("RSASSA-PKCS1-v1_5");let r=parseInt(t.slice(2),10);if(N(e.algorithm.hash)!==r)throw D(`SHA-${r}`,"algorithm.hash");break}
3case"PS256":case"PS384":case"PS512":{if(!M(e.algorithm,"RSA-PSS"))throw D("RSA-PSS");let r=parseInt(t.slice(2),10);if(N(e.algorithm.hash)!==r)throw D(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw D("Ed25519 or Ed448");break;case"ES256":case"ES384":case"ES512":{if(!M(e.algorithm,"ECDSA"))throw D("ECDSA");let r=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!==r)throw D(r,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}$(e,r)}(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(F(t,...V));return o.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw TypeError(F(t,...V,"Uint8Array"))}let eY=async(e,t,r,n)=>{let a=await eX(e,t,"verify");ed(e,a);let i=eq(e,a.algorithm);try{return await o.subtle.verify(i,a,r,n)}catch{return!1}};async function eQ(e,t,r){let n,a;if(!Q(e))throw new k("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new k('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new k("JWS Protected Header incorrect type");if(void 0===e.payload)throw new k("JWS Payload missing");if("string"!=typeof e.signature)throw new k("JWS Signature missing or incorrect type");if(void 0!==e.header&&!Q(e.header))throw new k("JWS Unprotected Header incorrect type");let i={};if(e.protected)try{let t=b(e.protected);i=JSON.parse(u.decode(t))}catch{throw new k("JWS Protected Header is invalid")}if(!Y(i,e.header))throw new k("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...i,...e.header},s=eJ(k,new Map([["b64",!0]]),r?.crit,i,o),d=!0;if(s.has("b64")&&"boolean"!=typeof(d=i.b64))throw new k('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:p}=o;if("string"!=typeof p||!p)throw new k('JWS "alg" (Algorithm) Header Parameter missing or invalid');let h=r&&eU("algorithms",r.algorithms);if(h&&!h.has(p))throw new A('"alg" (Algorithm) Header Parameter value not allowed');if(d){if("string"!=typeof e.payload)throw new k("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new k("JWS Payload must be a string or an Uint8Array instance");let y=!1;"function"==typeof t&&(t=await t(i,e),y=!0),eH(p,t,"verify");let f=l(c.encode(e.protected??""),c.encode("."),"string"==typeof e.payload?c.encode(e.payload):e.payload);try{n=b(e.signature)}catch{throw new k("Failed to base64url decode the signature")}if(!await eY(p,t,n,f))throw new R;if(d)try{a=b(e.payload)}catch{throw new k("Failed to base64url decode the payload")}else a="string"==typeof e.payload?c.encode(e.payload):e.payload;let w={payload:a};return(void 0!==e.protected&&(w.protectedHeader=i),void 0!==e.header&&(w.unprotectedHeader=e.header),y)?{...w,key:t}:w}async function eZ(e,t,r){if(e instanceof Uint8Array&&(e=u.decode(e)),"string"!=typeof e)throw new k("Compact JWS must be a string or Uint8Array");let{0:n,1:a,2:i,length:o}=e.split(".");if(3!==o)throw new k("Invalid Compact JWS");let s=await eQ({payload:a,protected:n,signature:i},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...c,key:s.key}:c}async function e0(e,t,r){if(!Q(e))throw new k("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(Q))throw new k("JWS Signatures missing or incorrect type");for(let n of e.signatures)try{return await eQ({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new R}let e1=e=>Math.floor(e.getTime()/1e3),e2=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,e8=e=>{let t,r=e2.exec(e);if(!r||r[4]&&r[1])throw TypeError("Invalid time period format");let n=parseFloat(r[2]);switch(r[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"-"===r[1]||"ago"===r[4]?-t:t},e5=e=>e.toLowerCase().replace(/^application\//,""),e4=(e,t,r={})=>{var n,a;let i,o,{typ:s}=r;if(s&&("string"!=typeof e.typ||e5(e.typ)!==e5(s)))throw new S('unex
3pected "typ" JWT header value',"typ","check_failed");try{i=JSON.parse(u.decode(t))}catch{}if(!Q(i))throw new H("JWT Claims Set must be a top-level JSON object");let{requiredClaims:c=[],issuer:l,subject:d,audience:p,maxTokenAge:h}=r,y=[...c];for(let e of(void 0!==h&&y.push("iat"),void 0!==p&&y.push("aud"),void 0!==d&&y.push("sub"),void 0!==l&&y.push("iss"),new Set(y.reverse())))if(!(e in i))throw new S(`missing required "${e}" claim`,e,"missing");if(l&&!(Array.isArray(l)?l:[l]).includes(i.iss))throw new S('unexpected "iss" claim value',"iss","check_failed");if(d&&i.sub!==d)throw new S('unexpected "sub" claim value',"sub","check_failed");if(p&&(n=i.aud,a="string"==typeof p?[p]:p,"string"==typeof n?!a.includes(n):!(Array.isArray(n)&&a.some(Set.prototype.has.bind(new Set(n))))))throw new S('unexpected "aud" claim value',"aud","check_failed");switch(typeof r.clockTolerance){case"string":o=e8(r.clockTolerance);break;case"number":o=r.clockTolerance;break;case"undefined":o=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:f}=r,w=e1(f||new Date);if((void 0!==i.iat||h)&&"number"!=typeof i.iat)throw new S('"iat" claim must be a number',"iat","invalid");if(void 0!==i.nbf){if("number"!=typeof i.nbf)throw new S('"nbf" claim must be a number',"nbf","invalid");if(i.nbf>w+o)throw new S('"nbf" claim timestamp check failed',"nbf","check_failed")}if(void 0!==i.exp){if("number"!=typeof i.exp)throw new S('"exp" claim must be a number',"exp","invalid");if(i.exp<=w-o)throw new v('"exp" claim timestamp check failed',"exp","check_failed")}if(h){let e=w-i.iat;if(e-o>("number"==typeof h?h:e8(h)))throw new v('"iat" claim timestamp check failed (too far in the past)',"iat","check_failed");if(e<0-o)throw new S('"iat" claim timestamp check failed (it should be in the past)',"iat","check_failed")}return i};async function e3(e,t,r){let n=await eZ(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&!1===n.protectedHeader.b64)throw new H("JWTs MUST NOT use unencoded payload");let a={payload:e4(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return"function"==typeof t?{...a,key:n.key}:a}async function e6(e,t,r){let n=await ej(e,t,r),a=e4(n.protectedHeader,n.plaintext,r),{protectedHeader:i}=n;if(void 0!==i.iss&&i.iss!==a.iss)throw new S('replicated "iss" claim header parameter mismatch',"iss","mismatch");if(void 0!==i.sub&&i.sub!==a.sub)throw new S('replicated "sub" claim header parameter mismatch',"sub","mismatch");if(void 0!==i.aud&&JSON.stringify(i.aud)!==JSON.stringify(a.aud))throw new S('replicated "aud" claim header parameter mismatch',"aud","mismatch");let o={payload:a,protectedHeader:i};return"function"==typeof t?{...o,key:n.key}:o}class e9{constructor(e){this._flattened=new eG(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(".")}}let e7=async(e,t,r)=>{let n=await eX(e,t,"sign");return ed(e,n),new Uint8Array(await o.subtle.sign(eq(e,n.algorithm),n,r))};class te{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 k("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Y(this._protectedHeader,this._unprotectedHeader))throw new k("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},a=eJ(k,new Map([["b64",!0]]),t?.crit,this._protectedHeader,n),i=!0;if(a.has("b64")&&"boolean"!=typeof(i=this._protectedHeader.b64))throw new k('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:o}=n;
3if("string"!=typeof o||!o)throw new k('JWS "alg" (Algorithm) Header Parameter missing or invalid');eH(o,e,"sign");let s=this._payload;i&&(s=c.encode(m(s)));let d=l(r=this._protectedHeader?c.encode(m(JSON.stringify(this._protectedHeader))):c.encode(""),c.encode("."),s),p={signature:m(await e7(o,e,d)),payload:""};return i&&(p.payload=u.decode(s)),this._unprotectedHeader&&(p.header=this._unprotectedHeader),this._protectedHeader&&(p.protected=u.decode(r)),p}}class tt{constructor(e){this._flattened=new te(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}`}}class tr{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}}class tn{constructor(e){this._signatures=[],this._payload=e}addSignature(e,t){let r=new tr(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new k("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],n=new te(this._payload);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);let{payload:a,...i}=await n.sign(r.key,r.options);if(0===t)e.payload=a;else if(e.payload!==a)throw new k("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(i)}return e}}function ta(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}class ti{constructor(e={}){if(!Q(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:ta("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:ta("setNotBefore",e1(e))}:this._payload={...this._payload,nbf:e1(new Date)+e8(e)},this}setExpirationTime(e){return"number"==typeof e?this._payload={...this._payload,exp:ta("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:ta("setExpirationTime",e1(e))}:this._payload={...this._payload,exp:e1(new Date)+e8(e)},this}setIssuedAt(e){return void 0===e?this._payload={...this._payload,iat:e1(new Date)}:e instanceof Date?this._payload={...this._payload,iat:ta("setIssuedAt",e1(e))}:"string"==typeof e?this._payload={...this._payload,iat:ta("setIssuedAt",e1(new Date)+e8(e))}:this._payload={...this._payload,iat:ta("setIssuedAt",e)},this}}class to extends ti{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){let r=new tt(c.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 H("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}class ts extends ti{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 e9(c.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),r.setProtectedHeader(this._protectedHeader),this._iv&&r.setInitializationVector(this._iv),this._cek&&r.setContentEncryptionKey(this._cek),this._keyManagementParameters&&r.setKeyManagementParameters(this._keyManagementParameters),r.encrypt(e,t)}}let tc=(e,t)=>{if("string"!=typeof e||!e)throw new O(`${t} missing or invalid`)};async function tu(e,t){let r;if(!Q(e))throw TypeError("JWK must be an object");
3if(t??(t="sha256"),"sha256"!==t&&"sha384"!==t&&"sha512"!==t)throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');switch(e.kty){case"EC":tc(e.crv,'"crv" (Curve) Parameter'),tc(e.x,'"x" (X Coordinate) Parameter'),tc(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":tc(e.crv,'"crv" (Subtype of Key Pair) Parameter'),tc(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":tc(e.e,'"e" (Exponent) Parameter'),tc(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":tc(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new _('"kty" (Key Type) Parameter missing or unsupported')}let n=c.encode(JSON.stringify(r));return m(await s(t,n))}async function tl(e,t){t??(t="sha256");let r=await tu(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function td(e,t){let r={...e,...t?.header};if(!Q(r.jwk))throw new k('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let n=await ek({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||"public"!==n.type)throw new k('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function tp(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(th)}function th(e){return Q(e)}class ty{constructor(e){if(this._cached=new WeakMap,!tp(e))throw new T("JSON Web Key Set malformed");this._jwks=function(e){return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}(e)}async getKey(e,t){let{alg:r,kid:n}={...e,...t?.header},a=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new _('Unsupported "alg" value for a JSON Web Key Set')}}(r),i=this._jwks.keys.filter(e=>{let t=a===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t&&"EdDSA"===r&&(t="Ed25519"===e.crv||"Ed448"===e.crv),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv}return t}),{0:o,length:s}=i;if(0===s)throw new K;if(1!==s){let e=new W,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(let e of i)try{yield await tf(t,e,r)}catch{}},e}return tf(this._cached,o,r)}}async function tf(e,t,r){let n=e.get(t)||e.set(t,{}).get(t);if(void 0===n[r]){let e=await ek({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new T("JSON Web Key Set members must be public keys");n[r]=e}return n[r]}function tw(e){let t=new ty(e);return async(e,r)=>t.getKey(e,r)}let tm=async(e,t,r)=>{let n,a,i=!1;"function"==typeof AbortController&&(n=new AbortController,a=setTimeout(()=>{i=!0,n.abort()},t));let o=await fetch(e.href,{signal:n?n.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{if(i)throw new I;throw e});if(void 0!==a&&clearTimeout(a),200!==o.status)throw new E("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await o.json()}catch{throw new E("Failed to parse the JSON Web Key Set HTTP response as JSON")}};("u"<typeof navigator||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(n="jose/v5.2.3");class tg extends ty{constructor(e,t){if(super({keys:[]}),this._jwks=void 0,!(e instanceof URL))throw TypeError("url must be an instance of URL");this._url=new URL(e.href),this._options={agent:t?.agent,headers:t?.headers},this._timeoutDuration="number"==typeof t?.timeoutDuration?t?.timeoutDuration:5e3,this._cooldownDuration="number"==typeof t?.cooldownDuration?t?.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof t?.cacheMaxAge?t?.cacheMaxAge:6e5}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._jwks&&this.fresh()||await this.reload();try{return await super.getKey(e,t)}catch(r){if(r instanceof K&&!1===this.coolingDown())return await this.reload(),super.getKey(e,t);throw r}}async reload(){this._pendingFetch&&("u">typeof WebSocketPair||"u">typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"u">
3typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0);let e=new Headers(this._options.headers);n&&!e.has("User-Agent")&&(e.set("User-Agent",n),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||(this._pendingFetch=tm(this._url,this._timeoutDuration,this._options).then(e=>{if(!tp(e))throw new T("JSON Web Key Set malformed");this._jwks={keys:e.keys},this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e})),await this._pendingFetch}}function tb(e,t){let r=new tg(e,t);return async(e,t)=>r.getKey(e,t)}class tE extends ti{encode(){let e=m(JSON.stringify({alg:"none"})),t=m(JSON.stringify(this._payload));return`${e}.${t}.`}static decode(e,t){let r;if("string"!=typeof e)throw new H("Unsecured JWT must be a string");let{0:n,1:a,2:i,length:o}=e.split(".");if(3!==o||""!==i)throw new H("Invalid Unsecured JWT");try{if(r=JSON.parse(u.decode(b(n))),"none"!==r.alg)throw Error()}catch{throw new H("Invalid Unsecured JWT")}return{payload:e4(r,b(a),t),header:r}}}let tS=m,tv=b;function tA(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(u.decode(tv(t)));if(!Q(e))throw Error();return e}catch{throw TypeError("Invalid Token or Protected Header formatting")}}function t_(e){let t,r;if("string"!=typeof e)throw new H("JWTs must use Compact JWS serialization, JWT must be a string");let{1:n,length:a}=e.split(".");if(5===a)throw new H("Only JWTs using Compact JWS serialization can be decoded");if(3!==a)throw new H("Invalid JWT");if(!n)throw new H("JWTs must contain a payload");try{t=tv(n)}catch{throw new H("Failed to base64url decode the payload")}try{r=JSON.parse(u.decode(t))}catch{throw new H("Failed to parse the decoded payload as JSON")}if(!Q(r))throw new H("Invalid JWT Claims Set");return r}async function tP(e,t){let r,n,a;switch(e){case"HS256":case"HS384":case"HS512":r=parseInt(e.slice(-3),10),n={name:"HMAC",hash:`SHA-${r}`,length:r},a=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return J(new Uint8Array((r=parseInt(e.slice(-3),10))>>3));case"A128KW":case"A192KW":case"A256KW":n={name:"AES-KW",length:r=parseInt(e.slice(1,4),10)},a=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":n={name:"AES-GCM",length:r=parseInt(e.slice(1,4),10)},a=["encrypt","decrypt"];break;default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return o.subtle.generateKey(n,t?.extractable??!1,a)}function tC(e){let t=e?.modulusLength??2048;if("number"!=typeof t||t<2048)throw new _("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function tk(e,t){let r,n;switch(e){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:tC(t)},n=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:tC(t)},n=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:tC(t)},n=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},n=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},n=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},n=["sign","verify"];break;case"EdDSA":{n=["sign","verify"];let e=t?.crv??"Ed25519";
3switch(e){case"Ed25519":case"Ed448":r={name:e};break;default:throw new _("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{n=["deriveKey","deriveBits"];let e=t?.crv??"P-256";switch(e){case"P-256":case"P-384":case"P-521":r={name:"ECDH",namedCurve:e};break;case"X25519":case"X448":r={name:e};break;default:throw new _("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new _('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return o.subtle.generateKey(r,t?.extractable??!1,n)}async function tH(e,t){return tk(e,t)}async function tO(e,t){return tP(e,t)}let tT="WebCryptoAPI"},65538:(e,t,r)=>{var n=r(12115),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=n.useState,o=n.useEffect,s=n.useLayoutEffect,c=n.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!a(e,r)}catch(e){return!0}}var l="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),n=i({inst:{value:r,getSnapshot:t}}),a=n[0].inst,l=n[1];return s(function(){a.value=r,a.getSnapshot=t,u(a)&&l({inst:a})},[e,r,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(r),r};t.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:l},72552:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineParallelCalls=t.getDeferred=t.doWhile=t.delay=void 0,t.delay=(e,t={})=>new Promise(r=>{let n=setTimeout(r,e);t.unref&&n.unref&&n.unref()}),t.doWhile=async function(e,t){do await e();while(await t())},t.getDeferred=function(){let e,t,r=new Promise((r,n)=>{e=r,t=n});return{resolve:e,reject:t,promise:r}},t.combineParallelCalls=function(e){let t;return()=>(void 0===t&&(t=e().finally(()=>{t=void 0})),t)}},76173:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r(49303),a=r(44784);t.default=function(){function e(){this._semaphore=new a.default(1)}return e.prototype.acquire=function(){return n.__awaiter(this,void 0,void 0,function(){return n.__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}()},79814:(e,t,r)=>{var n=Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};Object.defineProperty(t,"__esModule",{value:!0}),t.updateTeamMembers=t.getBillingData=t.cancelSubscription=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;var a=r(91943);for(var i in a)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,a,i);var o=r(91370);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 s=r(43814);Object.defineProperty(t,"prepareCheckout",{enumerable:!0,get:function(){return s.prepareCheckout}}),Object.defineProperty(t,"prefetchCheckout",{enumerable:!0,get:function(){return s.prefetchCheckout}}),Object.defineProperty(t,"goToCheckout",{enumerable:!0,get:function(){return s.goToCheckout}}),Object.defineProperty(t,"openNewCheckoutWindow",{enumerable:!0,get:function(){return s.openNewCheckoutWindow}});var c=r(83724);Object.defineProperty(t,"loginWithCode",{enumerable:!0,get:function(){return c.loginWithCode}}),Object.defineProperty(t,"sendAuthCode",{enumerable:!0,get:function(){return c.sendAuthCode}}),Object.defineProperty(t,"logOut",{enumerable:!0,get:function(){return c.logOut}}),Object.defineProperty(t,"AuthRejectedError",{enumerable:!0,get:function(){return c.AuthRejectedError}}),Object.defineProperty(t,"getLatestUserData",{enumerable:!0,get:function(){return c.getLatestUserData}}),Object.defineProperty(t,"getLastUserData",{enumerable:!0,get:function(){return c.getLastUserData}}),Object.defineProperty(t,"cancelSubscription",{enumerable:!0,get:function(){return c.cancelSubscription}}),Object.defineProperty(t,"getBillingData",{enumerable:!0,get:function(){return c.getBillingData}}),Object.defineProperty(t,"updateTeamMembers",{enumerable:!0,get:function(){return c.updateTeamMembers}})},83724:(e,t,r)=>{var n;let a;
3Object.defineProperty(t,"__esModule",{value:!0}),t.cancelSubscription=t.updateTeamMembers=t.getBillingData=t.getLatestUserData=t.getLastUserData=t.logOut=t.loginWithCode=t.sendAuthCode=t.AuthRejectedError=void 0;let i=r(42720),o=r(37662),s=r(31938),c=r(65287),u=r(25902),l=r(91370),d=(null==(n=null==globalThis?void 0:globalThis.crypto)?void 0:n.subtle)?(0,c.importSPKI)(`
4-----BEGIN PUBLIC KEY-----
5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzRLZvRoiWBQS8Fdqqh/h
6xVDI+ogFZ2LdIiMOQmkq2coYNvBXGX016Uw9KNlweUlCXUaQZkDuQBmwxcs80PEn
7IliLvJnOcIA9bAJFEF36uIwSI/ZRj0faExanLO78cdIx+B+p69kFGlohQGzJmS1S
8v/IYYu032hO+F5ypR+AoXn6qtGGLVN0zAvsvLEF3urY5jHiVbgk2FWD3FWMU3oBF
9jEEjeSlAFnwJZgeEMFeYni7W/rQ8seU8y3YMIg2UyHpeVNnuWbJFFwGq8Aumg4SC
10mCVpul3MYubdv034/ipGZSKJTwgubiHocrSBdeImNe3xdxOw/Mo04r0kcZBg2l/b
117QIDAQAB
12-----END PUBLIC KEY-----
13`.trim(),"RS256"):Promise.reject(Error("WebCrypto not available in your browser. Auth is only possible in secure contexts (HTTPS).")),p=new o.Mutex;if("u">typeof localStorage)try{a=JSON.parse(localStorage.getItem("tokens"))}catch(e){a=null,console.log("Invalid token",localStorage.getItem("tokens"),e)}function h(e){return p.runExclusive(()=>{a=e,localStorage.setItem("tokens",JSON.stringify(e))})}function y(){return p.runExclusive(()=>{if(!a)return;let e=a.accessTokenExpiry.valueOf()-Date.now(),t=e<6e5&&a.refreshToken?m(a.refreshToken):null;return e>5e3?a.accessToken:t?t:void w()})}class f extends s.CustomError{constructor(){super("Authentication failed")}}function w(){h(null)}async function m(e){try{let t=await fetch(`${u.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 a.accessToken=r.accessToken,a.accessTokenExpiry=r.expiresAt,localStorage.setItem("tokens",JSON.stringify(a)),r.accessToken}catch(e){if(e instanceof f)throw e;throw Error(`Failed to refresh token: ${(0,s.asErrorLike)(e).message||e}`)}}t.AuthRejectedError=f,t.sendAuthCode=async function(e,t){try{let r=await fetch(`${u.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,s.asErrorLike)(e).message||e}]`);throw Error(`Unexpected ${r.status} response: ${e}`)}}catch(e){throw Error(`Failed to send auth code: ${(0,s.asErrorLike)(e).message||e}`)}},t.loginWithCode=async function(e,t){try{let r=await fetch(`${u.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,s.asErrorLike)(e).message||e}]`);throw Error(`Unexpected ${r.status} response: ${e}`)}let n=await r.json();await h({accessToken:n.accessToken,refreshToken:n.refreshToken,accessTokenExpiry:n.expiresAt})}catch(e){if(e instanceof f)throw e;throw Error(`Failed to login with code: ${(0,s.asErrorLike)(e).message||e}`)}},t.logOut=w;let g=()=>({featureFlags:[],banned:!1});async function b(e,t){return e?(await (0,c.jwtVerify)(e,await d,{algorithms:["RS256"],audience:`https://httptoolkit.tech/${t}_data`,issuer:"https://httptoolkit.tech/"})).payload:null}function E(e){return e?{userId:e.user_id,email:e.email,subscription:v(e),teamSubscription:e.team_subscription?v(e.team_subscription):void 0,featureFlags:e.feature_flags||[],banned:!!e.banned}:g()}async function S(e){var t,r;if(!e)return{transactions:[],banned:!1};let n=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:v(e),transactions:n,teamMembers:e.team_members,teamOwner:e.team_owner,lockedLicenseExpiries:e.locked_license_expiries,banned:!!e.banned}}function v(e){var t;let r=null!=(t=e.subscription_sku)?t:(0,l.getSKUForPaddleId)(e.subscription_plan_id),[n,a]=r?r.split("-"):[],o={status:e.subscription_status,plan:r,sku:r,tierCode:n,interval:a,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(i.some(o)&&!o.plan)throw console.warn("Invalid raw subscription data",e),new s.CustomError("Invalid subscription data");return i.every(i.omit(o,"lastReceiptUrl","updateBillingDetailsUrl","cancelSubscriptionUrl"),e=>!i.isNil(e))?o:void 0}async function A(e,t={}){let r=await y();if(!r)return"";let n=await fetch(`${u.ACCOUNTS_API_BASE}/get-${e}-data`,{method:"GET",headers:{Authorization:`Bearer ${r}`}});if(!n.ok){if(console.log(`Received ${n.status} loading ${e} data, with body: ${await n.text()}`),401===n.status)return p.runExclusive(()=>{if(t.isRetry||!(null==a?void 0:a.refreshToken))throw new f;return m(a.refreshToken)}).then(()=>A(e,{isRetry:!0}));throw Error(`Failed to load ${e} data`)}return n.text()}t.getLastUserData=function(){try{var e;let t=localStorage.getItem("last_jwt"),r=(e=t)?(0,c.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");b(t,"app").catch(e=>{localStorage.removeItem("last_jwt"),console.log("Last JWT no longer valid - now cleared",e)})}return E(r)}catch(e){return console.warn("Couldn't parse saved user data",e),g()}},t.getLatestUserData=async function(){try{let e=await A("app"),t=await b(e,"app"),r=E(t);return localStorage.setItem("last_jwt",e),r}catch(e){try{let e=localStorage.getItem("last_jwt"),t=await b(e,"app");return E(t)}catch(e){return console.warn("Failed to validate last user JWT when updating",e),g()}}},t.getBillingData=async function(){let e=await A("billing");return S(await b(e,"billing"))},t.updateTeamMembers=async function(e,t){let r=await y();if(!r)throw Error("Can't update team without an auth token");let n=await fetch(`${u.ACCOUNTS_API_BASE}/update-team`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({idsToRemove:e,emailsToAdd:t})});if(!n.ok){let e=await n.text();throw console.log(`Received ${n.status} updating team members: ${e}`),Error(e||"Failed to update team members")}},t.cancelSubscription=async function(){let e=await y();if(!e)throw Error("Can't cancel account without an auth token");let t=await fetch(`${u.ACCOUNTS_API_BASE}/cancel-subscription`,{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Unexpected ${t.status} response cancelling subscription`)}},91370:(e,t,r)=>
13{Object.defineProperty(t,"__esModule",{value:!0}),t.getSKUForPaddleId=t.getPlanByCode=t.loadPlanPricesUntilSuccess=t.SubscriptionPlans=void 0;let n=r(42720),a=r(31938),i=r(25902);async function o(){let e=await fetch(`${i.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=n.find(t.SubscriptionPlans,{paddleId:e.product_id});if(!r)return;let a=e.currency,i=e.price.net,o="year"===e.subscription.interval?i/12:i;r.prices={rawTotal:i,currency:a,total:c(a,i),monthly:c(a,o)}}),t.SubscriptionPlans}async function s(){return await (0,a.doWhile)(()=>Promise.race([o().catch(console.warn),(0,a.delay)(5e3)]).then(()=>(0,a.delay)(1e3)),()=>n.some(t.SubscriptionPlans,e=>!e.prices)),t.SubscriptionPlans}function c(e,t){return Number(t).toLocaleString(void 0,{style:"currency",currency:e,minimumFractionDigits:2*(n.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.loadPlanPricesUntilSuccess=s,t.getPlanByCode=e=>t.SubscriptionPlans[e],t.getSKUForPaddleId=e=>n.findKey(t.SubscriptionPlans,{paddleId:e})},91943:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},92573:(e,t)=>{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 n 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=n;class a extends n{constructor(e,t,r={}){super(t,{...r,statusCode:e})}}t.StatusError=a;class i extends n{constructor(e,t=e=>e){super(`Unhandled case value: ${t(e)}`)}}t.UnreachableCheck=i,t.unreachableCheck=(e,t=e=>e)=>{throw new i(e,t)}}}]);
14//# sourceMappingURL=6651-6b500fcdb7bf9a4f.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.