@asgardeo/browser 0.5.11 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -36,14 +36,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  mod
37
37
  ));
38
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
- var __decorateClass = (decorators, target, key, kind) => {
40
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
41
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
42
- if (decorator = decorators[i])
43
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
44
- if (kind && result) __defProp(target, key, result);
45
- return result;
46
- };
47
39
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
48
40
 
49
41
  // ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
@@ -1924,7 +1916,9 @@ __export(index_exports, {
1924
1916
  AsgardeoBrowserClient: () => AsgardeoBrowserClient_default,
1925
1917
  AsgardeoSPAClient: () => AsgardeoSPAClient,
1926
1918
  AuthenticationHelper: () => AuthenticationHelper,
1919
+ FetchHttpClient: () => FetchHttpClient,
1927
1920
  Hooks: () => Hooks,
1921
+ HttpClient: () => import_javascript10.HttpClient,
1928
1922
  MainThreadClient: () => MainThreadClient,
1929
1923
  SPAHelper: () => SPAHelper,
1930
1924
  SPAUtils: () => SPAUtils,
@@ -1946,7 +1940,7 @@ __export(index_exports, {
1946
1940
  module.exports = __toCommonJS(index_exports);
1947
1941
 
1948
1942
  // src/__legacy__/client.ts
1949
- var import_javascript8 = require("@asgardeo/javascript");
1943
+ var import_javascript9 = require("@asgardeo/javascript");
1950
1944
 
1951
1945
  // inline-worker:__inline-worker
1952
1946
  function inlineWorker(scriptText) {
@@ -1959,11 +1953,11 @@ function inlineWorker(scriptText) {
1959
1953
 
1960
1954
  // src/web.worker.ts
1961
1955
  function Worker2() {
1962
- return inlineWorker('(()=>{var Xs=Object.create;var et=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var Zs=Object.getPrototypeOf,Qs=Object.prototype.hasOwnProperty;var bn=r=>{throw TypeError(r)};var ei=(r,e,t)=>e in r?et(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ue=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ti=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},ri=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ys(e))!Qs.call(r,o)&&o!==t&&et(r,o,{get:()=>e[o],enumerable:!(n=Sn(e,o))||n.enumerable});return r};var tt=(r,e,t)=>(t=r!=null?Xs(Zs(r)):{},ri(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r));var Tn=(r,e,t,n)=>{for(var o=n>1?void 0:n?Sn(e,t):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(o=(n?i(e,t,o):i(o))||o);return n&&o&&et(e,t,o),o};var E=(r,e,t)=>ei(r,typeof e!="symbol"?e+"":e,t),Rn=(r,e,t)=>e.has(r)||bn("Cannot "+t);var Pe=(r,e,t)=>(Rn(r,e,"read from private field"),t?t.call(r):e.get(r)),xt=(r,e,t)=>e.has(r)?bn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),or=(r,e,t,n)=>(Rn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var xn=ue(_t=>{"use strict";_t.byteLength=oi;_t.toByteArray=ii;_t.fromByteArray=li;var ne=[],G=[],ni=typeof Uint8Array<"u"?Uint8Array:Array,sr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Te=0,In=sr.length;Te<In;++Te)ne[Te]=sr[Te],G[sr.charCodeAt(Te)]=Te;var Te,In;G[45]=62;G[95]=63;function An(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function oi(r){var e=An(r),t=e[0],n=e[1];return(t+n)*3/4-n}function si(r,e,t){return(e+t)*3/4-t}function ii(r){var e,t=An(r),n=t[0],o=t[1],s=new ni(si(r,n,o)),i=0,a=o>0?n-4:n,l;for(l=0;l<a;l+=4)e=G[r.charCodeAt(l)]<<18|G[r.charCodeAt(l+1)]<<12|G[r.charCodeAt(l+2)]<<6|G[r.charCodeAt(l+3)],s[i++]=e>>16&255,s[i++]=e>>8&255,s[i++]=e&255;return o===2&&(e=G[r.charCodeAt(l)]<<2|G[r.charCodeAt(l+1)]>>4,s[i++]=e&255),o===1&&(e=G[r.charCodeAt(l)]<<10|G[r.charCodeAt(l+1)]<<4|G[r.charCodeAt(l+2)]>>2,s[i++]=e>>8&255,s[i++]=e&255),s}function ai(r){return ne[r>>18&63]+ne[r>>12&63]+ne[r>>6&63]+ne[r&63]}function ci(r,e,t){for(var n,o=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),o.push(ai(n));return o.join("")}function li(r){for(var e,t=r.length,n=t%3,o=[],s=16383,i=0,a=t-n;i<a;i+=s)o.push(ci(r,i,i+s>a?a:i+s));return n===1?(e=r[t-1],o.push(ne[e>>2]+ne[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],o.push(ne[e>>10]+ne[e>>4&63]+ne[e<<2&63]+"=")),o.join("")}});var _n=ue(ir=>{ir.read=function(r,e,t,n,o){var s,i,a=o*8-n-1,l=(1<<a)-1,c=l>>1,u=-7,f=t?o-1:0,h=t?-1:1,m=r[e+f];for(f+=h,s=m&(1<<-u)-1,m>>=-u,u+=a;u>0;s=s*256+r[e+f],f+=h,u-=8);for(i=s&(1<<-u)-1,s>>=-u,u+=n;u>0;i=i*256+r[e+f],f+=h,u-=8);if(s===0)s=1-c;else{if(s===l)return i?NaN:(m?-1:1)*(1/0);i=i+Math.pow(2,n),s=s-c}return(m?-1:1)*i*Math.pow(2,s-n)};ir.write=function(r,e,t,n,o,s){var i,a,l,c=s*8-o-1,u=(1<<c)-1,f=u>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:s-1,p=n?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=u):(i=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-i))<1&&(i--,l*=2),i+f>=1?e+=h/l:e+=h*Math.pow(2,1-f),e*l>=2&&(i++,l/=2),i+f>=u?(a=0,i=u):i+f>=1?(a=(e*l-1)*Math.pow(2,o),i=i+f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),i=0));o>=8;r[t+m]=a&255,m+=p,a/=256,o-=8);for(i=i<<o|a,c+=o;c>0;r[t+m]=i&255,m+=p,i/=256,c-=8);r[t+m-p]|=w*128}});var Ct=ue(De=>{"use strict";var ar=xn(),ke=_n(),vn=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;De.Buffer=g;De.SlowBuffer=gi;De.INSPECT_MAX_BYTES=50;var vt=2147483647;De.kMaxLength=vt;g.TYPED_ARRAY_SUPPORT=ui();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ui(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function fe(r){if(r>vt)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\');let e=new Uint8Array(r);return Object.setPrototypeOf(e,g.prototype),e}function g(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError(\'The "string" argument must be of type string. Received type number\');return fr(r)}return Un(r,e,t)}g.poolSize=8192;function Un(r,e,t){if(typeof r=="string")return di(r,e);if(ArrayBuffer.isView(r))return pi(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(oe(r,ArrayBuffer)||r&&oe(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(oe(r,SharedArrayBuffer)||r&&oe(r.buffer,SharedArrayBuffer)))return lr(r,e,t);if(typeof r=="number")throw new TypeError(\'The "value" argument must not be of type number. Received type number\');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return g.from(n,e,t);let o=hi(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return g.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}g.from=function(r,e,t){return Un(r,e,t)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function kn(r){if(typeof r!="number")throw new TypeError(\'"size" argument must be of type number\');if(r<0)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\')}function fi(r,e,t){return kn(r),r<=0?fe(r):e!==void 0?typeof t=="string"?fe(r).fill(e,t):fe(r).fill(e):fe(r)}g.alloc=function(r,e,t){return fi(r,e,t)};function fr(r){return kn(r),fe(r<0?0:dr(r)|0)}g.allocUnsafe=function(r){return fr(r)};g.allocUnsafeSlow=function(r){return fr(r)};function di(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Nn(r,e)|0,n=fe(t),o=n.write(r,e);return o!==t&&(n=n.slice(0,o)),n}function cr(r){let e=r.length<0?0:dr(r.length)|0,t=fe(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function pi(r){if(oe(r,Uint8Array)){let e=new Uint8Array(r);return lr(e.buffer,e.byteOffset,e.byteLength)}return cr(r)}function lr(r,e,t){if(e<0||r.byteLength<e)throw new RangeError(\'"offset" is outside of buffer bounds\');if(r.byteLength<e+(t||0))throw new RangeError(\'"length" is outside of buffer bounds\');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,g.prototype),n}function hi(r){if(g.isBuffer(r)){let e=dr(r.length)|0,t=fe(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||hr(r.length)?fe(0):cr(r);if(r.type==="Buffer"&&Array.isArray(r.data))return cr(r.data)}function dr(r){if(r>=vt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+vt.toString(16)+" bytes");return r|0}function gi(r){return+r!=r&&(r=0),g.alloc(+r)}g.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==g.prototype};g.compare=function(e,t){if(oe(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),oe(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),!g.isBuffer(e)||!g.isBuffer(t))throw new TypeError(\'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array\');if(e===t)return 0;let n=e.length,o=t.length;for(let s=0,i=Math.min(n,o);s<i;++s)if(e[s]!==t[s]){n=e[s],o=t[s];break}return n<o?-1:o<n?1:0};g.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(e,t){if(!Array.isArray(e))throw new TypeError(\'"list" argument must be an Array of Buffers\');if(e.length===0)return g.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=g.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){let i=e[n];if(oe(i,Uint8Array))s+i.length>o.length?(g.isBuffer(i)||(i=g.from(i)),i.copy(o,s)):Uint8Array.prototype.set.call(o,i,s);else if(g.isBuffer(i))i.copy(o,s);else throw new TypeError(\'"list" argument must be an Array of Buffers\');s+=i.length}return o};function Nn(r,e){if(g.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||oe(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError(\'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type \'+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ur(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Wn(r).length;default:if(o)return n?-1:ur(r).length;e=(""+e).toLowerCase(),o=!0}}g.byteLength=Nn;function mi(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return xi(this,e,t);case"utf8":case"utf-8":return Mn(this,e,t);case"ascii":return Ii(this,e,t);case"latin1":case"binary":return Ai(this,e,t);case"base64":return Ti(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _i(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}g.prototype._isBuffer=!0;function Re(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}g.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Re(this,t,t+1);return this};g.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Re(this,t,t+3),Re(this,t+1,t+2);return this};g.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Re(this,t,t+7),Re(this,t+1,t+6),Re(this,t+2,t+5),Re(this,t+3,t+4);return this};g.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Mn(this,0,e):mi.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(e){if(!g.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:g.compare(this,e)===0};g.prototype.inspect=function(){let e="",t=De.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};vn&&(g.prototype[vn]=g.prototype.inspect);g.prototype.compare=function(e,t,n,o,s){if(oe(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(e))throw new TypeError(\'The "target" argument must be one of type Buffer or Uint8Array. Received type \'+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),s===void 0&&(s=this.length),t<0||n>e.length||o<0||s>this.length)throw new RangeError("out of range index");if(o>=s&&t>=n)return 0;if(o>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,s>>>=0,this===e)return 0;let i=s-o,a=n-t,l=Math.min(i,a),c=this.slice(o,s),u=e.slice(t,n);for(let f=0;f<l;++f)if(c[f]!==u[f]){i=c[f],a=u[f];break}return i<a?-1:a<i?1:0};function Dn(r,e,t,n,o){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,hr(t)&&(t=o?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(o)return-1;t=r.length-1}else if(t<0)if(o)t=0;else return-1;if(typeof e=="string"&&(e=g.from(e,n)),g.isBuffer(e))return e.length===0?-1:On(r,e,t,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):On(r,[e],t,n,o);throw new TypeError("val must be string, number or Buffer")}function On(r,e,t,n,o){let s=1,i=r.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,i/=2,a/=2,t/=2}function l(u,f){return s===1?u[f]:u.readUInt16BE(f*s)}let c;if(o){let u=-1;for(c=t;c<i;c++)if(l(r,c)===l(e,u===-1?0:c-u)){if(u===-1&&(u=c),c-u+1===a)return u*s}else u!==-1&&(c-=c-u),u=-1}else for(t+a>i&&(t=i-a),c=t;c>=0;c--){let u=!0;for(let f=0;f<a;f++)if(l(r,c+f)!==l(e,f)){u=!1;break}if(u)return c}return-1}g.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};g.prototype.indexOf=function(e,t,n){return Dn(this,e,t,n,!0)};g.prototype.lastIndexOf=function(e,t,n){return Dn(this,e,t,n,!1)};function yi(r,e,t,n){t=Number(t)||0;let o=r.length-t;n?(n=Number(n),n>o&&(n=o)):n=o;let s=e.length;n>s/2&&(n=s/2);let i;for(i=0;i<n;++i){let a=parseInt(e.substr(i*2,2),16);if(hr(a))return i;r[t+i]=a}return i}function wi(r,e,t,n){return Ot(ur(e,r.length-t),r,t,n)}function Ei(r,e,t,n){return Ot(Pi(e),r,t,n)}function Si(r,e,t,n){return Ot(Wn(e),r,t,n)}function bi(r,e,t,n){return Ot(Ui(e,r.length-t),r,t,n)}g.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return yi(this,e,t,n);case"utf8":case"utf-8":return wi(this,e,t,n);case"ascii":case"latin1":case"binary":return Ei(this,e,t,n);case"base64":return Si(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return bi(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ti(r,e,t){return e===0&&t===r.length?ar.fromByteArray(r):ar.fromByteArray(r.slice(e,t))}function Mn(r,e,t){t=Math.min(r.length,t);let n=[],o=e;for(;o<t;){let s=r[o],i=null,a=s>239?4:s>223?3:s>191?2:1;if(o+a<=t){let l,c,u,f;switch(a){case 1:s<128&&(i=s);break;case 2:l=r[o+1],(l&192)===128&&(f=(s&31)<<6|l&63,f>127&&(i=f));break;case 3:l=r[o+1],c=r[o+2],(l&192)===128&&(c&192)===128&&(f=(s&15)<<12|(l&63)<<6|c&63,f>2047&&(f<55296||f>57343)&&(i=f));break;case 4:l=r[o+1],c=r[o+2],u=r[o+3],(l&192)===128&&(c&192)===128&&(u&192)===128&&(f=(s&15)<<18|(l&63)<<12|(c&63)<<6|u&63,f>65535&&f<1114112&&(i=f))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),o+=a}return Ri(n)}var Cn=4096;function Ri(r){let e=r.length;if(e<=Cn)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Cn));return t}function Ii(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]&127);return n}function Ai(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]);return n}function xi(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let o="";for(let s=e;s<t;++s)o+=ki[r[s]];return o}function _i(r,e,t){let n=r.slice(e,t),o="";for(let s=0;s<n.length-1;s+=2)o+=String.fromCharCode(n[s]+n[s+1]*256);return o}g.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,g.prototype),o};function B(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let o=this[e],s=1,i=0;for(;++i<t&&(s*=256);)o+=this[e+i]*s;return o};g.prototype.readUintBE=g.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let o=this[e+--t],s=1;for(;t>0&&(s*=256);)o+=this[e+--t]*s;return o};g.prototype.readUint8=g.prototype.readUInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]|this[e+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]<<8|this[e+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};g.prototype.readBigUInt64LE=me(function(e){e=e>>>0,Ne(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rt(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(s)<<BigInt(32))});g.prototype.readBigUInt64BE=me(function(e){e=e>>>0,Ne(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rt(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(s)});g.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let o=this[e],s=1,i=0;for(;++i<t&&(s*=256);)o+=this[e+i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};g.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let o=t,s=1,i=this[e+--o];for(;o>0&&(s*=256);)i+=this[e+--o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};g.prototype.readInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};g.prototype.readInt16LE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};g.prototype.readInt16BE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};g.prototype.readInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};g.prototype.readInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};g.prototype.readBigInt64LE=me(function(e){e=e>>>0,Ne(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rt(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});g.prototype.readBigInt64BE=me(function(e){e=e>>>0,Ne(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&rt(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});g.prototype.readFloatLE=function(e,t){return e=e>>>0,t||B(e,4,this.length),ke.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,t){return e=e>>>0,t||B(e,4,this.length),ke.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||B(e,8,this.length),ke.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||B(e,8,this.length),ke.read(this,e,!1,52,8)};function q(r,e,t,n,o,s){if(!g.isBuffer(r))throw new TypeError(\'"buffer" argument must be a Buffer instance\');if(e>o||e<s)throw new RangeError(\'"value" argument is out of bounds\');if(t+n>r.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let a=Math.pow(2,8*n)-1;q(this,e,t,n,a,0)}let s=1,i=0;for(this[t]=e&255;++i<n&&(s*=256);)this[t+i]=e/s&255;return t+n};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let a=Math.pow(2,8*n)-1;q(this,e,t,n,a,0)}let s=n-1,i=1;for(this[t+s]=e&255;--s>=0&&(i*=256);)this[t+s]=e/i&255;return t+n};g.prototype.writeUint8=g.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,1,255,0),this[t]=e&255,t+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Hn(r,e,t,n,o){Kn(e,n,o,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,t}function Ln(r,e,t,n,o){Kn(e,n,o,r,t,7);let s=Number(e&BigInt(4294967295));r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=i,i=i>>8,r[t+2]=i,i=i>>8,r[t+1]=i,i=i>>8,r[t]=i,t+8}g.prototype.writeBigUInt64LE=me(function(e,t=0){return Hn(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=me(function(e,t=0){return Ln(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);q(this,e,t,n,l-1,-l)}let s=0,i=1,a=0;for(this[t]=e&255;++s<n&&(i*=256);)e<0&&a===0&&this[t+s-1]!==0&&(a=1),this[t+s]=(e/i>>0)-a&255;return t+n};g.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);q(this,e,t,n,l-1,-l)}let s=n-1,i=1,a=0;for(this[t+s]=e&255;--s>=0&&(i*=256);)e<0&&a===0&&this[t+s+1]!==0&&(a=1),this[t+s]=(e/i>>0)-a&255;return t+n};g.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};g.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};g.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};g.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};g.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||q(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};g.prototype.writeBigInt64LE=me(function(e,t=0){return Hn(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=me(function(e,t=0){return Ln(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Bn(r,e,t,n,o,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Fn(r,e,t,n,o){return e=+e,t=t>>>0,o||Bn(r,e,t,4,34028234663852886e22,-34028234663852886e22),ke.write(r,e,t,n,23,4),t+4}g.prototype.writeFloatLE=function(e,t,n){return Fn(this,e,t,!0,n)};g.prototype.writeFloatBE=function(e,t,n){return Fn(this,e,t,!1,n)};function $n(r,e,t,n,o){return e=+e,t=t>>>0,o||Bn(r,e,t,8,17976931348623157e292,-17976931348623157e292),ke.write(r,e,t,n,52,8),t+8}g.prototype.writeDoubleLE=function(e,t,n){return $n(this,e,t,!0,n)};g.prototype.writeDoubleBE=function(e,t,n){return $n(this,e,t,!1,n)};g.prototype.copy=function(e,t,n,o){if(!g.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let s=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),s};g.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!g.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s<n;++s)this[s]=e;else{let i=g.isBuffer(e)?e:g.from(e,o),a=i.length;if(a===0)throw new TypeError(\'The value "\'+e+\'" is invalid for argument "value"\');for(s=0;s<n-t;++s)this[s+t]=i[s%a]}return this};var Ue={};function pr(r,e,t){Ue[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}pr("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);pr("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);pr("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,o=t;return Number.isInteger(t)&&Math.abs(t)>2**32?o=Pn(String(t)):typeof t=="bigint"&&(o=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(o=Pn(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);function Pn(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function vi(r,e,t){Ne(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&rt(e,r.length-(t+1))}function Kn(r,e,t,n,o,s){if(r>t||r<e){let i=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${i} and < 2${i} ** ${(s+1)*8}${i}`:a=`>= -(2${i} ** ${(s+1)*8-1}${i}) and < 2 ** ${(s+1)*8-1}${i}`:a=`>= ${e}${i} and <= ${t}${i}`,new Ue.ERR_OUT_OF_RANGE("value",a,r)}vi(n,o,s)}function Ne(r,e){if(typeof r!="number")throw new Ue.ERR_INVALID_ARG_TYPE(e,"number",r)}function rt(r,e,t){throw Math.floor(r)!==r?(Ne(r,t),new Ue.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Ue.ERR_BUFFER_OUT_OF_BOUNDS:new Ue.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Oi=/[^+/0-9A-Za-z-_]/g;function Ci(r){if(r=r.split("=")[0],r=r.trim().replace(Oi,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function ur(r,e){e=e||1/0;let t,n=r.length,o=null,s=[];for(let i=0;i<n;++i){if(t=r.charCodeAt(i),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(i+1===n){(e-=3)>-1&&s.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536}else o&&(e-=3)>-1&&s.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Pi(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Ui(r,e){let t,n,o,s=[];for(let i=0;i<r.length&&!((e-=2)<0);++i)t=r.charCodeAt(i),n=t>>8,o=t%256,s.push(o),s.push(n);return s}function Wn(r){return ar.toByteArray(Ci(r))}function Ot(r,e,t,n){let o;for(o=0;o<n&&!(o+t>=e.length||o>=r.length);++o)e[o+t]=r[o];return o}function oe(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function hr(r){return r!==r}var ki=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let o=0;o<16;++o)e[n+o]=r[t]+r[o]}return e})();function me(r){return typeof BigInt>"u"?Ni:r}function Ni(){throw new Error("BigInt not supported")}});var as=ue(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});function Oc(r){var e=4,t=r.length,n=t%e;if(!n)return r;var o=t,s=e-n,i=t+s,a=Buffer.alloc(i);for(a.write(r);s--;)a.write("=",o++);return a.toString()}en.default=Oc});var ls=ue(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});var Cc=as();function cs(r,e){return e===void 0&&(e="utf8"),Buffer.isBuffer(r)?tn(r.toString("base64")):tn(Buffer.from(r,e).toString("base64"))}function Pc(r,e){return e===void 0&&(e="utf8"),Buffer.from(rn(r),"base64").toString(e)}function rn(r){return r=r.toString(),Cc.default(r).replace(/\\-/g,"+").replace(/_/g,"/")}function tn(r){return r.replace(/=/g,"").replace(/\\+/g,"-").replace(/\\//g,"_")}function Uc(r){return Buffer.from(rn(r),"base64")}var Je=cs;Je.encode=cs;Je.decode=Pc;Je.toBase64=rn;Je.fromBase64=tn;Je.toBuffer=Uc;nn.default=Je});var us=ue((rh,Gt)=>{Gt.exports=ls().default;Gt.exports.default=Gt.exports});var ds=ue((fs,Xt)=>{(function(r,e){var t={};e(t);var n=t.default;for(var o in t)n[o]=t[o];typeof Xt=="object"&&typeof Xt.exports=="object"?Xt.exports=n:typeof define=="function"&&define.amd?define(function(){return n}):r.sha256=n})(fs,function(r){"use strict";r.__esModule=!0,r.digestLength=32,r.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function t(f,h,m,p,w){for(var y,S,T,_,v,A,M,O,U,C,ae,ce,re;w>=64;){for(y=h[0],S=h[1],T=h[2],_=h[3],v=h[4],A=h[5],M=h[6],O=h[7],C=0;C<16;C++)ae=p+C*4,f[C]=(m[ae]&255)<<24|(m[ae+1]&255)<<16|(m[ae+2]&255)<<8|m[ae+3]&255;for(C=16;C<64;C++)U=f[C-2],ce=(U>>>17|U<<15)^(U>>>19|U<<13)^U>>>10,U=f[C-15],re=(U>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,f[C]=(ce+f[C-7]|0)+(re+f[C-16]|0);for(C=0;C<64;C++)ce=(((v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7))+(v&A^~v&M)|0)+(O+(e[C]+f[C]|0)|0)|0,re=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&S^y&T^S&T)|0,O=M,M=A,A=v,v=_+ce|0,_=T,T=S,S=y,y=ce+re|0;h[0]+=y,h[1]+=S,h[2]+=T,h[3]+=_,h[4]+=v,h[5]+=A,h[6]+=M,h[7]+=O,p+=64,w-=64}return p}var n=(function(){function f(){this.digestLength=r.digestLength,this.blockSize=r.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return f.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},f.prototype.clean=function(){for(var h=0;h<this.buffer.length;h++)this.buffer[h]=0;for(var h=0;h<this.temp.length;h++)this.temp[h]=0;this.reset()},f.prototype.update=function(h,m){if(m===void 0&&(m=h.length),this.finished)throw new Error("SHA256: can\'t update because hash was finished.");var p=0;if(this.bytesHashed+=m,this.bufferLength>0){for(;this.bufferLength<64&&m>0;)this.buffer[this.bufferLength++]=h[p++],m--;this.bufferLength===64&&(t(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(m>=64&&(p=t(this.temp,this.state,h,p,m),m%=64);m>0;)this.buffer[this.bufferLength++]=h[p++],m--;return this},f.prototype.finish=function(h){if(!this.finished){var m=this.bytesHashed,p=this.bufferLength,w=m/536870912|0,y=m<<3,S=m%64<56?64:128;this.buffer[p]=128;for(var T=p+1;T<S-8;T++)this.buffer[T]=0;this.buffer[S-8]=w>>>24&255,this.buffer[S-7]=w>>>16&255,this.buffer[S-6]=w>>>8&255,this.buffer[S-5]=w>>>0&255,this.buffer[S-4]=y>>>24&255,this.buffer[S-3]=y>>>16&255,this.buffer[S-2]=y>>>8&255,this.buffer[S-1]=y>>>0&255,t(this.temp,this.state,this.buffer,0,S),this.finished=!0}for(var T=0;T<8;T++)h[T*4+0]=this.state[T]>>>24&255,h[T*4+1]=this.state[T]>>>16&255,h[T*4+2]=this.state[T]>>>8&255,h[T*4+3]=this.state[T]>>>0&255;return this},f.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},f.prototype._saveState=function(h){for(var m=0;m<this.state.length;m++)h[m]=this.state[m]},f.prototype._restoreState=function(h,m){for(var p=0;p<this.state.length;p++)this.state[p]=h[p];this.bytesHashed=m,this.finished=!1,this.bufferLength=0},f})();r.Hash=n;var o=(function(){function f(h){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var m=new Uint8Array(this.blockSize);if(h.length>this.blockSize)new n().update(h).finish(m).clean();else for(var p=0;p<h.length;p++)m[p]=h[p];for(var p=0;p<m.length;p++)m[p]^=54;this.inner.update(m);for(var p=0;p<m.length;p++)m[p]^=106;this.outer.update(m),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var p=0;p<m.length;p++)m[p]=0}return f.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},f.prototype.clean=function(){for(var h=0;h<this.istate.length;h++)this.ostate[h]=this.istate[h]=0;this.inner.clean(),this.outer.clean()},f.prototype.update=function(h){return this.inner.update(h),this},f.prototype.finish=function(h){return this.outer.finished?this.outer.finish(h):(this.inner.finish(h),this.outer.update(h,this.digestLength).finish(h)),this},f.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},f})();r.HMAC=o;function s(f){var h=new n().update(f),m=h.digest();return h.clean(),m}r.hash=s,r.default=s;function i(f,h){var m=new o(f).update(h),p=m.digest();return m.clean(),p}r.hmac=i;function a(f,h,m,p){var w=p[0];if(w===0)throw new Error("hkdf: cannot expand more");h.reset(),w>1&&h.update(f),m&&h.update(m),h.update(p),h.finish(f),p[0]++}var l=new Uint8Array(r.digestLength);function c(f,h,m,p){h===void 0&&(h=l),p===void 0&&(p=32);for(var w=new Uint8Array([1]),y=i(h,f),S=new o(y),T=new Uint8Array(S.digestLength),_=T.length,v=new Uint8Array(p),A=0;A<p;A++)_===T.length&&(a(T,S,m,w),_=0),v[A]=T[_++];return S.clean(),T.fill(0),w.fill(0),v}r.hkdf=c;function u(f,h,m,p){for(var w=new o(f),y=w.digestLength,S=new Uint8Array(4),T=new Uint8Array(y),_=new Uint8Array(y),v=new Uint8Array(p),A=0;A*y<p;A++){var M=A+1;S[0]=M>>>24&255,S[1]=M>>>16&255,S[2]=M>>>8&255,S[3]=M>>>0&255,w.reset(),w.update(h),w.update(S),w.finish(_);for(var O=0;O<y;O++)T[O]=_[O];for(var O=2;O<=m;O++){w.reset(),w.update(_).finish(_);for(var U=0;U<y;U++)T[U]^=_[U]}for(var O=0;O<y&&A*y+O<p;O++)v[A*y+O]=T[O]}for(var A=0;A<y;A++)T[A]=_[A]=0;for(var A=0;A<4;A++)S[A]=0;return w.clean(),v}r.pbkdf2=u})});var Ks=ue((gn,$s)=>{var Zt=Ct(),ie=Zt.Buffer;function Fs(r,e){for(var t in r)e[t]=r[t]}ie.from&&ie.alloc&&ie.allocUnsafe&&ie.allocUnsafeSlow?$s.exports=Zt:(Fs(Zt,gn),gn.Buffer=ve);function ve(r,e,t){return ie(r,e,t)}ve.prototype=Object.create(ie.prototype);Fs(ie,ve);ve.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return ie(r,e,t)};ve.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=ie(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};ve.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return ie(r)};ve.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return Zt.SlowBuffer(r)}});var Ws=ue((vg,yn)=>{"use strict";var mn=65536,Vc=4294967295;function Gc(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Xc=Ks().Buffer,Qt=self.crypto||self.msCrypto;Qt&&Qt.getRandomValues?yn.exports=Yc:yn.exports=Gc;function Yc(r,e){if(r>Vc)throw new RangeError("requested too many random bytes");var t=Xc.allocUnsafe(r);if(r>0)if(r>mn)for(var n=0;n<r;n+=mn)Qt.getRandomValues(t.slice(n,n+mn));else Qt.getRandomValues(t);return typeof e=="function"?process.nextTick(function(){e(null,t)}):t}});var Gs=tt(Ct(),1);var Di=Object.defineProperty,Mi=(r,e,t)=>e in r?Di(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,N=(r,e,t)=>Mi(r,typeof e!="symbol"?e+"":e,t),Hi={Endpoints:{AUTHORIZATION:"/oauth2/authorize",END_SESSION:"/oidc/logout",ISSUER:"/oauth2/token",JWKS:"/oauth2/jwks",REVOCATION:"/oauth2/revoke",SESSION_IFRAME:"/oidc/checksession",TOKEN:"/oauth2/token",USERINFO:"/oauth2/userinfo"},Storage:{StorageKeys:{Endpoints:{AUTHORIZATION:"authorization_endpoint",END_SESSION:"end_session_endpoint",ISSUER:"issuer",JWKS:"jwks_uri",REVOCATION:"revocation_endpoint",SESSION_IFRAME:"check_session_iframe",TOKEN:"token_endpoint",USERINFO:"userinfo_endpoint"},OPENID_PROVIDER_CONFIG_INITIATED:"op_config_initiated"}}},H=Hi,Li={Placeholders:{ACCESS_TOKEN:"{{accessToken}}",CLIENT_ID:"{{clientId}}",CLIENT_SECRET:"{{clientSecret}}",SCOPES:"{{scopes}}",USERNAME:"{{username}}"}},nt=Li,I=class{constructor(r,e,t){N(this,"name"),N(this,"code"),N(this,"message"),this.message=t,this.name=e,this.code=r,Object.setPrototypeOf(this,new.target.prototype)}};var Bi=r=>{let e={...r};return["iss","aud","exp","iat","acr","amr","azp","auth_time","nonce","c_hash","at_hash","nbf","isk","sid","jti","sub"].forEach(n=>{delete e[n]}),e},Fi=Bi,$i={INTERNAL_LOGIN:"internal_login",OPENID:"openid",PROFILE:"profile"},gr=$i,Ki={Params:{AUTHORIZATION_CODE:"code",SESSION_STATE:"session_state",SIGN_OUT_SUCCESS:"sign_out_success",STATE:"state"},SignIn:{Payload:{DEFAULT_SCOPES:[gr.OPENID,gr.PROFILE,gr.INTERNAL_LOGIN]}},SignOut:{Storage:{StorageKeys:{SIGN_OUT_URL:"sign_out_url"}}}},F=Ki,Wi=class Vn extends Error{constructor(e,t,n){let o=Vn.resolveOrigin(n);super(e),N(this,"code"),N(this,"origin"),this.name=new.target.name,this.code=t,this.origin=o,Error.captureStackTrace&&Error.captureStackTrace(this,new.target)}static resolveOrigin(e){return e?`@asgardeo/${e}`:"@asgardeo/javascript"}toString(){let e=`\\u{1F6E1}\\uFE0F Asgardeo - ${this.origin}:`;return`[${this.name}]\n${e} ${this.message}\n(code="${this.code}")`}},Gn=class extends Wi{constructor(r,e,t,n){super(r,e,t),this.details=n,Object.defineProperty(this,"name",{configurable:!0,value:"AsgardeoRuntimeError",writable:!0})}toString(){let r=this.details?`\nDetails: ${JSON.stringify(this.details,null,2)}`:"";return`[${this.name}] (code="${this.code}")${r}\nMessage: ${this.message}`}},ji=r=>{let e=[];if(r)if(Array.isArray(r))e=r;else if(typeof r=="string")e=r.split(" ");else throw new Gn("Scopes must be a string or an array of strings.","processOpenIDScopes-Invalid-001","javascript","The provided scopes are not in the expected format. Please provide a string or an array of strings.");return F.SignIn.Payload.DEFAULT_SCOPES.forEach(t=>{e.includes(t)||e.push(t)}),e.join(" ")},yr=ji,qi=class{constructor(r,e){N(this,"storageManager"),N(this,"config"),N(this,"oidcProviderMetaData"),N(this,"cryptoHelper"),this.storageManager=r,this.config=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaData=async()=>this.storageManager.loadOpenIDProviderConfiguration(),this.cryptoHelper=e}async resolveEndpoints(r){let e={},t=await this.config();return t.endpoints&&Object.keys(t.endpoints).forEach(n=>{let o=n.replace(/[A-Z]/g,s=>`_${s.toLowerCase()}`);e[o]=t?.endpoints?t.endpoints[n]:""}),{...r,...e}}async resolveEndpointsExplicitly(){let r={},e=await this.config(),t=[H.Storage.StorageKeys.Endpoints.AUTHORIZATION,H.Storage.StorageKeys.Endpoints.END_SESSION,H.Storage.StorageKeys.Endpoints.JWKS,H.Storage.StorageKeys.Endpoints.SESSION_IFRAME,H.Storage.StorageKeys.Endpoints.REVOCATION,H.Storage.StorageKeys.Endpoints.TOKEN,H.Storage.StorageKeys.Endpoints.ISSUER,H.Storage.StorageKeys.Endpoints.USERINFO];if(!(e.endpoints?t.every(o=>e.endpoints?Object.keys(e.endpoints).some(s=>s.replace(/[A-Z]/g,a=>`_${a.toLowerCase()}`)===o):!1):!1))throw new I("JS-AUTH_HELPER-REE-NF01","Required endpoints missing","Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object.");return e.endpoints&&Object.keys(e.endpoints).forEach(o=>{let s=o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`);r[s]=e?.endpoints?e.endpoints[o]:""}),{...r}}async resolveEndpointsByBaseURL(){let r={},e=await this.config(),{baseUrl:t}=e;if(!t)throw new I("JS-AUTH_HELPER_REBO-NF01","Base URL not defined.","Base URL is not defined in AuthClient config.");e.endpoints&&Object.keys(e.endpoints).forEach(i=>{let a=i.replace(/[A-Z]/g,l=>`_${l.toLowerCase()}`);r[a]=e?.endpoints?e.endpoints[i]:""});let n=H.Storage.StorageKeys.Endpoints,o=H.Endpoints,s={[n.AUTHORIZATION]:`${t}${o.AUTHORIZATION}`,[n.END_SESSION]:`${t}${o.END_SESSION}`,[n.ISSUER]:`${t}${o.ISSUER}`,[n.JWKS]:`${t}${o.JWKS}`,[n.SESSION_IFRAME]:`${t}${o.SESSION_IFRAME}`,[n.REVOCATION]:`${t}${o.REVOCATION}`,[n.TOKEN]:`${t}${o.TOKEN}`,[n.USERINFO]:`${t}${o.USERINFO}`};return e.platform==="AsgardeoV2"&&(s[H.Storage.StorageKeys.Endpoints.ISSUER]=`${t}`),{...s,...r}}async validateIdToken(r){let e=(await this.storageManager.loadOpenIDProviderConfiguration()).jwks_uri,t=await this.config();if(!e||e.trim().length===0)throw new I("JS_AUTH_HELPER-VIT-NF01","JWKS endpoint not found.","No JWKS endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the JWKS endpoint passed to the SDK is empty.");let n;try{n=await fetch(e,{credentials:t.sendCookiesInRequests?"include":"same-origin"})}catch(a){throw new I("JS-AUTH_HELPER-VIT-NE02","Request to jwks endpoint failed.",a??"The request sent to get the jwks from the server failed.")}if(n.status!==200||!n.ok)throw new I("JS-AUTH_HELPER-VIT-HE03",`Invalid response status received for jwks request (${n.statusText}).`,await n.json());let{issuer:o}=await this.oidcProviderMetaData(),{keys:s}=await n.json(),i=await this.cryptoHelper.getJWKForTheIdToken(r.split(".")[0],s);return this.cryptoHelper.isValidIdToken(r,i,(await this.config()).clientId,o??"",this.cryptoHelper.decodeJwtToken(r).sub,(await this.config()).tokenValidation?.idToken?.clockTolerance,(await this.config()).tokenValidation?.idToken?.validateIssuer??!0)}getAuthenticatedUserInfo(r){let e=this.cryptoHelper.decodeJwtToken(r),t=e?.username??"",n=e?.given_name??"",o=e?.family_name??"",s=n&&o?`${n} ${o}`:n||o||"";return{displayName:e.preferred_username??s,username:t,...Fi(e)}}async replaceCustomGrantTemplateTags(r,e){let t=await this.config(),n=t.organizationChain?.sourceInstanceId??null,o;if(n){let{clientId:i}=t,a;if(i?a=`instance_${n}-${i}`:a=`instance_${n}`,o=await this.storageManager.getSessionData(e,a),!o||!o.access_token)throw new I("JS-AUTH_HELPER-RCGTT-NE01","No session data found for source instance.","Failed to retrieve session data from the source organization context.")}else o=await this.storageManager.getSessionData(e);let s=yr(t.scopes);return typeof r!="string"?r:r.replace(nt.Placeholders.ACCESS_TOKEN,o.access_token).replace(nt.Placeholders.USERNAME,this.getAuthenticatedUserInfo(o.id_token).username).replace(nt.Placeholders.SCOPES,s).replace(nt.Placeholders.CLIENT_ID,t.clientId).replace(nt.Placeholders.CLIENT_SECRET,t.clientSecret??"")}async clearSession(r){await this.storageManager.removeTemporaryData(r),await this.storageManager.removeSessionData(r)}async handleTokenResponse(r,e){if(r.status!==200||!r.ok)throw new I("JS-AUTH_HELPER-HTR-NE01",`Invalid response status received for token request (${r.statusText}).`,await r.json());let t=await r.json();if(t.created_at=new Date().getTime(),(await this.config()).tokenValidation?.idToken?.validate)return this.validateIdToken(t.id_token).then(async()=>{await this.storageManager.setSessionData(t,e);let s={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return Promise.resolve(s)});let o={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return await this.storageManager.setSessionData(t,e),Promise.resolve(o)}},zi={DEFAULT_CODE_CHALLENGE_METHOD:"S256",Storage:{StorageKeys:{CODE_VERIFIER:"pkce_code_verifier",SEPARATOR:"#"}}},ye=zi,Ji={Endpoints:{WELL_KNOWN:"/.well-known/openid-configuration"}},Vi=Ji,Gi={SignatureValidation:{SUPPORTED_ALGORITHMS:["RS256","RS512","RS384","PS256"]},Storage:{StorageKeys:{REFRESH_TOKEN_TIMER:"refresh_token_timer"}}},ot=Gi,Xi=class{constructor(r){N(this,"cryptoUtils"),this.cryptoUtils=r}getCodeVerifier(){return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32))}async getCodeChallenge(r){let e=await this.cryptoUtils.hashSha256(r);return this.cryptoUtils.base64URLEncode(e)}getJWKForTheIdToken(r,e){let t=JSON.parse(this.cryptoUtils.base64URLDecode(r)),n=e.find(o=>t.kid===o.kid);if(n)return n;throw new I("JS-CRYPTO_UTIL-GJFTIT-IV01","kid not found.",`Failed to find the \'kid\' specified in the id_token. \'kid\' found in the header : ${t.kid}, Expected values: ${e.map(o=>o.kid).join(", ")}`)}isValidIdToken(r,e,t,n,o,s,i){return this.cryptoUtils.verifyJwt(r,e,ot.SignatureValidation.SUPPORTED_ALGORITHMS,t,n,o,s,i).then(a=>a?Promise.resolve(!0):Promise.reject(new I("JS-CRYPTO_HELPER-IVIT-IV01","Invalid ID token.","ID token validation returned false"))).catch(a=>Promise.reject(a))}decodeJwtToken(r){try{let e=this.cryptoUtils.base64URLDecode(r?.split(".")[1]);return JSON.parse(e)}catch(e){throw new I("JS-CRYPTO_UTIL-DIT-IV02","Decoding token failed.",e)}}},mr="asgardeo-session-active",Yi=class Pt{constructor(e,t){N(this,"id"),N(this,"store"),this.id=e,this.store=t}async setDataInBulk(e,t){let n=await this.store.getData(e)??null,s={...n&&JSON.parse(n),...t},i=JSON.stringify(s);await this.store.setData(e,i)}async setValue(e,t,n){let o=await this.store.getData(e)??null,i={...o&&JSON.parse(o),[t]:n},a=JSON.stringify(i);await this.store.setData(e,a)}async removeValue(e,t){let n=await this.store.getData(e)??null,s={...n&&JSON.parse(n)};delete s[t];let i=JSON.stringify(s);await this.store.setData(e,i)}resolveKey(e,t,n){return t&&n?`${e}-${n}-${t}`:t?`${e}-${this.id}-${t}`:n?`${e}-${n}`:`${e}-${this.id}`}static isLocalStorageAvailable(){try{let e="__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}async setConfigData(e){await this.setDataInBulk(this.resolveKey("config_data"),e)}async setOIDCProviderMetaData(e){this.setDataInBulk(this.resolveKey("oidc_provider_meta_data"),e)}async setTemporaryData(e,t){this.setDataInBulk(this.resolveKey("temporary_data",t),e)}async setSessionData(e,t){this.setDataInBulk(this.resolveKey("session_data",t),e)}async setCustomData(e,t,n){this.setDataInBulk(this.resolveKey(e,n),t)}async getConfigData(e){return JSON.parse(await this.store.getData(this.resolveKey("config_data",e))??null)}async loadOpenIDProviderConfiguration(){return JSON.parse(await this.store.getData(this.resolveKey("oidc_provider_meta_data"))??null)}async getTemporaryData(e){return JSON.parse(await this.store.getData(this.resolveKey("temporary_data",e))??null)}async getPersistedData(e){return JSON.parse(await this.store.getData(this.resolveKey("persisted_data",e))??null)}async setPersistedData(e,t){this.setDataInBulk(this.resolveKey("persisted_data",t),e)}async getSessionData(e,t){return JSON.parse(await this.store.getData(this.resolveKey("session_data",e,t))??null)}async getCustomData(e,t){return JSON.parse(await this.store.getData(this.resolveKey(e,t))??null)}setSessionStatus(e){Pt.isLocalStorageAvailable()&&localStorage.setItem(`${mr}`,e)}getSessionStatus(){return Pt.isLocalStorageAvailable()?localStorage.getItem(`${mr}`)??"":""}removeSessionStatus(){Pt.isLocalStorageAvailable()&&localStorage.removeItem(`${mr}`)}async removeConfigData(){await this.store.removeData(this.resolveKey("config_data"))}async removeOIDCProviderMetaData(){await this.store.removeData(this.resolveKey("oidc_provider_meta_data"))}async removeTemporaryData(e){await this.store.removeData(this.resolveKey("temporary_data",e))}async removeSessionData(e){await this.store.removeData(this.resolveKey("session_data",e))}async getConfigDataParameter(e){let t=await this.store.getData(this.resolveKey("config_data"));return t&&JSON.parse(t)[e]}async getOIDCProviderMetaDataParameter(e){let t=await this.store.getData(this.resolveKey("oidc_provider_meta_data"));return t&&JSON.parse(t)[e]}async getTemporaryDataParameter(e,t){let n=await this.store.getData(this.resolveKey("temporary_data",t));return n&&JSON.parse(n)[e]}async getSessionDataParameter(e,t){let n=await this.store.getData(this.resolveKey("session_data",t));return n&&JSON.parse(n)[e]}async setConfigDataParameter(e,t){await this.setValue(this.resolveKey("config_data"),e,t)}async setOIDCProviderMetaDataParameter(e,t){await this.setValue(this.resolveKey("oidc_provider_meta_data"),e,t)}async setTemporaryDataParameter(e,t,n){await this.setValue(this.resolveKey("temporary_data",n),e,t)}async setSessionDataParameter(e,t,n){await this.setValue(this.resolveKey("session_data",n),e,t)}async removeConfigDataParameter(e){await this.removeValue(this.resolveKey("config_data"),e)}async removeOIDCProviderMetaDataParameter(e){await this.removeValue(this.resolveKey("oidc_provider_meta_data"),e)}async removeTemporaryDataParameter(e,t){await this.removeValue(this.resolveKey("temporary_data",t),e)}async removeSessionDataParameter(e,t){await this.removeValue(this.resolveKey("session_data",t),e)}},jn=Yi,qn=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.prototype.toString.call(r)==="[object Object]",Xn=(r,...e)=>{if(!r||typeof r!="object")throw new Error("Target must be an object");let t={...r};return e.forEach(n=>{!n||typeof n!="object"||Object.keys(n).forEach(o=>{let s=n[o],i=t[o];qn(s)&&qn(i)?t[o]=Xn(i,s):s!==void 0&&(t[o]=s)})}),t},Zi=Xn,Qi=r=>{let e=parseInt(r.split("request_")[1],10);return`${ye.Storage.StorageKeys.CODE_VERIFIER}${ye.Storage.StorageKeys.SEPARATOR}${e}`},Ie=Qi,ea=r=>{let e=[];Object.keys(r).forEach(o=>{o.startsWith(ye.Storage.StorageKeys.CODE_VERIFIER)&&e.push(o)});let t=e.sort().pop(),n=parseInt(t?.split(ye.Storage.StorageKeys.SEPARATOR)[1]??"-1",10);return`${ye.Storage.StorageKeys.CODE_VERIFIER}${ye.Storage.StorageKeys.SEPARATOR}${n+1}`},ta=ea,ra=(r,e)=>{let t=parseInt(r.split(ye.Storage.StorageKeys.SEPARATOR)[1],10);return e?`${e}_request_${t}`:`request_${t}`},na=ra,oa=(r,e,t)=>{let{redirectUri:n,clientId:o,scopes:s,responseMode:i,codeChallenge:a,codeChallengeMethod:l,prompt:c}=r,u=new Map;u.set("response_type","code"),u.set("client_id",o),u.set("scope",s),u.set("redirect_uri",n),i&&u.set("response_mode",i);let f=e?.key;if(a)if(u.set("code_challenge",a),l)u.set("code_challenge_method",l);else throw new Gn("Code challenge method is required when code challenge is provided.","getAuthorizeRequestUrlParams-ValidationError-001","javascript","When PKCE is enabled, the code challenge method must be provided along with the code challenge.");c&&u.set("prompt",c),t&&Object.entries(t).forEach(([p,w])=>{p!==""&&w!==""&&p!==F.Params.STATE&&u.set(p,w.toString())});let h="instance_",m="";return r.instanceId?m=h+r.instanceId:t&&(m=t[F.Params.STATE]?.toString()??""),u.set(F.Params.STATE,na(f,m)),u},sa=oa,ia={enablePKCE:!0,responseMode:"query",sendCookiesInRequests:!0,tokenValidation:{idToken:{clockTolerance:300,validate:!0,validateIssuer:!0}}},Yn=class Zn{constructor(){N(this,"storageManager"),N(this,"configProvider"),N(this,"oidcProviderMetaDataProvider"),N(this,"authHelper"),N(this,"cryptoUtils"),N(this,"cryptoHelper"),N(this,"instanceIdValue")}async initialize(e,t,n,o){let{clientId:s}=e;this.instanceIdValue?this.instanceIdValue+=1:this.instanceIdValue=0,o!==void 0&&(this.instanceIdValue=o),s?this.storageManager=new jn(`instance_${this.instanceIdValue}-${s}`,t):this.storageManager=new jn(`instance_${this.instanceIdValue}`,t),this.cryptoUtils=n,this.cryptoHelper=new Xi(n),this.authHelper=new qi(this.storageManager,this.cryptoHelper),this.configProvider=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaDataProvider=async()=>this.storageManager.loadOpenIDProviderConfiguration(),Zn.authHelperInstance=this.authHelper;let{applicationId:i,platform:a,endpoints:l}=e,c=i;if(i)await this.storageManager.setPersistedData({applicationId:i});else{let f=await this.storageManager.getPersistedData();f.applicationId&&(c=f.applicationId)}let u=l||{};a==="AsgardeoV2"&&(u.wellKnown||(u.wellKnown=Vi.Endpoints.WELL_KNOWN)),await this.storageManager.setConfigData({...ia,...e,applicationId:c,endpoints:u,scope:yr(e.scopes)})}getStorageManager(){return this.storageManager}getInstanceId(){return this.instanceIdValue}async getSignInUrl(e,t){let n={...e};delete n?.forceInit;let o=async()=>{let s=await this.storageManager.getOIDCProviderMetaDataParameter(H.Storage.StorageKeys.Endpoints.AUTHORIZATION);if(!s||s.trim().length===0)throw new I("JS-AUTH_CORE-GAU-NF01","No authorization endpoint found.","No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty.");let i=new URL(s),a=await this.configProvider(),l=await this.storageManager.getTemporaryData(t),c=await ta(l),u,f;a.enablePKCE&&(u=this.cryptoHelper?.getCodeVerifier(),f=await this.cryptoHelper?.getCodeChallenge(u),await this.storageManager.setTemporaryDataParameter(c,u,t)),n.client_secret&&(n.client_secret=a.clientSecret);let h=sa({clientId:a.clientId,codeChallenge:f,codeChallengeMethod:ye.DEFAULT_CODE_CHALLENGE_METHOD,instanceId:this.getInstanceId().toString(),prompt:a.prompt,redirectUri:a.afterSignInUrl,responseMode:a.responseMode,scopes:yr(a.scopes)},{key:c},n);return Array.from(h.entries()).forEach(([m,p])=>{i.searchParams.append(m,p)}),i.toString()};return await this.storageManager.getTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)?o():this.loadOpenIDProviderConfiguration(e?.forceInit).then(()=>o())}async requestAccessToken(e,t,n,o,s){await this.storageManager.getTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let i=(await this.oidcProviderMetaDataProvider()).token_endpoint,a=await this.configProvider();if(!i||i.trim().length===0)throw new I("JS-AUTH_CORE-RAT1-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");t&&await this.storageManager.setSessionDataParameter(F.Params.SESSION_STATE,t,o);let l=new URLSearchParams;l.set("client_id",a.clientId),a.clientSecret&&a.clientSecret.trim().length>0&&l.set("client_secret",a.clientSecret);let c=e;l.set("code",c),l.set("grant_type","authorization_code"),l.set("redirect_uri",a.afterSignInUrl),s?.params&&Object.entries(s.params).forEach(([f,h])=>{l.append(f,h)}),a.enablePKCE&&(l.set("code_verifier",`${await this.storageManager.getTemporaryDataParameter(Ie(n),o)}`),await this.storageManager.removeTemporaryDataParameter(Ie(n),o));let u;try{u=await fetch(i,{body:l,credentials:a.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(f){throw new I("JS-AUTH_CORE-RAT1-NE02","Requesting access token failed",f??"The request to get the access token from the server failed.")}if(!u.ok)throw new I("JS-AUTH_CORE-RAT1-HE03",`Requesting access token failed with ${u.statusText}`,await u.json());return this.authHelper.handleTokenResponse(u,o)}async loadOpenIDProviderConfiguration(e){let t=await this.configProvider();if(!e&&await this.storageManager.getTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED))return Promise.resolve();let{wellKnownEndpoint:n,platform:o,discovery:s,baseUrl:i,endpoints:a}=t,l=n||(o==="AsgardeoV2"&&s?.wellKnown?.enabled?`${i}${a?.wellKnown??"/.well-known/openid-configuration"}`:void 0);if(l){let c;try{if(c=await fetch(l),c.status!==200||!c.ok)throw new Error}catch{throw new I("JS-AUTH_CORE-GOPMD-HE01","Invalid well-known response","The well known endpoint response has been failed with an error.")}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await c.json())),await this.storageManager.setTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}if(t.baseUrl){try{await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL())}catch(c){throw new I("JS-AUTH_CORE-GOPMD-IV02","Resolving endpoints failed.",c??"Resolving endpoints by base url failed.")}return await this.storageManager.setTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly()),await this.storageManager.setTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}async getSignOutUrl(e){let t=(await this.oidcProviderMetaDataProvider())?.end_session_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new I("JS-AUTH_CORE-GSOU-NF01","Sign-out endpoint not found.","No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty.");let o=n?.afterSignOutUrl??n?.afterSignInUrl;if(!o||o.trim().length===0)throw new I("JS-AUTH_CORE-GSOU-NF03","No sign-out redirect URL found.","The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. ");let s=new URLSearchParams;if(s.set("post_logout_redirect_uri",o),n.sendIdTokenInLogoutRequest){let i=(await this.storageManager.getSessionData(e))?.id_token;if(!i||i.trim().length===0)throw new I("JS-AUTH_CORE-GSOU-NF02","ID token not found.","No ID token could be found. Either the session information is lost or you have not signed in.");s.set("id_token_hint",i)}else s.set("client_id",n.clientId);return s.set("state",F.Params.SIGN_OUT_SUCCESS),`${t}?${s.toString()}`}async getOpenIDProviderEndpoints(){let e=await this.oidcProviderMetaDataProvider();return{authorizationEndpoint:e.authorization_endpoint??"",checkSessionIframe:e.check_session_iframe??"",endSessionEndpoint:e.end_session_endpoint??"",introspectionEndpoint:e.introspection_endpoint??"",issuer:e.issuer??"",jwksUri:e.jwks_uri??"",registrationEndpoint:e.registration_endpoint??"",revocationEndpoint:e.revocation_endpoint??"",tokenEndpoint:e.token_endpoint??"",userinfoEndpoint:e.userinfo_endpoint??""}}async decodeJwtToken(e){return this.cryptoHelper.decodeJwtToken(e)}async getDecodedIdToken(e,t){let n=(await this.storageManager.getSessionData(e)).id_token;return this.cryptoHelper.decodeJwtToken(n??t)}async getIdToken(e){return(await this.storageManager.getSessionData(e)).id_token}async getUser(e){let t=await this.storageManager.getSessionData(e),n=this.authHelper.getAuthenticatedUserInfo(t?.id_token);return Object.keys(n).forEach(o=>{(n[o]===void 0||n[o]===""||n[o]===null)&&delete n[o]}),n}async getUserSession(e){let t=await this.storageManager.getSessionData(e);return{scopes:t?.scope?.split(" "),sessionState:t?.session_state??""}}async getCrypto(){return this.cryptoHelper}async revokeAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).revocation_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new I("JS-AUTH_CORE-RAT3-NF01","No revoke access token endpoint found.","No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty.");let o=[];o.push(`client_id=${n.clientId}`),o.push(`token=${(await this.storageManager.getSessionData(e)).access_token}`),o.push("token_type_hint=access_token"),n.clientSecret&&n.clientSecret.trim().length>0&&o.push(`client_secret=${n.clientSecret}`);let s;try{s=await fetch(t,{body:o.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(i){throw new I("JS-AUTH_CORE-RAT3-NE02","The request to revoke access token failed.",i??"The request sent to revoke the access token failed.")}if(s.status!==200||!s.ok)throw new I("JS-AUTH_CORE-RAT3-HE03",`Invalid response status received for revoke access token request (${s.statusText}).`,await s.json());return this.authHelper.clearSession(e),Promise.resolve(s)}async refreshAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).token_endpoint,n=await this.configProvider(),o=await this.storageManager.getSessionData(e);if(!o.refresh_token)throw new I("JS-AUTH_CORE-RAT2-NF01","No refresh token found.","There was no refresh token found. Asgardeo doesn\'t return a refresh token if the refresh token grant is not enabled.");if(!t||t.trim().length===0)throw new I("JS-AUTH_CORE-RAT2-NF02","No refresh token endpoint found.","No refresh token endpoint was in the OIDC provider meta data returned by the well-known endpoint or the refresh token endpoint passed to the SDK is empty.");let s=[];s.push(`client_id=${n.clientId}`),s.push(`refresh_token=${o.refresh_token}`),s.push("grant_type=refresh_token"),n.clientSecret&&n.clientSecret.trim().length>0&&s.push(`client_secret=${n.clientSecret}`);let i;try{i=await fetch(t,{body:s.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(a){throw new I("JS-AUTH_CORE-RAT2-NR03","Refresh access token request failed.",a??"The request to refresh the access token failed.")}if(!i.ok)throw new I("JS-AUTH_CORE-RAT2-HE04",`Refreshing access token failed with ${i.statusText}`,await i.json());return this.authHelper.handleTokenResponse(i,e)}async getAccessToken(e){return(await this.storageManager.getSessionData(e))?.access_token}async exchangeToken(e,t){await this.storageManager.getTemporaryDataParameter(H.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let n=await this.oidcProviderMetaDataProvider(),o=await this.configProvider(),s;if(e.tokenEndpoint&&e.tokenEndpoint.trim().length!==0?s=e.tokenEndpoint:s=n.token_endpoint,!s||s.trim().length===0)throw new I("JS-AUTH_CORE-RCG-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");let i=await Promise.all(Object.entries(e.data).map(async([u,f])=>{let h=await this.authHelper.replaceCustomGrantTemplateTags(f,t);return`${u}=${h}`})),a={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"};e.attachToken&&(a={...a,Authorization:`Bearer ${(await this.storageManager.getSessionData(t)).access_token}`});let l={body:i.join("&"),credentials:o.sendCookiesInRequests?"include":"same-origin",headers:new Headers(a),method:"POST"},c;try{c=await fetch(s,l)}catch(u){throw new I("JS-AUTH_CORE-RCG-NE02","The custom grant request failed.",u??"The request sent to get the custom grant failed.")}if(c.status!==200||!c.ok)throw new I("JS-AUTH_CORE-RCG-HE03",`Invalid response status received for the custom grant request. (${c.statusText})`,await c.json());return e.returnsSession?this.authHelper.handleTokenResponse(c,t):Promise.resolve(await c.json())}async isSignedIn(e){let t=!!await this.getAccessToken(e),n=(await this.storageManager.getSessionData(e))?.created_at,o=(await this.storageManager.getSessionData(e))?.expires_in;if(!o)return!1;let s=parseInt(o,10)*1e3,i=new Date().getTime(),a=n+s>i;return t&&a}async getPKCECode(e,t){return await this.storageManager.getTemporaryDataParameter(Ie(e),t)}async setPKCECode(e,t,n){return this.storageManager.setTemporaryDataParameter(Ie(t),e,n)}static isSignOutSuccessful(e){let t=new URL(e),n=t.searchParams.get(F.Params.STATE),o=!!t.searchParams.get("error");return n?n===F.Params.SIGN_OUT_SUCCESS&&!o:!1}static didSignOutFail(e){let t=new URL(e),n=t.searchParams.get(F.Params.STATE),o=!!t.searchParams.get("error");return n?n===F.Params.SIGN_OUT_SUCCESS&&o:!1}async reInitialize(e){let t=this.storageManager.getConfigData(),n=Zi(t,e);await this.storageManager.setConfigData(n),await this.loadOpenIDProviderConfiguration(!0)}static async clearSession(e){await this.authHelperInstance.clearSession(e)}};N(Yn,"authHelperInstance");var Ae=Yn;var zn;(r=>{r.DEFAULT_AUTHENTICATOR_NAME="Username & Password"})(zn||(zn={}));var aa="\\u{1F6E1}\\uFE0F Asgardeo",ca={level:"info",prefix:`${aa}`,showLevel:!0,timestamps:!0},la=()=>typeof window<"u"&&typeof window.document<"u",ua=()=>typeof process<"u"&&process.versions&&process.versions.node,X={blue:"\\x1B[34m",bright:"\\x1B[1m",cyan:"\\x1B[36m",dim:"\\x1B[2m",gray:"\\x1B[90m",green:"\\x1B[32m",magenta:"\\x1B[35m",red:"\\x1B[31m",reset:"\\x1B[0m",white:"\\x1B[37m",yellow:"\\x1B[33m"},Me={debug:"color: #6b7280; font-weight: normal;",error:"color: #dc2626; font-weight: bold;",info:"color: #2563eb; font-weight: bold;",prefix:"color: #7c3aed; font-weight: bold;",timestamp:"color: #6b7280; font-size: 0.9em;",warn:"color: #d97706; font-weight: bold;"},Jn={debug:0,error:3,info:1,warn:2},fa=class He{constructor(e={}){N(this,"config"),this.config={...ca,...e}}configure(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}shouldLog(e){return Jn[e]>=Jn[this.config.level]}static getTimestamp(){return new Date().toISOString()}static getLevelString(e){switch(e){case"debug":return"DEBUG";case"info":return"INFO";case"warn":return"WARN";case"error":return"ERROR";default:return"UNKNOWN"}}formatForNode(e,t){let n=[];if(this.config.timestamps&&n.push(`${X.gray}[${He.getTimestamp()}]${X.reset}`),this.config.prefix&&n.push(`${X.magenta}${this.config.prefix}${X.reset}`),this.config.showLevel){let o=He.getLevelString(e),s;switch(e){case"debug":s=`${X.gray}[${o}]${X.reset}`;break;case"info":s=`${X.blue}[${o}]${X.reset}`;break;case"warn":s=`${X.yellow}[${o}]${X.reset}`;break;case"error":s=`${X.red}[${o}]${X.reset}`;break;default:s=`[${o}]`}n.push(s)}return n.push(t),n.join(" ")}logMessage(e,t,...n){if(this.shouldLog(e)){if(this.config.formatter){this.config.formatter(e,t,...n);return}la()?this.logToBrowser(e,t,...n):ua()?this.logToNode(e,t,...n):console.log(t,...n)}}logToBrowser(e,t,...n){let o=[],s=[];if(this.config.timestamps&&(o.push(`%c[${He.getTimestamp()}]`),s.push(Me.timestamp)),this.config.prefix&&(o.push(`%c${this.config.prefix}`),s.push(Me.prefix)),this.config.showLevel){let a=He.getLevelString(e);switch(o.push(`%c[${a}]`),e){case"debug":s.push(Me.debug);break;case"info":s.push(Me.info);break;case"warn":s.push(Me.warn);break;case"error":s.push(Me.error);break;default:s.push("")}}o.push(`%c${t}`),s.push("color: inherit; font-weight: normal;");let i=o.join(" ");switch(e){case"debug":console.debug(i,...s,...n);break;case"info":console.info(i,...s,...n);break;case"warn":console.warn(i,...s,...n);break;case"error":console.error(i,...s,...n);break;default:console.log(i,...s,...n)}}logToNode(e,t,...n){let o=this.formatForNode(e,t);switch(e){case"debug":console.debug(o,...n);break;case"info":console.info(o,...n);break;case"warn":console.warn(o,...n);break;case"error":console.error(o,...n);break;default:console.log(o,...n)}}debug(e,...t){this.logMessage("debug",e,...t)}info(e,...t){this.logMessage("info",e,...t)}warn(e,...t){this.logMessage("warn",e,...t)}error(e,...t){this.logMessage("error",e,...t)}child(e){let t=this.config.prefix?`${this.config.prefix} - ${e}`:e;return new He({...this.config,prefix:t})}setLevel(e){this.config.level=e}getLevel(){return this.config.level}},nl=new fa;var da=/\\{\\{\\s*([^}]+)\\s*\\}\\}/;var ol=new RegExp(da.source,"g");var wr="init";var Qn="sign-out",eo="http-request",to="http-request-all",ro="request-custom-grant",no="revoke-access-token";var oo="request-start",so="request-success";var io="request-finish",ao="get-oidc-service-endpoints",co="get-basic-user-info",lo="get-decoded-id-token";var uo="get-crypto-helper",fo="enable_http_handler",po="disable_http_handler",ho="get_auth_url",go="request_get_token",mo="is_authenticated",yo="get_sign_out_url",wo="refresh_access-token",Eo="refresh-access-token-error",So="set_session_state",bo="start_auto_refresh_token",To="update_config",Ro="get_id_token",Er="check_session_signed_in",Sr="check_session_signed_out",Io="get_config_data";var br="rpIFrame",Tr="promptNoneIFrame";var Rr="sign-in-silently";var Ir="initialized-silent-sign-in",Ar="promptNoneRequestSent";var Le="error",st="error_description",xr="custom_grant_config",_r="state";var vr="Access token is invalid";var b=class{constructor(){}static generateSuccessMessage(e){return{blob:e?.data instanceof Blob?e?.data:null,data:JSON.stringify(e??""),success:!0}}static generateFailureMessage(e){e?.toJSON&&delete e.toJSON;let t;try{if(e instanceof Error)t=JSON.stringify({name:e.name,message:e.message,stack:e.stack,...e});else if(typeof e=="object"&&e!==null)try{t=JSON.stringify(e)}catch{t=JSON.stringify({message:e.toString?e.toString():"Unknown error",originalError:String(e)})}else t=JSON.stringify(e??"Unknown error")}catch{t=JSON.stringify({message:"Error serialization failed",originalError:String(e)})}return{error:t,success:!1}}};var we=class we{constructor(){}static removeAuthorizationCode(){let e=location.href;history.pushState({},document.title,e.replace(/\\?code=.*$/,""))}static getPKCE(e){return sessionStorage.getItem(e)??""}static setPKCE(e,t){sessionStorage.setItem(e,t)}static setSignOutURL(e,t,n){sessionStorage.setItem(`${F.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${n}-${t}`,e)}static getSignOutUrl(e,t){return sessionStorage.getItem(`${F.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${t}-${e}`)??""}static removePKCE(e){sessionStorage.removeItem(e)}static canContinueSignIn(e,t){return!(e&&!we.hasErrorInURL()&&!we.hasAuthSearchParamsInURL()&&!t)}static isInitializedSilentSignIn(){return we.isSilentStatePresentInURL()}static wasSignInCalled(){return!!((we.hasErrorInURL()||we.hasAuthSearchParamsInURL())&&!this.isSilentStatePresentInURL())}static wasSilentSignInCalled(){let e=sessionStorage.getItem(Ir);return!!(e?JSON.parse(e):null)}static async isSignOutSuccessful(){if(Ae.isSignOutSuccessful(window.location.href)){let e=window.location.href.split("?")[0];return history.pushState({},document.title,e),await Ae.clearSession(),!0}return!1}static didSignOutFail(){if(Ae.didSignOutFail(window.location.href)){let e=new URL(window.location.href),t=e.searchParams.get(Le),n=e.searchParams.get(st),o=window.location.href.split("?")[0];return history.pushState({},document.title,o),{description:n??"",error:t??""}}return!1}static isSilentStatePresentInURL(){return new URL(window.location.href).searchParams.get("state")?.includes(Rr)??!1}static hasAuthSearchParamsInURL(e=window.location.search){return/[?&]code=[^&]+/.test(e)}static hasErrorInURL(e=window.location.href){let t=new URL(e);return!!t.searchParams.get(Le)&&t.searchParams.get(_r)!==F.Params.SIGN_OUT_SUCCESS}static canSendPromptNoneRequest(){let e=sessionStorage.getItem(Ar);return!(e?JSON.parse(e):null)}static setPromptNoneRequestSent(e){sessionStorage.setItem(Ar,JSON.stringify(e))}static async waitTillPageRedirect(e){let t=e??3e3;await new Promise(n=>setTimeout(n,t*1e3))}};E(we,"until",(e,t=500)=>{let n=o=>e()?o():setTimeout(()=>n(o),t);return new Promise(n)});var Ee=we;var Ut=class{constructor(e,t){E(this,"_authenticationClient");E(this,"_storageManager");E(this,"_spaHelper");E(this,"_instanceId");E(this,"_isTokenRefreshing");this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager(),this._spaHelper=t,this._instanceId=this._authenticationClient.getInstanceId(),this._isTokenRefreshing=!1}enableHttpHandler(e){e?.enableHandler&&e.enableHandler()}disableHttpHandler(e){e?.disableHandler&&e.disableHandler()}initializeSessionManger(e,t,n,o,s){s.initialize(e.clientId,t.checkSessionIframe??"",n,e.checkSessionInterval??3,e.sessionRefreshInterval??300,e.afterSignInUrl,o)}async exchangeToken(e,t){let n=await this._storageManager.getConfigData(),o=!0,s=!1;if(e?.tokenEndpoint)if(o=!1,n.storage==="webWorker"){for(let i of[...n?.allowedExternalUrls??[],e.baseUrl])if(i&&e.tokenEndpoint?.startsWith(i)){s=!0;break}}else s=!0;return e.shouldReplayAfterRefresh&&this._storageManager.setTemporaryDataParameter(xr,JSON.stringify(e)),o||s?this._authenticationClient.exchangeToken(e).then(async i=>(t&&typeof t=="function"&&t(e),e.returnsSession?(this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()):i)).catch(i=>Promise.reject(i)):Promise.reject(new I("SPA-MAIN_THREAD_CLIENT-RCG-IV01","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified token endpoint in this request cannot be found among the `allowedExternalUrls`"))}async getCustomGrantConfigData(){let e=await this._storageManager.getTemporaryDataParameter(xr);return e?JSON.parse(e):null}async refreshAccessToken(e){try{await this._authenticationClient.refreshAccessToken();let t=await this.getCustomGrantConfigData();return t&&await this.exchangeToken(t,e),this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()}catch(t){let n={type:Eo};return window.postMessage(n),Promise.reject(t)}}async retryFailedRequests(e){let t=e.httpClient,n=e.requestConfig,o=e.isHttpHandlerEnabled,s=e.httpErrorCallback,i=e.httpFinishCallback;await Ee.until(()=>!this._isTokenRefreshing);try{let a=await t.request(n);return Promise.resolve(a)}catch(a){return o&&(typeof s=="function"&&await s(a),typeof i=="function"&&i()),Promise.reject(a)}}async httpRequest(e,t,n,o,s,i){let a=!1,l=await this._storageManager.getConfigData();if(l.storage==="webWorker"){for(let c of[...l?.allowedExternalUrls??[],l.baseUrl])if(c&&t?.url?.startsWith(c)){a=!0;break}}else a=!0;return a?e.request(t).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){if(this._isTokenRefreshing)return this.retryFailedRequests({enableRetrievingSignOutURLFromSession:i,httpClient:e,httpErrorCallback:o,httpFinishCallback:s,isHttpHandlerEnabled:n,requestConfig:t});this._isTokenRefreshing=!0;let u;try{u=await this.refreshAccessToken(i),this._isTokenRefreshing=!1}catch(f){throw this._isTokenRefreshing=!1,n&&(typeof o=="function"&&await o({...c,code:vr}),typeof s=="function"&&s()),new I("SPA-AUTH_HELPER-HR-SE01",f?.name??"Refresh token request failed.",f?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(u)try{let f=await e.request(t);return Promise.resolve(f)}catch(f){return n&&(typeof o=="function"&&await o(f),typeof s=="function"&&s()),Promise.reject(f)}}return n&&(typeof o=="function"&&await o(c),typeof s=="function"&&s()),Promise.reject(c)}):Promise.reject(new I("SPA-AUTH_HELPER-HR-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`"))}async httpRequestAll(e,t,n,o,s){let i=!0,a=await this._storageManager.getConfigData();if(a.storage==="webWorker")for(let c of e){let u=!1;for(let f of[...a?.allowedExternalUrls??[],a.baseUrl])if(f&&c.url?.startsWith(f)){u=!0;break}if(!u){i=!1;break}}let l=[];if(i)return e.forEach(c=>{l.push(t.request(c))}),t?.all&&t.all(l).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){let u;try{u=await this._authenticationClient.refreshAccessToken()}catch(f){throw n&&(typeof o=="function"&&await o({...c,code:vr}),typeof s=="function"&&s()),new I("SPA-AUTH_HELPER-HRA-SE01",f?.name??"Refresh token request failed.",f?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(u)return t.all&&t.all(l).then(f=>Promise.resolve(f)).catch(async f=>(n&&(typeof o=="function"&&await o(f),typeof s=="function"&&s()),Promise.reject(f)))}return n&&(typeof o=="function"&&await o(c),typeof s=="function"&&s()),Promise.reject(c)});throw new I("SPA-AUTH_HELPER-HRA-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`")}async requestAccessToken(e,t,n,o,s,i){let a=await this._storageManager.getConfigData();if(a.storage==="browserMemory"&&a.enablePKCE&&t){let l=Ee.getPKCE(Ie(t));await this._authenticationClient.setPKCECode(Ie(t),l)}else a.storage==="webWorker"&&o&&await this._authenticationClient.setPKCECode(o,s??"");return e?this._authenticationClient.requestAccessToken(e,t??"",s??"",void 0,i).then(async()=>(a.storage!=="webWorker"?(Ee.setSignOutURL(await this._authenticationClient.getSignOutUrl(),a.clientId,this._instanceId),this._spaHelper&&(this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this)),n&&typeof n=="function"&&a.syncSession&&n()):this._spaHelper&&this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser())).catch(l=>Promise.reject(l)):Promise.reject(new I("SPA-AUTH_HELPER-RAT1-NF01","No authorization code.","No authorization code was found."))}async signInSilently(e,t,n,o,s){if(Ee.isInitializedSilentSignIn())return await n.receivePromptNoneResponse(),Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});let a=document.getElementById(br)?.contentDocument?.getElementById(Tr);try{let l=await e(o);a.src=l}catch(l){return Promise.reject(l)}return new Promise((l,c)=>{let u=setTimeout(()=>{l(!1)},1e4),f=async h=>{let m=h.data;m?.type==Sr&&(window.removeEventListener("message",f),clearTimeout(u),l(!1)),m?.type==Er&&m?.data?.code&&t(m?.data?.code,m?.data?.sessionState,m?.data?.state,s).then(p=>{window.removeEventListener("message",f),l(p)}).catch(p=>{window.removeEventListener("message",f),c(p)}).finally(()=>{clearTimeout(u)})};window.addEventListener("message",f)})}async handleSignIn(e,t,n){let o=await this._storageManager.getConfigData();if(await e())return Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});if(o.storage!=="webWorker"&&await this._authenticationClient.isSignedIn())return this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this),o.syncSession&&t(),Promise.resolve(await this._authenticationClient.getUser());let s=new URL(window.location.href).searchParams.get(Le),i=new URL(window.location.href).searchParams.get(st);if(s){let a=new URL(window.location.href);throw a.searchParams.delete(Le),a.searchParams.delete(st),history.pushState(null,document.title,a.toString()),new I("SPA-AUTH_HELPER-SI-SE01",s,i??"")}if(o.storage==="webWorker"&&n){let a=await n();if(a)return a}return Promise.resolve(void 0)}async attachTokenToRequestConfig(e){let t={attachToken:!0,...e};t.attachToken&&(t.shouldAttachIDPAccessToken?e.headers={...e.headers,Authorization:`Bearer ${await this.getIDPAccessToken()}`}:e.headers={...e.headers,Authorization:`Bearer ${await this.getAccessToken()}`})}async getUser(){return this._authenticationClient.getUser()}async getDecodedIdToken(e){return this._authenticationClient.getDecodedIdToken(e)}async getDecodedIDPIDToken(){return this._authenticationClient.getDecodedIdToken()}async getCrypto(){return this._authenticationClient.getCrypto()}async getIdToken(){return this._authenticationClient.getIdToken()}async getOpenIDProviderEndpoints(){return this._authenticationClient.getOpenIDProviderEndpoints()}async getAccessToken(e){return this._authenticationClient.getAccessToken(e)}async getIDPAccessToken(){return(await this._storageManager.getSessionData())?.access_token}getStorageManager(){return this._storageManager}async isSignedIn(){return this._authenticationClient.isSignedIn()}};var kt=class{constructor(e){E(this,"_authenticationClient");E(this,"_storageManager");this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager()}async refreshAccessTokenAutomatically(e){if(!((await this._storageManager.getConfigData())?.periodicTokenRefresh??!1))return;let n=await this._storageManager.getSessionData();if(n.refresh_token){let o=parseInt(n.expires_in),s=o<=10?o:o-10,i=setTimeout(async()=>{await e.refreshAccessToken()},s*1e3);await this._storageManager.setTemporaryDataParameter(ot.Storage.StorageKeys.REFRESH_TOKEN_TIMER,JSON.stringify(i))}}async getRefreshTimeoutTimer(){return await this._storageManager.getTemporaryDataParameter(ot.Storage.StorageKeys.REFRESH_TOKEN_TIMER)?JSON.parse(await this._storageManager.getTemporaryDataParameter(ot.Storage.StorageKeys.REFRESH_TOKEN_TIMER)):-1}async clearRefreshTokenTimeout(e){if(e){clearTimeout(e);return}let t=await this.getRefreshTimeoutTimer();t!==-1&&clearTimeout(t)}};function it(r,e){return function(){return r.apply(e,arguments)}}var{toString:ha}=Object.prototype,{getPrototypeOf:Cr}=Object,{iterator:Dt,toStringTag:xo}=Symbol,Mt=(r=>e=>{let t=ha.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Q=r=>(r=r.toLowerCase(),e=>Mt(e)===r),Ht=r=>e=>typeof e===r,{isArray:Fe}=Array,Be=Ht("undefined");function at(r){return r!==null&&!Be(r)&&r.constructor!==null&&!Be(r.constructor)&&z(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}var _o=Q("ArrayBuffer");function ga(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&_o(r.buffer),e}var ma=Ht("string"),z=Ht("function"),vo=Ht("number"),ct=r=>r!==null&&typeof r=="object",ya=r=>r===!0||r===!1,Nt=r=>{if(Mt(r)!=="object")return!1;let e=Cr(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(xo in r)&&!(Dt in r)},wa=r=>{if(!ct(r)||at(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},Ea=Q("Date"),Sa=Q("File"),ba=Q("Blob"),Ta=Q("FileList"),Ra=r=>ct(r)&&z(r.pipe),Ia=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||z(r.append)&&((e=Mt(r))==="formdata"||e==="object"&&z(r.toString)&&r.toString()==="[object FormData]"))},Aa=Q("URLSearchParams"),[xa,_a,va,Oa]=["ReadableStream","Request","Response","Headers"].map(Q),Ca=r=>r.trim?r.trim():r.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g,"");function lt(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,o;if(typeof r!="object"&&(r=[r]),Fe(r))for(n=0,o=r.length;n<o;n++)e.call(null,r[n],n,r);else{if(at(r))return;let s=t?Object.getOwnPropertyNames(r):Object.keys(r),i=s.length,a;for(n=0;n<i;n++)a=s[n],e.call(null,r[a],a,r)}}function Oo(r,e){if(at(r))return null;e=e.toLowerCase();let t=Object.keys(r),n=t.length,o;for(;n-- >0;)if(o=t[n],e===o.toLowerCase())return o;return null}var xe=typeof self<"u"||typeof self<"u"?self:typeof window<"u"?window:self,Co=r=>!Be(r)&&r!==xe;function Or(){let{caseless:r,skipUndefined:e}=Co(this)&&this||{},t={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;let i=r&&Oo(t,s)||s;Nt(t[i])&&Nt(o)?t[i]=Or(t[i],o):Nt(o)?t[i]=Or({},o):Fe(o)?t[i]=o.slice():(!e||!Be(o))&&(t[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&lt(arguments[o],n);return t}var Pa=(r,e,t,{allOwnKeys:n}={})=>(lt(e,(o,s)=>{t&&z(o)?Object.defineProperty(r,s,{value:it(o,t),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(r,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),r),Ua=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),ka=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),Object.defineProperty(r.prototype,"constructor",{value:r,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},Na=(r,e,t,n)=>{let o,s,i,a={};if(e=e||{},r==null)return e;do{for(o=Object.getOwnPropertyNames(r),s=o.length;s-- >0;)i=o[s],(!n||n(i,r,e))&&!a[i]&&(e[i]=r[i],a[i]=!0);r=t!==!1&&Cr(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Da=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;let n=r.indexOf(e,t);return n!==-1&&n===t},Ma=r=>{if(!r)return null;if(Fe(r))return r;let e=r.length;if(!vo(e))return null;let t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},Ha=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&Cr(Uint8Array)),La=(r,e)=>{let n=(r&&r[Dt]).call(r),o;for(;(o=n.next())&&!o.done;){let s=o.value;e.call(r,s[0],s[1])}},Ba=(r,e)=>{let t,n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},Fa=Q("HTMLFormElement"),$a=r=>r.toLowerCase().replace(/[-_\\s]([a-z\\d])(\\w*)/g,function(t,n,o){return n.toUpperCase()+o}),Ao=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Ka=Q("RegExp"),Po=(r,e)=>{let t=Object.getOwnPropertyDescriptors(r),n={};lt(t,(o,s)=>{let i;(i=e(o,s,r))!==!1&&(n[s]=i||o)}),Object.defineProperties(r,n)},Wa=r=>{Po(r,(e,t)=>{if(z(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;let n=r[t];if(z(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method \'"+t+"\'")})}})},ja=(r,e)=>{let t={},n=o=>{o.forEach(s=>{t[s]=!0})};return Fe(r)?n(r):n(String(r).split(e)),t},qa=()=>{},za=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function Ja(r){return!!(r&&z(r.append)&&r[xo]==="FormData"&&r[Dt])}var Va=r=>{let e=new Array(10),t=(n,o)=>{if(ct(n)){if(e.indexOf(n)>=0)return;if(at(n))return n;if(!("toJSON"in n)){e[o]=n;let s=Fe(n)?[]:{};return lt(n,(i,a)=>{let l=t(i,o+1);!Be(l)&&(s[a]=l)}),e[o]=void 0,s}}return n};return t(r,0)},Ga=Q("AsyncFunction"),Xa=r=>r&&(ct(r)||z(r))&&z(r.then)&&z(r.catch),Uo=((r,e)=>r?setImmediate:e?((t,n)=>(xe.addEventListener("message",({source:o,data:s})=>{o===xe&&s===t&&n.length&&n.shift()()},!1),o=>{n.push(o),xe.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",z(xe.postMessage)),Ya=typeof queueMicrotask<"u"?queueMicrotask.bind(xe):typeof process<"u"&&process.nextTick||Uo,Za=r=>r!=null&&z(r[Dt]),d={isArray:Fe,isArrayBuffer:_o,isBuffer:at,isFormData:Ia,isArrayBufferView:ga,isString:ma,isNumber:vo,isBoolean:ya,isObject:ct,isPlainObject:Nt,isEmptyObject:wa,isReadableStream:xa,isRequest:_a,isResponse:va,isHeaders:Oa,isUndefined:Be,isDate:Ea,isFile:Sa,isBlob:ba,isRegExp:Ka,isFunction:z,isStream:Ra,isURLSearchParams:Aa,isTypedArray:Ha,isFileList:Ta,forEach:lt,merge:Or,extend:Pa,trim:Ca,stripBOM:Ua,inherits:ka,toFlatObject:Na,kindOf:Mt,kindOfTest:Q,endsWith:Da,toArray:Ma,forEachEntry:La,matchAll:Ba,isHTMLForm:Fa,hasOwnProperty:Ao,hasOwnProp:Ao,reduceDescriptors:Po,freezeMethods:Wa,toObjectSet:ja,toCamelCase:$a,noop:qa,toFiniteNumber:za,findKey:Oo,global:xe,isContextDefined:Co,isSpecCompliantForm:Ja,toJSONObject:Va,isAsyncFn:Ga,isThenable:Xa,setImmediate:Uo,asap:Ya,isIterable:Za};var j=class r extends Error{static from(e,t,n,o,s,i){let a=new r(e.message,t||e.code,n,o,s);return a.cause=e,a.name=e.name,i&&Object.assign(a,i),a}constructor(e,t,n,o,s){super(e),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),o&&(this.request=o),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:d.toJSONObject(this.config),code:this.code,status:this.status}}};j.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";j.ERR_BAD_OPTION="ERR_BAD_OPTION";j.ECONNABORTED="ECONNABORTED";j.ETIMEDOUT="ETIMEDOUT";j.ERR_NETWORK="ERR_NETWORK";j.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";j.ERR_DEPRECATED="ERR_DEPRECATED";j.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";j.ERR_BAD_REQUEST="ERR_BAD_REQUEST";j.ERR_CANCELED="ERR_CANCELED";j.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";j.ERR_INVALID_URL="ERR_INVALID_URL";var R=j;var Lt=null;function Pr(r){return d.isPlainObject(r)||d.isArray(r)}function No(r){return d.endsWith(r,"[]")?r.slice(0,-2):r}function ko(r,e,t){return r?r.concat(e).map(function(o,s){return o=No(o),!t&&s?"["+o+"]":o}).join(t?".":""):e}function Qa(r){return d.isArray(r)&&!r.some(Pr)}var ec=d.toFlatObject(d,{},null,function(e){return/^is[A-Z]/.test(e)});function tc(r,e,t){if(!d.isObject(r))throw new TypeError("target must be an object");e=e||new(Lt||FormData),t=d.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,y){return!d.isUndefined(y[w])});let n=t.metaTokens,o=t.visitor||u,s=t.dots,i=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&d.isSpecCompliantForm(e);if(!d.isFunction(o))throw new TypeError("visitor must be a function");function c(p){if(p===null)return"";if(d.isDate(p))return p.toISOString();if(d.isBoolean(p))return p.toString();if(!l&&d.isBlob(p))throw new R("Blob is not supported. Use a Buffer instead.");return d.isArrayBuffer(p)||d.isTypedArray(p)?l&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,w,y){let S=p;if(p&&!y&&typeof p=="object"){if(d.endsWith(w,"{}"))w=n?w:w.slice(0,-2),p=JSON.stringify(p);else if(d.isArray(p)&&Qa(p)||(d.isFileList(p)||d.endsWith(w,"[]"))&&(S=d.toArray(p)))return w=No(w),S.forEach(function(_,v){!(d.isUndefined(_)||_===null)&&e.append(i===!0?ko([w],v,s):i===null?w:w+"[]",c(_))}),!1}return Pr(p)?!0:(e.append(ko(y,w,s),c(p)),!1)}let f=[],h=Object.assign(ec,{defaultVisitor:u,convertValue:c,isVisitable:Pr});function m(p,w){if(!d.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(p),d.forEach(p,function(S,T){(!(d.isUndefined(S)||S===null)&&o.call(e,S,d.isString(T)?T.trim():T,w,h))===!0&&m(S,w?w.concat(T):[T])}),f.pop()}}if(!d.isObject(r))throw new TypeError("data must be an object");return m(r),e}var Se=tc;function Do(r){let e={"!":"%21","\'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\\0"};return encodeURIComponent(r).replace(/[!\'()~]|%20|%00/g,function(n){return e[n]})}function Mo(r,e){this._pairs=[],r&&Se(r,this,e)}var Ho=Mo.prototype;Ho.append=function(e,t){this._pairs.push([e,t])};Ho.toString=function(e){let t=e?function(n){return e.call(this,n,Do)}:Do;return this._pairs.map(function(o){return t(o[0])+"="+t(o[1])},"").join("&")};var Bt=Mo;function rc(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ut(r,e,t){if(!e)return r;let n=t&&t.encode||rc,o=d.isFunction(t)?{serialize:t}:t,s=o&&o.serialize,i;if(s?i=s(e,o):i=d.isURLSearchParams(e)?e.toString():new Bt(e,o).toString(n),i){let a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+i}return r}var Ur=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){d.forEach(this.handlers,function(n){n!==null&&e(n)})}},kr=Ur;var $e={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var Lo=typeof URLSearchParams<"u"?URLSearchParams:Bt;var Bo=typeof FormData<"u"?FormData:null;var Fo=typeof Blob<"u"?Blob:null;var $o={isBrowser:!0,classes:{URLSearchParams:Lo,FormData:Bo,Blob:Fo},protocols:["http","https","file","blob","url","data"]};var Mr={};ti(Mr,{hasBrowserEnv:()=>Dr,hasStandardBrowserEnv:()=>nc,hasStandardBrowserWebWorkerEnv:()=>oc,navigator:()=>Nr,origin:()=>sc});var Dr=typeof window<"u"&&typeof document<"u",Nr=typeof navigator=="object"&&navigator||void 0,nc=Dr&&(!Nr||["ReactNative","NativeScript","NS"].indexOf(Nr.product)<0),oc=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",sc=Dr&&window.location.href||"http://localhost";var P={...Mr,...$o};function Hr(r,e){return Se(r,new P.classes.URLSearchParams,{visitor:function(t,n,o,s){return P.isNode&&d.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function ic(r){return d.matchAll(/\\w+|\\[(\\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ac(r){let e={},t=Object.keys(r),n,o=t.length,s;for(n=0;n<o;n++)s=t[n],e[s]=r[s];return e}function cc(r){function e(t,n,o,s){let i=t[s++];if(i==="__proto__")return!0;let a=Number.isFinite(+i),l=s>=t.length;return i=!i&&d.isArray(o)?o.length:i,l?(d.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!d.isObject(o[i]))&&(o[i]=[]),e(t,n,o[i],s)&&d.isArray(o[i])&&(o[i]=ac(o[i])),!a)}if(d.isFormData(r)&&d.isFunction(r.entries)){let t={};return d.forEachEntry(r,(n,o)=>{e(ic(n),o,t,0)}),t}return null}var Ft=cc;function lc(r,e,t){if(d.isString(r))try{return(e||JSON.parse)(r),d.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}var Lr={transitional:$e,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let n=t.getContentType()||"",o=n.indexOf("application/json")>-1,s=d.isObject(e);if(s&&d.isHTMLForm(e)&&(e=new FormData(e)),d.isFormData(e))return o?JSON.stringify(Ft(e)):e;if(d.isArrayBuffer(e)||d.isBuffer(e)||d.isStream(e)||d.isFile(e)||d.isBlob(e)||d.isReadableStream(e))return e;if(d.isArrayBufferView(e))return e.buffer;if(d.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Hr(e,this.formSerializer).toString();if((a=d.isFileList(e))||n.indexOf("multipart/form-data")>-1){let l=this.env&&this.env.FormData;return Se(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||o?(t.setContentType("application/json",!1),lc(e)):e}],transformResponse:[function(e){let t=this.transitional||Lr.transitional,n=t&&t.forcedJSONParsing,o=this.responseType==="json";if(d.isResponse(e)||d.isReadableStream(e))return e;if(e&&d.isString(e)&&(n&&!this.responseType||o)){let i=!(t&&t.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?R.from(a,R.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};d.forEach(["delete","get","head","post","put","patch"],r=>{Lr.headers[r]={}});var Ke=Lr;var uc=d.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ko=r=>{let e={},t,n,o;return r&&r.split(`\n`).forEach(function(i){o=i.indexOf(":"),t=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!t||e[t]&&uc[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e};var Wo=Symbol("internals");function ft(r){return r&&String(r).trim().toLowerCase()}function $t(r){return r===!1||r==null?r:d.isArray(r)?r.map($t):String(r)}function fc(r){let e=Object.create(null),t=/([^\\s,;=]+)\\s*(?:=\\s*([^,;]+))?/g,n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}var dc=r=>/^[-_a-zA-Z0-9^`|~,!#$%&\'*+.]+$/.test(r.trim());function Br(r,e,t,n,o){if(d.isFunction(n))return n.call(this,e,t);if(o&&(e=t),!!d.isString(e)){if(d.isString(n))return e.indexOf(n)!==-1;if(d.isRegExp(n))return n.test(e)}}function pc(r){return r.trim().toLowerCase().replace(/([a-z\\d])(\\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function hc(r,e){let t=d.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(o,s,i){return this[n].call(this,e,o,s,i)},configurable:!0})})}var We=class{constructor(e){e&&this.set(e)}set(e,t,n){let o=this;function s(a,l,c){let u=ft(l);if(!u)throw new Error("header name must be a non-empty string");let f=d.findKey(o,u);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=$t(a))}let i=(a,l)=>d.forEach(a,(c,u)=>s(c,u,l));if(d.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(d.isString(e)&&(e=e.trim())&&!dc(e))i(Ko(e),t);else if(d.isObject(e)&&d.isIterable(e)){let a={},l,c;for(let u of e){if(!d.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[c=u[0]]=(l=a[c])?d.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}i(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=ft(e),e){let n=d.findKey(this,e);if(n){let o=this[n];if(!t)return o;if(t===!0)return fc(o);if(d.isFunction(t))return t.call(this,o,n);if(d.isRegExp(t))return t.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ft(e),e){let n=d.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Br(this,this[n],n,t)))}return!1}delete(e,t){let n=this,o=!1;function s(i){if(i=ft(i),i){let a=d.findKey(n,i);a&&(!t||Br(n,n[a],a,t))&&(delete n[a],o=!0)}}return d.isArray(e)?e.forEach(s):s(e),o}clear(e){let t=Object.keys(this),n=t.length,o=!1;for(;n--;){let s=t[n];(!e||Br(this,this[s],s,e,!0))&&(delete this[s],o=!0)}return o}normalize(e){let t=this,n={};return d.forEach(this,(o,s)=>{let i=d.findKey(n,s);if(i){t[i]=$t(o),delete t[s];return}let a=e?pc(s):String(s).trim();a!==s&&delete t[s],t[a]=$t(o),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return d.forEach(this,(n,o)=>{n!=null&&n!==!1&&(t[o]=e&&d.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`\n`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(o=>n.set(o)),n}static accessor(e){let n=(this[Wo]=this[Wo]={accessors:{}}).accessors,o=this.prototype;function s(i){let a=ft(i);n[a]||(hc(o,i),n[a]=!0)}return d.isArray(e)?e.forEach(s):s(e),this}};We.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);d.reduceDescriptors(We.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}});d.freezeMethods(We);var L=We;function dt(r,e){let t=this||Ke,n=e||t,o=L.from(n.headers),s=n.data;return d.forEach(r,function(a){s=a.call(t,s,o.normalize(),e?e.status:void 0)}),o.normalize(),s}function pt(r){return!!(r&&r.__CANCEL__)}var Fr=class extends R{constructor(e,t,n){super(e??"canceled",R.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}},se=Fr;function ht(r,e,t){let n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new R("Request failed with status code "+t.status,[R.ERR_BAD_REQUEST,R.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function $r(r){let e=/^([-+\\w]{1,25})(:?\\/\\/|:)/.exec(r);return e&&e[1]||""}function gc(r,e){r=r||10;let t=new Array(r),n=new Array(r),o=0,s=0,i;return e=e!==void 0?e:1e3,function(l){let c=Date.now(),u=n[s];i||(i=c),t[o]=l,n[o]=c;let f=s,h=0;for(;f!==o;)h+=t[f++],f=f%r;if(o=(o+1)%r,o===s&&(s=(s+1)%r),c-i<e)return;let m=u&&c-u;return m?Math.round(h*1e3/m):void 0}}var jo=gc;function mc(r,e){let t=0,n=1e3/e,o,s,i=(c,u=Date.now())=>{t=u,o=null,s&&(clearTimeout(s),s=null),r(...c)};return[(...c)=>{let u=Date.now(),f=u-t;f>=n?i(c,u):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},n-f)))},()=>o&&i(o)]}var qo=mc;var je=(r,e,t=3)=>{let n=0,o=jo(50,250);return qo(s=>{let i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-n,c=o(l),u=i<=a;n=i;let f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};r(f)},t)},Kr=(r,e)=>{let t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},Wr=r=>(...e)=>d.asap(()=>r(...e));var zo=P.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,P.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(P.origin),P.navigator&&/(msie|trident)/i.test(P.navigator.userAgent)):()=>!0;var Jo=P.hasStandardBrowserEnv?{write(r,e,t,n,o,s,i){if(typeof document>"u")return;let a=[`${r}=${encodeURIComponent(e)}`];d.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),d.isString(n)&&a.push(`path=${n}`),d.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),d.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(r){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+r+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(r){this.write(r,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function jr(r){return typeof r!="string"?!1:/^([a-z][a-z\\d+\\-.]*:)?\\/\\//i.test(r)}function qr(r,e){return e?r.replace(/\\/?\\/$/,"")+"/"+e.replace(/^\\/+/,""):r}function gt(r,e,t){let n=!jr(e);return r&&(n||t==!1)?qr(r,e):e}var Vo=r=>r instanceof L?{...r}:r;function ee(r,e){e=e||{};let t={};function n(c,u,f,h){return d.isPlainObject(c)&&d.isPlainObject(u)?d.merge.call({caseless:h},c,u):d.isPlainObject(u)?d.merge({},u):d.isArray(u)?u.slice():u}function o(c,u,f,h){if(d.isUndefined(u)){if(!d.isUndefined(c))return n(void 0,c,f,h)}else return n(c,u,f,h)}function s(c,u){if(!d.isUndefined(u))return n(void 0,u)}function i(c,u){if(d.isUndefined(u)){if(!d.isUndefined(c))return n(void 0,c)}else return n(void 0,u)}function a(c,u,f){if(f in e)return n(c,u);if(f in r)return n(void 0,c)}let l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,u,f)=>o(Vo(c),Vo(u),f,!0)};return d.forEach(Object.keys({...r,...e}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;let f=d.hasOwnProp(l,u)?l[u]:o,h=f(r[u],e[u],u);d.isUndefined(h)&&f!==a||(t[u]=h)}),t}var Kt=r=>{let e=ee({},r),{data:t,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=e;if(e.headers=i=L.from(i),e.url=ut(gt(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),d.isFormData(t)){if(P.hasStandardBrowserEnv||P.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(d.isFunction(t.getHeaders)){let l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([u,f])=>{c.includes(u.toLowerCase())&&i.set(u,f)})}}if(P.hasStandardBrowserEnv&&(n&&d.isFunction(n)&&(n=n(e)),n||n!==!1&&zo(e.url))){let l=o&&s&&Jo.read(s);l&&i.set(o,l)}return e};var yc=typeof XMLHttpRequest<"u",Go=yc&&function(r){return new Promise(function(t,n){let o=Kt(r),s=o.data,i=L.from(o.headers).normalize(),{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,u,f,h,m,p;function w(){m&&m(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function S(){if(!y)return;let _=L.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),A={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:_,config:r,request:y};ht(function(O){t(O),w()},function(O){n(O),w()},A),y=null}"onloadend"in y?y.onloadend=S:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(S)},y.onabort=function(){y&&(n(new R("Request aborted",R.ECONNABORTED,r,y)),y=null)},y.onerror=function(v){let A=v&&v.message?v.message:"Network Error",M=new R(A,R.ERR_NETWORK,r,y);M.event=v||null,n(M),y=null},y.ontimeout=function(){let v=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",A=o.transitional||$e;o.timeoutErrorMessage&&(v=o.timeoutErrorMessage),n(new R(v,A.clarifyTimeoutError?R.ETIMEDOUT:R.ECONNABORTED,r,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&d.forEach(i.toJSON(),function(v,A){y.setRequestHeader(A,v)}),d.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),c&&([h,p]=je(c,!0),y.addEventListener("progress",h)),l&&y.upload&&([f,m]=je(l),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(u=_=>{y&&(n(!_||_.type?new se(null,r,y):_),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));let T=$r(o.url);if(T&&P.protocols.indexOf(T)===-1){n(new R("Unsupported protocol "+T+":",R.ERR_BAD_REQUEST,r));return}y.send(s||null)})};var wc=(r,e)=>{let{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,o,s=function(c){if(!o){o=!0,a();let u=c instanceof Error?c:this.reason;n.abort(u instanceof R?u:new se(u instanceof Error?u.message:u))}},i=e&&setTimeout(()=>{i=null,s(new R(`timeout of ${e}ms exceeded`,R.ETIMEDOUT))},e),a=()=>{r&&(i&&clearTimeout(i),i=null,r.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),r=null)};r.forEach(c=>c.addEventListener("abort",s));let{signal:l}=n;return l.unsubscribe=()=>d.asap(a),l}},Xo=wc;var Ec=function*(r,e){let t=r.byteLength;if(!e||t<e){yield r;return}let n=0,o;for(;n<t;)o=n+e,yield r.slice(n,o),n=o},Sc=async function*(r,e){for await(let t of bc(r))yield*Ec(t,e)},bc=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},zr=(r,e,t,n)=>{let o=Sc(r,e),s=0,i,a=l=>{i||(i=!0,n&&n(l))};return new ReadableStream({async pull(l){try{let{done:c,value:u}=await o.next();if(c){a(),l.close();return}let f=u.byteLength;if(t){let h=s+=f;t(h)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})};var Yo=64*1024,{isFunction:Wt}=d,Tc=(({Request:r,Response:e})=>({Request:r,Response:e}))(d.global),{ReadableStream:Zo,TextEncoder:Qo}=d.global,es=(r,...e)=>{try{return!!r(...e)}catch{return!1}},Rc=r=>{r=d.merge.call({skipUndefined:!0},Tc,r);let{fetch:e,Request:t,Response:n}=r,o=e?Wt(e):typeof fetch=="function",s=Wt(t),i=Wt(n);if(!o)return!1;let a=o&&Wt(Zo),l=o&&(typeof Qo=="function"?(p=>w=>p.encode(w))(new Qo):async p=>new Uint8Array(await new t(p).arrayBuffer())),c=s&&a&&es(()=>{let p=!1,w=new t(P.origin,{body:new Zo,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!w}),u=i&&a&&es(()=>d.isReadableStream(new n("").body)),f={stream:u&&(p=>p.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!f[p]&&(f[p]=(w,y)=>{let S=w&&w[p];if(S)return S.call(w);throw new R(`Response type \'${p}\' is not supported`,R.ERR_NOT_SUPPORT,y)})});let h=async p=>{if(p==null)return 0;if(d.isBlob(p))return p.size;if(d.isSpecCompliantForm(p))return(await new t(P.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(d.isArrayBufferView(p)||d.isArrayBuffer(p))return p.byteLength;if(d.isURLSearchParams(p)&&(p=p+""),d.isString(p))return(await l(p)).byteLength},m=async(p,w)=>{let y=d.toFiniteNumber(p.getContentLength());return y??h(w)};return async p=>{let{url:w,method:y,data:S,signal:T,cancelToken:_,timeout:v,onDownloadProgress:A,onUploadProgress:M,responseType:O,headers:U,withCredentials:C="same-origin",fetchOptions:ae}=Kt(p),ce=e||fetch;O=O?(O+"").toLowerCase():"text";let re=Xo([T,_&&_.toAbortSignal()],v),Oe=null,he=re&&re.unsubscribe&&(()=>{re.unsubscribe()}),tr;try{if(M&&c&&y!=="get"&&y!=="head"&&(tr=await m(U,S))!==0){let x=new t(w,{method:"POST",body:S,duplex:"half"}),W;if(d.isFormData(S)&&(W=x.headers.get("content-type"))&&U.setContentType(W),x.body){let[Ce,ge]=Kr(tr,je(Wr(M)));S=zr(x.body,Yo,Ce,ge)}}d.isString(C)||(C=C?"include":"omit");let K=s&&"credentials"in t.prototype,rr={...ae,signal:re,method:y.toUpperCase(),headers:U.normalize().toJSON(),body:S,duplex:"half",credentials:K?C:void 0};Oe=s&&new t(w,rr);let le=await(s?ce(Oe,ae):ce(w,rr)),nr=u&&(O==="stream"||O==="response");if(u&&(A||nr&&he)){let x={};["status","statusText","headers"].forEach(At=>{x[At]=le[At]});let W=d.toFiniteNumber(le.headers.get("content-length")),[Ce,ge]=A&&Kr(W,je(Wr(A),!0))||[];le=new n(zr(le.body,Yo,Ce,()=>{ge&&ge(),he&&he()}),x)}O=O||"text";let En=await f[d.findKey(f,O)||"text"](le,p);return!nr&&he&&he(),await new Promise((x,W)=>{ht(x,W,{data:En,headers:L.from(le.headers),status:le.status,statusText:le.statusText,config:p,request:Oe})})}catch(K){throw he&&he(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new R("Network Error",R.ERR_NETWORK,p,Oe,K&&K.response),{cause:K.cause||K}):R.from(K,K&&K.code,p,Oe,K&&K.response)}}},Ic=new Map,Jr=r=>{let e=r&&r.env||{},{fetch:t,Request:n,Response:o}=e,s=[n,o,t],i=s.length,a=i,l,c,u=Ic;for(;a--;)l=s[a],c=u.get(l),c===void 0&&u.set(l,c=a?new Map:Rc(e)),u=c;return c},md=Jr();var Vr={http:Lt,xhr:Go,fetch:{get:Jr}};d.forEach(Vr,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});var ts=r=>`- ${r}`,xc=r=>d.isFunction(r)||r===null||r===!1;function _c(r,e){r=d.isArray(r)?r:[r];let{length:t}=r,n,o,s={};for(let i=0;i<t;i++){n=r[i];let a;if(o=n,!xc(n)&&(o=Vr[(a=String(n)).toLowerCase()],o===void 0))throw new R(`Unknown adapter \'${a}\'`);if(o&&(d.isFunction(o)||(o=o.get(e))))break;s[a||"#"+i]=o}if(!o){let i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build")),a=t?i.length>1?`since :\n`+i.map(ts).join(`\n`):" "+ts(i[0]):"as no adapter specified";throw new R("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}var jt={getAdapter:_c,adapters:Vr};function Gr(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new se(null,r)}function qt(r){return Gr(r),r.headers=L.from(r.headers),r.data=dt.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),jt.getAdapter(r.adapter||Ke.adapter,r)(r).then(function(n){return Gr(r),n.data=dt.call(r,r.transformResponse,n),n.headers=L.from(n.headers),n},function(n){return pt(n)||(Gr(r),n&&n.response&&(n.response.data=dt.call(r,r.transformResponse,n.response),n.response.headers=L.from(n.response.headers))),Promise.reject(n)})}var zt="1.13.5";var Jt={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{Jt[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});var rs={};Jt.transitional=function(e,t,n){function o(s,i){return"[Axios v"+zt+"] Transitional option \'"+s+"\'"+i+(n?". "+n:"")}return(s,i,a)=>{if(e===!1)throw new R(o(i," has been removed"+(t?" in "+t:"")),R.ERR_DEPRECATED);return t&&!rs[i]&&(rs[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,i,a):!0}};Jt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function vc(r,e,t){if(typeof r!="object")throw new R("options must be an object",R.ERR_BAD_OPTION_VALUE);let n=Object.keys(r),o=n.length;for(;o-- >0;){let s=n[o],i=e[s];if(i){let a=r[s],l=a===void 0||i(a,s,r);if(l!==!0)throw new R("option "+s+" must be "+l,R.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new R("Unknown option "+s,R.ERR_BAD_OPTION)}}var mt={assertOptions:vc,validators:Jt};var Y=mt.validators,qe=class{constructor(e){this.defaults=e||{},this.interceptors={request:new kr,response:new kr}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let s=o.stack?o.stack.replace(/^.+\\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\\n.+\\n/,""))&&(n.stack+=`\n`+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=ee(this.defaults,t);let{transitional:n,paramsSerializer:o,headers:s}=t;n!==void 0&&mt.assertOptions(n,{silentJSONParsing:Y.transitional(Y.boolean),forcedJSONParsing:Y.transitional(Y.boolean),clarifyTimeoutError:Y.transitional(Y.boolean),legacyInterceptorReqResOrdering:Y.transitional(Y.boolean)},!1),o!=null&&(d.isFunction(o)?t.paramsSerializer={serialize:o}:mt.assertOptions(o,{encode:Y.function,serialize:Y.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),mt.assertOptions(t,{baseUrl:Y.spelling("baseURL"),withXsrfToken:Y.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=s&&d.merge(s.common,s[t.method]);s&&d.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),t.headers=L.concat(i,s);let a=[],l=!0;this.interceptors.request.forEach(function(w){if(typeof w.runWhen=="function"&&w.runWhen(t)===!1)return;l=l&&w.synchronous;let y=t.transitional||$e;y&&y.legacyInterceptorReqResOrdering?a.unshift(w.fulfilled,w.rejected):a.push(w.fulfilled,w.rejected)});let c=[];this.interceptors.response.forEach(function(w){c.push(w.fulfilled,w.rejected)});let u,f=0,h;if(!l){let p=[qt.bind(this),void 0];for(p.unshift(...a),p.push(...c),h=p.length,u=Promise.resolve(t);f<h;)u=u.then(p[f++],p[f++]);return u}h=a.length;let m=t;for(;f<h;){let p=a[f++],w=a[f++];try{m=p(m)}catch(y){w.call(this,y);break}}try{u=qt.call(this,m)}catch(p){return Promise.reject(p)}for(f=0,h=c.length;f<h;)u=u.then(c[f++],c[f++]);return u}getUri(e){e=ee(this.defaults,e);let t=gt(e.baseURL,e.url,e.allowAbsoluteUrls);return ut(t,e.params,e.paramsSerializer)}};d.forEach(["delete","get","head","options"],function(e){qe.prototype[e]=function(t,n){return this.request(ee(n||{},{method:e,url:t,data:(n||{}).data}))}});d.forEach(["post","put","patch"],function(e){function t(n){return function(s,i,a){return this.request(ee(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}qe.prototype[e]=t(),qe.prototype[e+"Form"]=t(!0)});var yt=qe;var Xr=class r{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});let n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s,i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},e(function(s,i,a){n.reason||(n.reason=new se(s,i,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new r(function(o){e=o}),cancel:e}}},ns=Xr;function Yr(r){return function(t){return r.apply(null,t)}}function Zr(r){return d.isObject(r)&&r.isAxiosError===!0}var Qr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Qr).forEach(([r,e])=>{Qr[e]=r});var os=Qr;function ss(r){let e=new yt(r),t=it(yt.prototype.request,e);return d.extend(t,yt.prototype,e,{allOwnKeys:!0}),d.extend(t,e,null,{allOwnKeys:!0}),t.create=function(o){return ss(ee(r,o))},t}var D=ss(Ke);D.Axios=yt;D.CanceledError=se;D.CancelToken=ns;D.isCancel=pt;D.VERSION=zt;D.toFormData=Se;D.AxiosError=R;D.Cancel=D.CanceledError;D.all=function(e){return Promise.all(e)};D.spread=Yr;D.isAxiosError=Zr;D.mergeConfig=ee;D.AxiosHeaders=L;D.formToJSON=r=>Ft(d.isHTMLForm(r)?new FormData(r):r);D.getAdapter=jt.getAdapter;D.HttpStatusCode=os;D.default=D;var ze=D;var{Axios:hp,AxiosError:gp,CanceledError:mp,isCancel:yp,CancelToken:wp,VERSION:Ep,all:Sp,Cancel:bp,isAxiosError:Tp,spread:Rp,toFormData:Ip,AxiosHeaders:Ap,HttpStatusCode:xp,formToJSON:_p,getAdapter:vp,mergeConfig:Op}=ze;function is(){return r=>r}var Z=class{constructor(){E(this,"isHandlerEnabled",!0);E(this,"attachToken",()=>Promise.resolve());E(this,"requestStartCallback",()=>null);E(this,"requestSuccessCallback",()=>null);E(this,"requestErrorCallback",()=>null);E(this,"requestFinishCallback",()=>null);this.init=this.init.bind(this),this.enableHandler=this.enableHandler.bind(this),this.disableHandler=this.disableHandler.bind(this),this.disableHandlerWithTimeout=this.disableHandlerWithTimeout.bind(this),this.setHttpRequestErrorCallback=this.setHttpRequestErrorCallback.bind(this),this.setHttpRequestFinishCallback=this.setHttpRequestFinishCallback.bind(this),this.setHttpRequestStartCallback=this.setHttpRequestStartCallback.bind(this),this.setHttpRequestSuccessCallback=this.setHttpRequestSuccessCallback.bind(this)}static getInstance(e=0){if(this.instances.has(e))return this.instances.get(e);let t=ze.create({withCredentials:!0}),n=new Z;return this.clientInstances.set(e,n),t.interceptors.request.use(async o=>await n.requestHandler(o)),t.interceptors.response.use(o=>n.successHandler(o),o=>n.errorHandler(o)),t.all=ze.all,t.spread=ze.spread,t.init=n.init,t.enableHandler=n.enableHandler,t.disableHandler=n.disableHandler,t.disableHandlerWithTimeout=n.disableHandlerWithTimeout,t.setHttpRequestStartCallback=n.setHttpRequestStartCallback,t.setHttpRequestSuccessCallback=n.setHttpRequestSuccessCallback,t.setHttpRequestErrorCallback=n.setHttpRequestErrorCallback,t.setHttpRequestFinishCallback=n.setHttpRequestFinishCallback,this.instances.set(e,t),t}static destroyInstance(e=0){let t=this.instances.get(e);t&&(t.interceptors.request.clear(),t.interceptors.response.clear()),this.instances.delete(e),this.clientInstances.delete(e)}async requestHandler(e){if(await this.attachToken(e),e?.shouldEncodeToFormData){let t=e?.data,n=new FormData;Object.keys(t).forEach(o=>{n.append(o,t[o])}),e.data=n}return e.startTimeInMs=new Date().getTime(),this.isHandlerEnabled&&this.requestStartCallback&&typeof this.requestStartCallback=="function"&&this.requestStartCallback(e),e}errorHandler(e){throw this.isHandlerEnabled&&(this.requestErrorCallback&&typeof this.requestErrorCallback=="function"&&this.requestErrorCallback(e),this.requestFinishCallback&&typeof this.requestFinishCallback=="function"&&this.requestFinishCallback()),e}successHandler(e){return this.isHandlerEnabled&&(this.requestSuccessCallback&&typeof this.requestSuccessCallback=="function"&&this.requestSuccessCallback(e),this.requestFinishCallback&&typeof this.requestFinishCallback=="function"&&this.requestFinishCallback()),e}async init(e=!0,t){this.isHandlerEnabled=e,this.attachToken=t}enableHandler(){this.isHandlerEnabled=!0}disableHandler(){this.isHandlerEnabled=!1}disableHandlerWithTimeout(e=Z.DEFAULT_HANDLER_DISABLE_TIMEOUT){this.isHandlerEnabled=!1,setTimeout(()=>{this.isHandlerEnabled=!0},e)}setHttpRequestStartCallback(e){this.requestStartCallback=e}setHttpRequestSuccessCallback(e){this.requestSuccessCallback=e}setHttpRequestErrorCallback(e){this.requestErrorCallback=e}setHttpRequestFinishCallback(e){this.requestFinishCallback=e}};E(Z,"instances",new Map),E(Z,"clientInstances",new Map),E(Z,"DEFAULT_HANDLER_DISABLE_TIMEOUT",1e3),Z=Tn([is()],Z);var Vt=class{constructor(){E(this,"_data");this._data=new Map}async setData(e,t){this._data.set(e,t)}async getData(e){return this._data?.get(e)??"{}"}async removeData(e){this._data.delete(e)}};var js=tt(Ct(),1);var wn=tt(us(),1),qs=tt(ds(),1);var Ve=new TextEncoder,de=new TextDecoder,nh=2**32;function ps(...r){let e=r.reduce((o,{length:s})=>o+s,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function hs(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function be(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof r=="string"?r:de.decode(r),{alphabet:"base64url"});let e=r;e instanceof Uint8Array&&(e=de.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\\s/g,"");try{return hs(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}var V=class extends Error{constructor(t,n){super(t,n);E(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};E(V,"code","ERR_JOSE_GENERIC");var J=class extends V{constructor(t,n,o="unspecified",s="unspecified"){super(t,{cause:{claim:o,reason:s,payload:n}});E(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");E(this,"claim");E(this,"reason");E(this,"payload");this.claim=o,this.reason=s,this.payload=n}};E(J,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");var Ge=class extends V{constructor(t,n,o="unspecified",s="unspecified"){super(t,{cause:{claim:o,reason:s,payload:n}});E(this,"code","ERR_JWT_EXPIRED");E(this,"claim");E(this,"reason");E(this,"payload");this.claim=o,this.reason=s,this.payload=n}};E(Ge,"code","ERR_JWT_EXPIRED");var wt=class extends V{constructor(){super(...arguments);E(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}};E(wt,"code","ERR_JOSE_ALG_NOT_ALLOWED");var $=class extends V{constructor(){super(...arguments);E(this,"code","ERR_JOSE_NOT_SUPPORTED")}};E($,"code","ERR_JOSE_NOT_SUPPORTED");var k=class extends V{constructor(){super(...arguments);E(this,"code","ERR_JWS_INVALID")}};E(k,"code","ERR_JWS_INVALID");var _e=class extends V{constructor(){super(...arguments);E(this,"code","ERR_JWT_INVALID")}};E(_e,"code","ERR_JWT_INVALID");var Xe=class extends V{constructor(){super(...arguments);E(this,"code","ERR_JWKS_INVALID")}};E(Xe,"code","ERR_JWKS_INVALID");var Et=class extends V{constructor(t="no applicable key found in the JSON Web Key Set",n){super(t,n);E(this,"code","ERR_JWKS_NO_MATCHING_KEY")}};E(Et,"code","ERR_JWKS_NO_MATCHING_KEY");var gs,ms,St=class extends(ms=V,gs=Symbol.asyncIterator,ms){constructor(t="multiple matching keys found in the JSON Web Key Set",n){super(t,n);E(this,gs);E(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}};E(St,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var bt=class extends V{constructor(t="signature verification failed",n){super(t,n);E(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}};E(bt,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function pe(r,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${r}`)}function Tt(r,e){return r.name===e}function on(r){return parseInt(r.name.slice(4),10)}function Dc(r){switch(r){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Mc(r,e){if(e&&!r.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function ys(r,e,t){switch(e){case"HS256":case"HS384":case"HS512":{if(!Tt(r.algorithm,"HMAC"))throw pe("HMAC");let n=parseInt(e.slice(2),10);if(on(r.algorithm.hash)!==n)throw pe(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!Tt(r.algorithm,"RSASSA-PKCS1-v1_5"))throw pe("RSASSA-PKCS1-v1_5");let n=parseInt(e.slice(2),10);if(on(r.algorithm.hash)!==n)throw pe(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!Tt(r.algorithm,"RSA-PSS"))throw pe("RSA-PSS");let n=parseInt(e.slice(2),10);if(on(r.algorithm.hash)!==n)throw pe(`SHA-${n}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":{if(!Tt(r.algorithm,"Ed25519"))throw pe("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!Tt(r.algorithm,"ECDSA"))throw pe("ECDSA");let n=Dc(e);if(r.algorithm.namedCurve!==n)throw pe(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Mc(r,t)}function ws(r,e,...t){if(t=t.filter(Boolean),t.length>2){let n=t.pop();r+=`one of type ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of type ${t[0]} or ${t[1]}.`:r+=`of type ${t[0]}.`;return e==null?r+=` Received ${e}`:typeof e=="function"&&e.name?r+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(r+=` Received an instance of ${e.constructor.name}`),r}var Es=(r,...e)=>ws("Key must be ",r,...e);function sn(r,e,...t){return ws(`Key for the ${r} algorithm must be `,e,...t)}function an(r){return r?.[Symbol.toStringTag]==="CryptoKey"}function cn(r){return r?.[Symbol.toStringTag]==="KeyObject"}var ln=r=>an(r)||cn(r);var Ss=(...r)=>{let e=r.filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(let n of e){let o=Object.keys(n);if(!t||t.size===0){t=new Set(o);continue}for(let s of o){if(t.has(s))return!1;t.add(s)}}return!0};function Hc(r){return typeof r=="object"&&r!==null}var te=r=>{if(!Hc(r)||Object.prototype.toString.call(r)!=="[object Object]")return!1;if(Object.getPrototypeOf(r)===null)return!0;let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e};var bs=(r,e)=>{if(r.startsWith("RS")||r.startsWith("PS")){let{modulusLength:t}=e.algorithm;if(typeof t!="number"||t<2048)throw new TypeError(`${r} requires key modulusLength to be 2048 bits or larger`)}};function Lc(r){let e,t;switch(r.kty){case"RSA":{switch(r.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(r.alg.slice(-3),10)||1}`},t=r.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new $(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"EC":{switch(r.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},t=r.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},t=r.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new $(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"OKP":{switch(r.alg){case"Ed25519":case"EdDSA":e={name:"Ed25519"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:r.crv},t=r.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:e,keyUsages:t}}var Yt=async r=>{if(!r.alg)throw new TypeError(\'"alg" argument is required when "jwk.alg" is not present\');let{algorithm:e,keyUsages:t}=Lc(r),n={...r};return delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,e,r.ext??!r.d,r.key_ops??t)};async function Ts(r,e,t){if(!te(r))throw new TypeError("JWK must be an object");let n;switch(e??(e=r.alg),n??(n=t?.extractable??r.ext),r.kty){case"oct":if(typeof r.k!="string"||!r.k)throw new TypeError(\'missing "k" (Key Value) Parameter value\');return be(r.k);case"RSA":if("oth"in r&&r.oth!==void 0)throw new $(\'RSA JWK "oth" (Other Primes Info) Parameter value is not supported\');case"EC":case"OKP":return Yt({...r,alg:e,ext:n});default:throw new $(\'Unsupported "kty" (Key Type) Parameter value\')}}var Rs=(r,e,t,n,o)=>{if(o.crit!==void 0&&n?.crit===void 0)throw new r(\'"crit" (Critical) Header Parameter MUST be integrity protected\');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(i=>typeof i!="string"||i.length===0))throw new r(\'"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present\');let s;t!==void 0?s=new Map([...Object.entries(t),...e.entries()]):s=e;for(let i of n.crit){if(!s.has(i))throw new $(`Extension Header Parameter "${i}" is not recognized`);if(o[i]===void 0)throw new r(`Extension Header Parameter "${i}" is missing`);if(s.get(i)&&n[i]===void 0)throw new r(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(n.crit)};var Is=(r,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new TypeError(`"${r}" option must be an array of strings`);if(e)return new Set(e)};function Rt(r){return te(r)&&typeof r.kty=="string"}function As(r){return r.kty!=="oct"&&typeof r.d=="string"}function xs(r){return r.kty!=="oct"&&typeof r.d>"u"}function _s(r){return r.kty==="oct"&&typeof r.k=="string"}var Ye,vs=async(r,e,t,n=!1)=>{Ye||(Ye=new WeakMap);let o=Ye.get(r);if(o?.[t])return o[t];let s=await Yt({...e,alg:t});return n&&Object.freeze(r),o?o[t]=s:Ye.set(r,{[t]:s}),s},Fc=(r,e)=>{Ye||(Ye=new WeakMap);let t=Ye.get(r);if(t?.[e])return t[e];let n=r.type==="public",o=!!n,s;if(r.asymmetricKeyType==="x25519"){switch(e){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}s=r.toCryptoKey(r.asymmetricKeyType,o,n?[]:["deriveBits"])}if(r.asymmetricKeyType==="ed25519"){if(e!=="EdDSA"&&e!=="Ed25519")throw new TypeError("given KeyObject instance cannot be used for this algorithm");s=r.toCryptoKey(r.asymmetricKeyType,o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="rsa"){let i;switch(e){case"RSA-OAEP":i="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":i="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":i="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":i="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(e.startsWith("RSA-OAEP"))return r.toCryptoKey({name:"RSA-OAEP",hash:i},o,n?["encrypt"]:["decrypt"]);s=r.toCryptoKey({name:e.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:i},o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="ec"){let a=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(r.asymmetricKeyDetails?.namedCurve);if(!a)throw new TypeError("given KeyObject instance cannot be used for this algorithm");e==="ES256"&&a==="P-256"&&(s=r.toCryptoKey({name:"ECDSA",namedCurve:a},o,[n?"verify":"sign"])),e==="ES384"&&a==="P-384"&&(s=r.toCryptoKey({name:"ECDSA",namedCurve:a},o,[n?"verify":"sign"])),e==="ES512"&&a==="P-521"&&(s=r.toCryptoKey({name:"ECDSA",namedCurve:a},o,[n?"verify":"sign"])),e.startsWith("ECDH-ES")&&(s=r.toCryptoKey({name:"ECDH",namedCurve:a},o,n?[]:["deriveBits"]))}if(!s)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return t?t[e]=s:Ye.set(r,{[e]:s}),s},Os=async(r,e)=>{if(r instanceof Uint8Array||an(r))return r;if(cn(r)){if(r.type==="secret")return r.export();if("toCryptoKey"in r&&typeof r.toCryptoKey=="function")try{return Fc(r,e)}catch(n){if(n instanceof TypeError)throw n}let t=r.export({format:"jwk"});return vs(r,t,e)}if(Rt(r))return r.k?be(r.k):vs(r,r,e,!0);throw new Error("unreachable")};var Ze=r=>r?.[Symbol.toStringTag],un=(r,e,t)=>{if(e.use!==void 0){let n;switch(t){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(e.use!==n)throw new TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(e.alg!==void 0&&e.alg!==r)throw new TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);if(Array.isArray(e.key_ops)){let n;switch(!0){case(t==="sign"||t==="verify"):case r==="dir":case r.includes("CBC-HS"):n=t;break;case r.startsWith("PBES2"):n="deriveBits";break;case/^A\\d{3}(?:GCM)?(?:KW)?$/.test(r):!r.includes("GCM")&&r.endsWith("KW")?n=t==="encrypt"?"wrapKey":"unwrapKey":n=t;break;case(t==="encrypt"&&r.startsWith("RSA")):n="wrapKey";break;case t==="decrypt":n=r.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&e.key_ops?.includes?.(n)===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},$c=(r,e,t)=>{if(!(e instanceof Uint8Array)){if(Rt(e)){if(_s(e)&&un(r,e,t))return;throw new TypeError(\'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present\')}if(!ln(e))throw new TypeError(sn(r,e,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Ze(e)} instances for symmetric algorithms must be of type "secret"`)}},Kc=(r,e,t)=>{if(Rt(e))switch(t){case"decrypt":case"sign":if(As(e)&&un(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(xs(e)&&un(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!ln(e))throw new TypeError(sn(r,e,"CryptoKey","KeyObject","JSON Web Key"));if(e.type==="secret")throw new TypeError(`${Ze(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.type==="public")switch(t){case"sign":throw new TypeError(`${Ze(e)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Ze(e)} instances for asymmetric algorithm decryption must be of type "private"`);default:break}if(e.type==="private")switch(t){case"verify":throw new TypeError(`${Ze(e)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Ze(e)} instances for asymmetric algorithm encryption must be of type "public"`);default:break}},Cs=(r,e,t)=>{r.startsWith("HS")||r==="dir"||r.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(r)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(r)?$c(r,e,t):Kc(r,e,t)};var Ps=(r,e)=>{let t=`SHA-${r.slice(-3)}`;switch(r){case"HS256":case"HS384":case"HS512":return{hash:t,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:t,name:"RSA-PSS",saltLength:parseInt(r.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:t,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:t,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};default:throw new $(`alg ${r} is not supported either by JOSE or your javascript runtime`)}};var Us=async(r,e,t)=>{if(e instanceof Uint8Array){if(!r.startsWith("HS"))throw new TypeError(Es(e,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",e,{hash:`SHA-${r.slice(-3)}`,name:"HMAC"},!1,[t])}return ys(e,r,t),e};var ks=async(r,e,t,n)=>{let o=await Us(r,e,"verify");bs(r,o);let s=Ps(r,o.algorithm);try{return await crypto.subtle.verify(s,o,t,n)}catch{return!1}};async function Ns(r,e,t){if(!te(r))throw new k("Flattened JWS must be an object");if(r.protected===void 0&&r.header===void 0)throw new k(\'Flattened JWS must have either of the "protected" or "header" members\');if(r.protected!==void 0&&typeof r.protected!="string")throw new k("JWS Protected Header incorrect type");if(r.payload===void 0)throw new k("JWS Payload missing");if(typeof r.signature!="string")throw new k("JWS Signature missing or incorrect type");if(r.header!==void 0&&!te(r.header))throw new k("JWS Unprotected Header incorrect type");let n={};if(r.protected)try{let y=be(r.protected);n=JSON.parse(de.decode(y))}catch{throw new k("JWS Protected Header is invalid")}if(!Ss(n,r.header))throw new k("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...n,...r.header},s=Rs(k,new Map([["b64",!0]]),t?.crit,n,o),i=!0;if(s.has("b64")&&(i=n.b64,typeof i!="boolean"))throw new k(\'The "b64" (base64url-encode payload) Header Parameter must be a boolean\');let{alg:a}=o;if(typeof a!="string"||!a)throw new k(\'JWS "alg" (Algorithm) Header Parameter missing or invalid\');let l=t&&Is("algorithms",t.algorithms);if(l&&!l.has(a))throw new wt(\'"alg" (Algorithm) Header Parameter value not allowed\');if(i){if(typeof r.payload!="string")throw new k("JWS Payload must be a string")}else if(typeof r.payload!="string"&&!(r.payload instanceof Uint8Array))throw new k("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof e=="function"&&(e=await e(n,r),c=!0),Cs(a,e,"verify");let u=ps(Ve.encode(r.protected??""),Ve.encode("."),typeof r.payload=="string"?Ve.encode(r.payload):r.payload),f;try{f=be(r.signature)}catch{throw new k("Failed to base64url decode the signature")}let h=await Os(e,a);if(!await ks(a,h,f,u))throw new bt;let p;if(i)try{p=be(r.payload)}catch{throw new k("Failed to base64url decode the payload")}else typeof r.payload=="string"?p=Ve.encode(r.payload):p=r.payload;let w={payload:p};return r.protected!==void 0&&(w.protectedHeader=n),r.header!==void 0&&(w.unprotectedHeader=r.header),c?{...w,key:h}:w}async function Ds(r,e,t){if(r instanceof Uint8Array&&(r=de.decode(r)),typeof r!="string")throw new k("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:s,length:i}=r.split(".");if(i!==3)throw new k("Invalid Compact JWS");let a=await Ns({payload:o,protected:n,signature:s},e,t),l={payload:a.payload,protectedHeader:a.protectedHeader};return typeof e=="function"?{...l,key:a.key}:l}var Ms=r=>Math.floor(r.getTime()/1e3);var Wc=/^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,fn=r=>{let e=Wc.exec(r);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let t=parseFloat(e[2]),n=e[3].toLowerCase(),o;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(t);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(t*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(t*3600);break;case"day":case"days":case"d":o=Math.round(t*86400);break;case"week":case"weeks":case"w":o=Math.round(t*604800);break;default:o=Math.round(t*31557600);break}return e[1]==="-"||e[4]==="ago"?-o:o};var Hs=r=>r.includes("/")?r.toLowerCase():`application/${r.toLowerCase()}`,jc=(r,e)=>typeof r=="string"?e.includes(r):Array.isArray(r)?e.some(Set.prototype.has.bind(new Set(r))):!1;function Ls(r,e,t={}){let n;try{n=JSON.parse(de.decode(e))}catch{}if(!te(n))throw new _e("JWT Claims Set must be a top-level JSON object");let{typ:o}=t;if(o&&(typeof r.typ!="string"||Hs(r.typ)!==Hs(o)))throw new J(\'unexpected "typ" JWT header value\',n,"typ","check_failed");let{requiredClaims:s=[],issuer:i,subject:a,audience:l,maxTokenAge:c}=t,u=[...s];c!==void 0&&u.push("iat"),l!==void 0&&u.push("aud"),a!==void 0&&u.push("sub"),i!==void 0&&u.push("iss");for(let p of new Set(u.reverse()))if(!(p in n))throw new J(`missing required "${p}" claim`,n,p,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(n.iss))throw new J(\'unexpected "iss" claim value\',n,"iss","check_failed");if(a&&n.sub!==a)throw new J(\'unexpected "sub" claim value\',n,"sub","check_failed");if(l&&!jc(n.aud,typeof l=="string"?[l]:l))throw new J(\'unexpected "aud" claim value\',n,"aud","check_failed");let f;switch(typeof t.clockTolerance){case"string":f=fn(t.clockTolerance);break;case"number":f=t.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}let{currentDate:h}=t,m=Ms(h||new Date);if((n.iat!==void 0||c)&&typeof n.iat!="number")throw new J(\'"iat" claim must be a number\',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new J(\'"nbf" claim must be a number\',n,"nbf","invalid");if(n.nbf>m+f)throw new J(\'"nbf" claim timestamp check failed\',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new J(\'"exp" claim must be a number\',n,"exp","invalid");if(n.exp<=m-f)throw new Ge(\'"exp" claim timestamp check failed\',n,"exp","check_failed")}if(c){let p=m-n.iat,w=typeof c=="number"?c:fn(c);if(p-f>w)throw new Ge(\'"iat" claim timestamp check failed (too far in the past)\',n,"iat","check_failed");if(p<0-f)throw new J(\'"iat" claim timestamp check failed (it should be in the past)\',n,"iat","check_failed")}return n}async function dn(r,e,t){let n=await Ds(r,e,t);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new _e("JWTs MUST NOT use unencoded payload");let s={payload:Ls(n.protectedHeader,n.payload,t),protectedHeader:n.protectedHeader};return typeof e=="function"?{...s,key:n.key}:s}function qc(r){switch(typeof r=="string"&&r.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\')}}function zc(r){return r&&typeof r=="object"&&Array.isArray(r.keys)&&r.keys.every(Jc)}function Jc(r){return te(r)}var Qe,It,pn=class{constructor(e){xt(this,Qe);xt(this,It,new WeakMap);if(!zc(e))throw new Xe("JSON Web Key Set malformed");or(this,Qe,structuredClone(e))}jwks(){return Pe(this,Qe)}async getKey(e,t){let{alg:n,kid:o}={...e,...t?.header},s=qc(n),i=Pe(this,Qe).keys.filter(c=>{let u=s===c.kty;if(u&&typeof o=="string"&&(u=o===c.kid),u&&typeof c.alg=="string"&&(u=n===c.alg),u&&typeof c.use=="string"&&(u=c.use==="sig"),u&&Array.isArray(c.key_ops)&&(u=c.key_ops.includes("verify")),u)switch(n){case"ES256":u=c.crv==="P-256";break;case"ES384":u=c.crv==="P-384";break;case"ES512":u=c.crv==="P-521";break;case"Ed25519":case"EdDSA":u=c.crv==="Ed25519";break}return u}),{0:a,length:l}=i;if(l===0)throw new Et;if(l!==1){let c=new St,u=Pe(this,It);throw c[Symbol.asyncIterator]=async function*(){for(let f of i)try{yield await Bs(u,f,n)}catch{}},c}return Bs(Pe(this,It),a,n)}};Qe=new WeakMap,It=new WeakMap;async function Bs(r,e,t){let n=r.get(e)||r.set(e,{}).get(e);if(n[t]===void 0){let o=await Ts({...e,ext:!0},t);if(o instanceof Uint8Array||o.type!=="public")throw new Xe("JSON Web Key Set members must be public keys");n[t]=o}return n[t]}function hn(r){let e=new pn(r),t=async(n,o)=>e.getKey(n,o);return Object.defineProperties(t,{jwks:{value:()=>structuredClone(e.jwks()),enumerable:!1,configurable:!1,writable:!1}}),t}var zs=tt(Ws(),1),er=class{base64URLEncode(e){return wn.default.encode(e).replace(/\\+/g,"-").replace(/\\//g,"_").replace(/=/g,"")}base64URLDecode(e){return wn.default.decode(e).toString()}hashSha256(e){return js.Buffer.from((0,qs.default)(new TextEncoder().encode(e)))}generateRandomBytes(e){return(0,zs.default)(e)}verifyJwt(e,t,n,o,s,i,a,l){let c={algorithms:n,audience:[o],clockTolerance:a,subject:i};return(l??!0)&&(c.issuer=s),dn(e,hn({keys:[t]}),c).then(()=>Promise.resolve(!0)).catch(u=>Promise.reject(new I("SPA-CRYPTO-UTILS-VJ-IV01",u?.reason??JSON.stringify(u),`${u?.code} ${u?.claim}`)))}};var Js=async(r,e,t)=>{let n=new Vt,o=new er,s=new Ae;await s.initialize(e,n,o,r);let i=new kt(s),a=t(s,i),l=s.getStorageManager(),c=Z.getInstance(r),u=async x=>{await a.attachTokenToRequestConfig(x)};return c?.init&&await c.init(!0,u),{disableHttpHandler:()=>{a.disableHttpHandler(c)},enableHttpHandler:()=>{a.enableHttpHandler(c)},getAccessToken:()=>a.getAccessToken(),getSignInUrl:async x=>s.getSignInUrl(x).then(async W=>{let ge=new URL(W).searchParams.get(F.Params.STATE)??"",At=await s.getPKCECode(ge);return{authorizationURL:W,pkce:At}}).catch(W=>Promise.reject(W)),getUser:async()=>a.getUser(),getConfigData:async()=>l.getConfigData(),getCrypto:async()=>a.getCrypto(),getDecodedIDPIDToken:async()=>a.getDecodedIDPIDToken(),getDecodedIdToken:async x=>a.getDecodedIdToken(x),getIdToken:async()=>a.getIdToken(),getOpenIDProviderEndpoints:async()=>a.getOpenIDProviderEndpoints(),getSignOutUrl:async()=>await s.getSignOutUrl(),httpRequest:async x=>await a.httpRequest(c,x),httpRequestAll:async x=>await a.httpRequestAll(x,c),isSignedIn:()=>a.isSignedIn(),refreshAccessToken:async()=>{try{return await a.refreshAccessToken()}catch(x){return Promise.reject(x)}},requestAccessToken:async(x,W,Ce,ge)=>await a.requestAccessToken(x,W,void 0,Ce,ge),exchangeToken:async x=>await a.exchangeToken(x),revokeAccessToken:async()=>{let x=await i.getRefreshTimeoutTimer();return s.revokeAccessToken().then(()=>(i.clearRefreshTokenTimeout(x),Promise.resolve(!0))).catch(W=>Promise.reject(W))},setHttpRequestFinishCallback:x=>{c?.setHttpRequestFinishCallback&&c.setHttpRequestFinishCallback(x)},setHttpRequestStartCallback:x=>{c?.setHttpRequestStartCallback&&c.setHttpRequestStartCallback(x)},setHttpRequestSuccessCallback:x=>{c?.setHttpRequestSuccessCallback&&c.setHttpRequestSuccessCallback(x)},setSessionState:async x=>{await l.setSessionDataParameter(F.Params.SESSION_STATE,x)},signOut:async()=>(i.clearRefreshTokenTimeout(),await s.getSignOutUrl()),startAutoRefreshToken:async()=>{i.clearRefreshTokenTimeout(),i.refreshAccessTokenAutomatically(a)},reInitialize:async x=>{await s.reInitialize(x)}}};var Vs=r=>{let e=self,t;e.onmessage=async({data:i,ports:a})=>{let l=a[0];if(i.type!==wr&&!t){l.postMessage(b.generateFailureMessage(new I("SPA-CLIENT_WORKER-ONMSG-NF01","The web worker has not been initialized yet.","The initialize method needs to be called before the specified operation can be carried out.")));return}switch(i.type){case wr:try{let c=i.instanceId??0,u={...i.data};t=await Js(c,u,r),t.setHttpRequestFinishCallback(s),t.setHttpRequestStartCallback(n),t.setHttpRequestSuccessCallback(o),l.postMessage(b.generateSuccessMessage())}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case ho:t.getSignInUrl(i?.data).then(c=>{l.postMessage(b.generateSuccessMessage(c))}).catch(c=>{l.postMessage(b.generateFailureMessage(c))});break;case go:t.requestAccessToken(i?.data?.code,i?.data?.sessionState,i?.data?.pkce,i?.data?.state).then(c=>{l.postMessage(b.generateSuccessMessage(c))}).catch(c=>{l.postMessage(b.generateFailureMessage(c))});break;case eo:{let c=i.data,u=c?.data;if(i.data?.data?.formData===!0){let f=new FormData;for(let h in u)h!=="formData"&&f.append(h,u[h]);c.data=f}t.httpRequest(c).then(f=>{l.postMessage(b.generateSuccessMessage(f))}).catch(f=>{l.postMessage(b.generateFailureMessage(f))});break}case to:t.httpRequestAll(i.data).then(c=>{l.postMessage(b.generateSuccessMessage(c))}).catch(c=>{l.postMessage(b.generateFailureMessage(c))});break;case Qn:try{l.postMessage(b.generateSuccessMessage(await t.signOut()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case ro:t.exchangeToken(i.data).then(c=>{l.postMessage(b.generateSuccessMessage(c))}).catch(c=>{l.postMessage(b.generateFailureMessage(c))});break;case no:t.revokeAccessToken().then(c=>{l.postMessage(b.generateSuccessMessage(c))}).catch(c=>{l.postMessage(b.generateFailureMessage(c))});break;case ao:try{l.postMessage(b.generateSuccessMessage(await t.getOpenIDProviderEndpoints()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case co:try{l.postMessage(b.generateSuccessMessage(await t.getUser()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case lo:try{l.postMessage(b.generateSuccessMessage(await t.getDecodedIdToken()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case uo:try{l.postMessage(b.generateSuccessMessage(await t.getCrypto()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case Ro:try{l.postMessage(b.generateSuccessMessage(await t.getIdToken()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case fo:t.enableHttpHandler(),l.postMessage(b.generateSuccessMessage());break;case po:t.disableHttpHandler(),l.postMessage(b.generateSuccessMessage());break;case mo:try{l.postMessage(b.generateSuccessMessage(await t.isSignedIn()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case yo:try{l.postMessage(b.generateSuccessMessage(await t.getSignOutUrl()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case wo:try{l.postMessage(b.generateSuccessMessage(await t.refreshAccessToken()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case bo:try{l.postMessage(b.generateSuccessMessage(t.startAutoRefreshToken()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case So:try{l.postMessage(b.generateSuccessMessage(await t.setSessionState(i?.data)))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case To:try{l.postMessage(b.generateSuccessMessage(await t.reInitialize(i?.data)))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;case Io:try{l.postMessage(b.generateSuccessMessage(await t.getConfigData()))}catch(c){l.postMessage(b.generateFailureMessage(c))}break;default:l?.postMessage(b.generateFailureMessage(new I("SPA-CLIENT_WORKER-ONMSG-IV02","The message type is invalid.",`The message type provided, ${i.type}, is invalid.`)))}};let n=()=>{e.postMessage({type:oo})},o=i=>{e.postMessage({data:JSON.stringify(i??""),type:so})},s=()=>{e.postMessage({type:io})}};typeof self<"u"&&!self.Buffer&&(self.Buffer=Gs.Buffer);typeof self<"u"&&(self.global||(self.global=self));Vs((r,e)=>new Ut(r,e));var cm={};})();\n/*! Bundled license information:\n\nieee754/index.js:\n (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n\nbuffer/index.js:\n (*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n *)\n\nsafe-buffer/index.js:\n (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n*/\n');
1956
+ return inlineWorker('(()=>{var Wn=Object.create;var rt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var Jt=r=>{throw TypeError(r)};var Gn=(r,e,t)=>e in r?rt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var q=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Vn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zn(e))!Jn.call(r,o)&&o!==t&&rt(r,o,{get:()=>e[o],enumerable:!(n=jn(e,o))||n.enumerable});return r};var _e=(r,e,t)=>(t=r!=null?Wn(qn(r)):{},Vn(e||!r||!r.__esModule?rt(t,"default",{value:r,enumerable:!0}):t,r));var y=(r,e,t)=>Gn(r,typeof e!="symbol"?e+"":e,t),Gt=(r,e,t)=>e.has(r)||Jt("Cannot "+t);var ue=(r,e,t)=>(Gt(r,e,"read from private field"),t?t.call(r):e.get(r)),He=(r,e,t)=>e.has(r)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),nt=(r,e,t,n)=>(Gt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Yt=q(Be=>{"use strict";Be.byteLength=Yn;Be.toByteArray=Qn;Be.fromByteArray=ro;var W=[],B=[],Xn=typeof Uint8Array<"u"?Uint8Array:Array,ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(re=0,Vt=ot.length;re<Vt;++re)W[re]=ot[re],B[ot.charCodeAt(re)]=re;var re,Vt;B[45]=62;B[95]=63;function Xt(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Yn(r){var e=Xt(r),t=e[0],n=e[1];return(t+n)*3/4-n}function Zn(r,e,t){return(e+t)*3/4-t}function Qn(r){var e,t=Xt(r),n=t[0],o=t[1],a=new Xn(Zn(r,n,o)),i=0,s=o>0?n-4:n,l;for(l=0;l<s;l+=4)e=B[r.charCodeAt(l)]<<18|B[r.charCodeAt(l+1)]<<12|B[r.charCodeAt(l+2)]<<6|B[r.charCodeAt(l+3)],a[i++]=e>>16&255,a[i++]=e>>8&255,a[i++]=e&255;return o===2&&(e=B[r.charCodeAt(l)]<<2|B[r.charCodeAt(l+1)]>>4,a[i++]=e&255),o===1&&(e=B[r.charCodeAt(l)]<<10|B[r.charCodeAt(l+1)]<<4|B[r.charCodeAt(l+2)]>>2,a[i++]=e>>8&255,a[i++]=e&255),a}function eo(r){return W[r>>18&63]+W[r>>12&63]+W[r>>6&63]+W[r&63]}function to(r,e,t){for(var n,o=[],a=e;a<t;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255),o.push(eo(n));return o.join("")}function ro(r){for(var e,t=r.length,n=t%3,o=[],a=16383,i=0,s=t-n;i<s;i+=a)o.push(to(r,i,i+a>s?s:i+a));return n===1?(e=r[t-1],o.push(W[e>>2]+W[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],o.push(W[e>>10]+W[e>>4&63]+W[e<<2&63]+"=")),o.join("")}});var Zt=q(at=>{at.read=function(r,e,t,n,o){var a,i,s=o*8-n-1,l=(1<<s)-1,c=l>>1,d=-7,u=t?o-1:0,p=t?-1:1,h=r[e+u];for(u+=p,a=h&(1<<-d)-1,h>>=-d,d+=s;d>0;a=a*256+r[e+u],u+=p,d-=8);for(i=a&(1<<-d)-1,a>>=-d,d+=n;d>0;i=i*256+r[e+u],u+=p,d-=8);if(a===0)a=1-c;else{if(a===l)return i?NaN:(h?-1:1)*(1/0);i=i+Math.pow(2,n),a=a-c}return(h?-1:1)*i*Math.pow(2,a-n)};at.write=function(r,e,t,n,o,a){var i,s,l,c=a*8-o-1,d=(1<<c)-1,u=d>>1,p=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,i=d):(i=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-i))<1&&(i--,l*=2),i+u>=1?e+=p/l:e+=p*Math.pow(2,1-u),e*l>=2&&(i++,l/=2),i+u>=d?(s=0,i=d):i+u>=1?(s=(e*l-1)*Math.pow(2,o),i=i+u):(s=e*Math.pow(2,u-1)*Math.pow(2,o),i=0));o>=8;r[t+h]=s&255,h+=g,s/=256,o-=8);for(i=i<<o|s,c+=o;c>0;r[t+h]=i&255,h+=g,i/=256,c-=8);r[t+h-g]|=S*128}});var Ke=q(he=>{"use strict";var it=Yt(),fe=Zt(),Qt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;he.Buffer=f;he.SlowBuffer=co;he.INSPECT_MAX_BYTES=50;var Le=2147483647;he.kMaxLength=Le;f.TYPED_ARRAY_SUPPORT=no();!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function no(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function J(r){if(r>Le)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\');let e=new Uint8Array(r);return Object.setPrototypeOf(e,f.prototype),e}function f(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError(\'The "string" argument must be of type string. Received type number\');return ut(r)}return nr(r,e,t)}f.poolSize=8192;function nr(r,e,t){if(typeof r=="string")return ao(r,e);if(ArrayBuffer.isView(r))return io(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(j(r,ArrayBuffer)||r&&j(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(j(r,SharedArrayBuffer)||r&&j(r.buffer,SharedArrayBuffer)))return ct(r,e,t);if(typeof r=="number")throw new TypeError(\'The "value" argument must not be of type number. Received type number\');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return f.from(n,e,t);let o=so(r);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return f.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}f.from=function(r,e,t){return nr(r,e,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function or(r){if(typeof r!="number")throw new TypeError(\'"size" argument must be of type number\');if(r<0)throw new RangeError(\'The value "\'+r+\'" is invalid for option "size"\')}function oo(r,e,t){return or(r),r<=0?J(r):e!==void 0?typeof t=="string"?J(r).fill(e,t):J(r).fill(e):J(r)}f.alloc=function(r,e,t){return oo(r,e,t)};function ut(r){return or(r),J(r<0?0:dt(r)|0)}f.allocUnsafe=function(r){return ut(r)};f.allocUnsafeSlow=function(r){return ut(r)};function ao(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ar(r,e)|0,n=J(t),o=n.write(r,e);return o!==t&&(n=n.slice(0,o)),n}function st(r){let e=r.length<0?0:dt(r.length)|0,t=J(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function io(r){if(j(r,Uint8Array)){let e=new Uint8Array(r);return ct(e.buffer,e.byteOffset,e.byteLength)}return st(r)}function ct(r,e,t){if(e<0||r.byteLength<e)throw new RangeError(\'"offset" is outside of buffer bounds\');if(r.byteLength<e+(t||0))throw new RangeError(\'"length" is outside of buffer bounds\');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,f.prototype),n}function so(r){if(f.isBuffer(r)){let e=dt(r.length)|0,t=J(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||pt(r.length)?J(0):st(r);if(r.type==="Buffer"&&Array.isArray(r.data))return st(r.data)}function dt(r){if(r>=Le)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Le.toString(16)+" bytes");return r|0}function co(r){return+r!=r&&(r=0),f.alloc(+r)}f.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==f.prototype};f.compare=function(e,t){if(j(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),j(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(e)||!f.isBuffer(t))throw new TypeError(\'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array\');if(e===t)return 0;let n=e.length,o=t.length;for(let a=0,i=Math.min(n,o);a<i;++a)if(e[a]!==t[a]){n=e[a],o=t[a];break}return n<o?-1:o<n?1:0};f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};f.concat=function(e,t){if(!Array.isArray(e))throw new TypeError(\'"list" argument must be an Array of Buffers\');if(e.length===0)return f.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=f.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){let i=e[n];if(j(i,Uint8Array))a+i.length>o.length?(f.isBuffer(i)||(i=f.from(i)),i.copy(o,a)):Uint8Array.prototype.set.call(o,i,a);else if(f.isBuffer(i))i.copy(o,a);else throw new TypeError(\'"list" argument must be an Array of Buffers\');a+=i.length}return o};function ar(r,e){if(f.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||j(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError(\'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type \'+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return lt(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return hr(r).length;default:if(o)return n?-1:lt(r).length;e=(""+e).toLowerCase(),o=!0}}f.byteLength=ar;function lo(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Eo(this,e,t);case"utf8":case"utf-8":return sr(this,e,t);case"ascii":return wo(this,e,t);case"latin1":case"binary":return So(this,e,t);case"base64":return mo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return To(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}f.prototype._isBuffer=!0;function ne(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}f.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)ne(this,t,t+1);return this};f.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)ne(this,t,t+3),ne(this,t+1,t+2);return this};f.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)ne(this,t,t+7),ne(this,t+1,t+6),ne(this,t+2,t+5),ne(this,t+3,t+4);return this};f.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?sr(this,0,e):lo.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:f.compare(this,e)===0};f.prototype.inspect=function(){let e="",t=he.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Qt&&(f.prototype[Qt]=f.prototype.inspect);f.prototype.compare=function(e,t,n,o,a){if(j(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(e))throw new TypeError(\'The "target" argument must be one of type Buffer or Uint8Array. Received type \'+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),a===void 0&&(a=this.length),t<0||n>e.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&t>=n)return 0;if(o>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,a>>>=0,this===e)return 0;let i=a-o,s=n-t,l=Math.min(i,s),c=this.slice(o,a),d=e.slice(t,n);for(let u=0;u<l;++u)if(c[u]!==d[u]){i=c[u],s=d[u];break}return i<s?-1:s<i?1:0};function ir(r,e,t,n,o){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,pt(t)&&(t=o?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(o)return-1;t=r.length-1}else if(t<0)if(o)t=0;else return-1;if(typeof e=="string"&&(e=f.from(e,n)),f.isBuffer(e))return e.length===0?-1:er(r,e,t,n,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):er(r,[e],t,n,o);throw new TypeError("val must be string, number or Buffer")}function er(r,e,t,n,o){let a=1,i=r.length,s=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;a=2,i/=2,s/=2,t/=2}function l(d,u){return a===1?d[u]:d.readUInt16BE(u*a)}let c;if(o){let d=-1;for(c=t;c<i;c++)if(l(r,c)===l(e,d===-1?0:c-d)){if(d===-1&&(d=c),c-d+1===s)return d*a}else d!==-1&&(c-=c-d),d=-1}else for(t+s>i&&(t=i-s),c=t;c>=0;c--){let d=!0;for(let u=0;u<s;u++)if(l(r,c+u)!==l(e,u)){d=!1;break}if(d)return c}return-1}f.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};f.prototype.indexOf=function(e,t,n){return ir(this,e,t,n,!0)};f.prototype.lastIndexOf=function(e,t,n){return ir(this,e,t,n,!1)};function uo(r,e,t,n){t=Number(t)||0;let o=r.length-t;n?(n=Number(n),n>o&&(n=o)):n=o;let a=e.length;n>a/2&&(n=a/2);let i;for(i=0;i<n;++i){let s=parseInt(e.substr(i*2,2),16);if(pt(s))return i;r[t+i]=s}return i}function fo(r,e,t,n){return Fe(lt(e,r.length-t),r,t,n)}function po(r,e,t,n){return Fe(vo(e),r,t,n)}function ho(r,e,t,n){return Fe(hr(e),r,t,n)}function go(r,e,t,n){return Fe(_o(e,r.length-t),r,t,n)}f.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-t;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return uo(this,e,t,n);case"utf8":case"utf-8":return fo(this,e,t,n);case"ascii":case"latin1":case"binary":return po(this,e,t,n);case"base64":return ho(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return go(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function mo(r,e,t){return e===0&&t===r.length?it.fromByteArray(r):it.fromByteArray(r.slice(e,t))}function sr(r,e,t){t=Math.min(r.length,t);let n=[],o=e;for(;o<t;){let a=r[o],i=null,s=a>239?4:a>223?3:a>191?2:1;if(o+s<=t){let l,c,d,u;switch(s){case 1:a<128&&(i=a);break;case 2:l=r[o+1],(l&192)===128&&(u=(a&31)<<6|l&63,u>127&&(i=u));break;case 3:l=r[o+1],c=r[o+2],(l&192)===128&&(c&192)===128&&(u=(a&15)<<12|(l&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:l=r[o+1],c=r[o+2],d=r[o+3],(l&192)===128&&(c&192)===128&&(d&192)===128&&(u=(a&15)<<18|(l&63)<<12|(c&63)<<6|d&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),o+=s}return yo(n)}var tr=4096;function yo(r){let e=r.length;if(e<=tr)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=tr));return t}function wo(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]&127);return n}function So(r,e,t){let n="";t=Math.min(r.length,t);for(let o=e;o<t;++o)n+=String.fromCharCode(r[o]);return n}function Eo(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let o="";for(let a=e;a<t;++a)o+=Ao[r[a]];return o}function To(r,e,t){let n=r.slice(e,t),o="";for(let a=0;a<n.length-1;a+=2)o+=String.fromCharCode(n[a]+n[a+1]*256);return o}f.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,f.prototype),o};function U(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],a=1,i=0;for(;++i<t&&(a*=256);)o+=this[e+i]*a;return o};f.prototype.readUintBE=f.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e+--t],a=1;for(;t>0&&(a*=256);)o+=this[e+--t]*a;return o};f.prototype.readUint8=f.prototype.readUInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]|this[e+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]<<8|this[e+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readBigUInt64LE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,a=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(a)<<BigInt(32))});f.prototype.readBigUInt64BE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],a=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(o)<<BigInt(32))+BigInt(a)});f.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],a=1,i=0;for(;++i<t&&(a*=256);)o+=this[e+i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*t)),o};f.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=t,a=1,i=this[e+--o];for(;o>0&&(a*=256);)i+=this[e+--o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*t)),i};f.prototype.readInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};f.prototype.readInt16LE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};f.prototype.readInt16BE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};f.prototype.readInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readBigInt64LE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});f.prototype.readBigInt64BE=Y(function(e){e=e>>>0,pe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});f.prototype.readFloatLE=function(e,t){return e=e>>>0,t||U(e,4,this.length),fe.read(this,e,!0,23,4)};f.prototype.readFloatBE=function(e,t){return e=e>>>0,t||U(e,4,this.length),fe.read(this,e,!1,23,4)};f.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||U(e,8,this.length),fe.read(this,e,!0,52,8)};f.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||U(e,8,this.length),fe.read(this,e,!1,52,8)};function M(r,e,t,n,o,a){if(!f.isBuffer(r))throw new TypeError(\'"buffer" argument must be a Buffer instance\');if(e>o||e<a)throw new RangeError(\'"value" argument is out of bounds\');if(t+n>r.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let s=Math.pow(2,8*n)-1;M(this,e,t,n,s,0)}let a=1,i=0;for(this[t]=e&255;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let s=Math.pow(2,8*n)-1;M(this,e,t,n,s,0)}let a=n-1,i=1;for(this[t+a]=e&255;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n};f.prototype.writeUint8=f.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function cr(r,e,t,n,o){pr(e,n,o,r,t,7);let a=Number(e&BigInt(4294967295));r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a,a=a>>8,r[t++]=a;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,i=i>>8,r[t++]=i,t}function lr(r,e,t,n,o){pr(e,n,o,r,t,7);let a=Number(e&BigInt(4294967295));r[t+7]=a,a=a>>8,r[t+6]=a,a=a>>8,r[t+5]=a,a=a>>8,r[t+4]=a;let i=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=i,i=i>>8,r[t+2]=i,i=i>>8,r[t+1]=i,i=i>>8,r[t]=i,t+8}f.prototype.writeBigUInt64LE=Y(function(e,t=0){return cr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=Y(function(e,t=0){return lr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);M(this,e,t,n,l-1,-l)}let a=0,i=1,s=0;for(this[t]=e&255;++a<n&&(i*=256);)e<0&&s===0&&this[t+a-1]!==0&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n};f.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let l=Math.pow(2,8*n-1);M(this,e,t,n,l-1,-l)}let a=n-1,i=1,s=0;for(this[t+a]=e&255;--a>=0&&(i*=256);)e<0&&s===0&&this[t+a+1]!==0&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n};f.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};f.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};f.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};f.prototype.writeBigInt64LE=Y(function(e,t=0){return cr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=Y(function(e,t=0){return lr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ur(r,e,t,n,o,a){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function dr(r,e,t,n,o){return e=+e,t=t>>>0,o||ur(r,e,t,4,34028234663852886e22,-34028234663852886e22),fe.write(r,e,t,n,23,4),t+4}f.prototype.writeFloatLE=function(e,t,n){return dr(this,e,t,!0,n)};f.prototype.writeFloatBE=function(e,t,n){return dr(this,e,t,!1,n)};function fr(r,e,t,n,o){return e=+e,t=t>>>0,o||ur(r,e,t,8,17976931348623157e292,-17976931348623157e292),fe.write(r,e,t,n,52,8),t+8}f.prototype.writeDoubleLE=function(e,t,n){return fr(this,e,t,!0,n)};f.prototype.writeDoubleBE=function(e,t,n){return fr(this,e,t,!1,n)};f.prototype.copy=function(e,t,n,o){if(!f.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let a=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),a};f.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let a;if(typeof e=="number")for(a=t;a<n;++a)this[a]=e;else{let i=f.isBuffer(e)?e:f.from(e,o),s=i.length;if(s===0)throw new TypeError(\'The value "\'+e+\'" is invalid for argument "value"\');for(a=0;a<n-t;++a)this[a+t]=i[a%s]}return this};var de={};function ft(r,e,t){de[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ft("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ft("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,o=t;return Number.isInteger(t)&&Math.abs(t)>2**32?o=rr(String(t)):typeof t=="bigint"&&(o=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(o=rr(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n},RangeError);function rr(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function bo(r,e,t){pe(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Ae(e,r.length-(t+1))}function pr(r,e,t,n,o,a){if(r>t||r<e){let i=typeof e=="bigint"?"n":"",s;throw a>3?e===0||e===BigInt(0)?s=`>= 0${i} and < 2${i} ** ${(a+1)*8}${i}`:s=`>= -(2${i} ** ${(a+1)*8-1}${i}) and < 2 ** ${(a+1)*8-1}${i}`:s=`>= ${e}${i} and <= ${t}${i}`,new de.ERR_OUT_OF_RANGE("value",s,r)}bo(n,o,a)}function pe(r,e){if(typeof r!="number")throw new de.ERR_INVALID_ARG_TYPE(e,"number",r)}function Ae(r,e,t){throw Math.floor(r)!==r?(pe(r,t),new de.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new de.ERR_BUFFER_OUT_OF_BOUNDS:new de.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Io=/[^+/0-9A-Za-z-_]/g;function Ro(r){if(r=r.split("=")[0],r=r.trim().replace(Io,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function lt(r,e){e=e||1/0;let t,n=r.length,o=null,a=[];for(let i=0;i<n;++i){if(t=r.charCodeAt(i),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(i+1===n){(e-=3)>-1&&a.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&a.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536}else o&&(e-=3)>-1&&a.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;a.push(t)}else if(t<2048){if((e-=2)<0)break;a.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;a.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;a.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return a}function vo(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function _o(r,e){let t,n,o,a=[];for(let i=0;i<r.length&&!((e-=2)<0);++i)t=r.charCodeAt(i),n=t>>8,o=t%256,a.push(o),a.push(n);return a}function hr(r){return it.toByteArray(Ro(r))}function Fe(r,e,t,n){let o;for(o=0;o<n&&!(o+t>=e.length||o>=r.length);++o)e[o+t]=r[o];return o}function j(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function pt(r){return r!==r}var Ao=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let o=0;o<16;++o)e[n+o]=r[t]+r[o]}return e})();function Y(r){return typeof BigInt>"u"?xo:r}function xo(){throw new Error("BigInt not supported")}});var Zr=q(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});function ca(r){var e=4,t=r.length,n=t%e;if(!n)return r;var o=t,a=e-n,i=t+a,s=Buffer.alloc(i);for(s.write(r);a--;)s.write("=",o++);return s.toString()}xt.default=ca});var en=q(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});var la=Zr();function Qr(r,e){return e===void 0&&(e="utf8"),Buffer.isBuffer(r)?Ct(r.toString("base64")):Ct(Buffer.from(r,e).toString("base64"))}function ua(r,e){return e===void 0&&(e="utf8"),Buffer.from(Ot(r),"base64").toString(e)}function Ot(r){return r=r.toString(),la.default(r).replace(/\\-/g,"+").replace(/_/g,"/")}function Ct(r){return r.replace(/=/g,"").replace(/\\+/g,"-").replace(/\\//g,"_")}function da(r){return Buffer.from(Ot(r),"base64")}var we=Qr;we.encode=Qr;we.decode=ua;we.toBase64=Ot;we.fromBase64=Ct;we.toBuffer=da;Pt.default=we});var tn=q((ms,Ve)=>{Ve.exports=en().default;Ve.exports.default=Ve.exports});var nn=q((rn,Xe)=>{(function(r,e){var t={};e(t);var n=t.default;for(var o in t)n[o]=t[o];typeof Xe=="object"&&typeof Xe.exports=="object"?Xe.exports=n:typeof define=="function"&&define.amd?define(function(){return n}):r.sha256=n})(rn,function(r){"use strict";r.__esModule=!0,r.digestLength=32,r.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function t(u,p,h,g,S){for(var T,b,E,D,A,v,F,x,P,C,ce,le,ve;S>=64;){for(T=p[0],b=p[1],E=p[2],D=p[3],A=p[4],v=p[5],F=p[6],x=p[7],C=0;C<16;C++)ce=g+C*4,u[C]=(h[ce]&255)<<24|(h[ce+1]&255)<<16|(h[ce+2]&255)<<8|h[ce+3]&255;for(C=16;C<64;C++)P=u[C-2],le=(P>>>17|P<<15)^(P>>>19|P<<13)^P>>>10,P=u[C-15],ve=(P>>>7|P<<25)^(P>>>18|P<<14)^P>>>3,u[C]=(le+u[C-7]|0)+(ve+u[C-16]|0);for(C=0;C<64;C++)le=(((A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&v^~A&F)|0)+(x+(e[C]+u[C]|0)|0)|0,ve=((T>>>2|T<<30)^(T>>>13|T<<19)^(T>>>22|T<<10))+(T&b^T&E^b&E)|0,x=F,F=v,v=A,A=D+le|0,D=E,E=b,b=T,T=le+ve|0;p[0]+=T,p[1]+=b,p[2]+=E,p[3]+=D,p[4]+=A,p[5]+=v,p[6]+=F,p[7]+=x,g+=64,S-=64}return g}var n=(function(){function u(){this.digestLength=r.digestLength,this.blockSize=r.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return u.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},u.prototype.clean=function(){for(var p=0;p<this.buffer.length;p++)this.buffer[p]=0;for(var p=0;p<this.temp.length;p++)this.temp[p]=0;this.reset()},u.prototype.update=function(p,h){if(h===void 0&&(h=p.length),this.finished)throw new Error("SHA256: can\'t update because hash was finished.");var g=0;if(this.bytesHashed+=h,this.bufferLength>0){for(;this.bufferLength<64&&h>0;)this.buffer[this.bufferLength++]=p[g++],h--;this.bufferLength===64&&(t(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(h>=64&&(g=t(this.temp,this.state,p,g,h),h%=64);h>0;)this.buffer[this.bufferLength++]=p[g++],h--;return this},u.prototype.finish=function(p){if(!this.finished){var h=this.bytesHashed,g=this.bufferLength,S=h/536870912|0,T=h<<3,b=h%64<56?64:128;this.buffer[g]=128;for(var E=g+1;E<b-8;E++)this.buffer[E]=0;this.buffer[b-8]=S>>>24&255,this.buffer[b-7]=S>>>16&255,this.buffer[b-6]=S>>>8&255,this.buffer[b-5]=S>>>0&255,this.buffer[b-4]=T>>>24&255,this.buffer[b-3]=T>>>16&255,this.buffer[b-2]=T>>>8&255,this.buffer[b-1]=T>>>0&255,t(this.temp,this.state,this.buffer,0,b),this.finished=!0}for(var E=0;E<8;E++)p[E*4+0]=this.state[E]>>>24&255,p[E*4+1]=this.state[E]>>>16&255,p[E*4+2]=this.state[E]>>>8&255,p[E*4+3]=this.state[E]>>>0&255;return this},u.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},u.prototype._saveState=function(p){for(var h=0;h<this.state.length;h++)p[h]=this.state[h]},u.prototype._restoreState=function(p,h){for(var g=0;g<this.state.length;g++)this.state[g]=p[g];this.bytesHashed=h,this.finished=!1,this.bufferLength=0},u})();r.Hash=n;var o=(function(){function u(p){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var h=new Uint8Array(this.blockSize);if(p.length>this.blockSize)new n().update(p).finish(h).clean();else for(var g=0;g<p.length;g++)h[g]=p[g];for(var g=0;g<h.length;g++)h[g]^=54;this.inner.update(h);for(var g=0;g<h.length;g++)h[g]^=106;this.outer.update(h),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var g=0;g<h.length;g++)h[g]=0}return u.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},u.prototype.clean=function(){for(var p=0;p<this.istate.length;p++)this.ostate[p]=this.istate[p]=0;this.inner.clean(),this.outer.clean()},u.prototype.update=function(p){return this.inner.update(p),this},u.prototype.finish=function(p){return this.outer.finished?this.outer.finish(p):(this.inner.finish(p),this.outer.update(p,this.digestLength).finish(p)),this},u.prototype.digest=function(){var p=new Uint8Array(this.digestLength);return this.finish(p),p},u})();r.HMAC=o;function a(u){var p=new n().update(u),h=p.digest();return p.clean(),h}r.hash=a,r.default=a;function i(u,p){var h=new o(u).update(p),g=h.digest();return h.clean(),g}r.hmac=i;function s(u,p,h,g){var S=g[0];if(S===0)throw new Error("hkdf: cannot expand more");p.reset(),S>1&&p.update(u),h&&p.update(h),p.update(g),p.finish(u),g[0]++}var l=new Uint8Array(r.digestLength);function c(u,p,h,g){p===void 0&&(p=l),g===void 0&&(g=32);for(var S=new Uint8Array([1]),T=i(p,u),b=new o(T),E=new Uint8Array(b.digestLength),D=E.length,A=new Uint8Array(g),v=0;v<g;v++)D===E.length&&(s(E,b,h,S),D=0),A[v]=E[D++];return b.clean(),E.fill(0),S.fill(0),A}r.hkdf=c;function d(u,p,h,g){for(var S=new o(u),T=S.digestLength,b=new Uint8Array(4),E=new Uint8Array(T),D=new Uint8Array(T),A=new Uint8Array(g),v=0;v*T<g;v++){var F=v+1;b[0]=F>>>24&255,b[1]=F>>>16&255,b[2]=F>>>8&255,b[3]=F>>>0&255,S.reset(),S.update(p),S.update(b),S.finish(D);for(var x=0;x<T;x++)E[x]=D[x];for(var x=2;x<=h;x++){S.reset(),S.update(D).finish(D);for(var P=0;P<T;P++)E[P]^=D[P]}for(var x=0;x<T&&v*T+x<g;x++)A[v*T+x]=E[x]}for(var v=0;v<T;v++)E[v]=D[v]=0;for(var v=0;v<4;v++)b[v]=0;return S.clean(),A}r.pbkdf2=d})});var Nn=q((Kt,kn)=>{var Ze=Ke(),z=Ze.Buffer;function Un(r,e){for(var t in r)e[t]=r[t]}z.from&&z.alloc&&z.allocUnsafe&&z.allocUnsafeSlow?kn.exports=Ze:(Un(Ze,Kt),Kt.Buffer=se);function se(r,e,t){return z(r,e,t)}se.prototype=Object.create(z.prototype);Un(z,se);se.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return z(r,e,t)};se.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=z(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};se.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return z(r)};se.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return Ze.SlowBuffer(r)}});var Dn=q((Kc,jt)=>{"use strict";var Wt=65536,Aa=4294967295;function xa(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Ca=Nn().Buffer,Qe=self.crypto||self.msCrypto;Qe&&Qe.getRandomValues?jt.exports=Oa:jt.exports=xa;function Oa(r,e){if(r>Aa)throw new RangeError("requested too many random bytes");var t=Ca.allocUnsafe(r);if(r>0)if(r>Wt)for(var n=0;n<r;n+=Wt)Qe.getRandomValues(t.slice(n,n+Wt));else Qe.getRandomValues(t);return typeof e=="function"?process.nextTick(function(){e(null,t)}):t}});var Fn=_e(Ke(),1);var Co=Object.defineProperty,Oo=(r,e,t)=>e in r?Co(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,R=(r,e,t)=>Oo(r,typeof e!="symbol"?e+"":e,t),Po={Endpoints:{AUTHORIZATION:"/oauth2/authorize",END_SESSION:"/oidc/logout",ISSUER:"/oauth2/token",JWKS:"/oauth2/jwks",REVOCATION:"/oauth2/revoke",SESSION_IFRAME:"/oidc/checksession",TOKEN:"/oauth2/token",USERINFO:"/oauth2/userinfo"},Storage:{StorageKeys:{Endpoints:{AUTHORIZATION:"authorization_endpoint",END_SESSION:"end_session_endpoint",ISSUER:"issuer",JWKS:"jwks_uri",REVOCATION:"revocation_endpoint",SESSION_IFRAME:"check_session_iframe",TOKEN:"token_endpoint",USERINFO:"userinfo_endpoint"},OPENID_PROVIDER_CONFIG_INITIATED:"op_config_initiated"}}},O=Po,Uo={Placeholders:{ACCESS_TOKEN:"{{accessToken}}",CLIENT_ID:"{{clientId}}",CLIENT_SECRET:"{{clientSecret}}",SCOPES:"{{scopes}}",USERNAME:"{{username}}"}},xe=Uo,w=class{constructor(r,e,t){R(this,"name"),R(this,"code"),R(this,"message"),this.message=t,this.name=e,this.code=r,Object.setPrototypeOf(this,new.target.prototype)}};var ko=r=>{let e={...r};return["iss","aud","exp","iat","acr","amr","azp","auth_time","nonce","c_hash","at_hash","nbf","isk","sid","jti","sub"].forEach(n=>{delete e[n]}),e},No=ko,Do={INTERNAL_LOGIN:"internal_login",OPENID:"openid",PROFILE:"profile"},ht=Do,Mo={Params:{AUTHORIZATION_CODE:"code",SESSION_STATE:"session_state",SIGN_OUT_SUCCESS:"sign_out_success",STATE:"state"},SignIn:{Payload:{DEFAULT_SCOPES:[ht.OPENID,ht.PROFILE,ht.INTERNAL_LOGIN]}},SignOut:{Storage:{StorageKeys:{SIGN_OUT_URL:"sign_out_url"}}}},k=Mo,$o=class Sr extends Error{constructor(e,t,n){let o=Sr.resolveOrigin(n);super(e),R(this,"code"),R(this,"origin"),this.name=new.target.name,this.code=t,this.origin=o,Error.captureStackTrace&&Error.captureStackTrace(this,new.target)}static resolveOrigin(e){return e?`@asgardeo/${e}`:"@asgardeo/javascript"}toString(){let e=`\\u{1F6E1}\\uFE0F Asgardeo - ${this.origin}:`;return`[${this.name}]\n${e} ${this.message}\n(code="${this.code}")`}},Er=class extends $o{constructor(r,e,t,n){super(r,e,t),this.details=n,Object.defineProperty(this,"name",{configurable:!0,value:"AsgardeoRuntimeError",writable:!0})}toString(){let r=this.details?`\nDetails: ${JSON.stringify(this.details,null,2)}`:"";return`[${this.name}] (code="${this.code}")${r}\nMessage: ${this.message}`}},Ho=r=>{let e=[];if(r)if(Array.isArray(r))e=r;else if(typeof r=="string")e=r.split(" ");else throw new Er("Scopes must be a string or an array of strings.","processOpenIDScopes-Invalid-001","javascript","The provided scopes are not in the expected format. Please provide a string or an array of strings.");return k.SignIn.Payload.DEFAULT_SCOPES.forEach(t=>{e.includes(t)||e.push(t)}),e.join(" ")},mt=Ho,Bo=class{constructor(r,e){R(this,"storageManager"),R(this,"config"),R(this,"oidcProviderMetaData"),R(this,"cryptoHelper"),this.storageManager=r,this.config=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaData=async()=>this.storageManager.loadOpenIDProviderConfiguration(),this.cryptoHelper=e}async resolveEndpoints(r){let e={},t=await this.config();return t.endpoints&&Object.keys(t.endpoints).forEach(n=>{let o=n.replace(/[A-Z]/g,a=>`_${a.toLowerCase()}`);e[o]=t?.endpoints?t.endpoints[n]:""}),{...r,...e}}async resolveEndpointsExplicitly(){let r={},e=await this.config(),t=[O.Storage.StorageKeys.Endpoints.AUTHORIZATION,O.Storage.StorageKeys.Endpoints.END_SESSION,O.Storage.StorageKeys.Endpoints.JWKS,O.Storage.StorageKeys.Endpoints.SESSION_IFRAME,O.Storage.StorageKeys.Endpoints.REVOCATION,O.Storage.StorageKeys.Endpoints.TOKEN,O.Storage.StorageKeys.Endpoints.ISSUER,O.Storage.StorageKeys.Endpoints.USERINFO];if(!(e.endpoints?t.every(o=>e.endpoints?Object.keys(e.endpoints).some(a=>a.replace(/[A-Z]/g,s=>`_${s.toLowerCase()}`)===o):!1):!1))throw new w("JS-AUTH_HELPER-REE-NF01","Required endpoints missing","Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object.");return e.endpoints&&Object.keys(e.endpoints).forEach(o=>{let a=o.replace(/[A-Z]/g,i=>`_${i.toLowerCase()}`);r[a]=e?.endpoints?e.endpoints[o]:""}),{...r}}async resolveEndpointsByBaseURL(){let r={},e=await this.config(),{baseUrl:t}=e;if(!t)throw new w("JS-AUTH_HELPER_REBO-NF01","Base URL not defined.","Base URL is not defined in AuthClient config.");e.endpoints&&Object.keys(e.endpoints).forEach(i=>{let s=i.replace(/[A-Z]/g,l=>`_${l.toLowerCase()}`);r[s]=e?.endpoints?e.endpoints[i]:""});let n=O.Storage.StorageKeys.Endpoints,o=O.Endpoints,a={[n.AUTHORIZATION]:`${t}${o.AUTHORIZATION}`,[n.END_SESSION]:`${t}${o.END_SESSION}`,[n.ISSUER]:`${t}${o.ISSUER}`,[n.JWKS]:`${t}${o.JWKS}`,[n.SESSION_IFRAME]:`${t}${o.SESSION_IFRAME}`,[n.REVOCATION]:`${t}${o.REVOCATION}`,[n.TOKEN]:`${t}${o.TOKEN}`,[n.USERINFO]:`${t}${o.USERINFO}`};return e.platform==="AsgardeoV2"&&(a[O.Storage.StorageKeys.Endpoints.ISSUER]=`${t}`),{...a,...r}}async validateIdToken(r){let e=(await this.storageManager.loadOpenIDProviderConfiguration()).jwks_uri,t=await this.config();if(!e||e.trim().length===0)throw new w("JS_AUTH_HELPER-VIT-NF01","JWKS endpoint not found.","No JWKS endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the JWKS endpoint passed to the SDK is empty.");let n;try{n=await fetch(e,{credentials:t.sendCookiesInRequests?"include":"same-origin"})}catch(s){throw new w("JS-AUTH_HELPER-VIT-NE02","Request to jwks endpoint failed.",s??"The request sent to get the jwks from the server failed.")}if(n.status!==200||!n.ok)throw new w("JS-AUTH_HELPER-VIT-HE03",`Invalid response status received for jwks request (${n.statusText}).`,await n.json());let{issuer:o}=await this.oidcProviderMetaData(),{keys:a}=await n.json(),i=await this.cryptoHelper.getJWKForTheIdToken(r.split(".")[0],a);return this.cryptoHelper.isValidIdToken(r,i,(await this.config()).clientId,o??"",this.cryptoHelper.decodeJwtToken(r).sub,(await this.config()).tokenValidation?.idToken?.clockTolerance,(await this.config()).tokenValidation?.idToken?.validateIssuer??!0)}getAuthenticatedUserInfo(r){let e=this.cryptoHelper.decodeJwtToken(r),t=e?.username??"",n=e?.given_name??"",o=e?.family_name??"",a=n&&o?`${n} ${o}`:n||o||"";return{displayName:e.preferred_username??a,username:t,...No(e)}}async replaceCustomGrantTemplateTags(r,e){let t=await this.config(),n=t.organizationChain?.sourceInstanceId??null,o;if(n){let{clientId:i}=t,s;if(i?s=`instance_${n}-${i}`:s=`instance_${n}`,o=await this.storageManager.getSessionData(e,s),!o||!o.access_token)throw new w("JS-AUTH_HELPER-RCGTT-NE01","No session data found for source instance.","Failed to retrieve session data from the source organization context.")}else o=await this.storageManager.getSessionData(e);let a=mt(t.scopes);return typeof r!="string"?r:r.replace(xe.Placeholders.ACCESS_TOKEN,o.access_token).replace(xe.Placeholders.USERNAME,this.getAuthenticatedUserInfo(o.id_token).username).replace(xe.Placeholders.SCOPES,a).replace(xe.Placeholders.CLIENT_ID,t.clientId).replace(xe.Placeholders.CLIENT_SECRET,t.clientSecret??"")}async clearSession(r){await this.storageManager.removeTemporaryData(r),await this.storageManager.removeSessionData(r)}async handleTokenResponse(r,e){if(r.status!==200||!r.ok)throw new w("JS-AUTH_HELPER-HTR-NE01",`Invalid response status received for token request (${r.statusText}).`,await r.json());let t=await r.json();if(t.created_at=new Date().getTime(),(await this.config()).tokenValidation?.idToken?.validate)return this.validateIdToken(t.id_token).then(async()=>{await this.storageManager.setSessionData(t,e);let a={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return Promise.resolve(a)});let o={accessToken:t.access_token,createdAt:t.created_at,expiresIn:t.expires_in,idToken:t.id_token,refreshToken:t.refresh_token,scope:t.scope,tokenType:t.token_type};return await this.storageManager.setSessionData(t,e),Promise.resolve(o)}},Lo={DEFAULT_CODE_CHALLENGE_METHOD:"S256",Storage:{StorageKeys:{CODE_VERIFIER:"pkce_code_verifier",SEPARATOR:"#"}}},Z=Lo,Fo={Endpoints:{WELL_KNOWN:"/.well-known/openid-configuration"}},Ko=Fo,Wo={SignatureValidation:{SUPPORTED_ALGORITHMS:["RS256","RS512","RS384","PS256"]},Storage:{StorageKeys:{REFRESH_TOKEN_TIMER:"refresh_token_timer"}}},Ce=Wo,jo=class{constructor(r){R(this,"cryptoUtils"),this.cryptoUtils=r}getCodeVerifier(){return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32))}async getCodeChallenge(r){let e=await this.cryptoUtils.hashSha256(r);return this.cryptoUtils.base64URLEncode(e)}getJWKForTheIdToken(r,e){let t=JSON.parse(this.cryptoUtils.base64URLDecode(r)),n=e.find(o=>t.kid===o.kid);if(n)return n;throw new w("JS-CRYPTO_UTIL-GJFTIT-IV01","kid not found.",`Failed to find the \'kid\' specified in the id_token. \'kid\' found in the header : ${t.kid}, Expected values: ${e.map(o=>o.kid).join(", ")}`)}isValidIdToken(r,e,t,n,o,a,i){return this.cryptoUtils.verifyJwt(r,e,Ce.SignatureValidation.SUPPORTED_ALGORITHMS,t,n,o,a,i).then(s=>s?Promise.resolve(!0):Promise.reject(new w("JS-CRYPTO_HELPER-IVIT-IV01","Invalid ID token.","ID token validation returned false"))).catch(s=>Promise.reject(s))}decodeJwtToken(r){try{let e=this.cryptoUtils.base64URLDecode(r?.split(".")[1]);return JSON.parse(e)}catch(e){throw new w("JS-CRYPTO_UTIL-DIT-IV02","Decoding token failed.",e)}}},gt="asgardeo-session-active",zo=class We{constructor(e,t){R(this,"id"),R(this,"store"),this.id=e,this.store=t}async setDataInBulk(e,t){let n=await this.store.getData(e)??null,a={...n&&JSON.parse(n),...t},i=JSON.stringify(a);await this.store.setData(e,i)}async setValue(e,t,n){let o=await this.store.getData(e)??null,i={...o&&JSON.parse(o),[t]:n},s=JSON.stringify(i);await this.store.setData(e,s)}async removeValue(e,t){let n=await this.store.getData(e)??null,a={...n&&JSON.parse(n)};delete a[t];let i=JSON.stringify(a);await this.store.setData(e,i)}resolveKey(e,t,n){return t&&n?`${e}-${n}-${t}`:t?`${e}-${this.id}-${t}`:n?`${e}-${n}`:`${e}-${this.id}`}static isLocalStorageAvailable(){try{let e="__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}async setConfigData(e){await this.setDataInBulk(this.resolveKey("config_data"),e)}async setOIDCProviderMetaData(e){this.setDataInBulk(this.resolveKey("oidc_provider_meta_data"),e)}async setTemporaryData(e,t){this.setDataInBulk(this.resolveKey("temporary_data",t),e)}async setSessionData(e,t){this.setDataInBulk(this.resolveKey("session_data",t),e)}async setCustomData(e,t,n){this.setDataInBulk(this.resolveKey(e,n),t)}async getConfigData(e){return JSON.parse(await this.store.getData(this.resolveKey("config_data",e))??null)}async loadOpenIDProviderConfiguration(){return JSON.parse(await this.store.getData(this.resolveKey("oidc_provider_meta_data"))??null)}async getTemporaryData(e){return JSON.parse(await this.store.getData(this.resolveKey("temporary_data",e))??null)}async getPersistedData(e){return JSON.parse(await this.store.getData(this.resolveKey("persisted_data",e))??null)}async setPersistedData(e,t){this.setDataInBulk(this.resolveKey("persisted_data",t),e)}async getSessionData(e,t){return JSON.parse(await this.store.getData(this.resolveKey("session_data",e,t))??null)}async getCustomData(e,t){return JSON.parse(await this.store.getData(this.resolveKey(e,t))??null)}setSessionStatus(e){We.isLocalStorageAvailable()&&localStorage.setItem(`${gt}`,e)}getSessionStatus(){return We.isLocalStorageAvailable()?localStorage.getItem(`${gt}`)??"":""}removeSessionStatus(){We.isLocalStorageAvailable()&&localStorage.removeItem(`${gt}`)}async removeConfigData(){await this.store.removeData(this.resolveKey("config_data"))}async removeOIDCProviderMetaData(){await this.store.removeData(this.resolveKey("oidc_provider_meta_data"))}async removeTemporaryData(e){await this.store.removeData(this.resolveKey("temporary_data",e))}async removeSessionData(e){await this.store.removeData(this.resolveKey("session_data",e))}async getConfigDataParameter(e){let t=await this.store.getData(this.resolveKey("config_data"));return t&&JSON.parse(t)[e]}async getOIDCProviderMetaDataParameter(e){let t=await this.store.getData(this.resolveKey("oidc_provider_meta_data"));return t&&JSON.parse(t)[e]}async getTemporaryDataParameter(e,t){let n=await this.store.getData(this.resolveKey("temporary_data",t));return n&&JSON.parse(n)[e]}async getSessionDataParameter(e,t){let n=await this.store.getData(this.resolveKey("session_data",t));return n&&JSON.parse(n)[e]}async setConfigDataParameter(e,t){await this.setValue(this.resolveKey("config_data"),e,t)}async setOIDCProviderMetaDataParameter(e,t){await this.setValue(this.resolveKey("oidc_provider_meta_data"),e,t)}async setTemporaryDataParameter(e,t,n){await this.setValue(this.resolveKey("temporary_data",n),e,t)}async setSessionDataParameter(e,t,n){await this.setValue(this.resolveKey("session_data",n),e,t)}async removeConfigDataParameter(e){await this.removeValue(this.resolveKey("config_data"),e)}async removeOIDCProviderMetaDataParameter(e){await this.removeValue(this.resolveKey("oidc_provider_meta_data"),e)}async removeTemporaryDataParameter(e,t){await this.removeValue(this.resolveKey("temporary_data",t),e)}async removeSessionDataParameter(e,t){await this.removeValue(this.resolveKey("session_data",t),e)}},gr=zo,mr=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.prototype.toString.call(r)==="[object Object]",Tr=(r,...e)=>{if(!r||typeof r!="object")throw new Error("Target must be an object");let t={...r};return e.forEach(n=>{!n||typeof n!="object"||Object.keys(n).forEach(o=>{let a=n[o],i=t[o];mr(a)&&mr(i)?t[o]=Tr(i,a):a!==void 0&&(t[o]=a)})}),t},qo=Tr,Jo=r=>{let e=parseInt(r.split("request_")[1],10);return`${Z.Storage.StorageKeys.CODE_VERIFIER}${Z.Storage.StorageKeys.SEPARATOR}${e}`},oe=Jo,Go=r=>{let e=[];Object.keys(r).forEach(o=>{o.startsWith(Z.Storage.StorageKeys.CODE_VERIFIER)&&e.push(o)});let t=e.sort().pop(),n=parseInt(t?.split(Z.Storage.StorageKeys.SEPARATOR)[1]??"-1",10);return`${Z.Storage.StorageKeys.CODE_VERIFIER}${Z.Storage.StorageKeys.SEPARATOR}${n+1}`},Vo=Go,Xo=(r,e)=>{let t=parseInt(r.split(Z.Storage.StorageKeys.SEPARATOR)[1],10);return e?`${e}_request_${t}`:`request_${t}`},Yo=Xo,Zo=(r,e,t)=>{let{redirectUri:n,clientId:o,scopes:a,responseMode:i,codeChallenge:s,codeChallengeMethod:l,prompt:c}=r,d=new Map;d.set("response_type","code"),d.set("client_id",o),d.set("scope",a),d.set("redirect_uri",n),i&&d.set("response_mode",i);let u=e?.key;if(s)if(d.set("code_challenge",s),l)d.set("code_challenge_method",l);else throw new Er("Code challenge method is required when code challenge is provided.","getAuthorizeRequestUrlParams-ValidationError-001","javascript","When PKCE is enabled, the code challenge method must be provided along with the code challenge.");c&&d.set("prompt",c),t&&Object.entries(t).forEach(([g,S])=>{g!==""&&S!==""&&g!==k.Params.STATE&&d.set(g,S.toString())});let p="instance_",h="";return r.instanceId?h=p+r.instanceId:t&&(h=t[k.Params.STATE]?.toString()??""),d.set(k.Params.STATE,Yo(u,h)),d},Qo=Zo,ea={enablePKCE:!0,responseMode:"query",sendCookiesInRequests:!0,tokenValidation:{idToken:{clockTolerance:300,validate:!0,validateIssuer:!0}}},br=class Ir{constructor(){R(this,"storageManager"),R(this,"configProvider"),R(this,"oidcProviderMetaDataProvider"),R(this,"authHelper"),R(this,"cryptoUtils"),R(this,"cryptoHelper"),R(this,"instanceIdValue")}async initialize(e,t,n,o){let{clientId:a}=e;this.instanceIdValue?this.instanceIdValue+=1:this.instanceIdValue=0,o!==void 0&&(this.instanceIdValue=o),a?this.storageManager=new gr(`instance_${this.instanceIdValue}-${a}`,t):this.storageManager=new gr(`instance_${this.instanceIdValue}`,t),this.cryptoUtils=n,this.cryptoHelper=new jo(n),this.authHelper=new Bo(this.storageManager,this.cryptoHelper),this.configProvider=async()=>this.storageManager.getConfigData(),this.oidcProviderMetaDataProvider=async()=>this.storageManager.loadOpenIDProviderConfiguration(),Ir.authHelperInstance=this.authHelper;let{applicationId:i,platform:s,endpoints:l}=e,c=i;if(i)await this.storageManager.setPersistedData({applicationId:i});else{let u=await this.storageManager.getPersistedData();u.applicationId&&(c=u.applicationId)}let d=l||{};s==="AsgardeoV2"&&(d.wellKnown||(d.wellKnown=Ko.Endpoints.WELL_KNOWN)),await this.storageManager.setConfigData({...ea,...e,applicationId:c,endpoints:d,scope:mt(e.scopes)})}getStorageManager(){return this.storageManager}getInstanceId(){return this.instanceIdValue}async getSignInUrl(e,t){let n={...e};delete n?.forceInit;let o=async()=>{let a=await this.storageManager.getOIDCProviderMetaDataParameter(O.Storage.StorageKeys.Endpoints.AUTHORIZATION);if(!a||a.trim().length===0)throw new w("JS-AUTH_CORE-GAU-NF01","No authorization endpoint found.","No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty.");let i=new URL(a),s=await this.configProvider(),l=await this.storageManager.getTemporaryData(t),c=await Vo(l),d,u;s.enablePKCE&&(d=this.cryptoHelper?.getCodeVerifier(),u=await this.cryptoHelper?.getCodeChallenge(d),await this.storageManager.setTemporaryDataParameter(c,d,t)),n.client_secret&&(n.client_secret=s.clientSecret);let p=Qo({clientId:s.clientId,codeChallenge:u,codeChallengeMethod:Z.DEFAULT_CODE_CHALLENGE_METHOD,instanceId:this.getInstanceId().toString(),prompt:s.prompt,redirectUri:s.afterSignInUrl,responseMode:s.responseMode,scopes:mt(s.scopes)},{key:c},n);return Array.from(p.entries()).forEach(([h,g])=>{i.searchParams.append(h,g)}),i.toString()};return await this.storageManager.getTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)?o():this.loadOpenIDProviderConfiguration(e?.forceInit).then(()=>o())}async requestAccessToken(e,t,n,o,a){await this.storageManager.getTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let i=(await this.oidcProviderMetaDataProvider()).token_endpoint,s=await this.configProvider();if(!i||i.trim().length===0)throw new w("JS-AUTH_CORE-RAT1-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");t&&await this.storageManager.setSessionDataParameter(k.Params.SESSION_STATE,t,o);let l=new URLSearchParams;l.set("client_id",s.clientId),s.clientSecret&&s.clientSecret.trim().length>0&&l.set("client_secret",s.clientSecret);let c=e;l.set("code",c),l.set("grant_type","authorization_code"),l.set("redirect_uri",s.afterSignInUrl),a?.params&&Object.entries(a.params).forEach(([u,p])=>{l.append(u,p)}),s.enablePKCE&&(l.set("code_verifier",`${await this.storageManager.getTemporaryDataParameter(oe(n),o)}`),await this.storageManager.removeTemporaryDataParameter(oe(n),o));let d;try{d=await fetch(i,{body:l,credentials:s.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(u){throw new w("JS-AUTH_CORE-RAT1-NE02","Requesting access token failed",u??"The request to get the access token from the server failed.")}if(!d.ok)throw new w("JS-AUTH_CORE-RAT1-HE03",`Requesting access token failed with ${d.statusText}`,await d.json());return this.authHelper.handleTokenResponse(d,o)}async loadOpenIDProviderConfiguration(e){let t=await this.configProvider();if(!e&&await this.storageManager.getTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED))return Promise.resolve();let{wellKnownEndpoint:n,platform:o,discovery:a,baseUrl:i,endpoints:s}=t,l=n||(o==="AsgardeoV2"&&a?.wellKnown?.enabled?`${i}${s?.wellKnown??"/.well-known/openid-configuration"}`:void 0);if(l){let c;try{if(c=await fetch(l),c.status!==200||!c.ok)throw new Error}catch{throw new w("JS-AUTH_CORE-GOPMD-HE01","Invalid well-known response","The well known endpoint response has been failed with an error.")}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await c.json())),await this.storageManager.setTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}if(t.baseUrl){try{await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL())}catch(c){throw new w("JS-AUTH_CORE-GOPMD-IV02","Resolving endpoints failed.",c??"Resolving endpoints by base url failed.")}return await this.storageManager.setTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}return await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly()),await this.storageManager.setTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,!0),Promise.resolve()}async getSignOutUrl(e){let t=(await this.oidcProviderMetaDataProvider())?.end_session_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new w("JS-AUTH_CORE-GSOU-NF01","Sign-out endpoint not found.","No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty.");let o=n?.afterSignOutUrl??n?.afterSignInUrl;if(!o||o.trim().length===0)throw new w("JS-AUTH_CORE-GSOU-NF03","No sign-out redirect URL found.","The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. ");let a=new URLSearchParams;if(a.set("post_logout_redirect_uri",o),n.sendIdTokenInLogoutRequest){let i=(await this.storageManager.getSessionData(e))?.id_token;if(!i||i.trim().length===0)throw new w("JS-AUTH_CORE-GSOU-NF02","ID token not found.","No ID token could be found. Either the session information is lost or you have not signed in.");a.set("id_token_hint",i)}else a.set("client_id",n.clientId);return a.set("state",k.Params.SIGN_OUT_SUCCESS),`${t}?${a.toString()}`}async getOpenIDProviderEndpoints(){let e=await this.oidcProviderMetaDataProvider();return{authorizationEndpoint:e.authorization_endpoint??"",checkSessionIframe:e.check_session_iframe??"",endSessionEndpoint:e.end_session_endpoint??"",introspectionEndpoint:e.introspection_endpoint??"",issuer:e.issuer??"",jwksUri:e.jwks_uri??"",registrationEndpoint:e.registration_endpoint??"",revocationEndpoint:e.revocation_endpoint??"",tokenEndpoint:e.token_endpoint??"",userinfoEndpoint:e.userinfo_endpoint??""}}async decodeJwtToken(e){return this.cryptoHelper.decodeJwtToken(e)}async getDecodedIdToken(e,t){let n=(await this.storageManager.getSessionData(e)).id_token;return this.cryptoHelper.decodeJwtToken(n??t)}async getIdToken(e){return(await this.storageManager.getSessionData(e)).id_token}async getUser(e){let t=await this.storageManager.getSessionData(e),n=this.authHelper.getAuthenticatedUserInfo(t?.id_token);return Object.keys(n).forEach(o=>{(n[o]===void 0||n[o]===""||n[o]===null)&&delete n[o]}),n}async getUserSession(e){let t=await this.storageManager.getSessionData(e);return{scopes:t?.scope?.split(" "),sessionState:t?.session_state??""}}async getCrypto(){return this.cryptoHelper}async revokeAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).revocation_endpoint,n=await this.configProvider();if(!t||t.trim().length===0)throw new w("JS-AUTH_CORE-RAT3-NF01","No revoke access token endpoint found.","No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty.");let o=[];o.push(`client_id=${n.clientId}`),o.push(`token=${(await this.storageManager.getSessionData(e)).access_token}`),o.push("token_type_hint=access_token"),n.clientSecret&&n.clientSecret.trim().length>0&&o.push(`client_secret=${n.clientSecret}`);let a;try{a=await fetch(t,{body:o.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(i){throw new w("JS-AUTH_CORE-RAT3-NE02","The request to revoke access token failed.",i??"The request sent to revoke the access token failed.")}if(a.status!==200||!a.ok)throw new w("JS-AUTH_CORE-RAT3-HE03",`Invalid response status received for revoke access token request (${a.statusText}).`,await a.json());return this.authHelper.clearSession(e),Promise.resolve(a)}async refreshAccessToken(e){let t=(await this.oidcProviderMetaDataProvider()).token_endpoint,n=await this.configProvider(),o=await this.storageManager.getSessionData(e);if(!o.refresh_token)throw new w("JS-AUTH_CORE-RAT2-NF01","No refresh token found.","There was no refresh token found. Asgardeo doesn\'t return a refresh token if the refresh token grant is not enabled.");if(!t||t.trim().length===0)throw new w("JS-AUTH_CORE-RAT2-NF02","No refresh token endpoint found.","No refresh token endpoint was in the OIDC provider meta data returned by the well-known endpoint or the refresh token endpoint passed to the SDK is empty.");let a=[];a.push(`client_id=${n.clientId}`),a.push(`refresh_token=${o.refresh_token}`),a.push("grant_type=refresh_token"),n.clientSecret&&n.clientSecret.trim().length>0&&a.push(`client_secret=${n.clientSecret}`);let i;try{i=await fetch(t,{body:a.join("&"),credentials:n.sendCookiesInRequests?"include":"same-origin",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},method:"POST"})}catch(s){throw new w("JS-AUTH_CORE-RAT2-NR03","Refresh access token request failed.",s??"The request to refresh the access token failed.")}if(!i.ok)throw new w("JS-AUTH_CORE-RAT2-HE04",`Refreshing access token failed with ${i.statusText}`,await i.json());return this.authHelper.handleTokenResponse(i,e)}async getAccessToken(e){return(await this.storageManager.getSessionData(e))?.access_token}async exchangeToken(e,t){await this.storageManager.getTemporaryDataParameter(O.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)||await this.loadOpenIDProviderConfiguration(!1);let n=await this.oidcProviderMetaDataProvider(),o=await this.configProvider(),a;if(e.tokenEndpoint&&e.tokenEndpoint.trim().length!==0?a=e.tokenEndpoint:a=n.token_endpoint,!a||a.trim().length===0)throw new w("JS-AUTH_CORE-RCG-NF01","Token endpoint not found.","No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");let i=await Promise.all(Object.entries(e.data).map(async([d,u])=>{let p=await this.authHelper.replaceCustomGrantTemplateTags(u,t);return`${d}=${p}`})),s={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"};e.attachToken&&(s={...s,Authorization:`Bearer ${(await this.storageManager.getSessionData(t)).access_token}`});let l={body:i.join("&"),credentials:o.sendCookiesInRequests?"include":"same-origin",headers:new Headers(s),method:"POST"},c;try{c=await fetch(a,l)}catch(d){throw new w("JS-AUTH_CORE-RCG-NE02","The custom grant request failed.",d??"The request sent to get the custom grant failed.")}if(c.status!==200||!c.ok)throw new w("JS-AUTH_CORE-RCG-HE03",`Invalid response status received for the custom grant request. (${c.statusText})`,await c.json());return e.returnsSession?this.authHelper.handleTokenResponse(c,t):Promise.resolve(await c.json())}async isSignedIn(e){let t=!!await this.getAccessToken(e),n=(await this.storageManager.getSessionData(e))?.created_at,o=(await this.storageManager.getSessionData(e))?.expires_in;if(!o)return!1;let a=parseInt(o,10)*1e3,i=new Date().getTime(),s=n+a>i;return t&&s}async getPKCECode(e,t){return await this.storageManager.getTemporaryDataParameter(oe(e),t)}async setPKCECode(e,t,n){return this.storageManager.setTemporaryDataParameter(oe(t),e,n)}static isSignOutSuccessful(e){let t=new URL(e),n=t.searchParams.get(k.Params.STATE),o=!!t.searchParams.get("error");return n?n===k.Params.SIGN_OUT_SUCCESS&&!o:!1}static didSignOutFail(e){let t=new URL(e),n=t.searchParams.get(k.Params.STATE),o=!!t.searchParams.get("error");return n?n===k.Params.SIGN_OUT_SUCCESS&&o:!1}async reInitialize(e){let t=this.storageManager.getConfigData(),n=qo(t,e);await this.storageManager.setConfigData(n),await this.loadOpenIDProviderConfiguration(!0)}static async clearSession(e){await this.authHelperInstance.clearSession(e)}};R(br,"authHelperInstance");var ae=br;var yr;(r=>{r.DEFAULT_AUTHENTICATOR_NAME="Username & Password"})(yr||(yr={}));var ta="\\u{1F6E1}\\uFE0F Asgardeo",ra={level:"info",prefix:`${ta}`,showLevel:!0,timestamps:!0},na=()=>typeof window<"u"&&typeof window.document<"u",oa=()=>typeof process<"u"&&process.versions&&process.versions.node,L={blue:"\\x1B[34m",bright:"\\x1B[1m",cyan:"\\x1B[36m",dim:"\\x1B[2m",gray:"\\x1B[90m",green:"\\x1B[32m",magenta:"\\x1B[35m",red:"\\x1B[31m",reset:"\\x1B[0m",white:"\\x1B[37m",yellow:"\\x1B[33m"},ge={debug:"color: #6b7280; font-weight: normal;",error:"color: #dc2626; font-weight: bold;",info:"color: #2563eb; font-weight: bold;",prefix:"color: #7c3aed; font-weight: bold;",timestamp:"color: #6b7280; font-size: 0.9em;",warn:"color: #d97706; font-weight: bold;"},wr={debug:0,error:3,info:1,warn:2},aa=class me{constructor(e={}){R(this,"config"),this.config={...ra,...e}}configure(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}shouldLog(e){return wr[e]>=wr[this.config.level]}static getTimestamp(){return new Date().toISOString()}static getLevelString(e){switch(e){case"debug":return"DEBUG";case"info":return"INFO";case"warn":return"WARN";case"error":return"ERROR";default:return"UNKNOWN"}}formatForNode(e,t){let n=[];if(this.config.timestamps&&n.push(`${L.gray}[${me.getTimestamp()}]${L.reset}`),this.config.prefix&&n.push(`${L.magenta}${this.config.prefix}${L.reset}`),this.config.showLevel){let o=me.getLevelString(e),a;switch(e){case"debug":a=`${L.gray}[${o}]${L.reset}`;break;case"info":a=`${L.blue}[${o}]${L.reset}`;break;case"warn":a=`${L.yellow}[${o}]${L.reset}`;break;case"error":a=`${L.red}[${o}]${L.reset}`;break;default:a=`[${o}]`}n.push(a)}return n.push(t),n.join(" ")}logMessage(e,t,...n){if(this.shouldLog(e)){if(this.config.formatter){this.config.formatter(e,t,...n);return}na()?this.logToBrowser(e,t,...n):oa()?this.logToNode(e,t,...n):console.log(t,...n)}}logToBrowser(e,t,...n){let o=[],a=[];if(this.config.timestamps&&(o.push(`%c[${me.getTimestamp()}]`),a.push(ge.timestamp)),this.config.prefix&&(o.push(`%c${this.config.prefix}`),a.push(ge.prefix)),this.config.showLevel){let s=me.getLevelString(e);switch(o.push(`%c[${s}]`),e){case"debug":a.push(ge.debug);break;case"info":a.push(ge.info);break;case"warn":a.push(ge.warn);break;case"error":a.push(ge.error);break;default:a.push("")}}o.push(`%c${t}`),a.push("color: inherit; font-weight: normal;");let i=o.join(" ");switch(e){case"debug":console.debug(i,...a,...n);break;case"info":console.info(i,...a,...n);break;case"warn":console.warn(i,...a,...n);break;case"error":console.error(i,...a,...n);break;default:console.log(i,...a,...n)}}logToNode(e,t,...n){let o=this.formatForNode(e,t);switch(e){case"debug":console.debug(o,...n);break;case"info":console.info(o,...n);break;case"warn":console.warn(o,...n);break;case"error":console.error(o,...n);break;default:console.log(o,...n)}}debug(e,...t){this.logMessage("debug",e,...t)}info(e,...t){this.logMessage("info",e,...t)}warn(e,...t){this.logMessage("warn",e,...t)}error(e,...t){this.logMessage("error",e,...t)}child(e){let t=this.config.prefix?`${this.config.prefix} - ${e}`:e;return new me({...this.config,prefix:t})}setLevel(e){this.config.level=e}getLevel(){return this.config.level}},ja=new aa;var ia=/\\{\\{\\s*([^}]+)\\s*\\}\\}/;var za=new RegExp(ia.source,"g");var Rr=class vr{constructor(e=!0,t=()=>Promise.resolve()){this.isHandlerEnabled=e,this.attachToken=t,R(this,"requestStartCallback",()=>null),R(this,"requestSuccessCallback",()=>null),R(this,"requestErrorCallback",()=>null),R(this,"requestFinishCallback",()=>null)}async request(e){let t=await this.requestHandler(e);try{let n=await this.transport(t);return this.successHandler(n)}catch(n){throw this.errorHandler(n),n}}enableHandler(){this.isHandlerEnabled=!0}disableHandler(){this.isHandlerEnabled=!1}disableHandlerWithTimeout(e=vr.DEFAULT_HANDLER_DISABLE_TIMEOUT){this.isHandlerEnabled=!1,setTimeout(()=>{this.isHandlerEnabled=!0},e)}setHttpRequestStartCallback(e){this.requestStartCallback=e}setHttpRequestSuccessCallback(e){this.requestSuccessCallback=e}setHttpRequestErrorCallback(e){this.requestErrorCallback=e}setHttpRequestFinishCallback(e){this.requestFinishCallback=e}all(e){return Promise.all(e)}spread(e){return t=>e(...t)}async requestHandler(e){if(await this.attachToken(e),e.shouldEncodeToFormData&&e.data){let t=new FormData;Object.keys(e.data).forEach(n=>t.append(n,e.data[n])),e.data=t}return e.startTimeInMs=Date.now(),this.isHandlerEnabled&&typeof this.requestStartCallback=="function"&&this.requestStartCallback(e),e}successHandler(e){return this.isHandlerEnabled&&(typeof this.requestSuccessCallback=="function"&&this.requestSuccessCallback(e),typeof this.requestFinishCallback=="function"&&this.requestFinishCallback()),e}errorHandler(e){this.isHandlerEnabled&&(typeof this.requestErrorCallback=="function"&&this.requestErrorCallback(e),typeof this.requestFinishCallback=="function"&&this.requestFinishCallback())}};R(Rr,"DEFAULT_HANDLER_DISABLE_TIMEOUT",1e3);var _r=Rr;var yt="init";var Ar="sign-out",xr="http-request",Cr="http-request-all",Or="request-custom-grant",Pr="revoke-access-token";var Ur="request-start",kr="request-success";var Nr="request-finish",Dr="get-oidc-service-endpoints",Mr="get-basic-user-info",$r="get-decoded-id-token";var Hr="get-crypto-helper",Br="enable_http_handler",Lr="disable_http_handler",Fr="get_auth_url",Kr="request_get_token",Wr="is_authenticated",jr="get_sign_out_url",zr="refresh_access-token",qr="refresh-access-token-error",Jr="set_session_state",Gr="start_auto_refresh_token",Vr="update_config",Xr="get_id_token",wt="check_session_signed_in",St="check_session_signed_out",Yr="get_config_data";var Et="rpIFrame",Tt="promptNoneIFrame";var bt="sign-in-silently";var It="initialized-silent-sign-in",Rt="promptNoneRequestSent";var ye="error",Oe="error_description",vt="custom_grant_config",_t="state";var At="Access token is invalid";var m=class{constructor(){}static generateSuccessMessage(e){return{blob:e?.data instanceof Blob?e?.data:null,data:JSON.stringify(e??""),success:!0}}static generateFailureMessage(e){e?.toJSON&&delete e.toJSON;let t;try{if(e instanceof Error)t=JSON.stringify({name:e.name,message:e.message,stack:e.stack,...e});else if(typeof e=="object"&&e!==null)try{t=JSON.stringify(e)}catch{t=JSON.stringify({message:e.toString?e.toString():"Unknown error",originalError:String(e)})}else t=JSON.stringify(e??"Unknown error")}catch{t=JSON.stringify({message:"Error serialization failed",originalError:String(e)})}return{error:t,success:!1}}};var Q=class Q{constructor(){}static removeAuthorizationCode(){let e=location.href;history.pushState({},document.title,e.replace(/\\?code=.*$/,""))}static getPKCE(e){return sessionStorage.getItem(e)??""}static setPKCE(e,t){sessionStorage.setItem(e,t)}static setSignOutURL(e,t,n){sessionStorage.setItem(`${k.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${n}-${t}`,e)}static getSignOutUrl(e,t){return sessionStorage.getItem(`${k.SignOut.Storage.StorageKeys.SIGN_OUT_URL}-instance_${t}-${e}`)??""}static removePKCE(e){sessionStorage.removeItem(e)}static canContinueSignIn(e,t){return!(e&&!Q.hasErrorInURL()&&!Q.hasAuthSearchParamsInURL()&&!t)}static isInitializedSilentSignIn(){return Q.isSilentStatePresentInURL()}static wasSignInCalled(){return!!((Q.hasErrorInURL()||Q.hasAuthSearchParamsInURL())&&!this.isSilentStatePresentInURL())}static wasSilentSignInCalled(){let e=sessionStorage.getItem(It);return!!(e?JSON.parse(e):null)}static async isSignOutSuccessful(){if(ae.isSignOutSuccessful(window.location.href)){let e=window.location.href.split("?")[0];return history.pushState({},document.title,e),await ae.clearSession(),!0}return!1}static didSignOutFail(){if(ae.didSignOutFail(window.location.href)){let e=new URL(window.location.href),t=e.searchParams.get(ye),n=e.searchParams.get(Oe),o=window.location.href.split("?")[0];return history.pushState({},document.title,o),{description:n??"",error:t??""}}return!1}static isSilentStatePresentInURL(){return new URL(window.location.href).searchParams.get("state")?.includes(bt)??!1}static hasAuthSearchParamsInURL(e=window.location.search){return/[?&]code=[^&]+/.test(e)}static hasErrorInURL(e=window.location.href){let t=new URL(e);return!!t.searchParams.get(ye)&&t.searchParams.get(_t)!==k.Params.SIGN_OUT_SUCCESS}static canSendPromptNoneRequest(){let e=sessionStorage.getItem(Rt);return!(e?JSON.parse(e):null)}static setPromptNoneRequestSent(e){sessionStorage.setItem(Rt,JSON.stringify(e))}static async waitTillPageRedirect(e){let t=e??3e3;await new Promise(n=>setTimeout(n,t*1e3))}};y(Q,"until",(e,t=500)=>{let n=o=>e()?o():setTimeout(()=>n(o),t);return new Promise(n)});var ee=Q;var je=class{constructor(e,t){y(this,"_authenticationClient");y(this,"_storageManager");y(this,"_spaHelper");y(this,"_instanceId");y(this,"_isTokenRefreshing");this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager(),this._spaHelper=t,this._instanceId=this._authenticationClient.getInstanceId(),this._isTokenRefreshing=!1}enableHttpHandler(e){e?.enableHandler&&e.enableHandler()}disableHttpHandler(e){e?.disableHandler&&e.disableHandler()}initializeSessionManger(e,t,n,o,a){a.initialize(e.clientId,t.checkSessionIframe??"",n,e.checkSessionInterval??3,e.sessionRefreshInterval??300,e.afterSignInUrl,o)}async exchangeToken(e,t){let n=await this._storageManager.getConfigData(),o=!0,a=!1;if(e?.tokenEndpoint)if(o=!1,n.storage==="webWorker"){for(let i of[...n?.allowedExternalUrls??[],e.baseUrl])if(i&&e.tokenEndpoint?.startsWith(i)){a=!0;break}}else a=!0;return e.shouldReplayAfterRefresh&&this._storageManager.setTemporaryDataParameter(vt,JSON.stringify(e)),o||a?this._authenticationClient.exchangeToken(e).then(async i=>(t&&typeof t=="function"&&t(e),e.returnsSession?(this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()):i)).catch(i=>Promise.reject(i)):Promise.reject(new w("SPA-MAIN_THREAD_CLIENT-RCG-IV01","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified token endpoint in this request cannot be found among the `allowedExternalUrls`"))}async getCustomGrantConfigData(){let e=await this._storageManager.getTemporaryDataParameter(vt);return e?JSON.parse(e):null}async refreshAccessToken(e){try{await this._authenticationClient.refreshAccessToken();let t=await this.getCustomGrantConfigData();return t&&await this.exchangeToken(t,e),this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser()}catch(t){let n={type:qr};return window.postMessage(n),Promise.reject(t)}}async retryFailedRequests(e){let t=e.httpClient,n=e.requestConfig,o=e.isHttpHandlerEnabled,a=e.httpErrorCallback,i=e.httpFinishCallback;await ee.until(()=>!this._isTokenRefreshing);try{let s=await t.request(n);return Promise.resolve(s)}catch(s){return o&&(typeof a=="function"&&await a(s),typeof i=="function"&&i()),Promise.reject(s)}}async httpRequest(e,t,n,o,a,i){let s=!1,l=await this._storageManager.getConfigData();if(l.storage==="webWorker"){for(let c of[...l?.allowedExternalUrls??[],l.baseUrl])if(c&&t?.url?.startsWith(c)){s=!0;break}}else s=!0;return s?e.request(t).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){if(this._isTokenRefreshing)return this.retryFailedRequests({enableRetrievingSignOutURLFromSession:i,httpClient:e,httpErrorCallback:o,httpFinishCallback:a,isHttpHandlerEnabled:n,requestConfig:t});this._isTokenRefreshing=!0;let d;try{d=await this.refreshAccessToken(i),this._isTokenRefreshing=!1}catch(u){throw this._isTokenRefreshing=!1,n&&(typeof o=="function"&&await o({...c,code:At}),typeof a=="function"&&a()),new w("SPA-AUTH_HELPER-HR-SE01",u?.name??"Refresh token request failed.",u?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(d)try{let u=await e.request(t);return Promise.resolve(u)}catch(u){return n&&(typeof o=="function"&&await o(u),typeof a=="function"&&a()),Promise.reject(u)}}return n&&(typeof o=="function"&&await o(c),typeof a=="function"&&a()),Promise.reject(c)}):Promise.reject(new w("SPA-AUTH_HELPER-HR-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`"))}async httpRequestAll(e,t,n,o,a){let i=!0,s=await this._storageManager.getConfigData();if(s.storage==="webWorker")for(let c of e){let d=!1;for(let u of[...s?.allowedExternalUrls??[],s.baseUrl])if(u&&c.url?.startsWith(u)){d=!0;break}if(!d){i=!1;break}}let l=[];if(i)return e.forEach(c=>{l.push(t.request(c))}),t?.all&&t.all(l).then(c=>Promise.resolve(c)).catch(async c=>{if(c?.response?.status===401||!c?.response){let d;try{d=await this._authenticationClient.refreshAccessToken()}catch(u){throw n&&(typeof o=="function"&&await o({...c,code:At}),typeof a=="function"&&a()),new w("SPA-AUTH_HELPER-HRA-SE01",u?.name??"Refresh token request failed.",u?.message??"An error occurred while trying to refresh the access token following a 401 response from the server.")}if(d)return t.all&&t.all(l).then(u=>Promise.resolve(u)).catch(async u=>(n&&(typeof o=="function"&&await o(u),typeof a=="function"&&a()),Promise.reject(u)))}return n&&(typeof o=="function"&&await o(c),typeof a=="function"&&a()),Promise.reject(c)});throw new w("SPA-AUTH_HELPER-HRA-IV02","Request to the provided endpoint is prohibited.","Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`")}async requestAccessToken(e,t,n,o,a,i){let s=await this._storageManager.getConfigData();if(s.storage==="browserMemory"&&s.enablePKCE&&t){let l=ee.getPKCE(oe(t));await this._authenticationClient.setPKCECode(oe(t),l)}else s.storage==="webWorker"&&o&&await this._authenticationClient.setPKCECode(o,a??"");return e?this._authenticationClient.requestAccessToken(e,t??"",a??"",void 0,i).then(async()=>(s.storage!=="webWorker"?(ee.setSignOutURL(await this._authenticationClient.getSignOutUrl(),s.clientId,this._instanceId),this._spaHelper&&(this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this)),n&&typeof n=="function"&&s.syncSession&&n()):this._spaHelper&&this._spaHelper.refreshAccessTokenAutomatically(this),this._authenticationClient.getUser())).catch(l=>Promise.reject(l)):Promise.reject(new w("SPA-AUTH_HELPER-RAT1-NF01","No authorization code.","No authorization code was found."))}async signInSilently(e,t,n,o,a){if(ee.isInitializedSilentSignIn())return await n.receivePromptNoneResponse(),Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});let s=document.getElementById(Et)?.contentDocument?.getElementById(Tt);try{let l=await e(o);s.src=l}catch(l){return Promise.reject(l)}return new Promise((l,c)=>{let d=setTimeout(()=>{l(!1)},1e4),u=async p=>{let h=p.data;h?.type==St&&(window.removeEventListener("message",u),clearTimeout(d),l(!1)),h?.type==wt&&h?.data?.code&&t(h?.data?.code,h?.data?.sessionState,h?.data?.state,a).then(g=>{window.removeEventListener("message",u),l(g)}).catch(g=>{window.removeEventListener("message",u),c(g)}).finally(()=>{clearTimeout(d)})};window.addEventListener("message",u)})}async handleSignIn(e,t,n){let o=await this._storageManager.getConfigData();if(await e())return Promise.resolve({allowedScopes:"",displayName:"",email:"",sessionState:"",sub:"",tenantDomain:"",username:""});if(o.storage!=="webWorker"&&await this._authenticationClient.isSignedIn())return this._spaHelper.clearRefreshTokenTimeout(),this._spaHelper.refreshAccessTokenAutomatically(this),o.syncSession&&t(),Promise.resolve(await this._authenticationClient.getUser());let a=new URL(window.location.href).searchParams.get(ye),i=new URL(window.location.href).searchParams.get(Oe);if(a){let s=new URL(window.location.href);throw s.searchParams.delete(ye),s.searchParams.delete(Oe),history.pushState(null,document.title,s.toString()),new w("SPA-AUTH_HELPER-SI-SE01",a,i??"")}if(o.storage==="webWorker"&&n){let s=await n();if(s)return s}return Promise.resolve(void 0)}async attachTokenToRequestConfig(e){let t={attachToken:!0,...e};t.attachToken&&(t.shouldAttachIDPAccessToken?e.headers={...e.headers,Authorization:`Bearer ${await this.getIDPAccessToken()}`}:e.headers={...e.headers,Authorization:`Bearer ${await this.getAccessToken()}`})}async getUser(){return this._authenticationClient.getUser()}async getDecodedIdToken(e){return this._authenticationClient.getDecodedIdToken(e)}async getDecodedIDPIDToken(){return this._authenticationClient.getDecodedIdToken()}async getCrypto(){return this._authenticationClient.getCrypto()}async getIdToken(){return this._authenticationClient.getIdToken()}async getOpenIDProviderEndpoints(){return this._authenticationClient.getOpenIDProviderEndpoints()}async getAccessToken(e){return this._authenticationClient.getAccessToken(e)}async getIDPAccessToken(){return(await this._storageManager.getSessionData())?.access_token}getStorageManager(){return this._storageManager}async isSignedIn(){return this._authenticationClient.isSignedIn()}};var ze=class{constructor(e){y(this,"_authenticationClient");y(this,"_storageManager");this._authenticationClient=e,this._storageManager=this._authenticationClient.getStorageManager()}async refreshAccessTokenAutomatically(e){if(!((await this._storageManager.getConfigData())?.periodicTokenRefresh??!1))return;let n=await this._storageManager.getSessionData();if(n.refresh_token){let o=parseInt(n.expires_in),a=o<=10?o:o-10,i=setTimeout(async()=>{await e.refreshAccessToken()},a*1e3);await this._storageManager.setTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER,JSON.stringify(i))}}async getRefreshTimeoutTimer(){return await this._storageManager.getTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER)?JSON.parse(await this._storageManager.getTemporaryDataParameter(Ce.Storage.StorageKeys.REFRESH_TOKEN_TIMER)):-1}async clearRefreshTokenTimeout(e){if(e){clearTimeout(e);return}let t=await this.getRefreshTimeoutTimer();t!==-1&&clearTimeout(t)}};var Je=class Je extends _r{static getInstance(e=0,t=!0,n=()=>Promise.resolve()){return this.instances.has(e)||this.instances.set(e,new Je(t,n)),this.instances.get(e)}static destroyInstance(e=0){this.instances.delete(e)}async transport(e){let t=e.url??"";if(e.params){let c=new URLSearchParams(e.params).toString();c&&(t=`${t}?${c}`)}let n={...e.headers??{}},o;e.data!==void 0&&(e.data instanceof FormData?o=e.data:(o=JSON.stringify(e.data),!n["Content-Type"]&&!n["content-type"]&&(n["Content-Type"]="application/json")));let a;try{a=await fetch(t,{body:o,credentials:"include",headers:n,method:(e.method??"GET").toUpperCase()})}catch(c){throw Object.assign(new Error(c.message),{code:"NETWORK_ERROR",config:e})}let s=(a.headers.get("content-type")??"").includes("application/json")?await a.json():await a.text(),l={};if(a.headers.forEach((c,d)=>{l[d]=c}),!a.ok)throw Object.assign(new Error(a.statusText),{config:e,response:{data:s,headers:l,status:a.status,statusText:a.statusText}});return{config:e,data:s,headers:l,status:a.status,statusText:a.statusText}}};y(Je,"instances",new Map);var qe=Je;var Ge=class{constructor(){y(this,"_data");this._data=new Map}async setData(e,t){this._data.set(e,t)}async getData(e){return this._data?.get(e)??"{}"}async removeData(e){this._data.delete(e)}};var Mn=_e(Ke(),1);var zt=_e(tn(),1),$n=_e(nn(),1);var Se=new TextEncoder,G=new TextDecoder,ys=2**32;function on(...r){let e=r.reduce((o,{length:a})=>o+a,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function an(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function te(r){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof r=="string"?r:G.decode(r),{alphabet:"base64url"});let e=r;e instanceof Uint8Array&&(e=G.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\\s/g,"");try{return an(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}var H=class extends Error{constructor(t,n){super(t,n);y(this,"code","ERR_JOSE_GENERIC");this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};y(H,"code","ERR_JOSE_GENERIC");var $=class extends H{constructor(t,n,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:n}});y(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");y(this,"claim");y(this,"reason");y(this,"payload");this.claim=o,this.reason=a,this.payload=n}};y($,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");var Ee=class extends H{constructor(t,n,o="unspecified",a="unspecified"){super(t,{cause:{claim:o,reason:a,payload:n}});y(this,"code","ERR_JWT_EXPIRED");y(this,"claim");y(this,"reason");y(this,"payload");this.claim=o,this.reason=a,this.payload=n}};y(Ee,"code","ERR_JWT_EXPIRED");var Pe=class extends H{constructor(){super(...arguments);y(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}};y(Pe,"code","ERR_JOSE_ALG_NOT_ALLOWED");var N=class extends H{constructor(){super(...arguments);y(this,"code","ERR_JOSE_NOT_SUPPORTED")}};y(N,"code","ERR_JOSE_NOT_SUPPORTED");var _=class extends H{constructor(){super(...arguments);y(this,"code","ERR_JWS_INVALID")}};y(_,"code","ERR_JWS_INVALID");var ie=class extends H{constructor(){super(...arguments);y(this,"code","ERR_JWT_INVALID")}};y(ie,"code","ERR_JWT_INVALID");var Te=class extends H{constructor(){super(...arguments);y(this,"code","ERR_JWKS_INVALID")}};y(Te,"code","ERR_JWKS_INVALID");var Ue=class extends H{constructor(t="no applicable key found in the JSON Web Key Set",n){super(t,n);y(this,"code","ERR_JWKS_NO_MATCHING_KEY")}};y(Ue,"code","ERR_JWKS_NO_MATCHING_KEY");var sn,cn,ke=class extends(cn=H,sn=Symbol.asyncIterator,cn){constructor(t="multiple matching keys found in the JSON Web Key Set",n){super(t,n);y(this,sn);y(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}};y(ke,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var Ne=class extends H{constructor(t="signature verification failed",n){super(t,n);y(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}};y(Ne,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");function V(r,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${r}`)}function De(r,e){return r.name===e}function Ut(r){return parseInt(r.name.slice(4),10)}function ha(r){switch(r){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function ga(r,e){if(e&&!r.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function ln(r,e,t){switch(e){case"HS256":case"HS384":case"HS512":{if(!De(r.algorithm,"HMAC"))throw V("HMAC");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw V(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!De(r.algorithm,"RSASSA-PKCS1-v1_5"))throw V("RSASSA-PKCS1-v1_5");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw V(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!De(r.algorithm,"RSA-PSS"))throw V("RSA-PSS");let n=parseInt(e.slice(2),10);if(Ut(r.algorithm.hash)!==n)throw V(`SHA-${n}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":{if(!De(r.algorithm,"Ed25519"))throw V("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!De(r.algorithm,"ECDSA"))throw V("ECDSA");let n=ha(e);if(r.algorithm.namedCurve!==n)throw V(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}ga(r,t)}function un(r,e,...t){if(t=t.filter(Boolean),t.length>2){let n=t.pop();r+=`one of type ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of type ${t[0]} or ${t[1]}.`:r+=`of type ${t[0]}.`;return e==null?r+=` Received ${e}`:typeof e=="function"&&e.name?r+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(r+=` Received an instance of ${e.constructor.name}`),r}var dn=(r,...e)=>un("Key must be ",r,...e);function kt(r,e,...t){return un(`Key for the ${r} algorithm must be `,e,...t)}function Nt(r){return r?.[Symbol.toStringTag]==="CryptoKey"}function Dt(r){return r?.[Symbol.toStringTag]==="KeyObject"}var Mt=r=>Nt(r)||Dt(r);var fn=(...r)=>{let e=r.filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(let n of e){let o=Object.keys(n);if(!t||t.size===0){t=new Set(o);continue}for(let a of o){if(t.has(a))return!1;t.add(a)}}return!0};function ma(r){return typeof r=="object"&&r!==null}var K=r=>{if(!ma(r)||Object.prototype.toString.call(r)!=="[object Object]")return!1;if(Object.getPrototypeOf(r)===null)return!0;let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e};var pn=(r,e)=>{if(r.startsWith("RS")||r.startsWith("PS")){let{modulusLength:t}=e.algorithm;if(typeof t!="number"||t<2048)throw new TypeError(`${r} requires key modulusLength to be 2048 bits or larger`)}};function ya(r){let e,t;switch(r.kty){case"RSA":{switch(r.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.alg.slice(-3)}`},t=r.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(r.alg.slice(-3),10)||1}`},t=r.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new N(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"EC":{switch(r.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},t=r.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},t=r.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new N(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}case"OKP":{switch(r.alg){case"Ed25519":case"EdDSA":e={name:"Ed25519"},t=r.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:r.crv},t=r.d?["deriveBits"]:[];break;default:throw new N(\'Invalid or unsupported JWK "alg" (Algorithm) Parameter value\')}break}default:throw new N(\'Invalid or unsupported JWK "kty" (Key Type) Parameter value\')}return{algorithm:e,keyUsages:t}}var Ye=async r=>{if(!r.alg)throw new TypeError(\'"alg" argument is required when "jwk.alg" is not present\');let{algorithm:e,keyUsages:t}=ya(r),n={...r};return delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,e,r.ext??!r.d,r.key_ops??t)};async function hn(r,e,t){if(!K(r))throw new TypeError("JWK must be an object");let n;switch(e??(e=r.alg),n??(n=t?.extractable??r.ext),r.kty){case"oct":if(typeof r.k!="string"||!r.k)throw new TypeError(\'missing "k" (Key Value) Parameter value\');return te(r.k);case"RSA":if("oth"in r&&r.oth!==void 0)throw new N(\'RSA JWK "oth" (Other Primes Info) Parameter value is not supported\');case"EC":case"OKP":return Ye({...r,alg:e,ext:n});default:throw new N(\'Unsupported "kty" (Key Type) Parameter value\')}}var gn=(r,e,t,n,o)=>{if(o.crit!==void 0&&n?.crit===void 0)throw new r(\'"crit" (Critical) Header Parameter MUST be integrity protected\');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(i=>typeof i!="string"||i.length===0))throw new r(\'"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present\');let a;t!==void 0?a=new Map([...Object.entries(t),...e.entries()]):a=e;for(let i of n.crit){if(!a.has(i))throw new N(`Extension Header Parameter "${i}" is not recognized`);if(o[i]===void 0)throw new r(`Extension Header Parameter "${i}" is missing`);if(a.get(i)&&n[i]===void 0)throw new r(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(n.crit)};var mn=(r,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new TypeError(`"${r}" option must be an array of strings`);if(e)return new Set(e)};function Me(r){return K(r)&&typeof r.kty=="string"}function yn(r){return r.kty!=="oct"&&typeof r.d=="string"}function wn(r){return r.kty!=="oct"&&typeof r.d>"u"}function Sn(r){return r.kty==="oct"&&typeof r.k=="string"}var be,En=async(r,e,t,n=!1)=>{be||(be=new WeakMap);let o=be.get(r);if(o?.[t])return o[t];let a=await Ye({...e,alg:t});return n&&Object.freeze(r),o?o[t]=a:be.set(r,{[t]:a}),a},Sa=(r,e)=>{be||(be=new WeakMap);let t=be.get(r);if(t?.[e])return t[e];let n=r.type==="public",o=!!n,a;if(r.asymmetricKeyType==="x25519"){switch(e){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}a=r.toCryptoKey(r.asymmetricKeyType,o,n?[]:["deriveBits"])}if(r.asymmetricKeyType==="ed25519"){if(e!=="EdDSA"&&e!=="Ed25519")throw new TypeError("given KeyObject instance cannot be used for this algorithm");a=r.toCryptoKey(r.asymmetricKeyType,o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="rsa"){let i;switch(e){case"RSA-OAEP":i="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":i="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":i="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":i="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(e.startsWith("RSA-OAEP"))return r.toCryptoKey({name:"RSA-OAEP",hash:i},o,n?["encrypt"]:["decrypt"]);a=r.toCryptoKey({name:e.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:i},o,[n?"verify":"sign"])}if(r.asymmetricKeyType==="ec"){let s=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(r.asymmetricKeyDetails?.namedCurve);if(!s)throw new TypeError("given KeyObject instance cannot be used for this algorithm");e==="ES256"&&s==="P-256"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e==="ES384"&&s==="P-384"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e==="ES512"&&s==="P-521"&&(a=r.toCryptoKey({name:"ECDSA",namedCurve:s},o,[n?"verify":"sign"])),e.startsWith("ECDH-ES")&&(a=r.toCryptoKey({name:"ECDH",namedCurve:s},o,n?[]:["deriveBits"]))}if(!a)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return t?t[e]=a:be.set(r,{[e]:a}),a},Tn=async(r,e)=>{if(r instanceof Uint8Array||Nt(r))return r;if(Dt(r)){if(r.type==="secret")return r.export();if("toCryptoKey"in r&&typeof r.toCryptoKey=="function")try{return Sa(r,e)}catch(n){if(n instanceof TypeError)throw n}let t=r.export({format:"jwk"});return En(r,t,e)}if(Me(r))return r.k?te(r.k):En(r,r,e,!0);throw new Error("unreachable")};var Ie=r=>r?.[Symbol.toStringTag],$t=(r,e,t)=>{if(e.use!==void 0){let n;switch(t){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(e.use!==n)throw new TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(e.alg!==void 0&&e.alg!==r)throw new TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);if(Array.isArray(e.key_ops)){let n;switch(!0){case(t==="sign"||t==="verify"):case r==="dir":case r.includes("CBC-HS"):n=t;break;case r.startsWith("PBES2"):n="deriveBits";break;case/^A\\d{3}(?:GCM)?(?:KW)?$/.test(r):!r.includes("GCM")&&r.endsWith("KW")?n=t==="encrypt"?"wrapKey":"unwrapKey":n=t;break;case(t==="encrypt"&&r.startsWith("RSA")):n="wrapKey";break;case t==="decrypt":n=r.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&e.key_ops?.includes?.(n)===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},Ea=(r,e,t)=>{if(!(e instanceof Uint8Array)){if(Me(e)){if(Sn(e)&&$t(r,e,t))return;throw new TypeError(\'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present\')}if(!Mt(e))throw new TypeError(kt(r,e,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Ie(e)} instances for symmetric algorithms must be of type "secret"`)}},Ta=(r,e,t)=>{if(Me(e))switch(t){case"decrypt":case"sign":if(yn(e)&&$t(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(wn(e)&&$t(r,e,t))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!Mt(e))throw new TypeError(kt(r,e,"CryptoKey","KeyObject","JSON Web Key"));if(e.type==="secret")throw new TypeError(`${Ie(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.type==="public")switch(t){case"sign":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm decryption must be of type "private"`);default:break}if(e.type==="private")switch(t){case"verify":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Ie(e)} instances for asymmetric algorithm encryption must be of type "public"`);default:break}},bn=(r,e,t)=>{r.startsWith("HS")||r==="dir"||r.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(r)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(r)?Ea(r,e,t):Ta(r,e,t)};var In=(r,e)=>{let t=`SHA-${r.slice(-3)}`;switch(r){case"HS256":case"HS384":case"HS512":return{hash:t,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:t,name:"RSA-PSS",saltLength:parseInt(r.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:t,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:t,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};default:throw new N(`alg ${r} is not supported either by JOSE or your javascript runtime`)}};var Rn=async(r,e,t)=>{if(e instanceof Uint8Array){if(!r.startsWith("HS"))throw new TypeError(dn(e,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",e,{hash:`SHA-${r.slice(-3)}`,name:"HMAC"},!1,[t])}return ln(e,r,t),e};var vn=async(r,e,t,n)=>{let o=await Rn(r,e,"verify");pn(r,o);let a=In(r,o.algorithm);try{return await crypto.subtle.verify(a,o,t,n)}catch{return!1}};async function _n(r,e,t){if(!K(r))throw new _("Flattened JWS must be an object");if(r.protected===void 0&&r.header===void 0)throw new _(\'Flattened JWS must have either of the "protected" or "header" members\');if(r.protected!==void 0&&typeof r.protected!="string")throw new _("JWS Protected Header incorrect type");if(r.payload===void 0)throw new _("JWS Payload missing");if(typeof r.signature!="string")throw new _("JWS Signature missing or incorrect type");if(r.header!==void 0&&!K(r.header))throw new _("JWS Unprotected Header incorrect type");let n={};if(r.protected)try{let T=te(r.protected);n=JSON.parse(G.decode(T))}catch{throw new _("JWS Protected Header is invalid")}if(!fn(n,r.header))throw new _("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...n,...r.header},a=gn(_,new Map([["b64",!0]]),t?.crit,n,o),i=!0;if(a.has("b64")&&(i=n.b64,typeof i!="boolean"))throw new _(\'The "b64" (base64url-encode payload) Header Parameter must be a boolean\');let{alg:s}=o;if(typeof s!="string"||!s)throw new _(\'JWS "alg" (Algorithm) Header Parameter missing or invalid\');let l=t&&mn("algorithms",t.algorithms);if(l&&!l.has(s))throw new Pe(\'"alg" (Algorithm) Header Parameter value not allowed\');if(i){if(typeof r.payload!="string")throw new _("JWS Payload must be a string")}else if(typeof r.payload!="string"&&!(r.payload instanceof Uint8Array))throw new _("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof e=="function"&&(e=await e(n,r),c=!0),bn(s,e,"verify");let d=on(Se.encode(r.protected??""),Se.encode("."),typeof r.payload=="string"?Se.encode(r.payload):r.payload),u;try{u=te(r.signature)}catch{throw new _("Failed to base64url decode the signature")}let p=await Tn(e,s);if(!await vn(s,p,u,d))throw new Ne;let g;if(i)try{g=te(r.payload)}catch{throw new _("Failed to base64url decode the payload")}else typeof r.payload=="string"?g=Se.encode(r.payload):g=r.payload;let S={payload:g};return r.protected!==void 0&&(S.protectedHeader=n),r.header!==void 0&&(S.unprotectedHeader=r.header),c?{...S,key:p}:S}async function An(r,e,t){if(r instanceof Uint8Array&&(r=G.decode(r)),typeof r!="string")throw new _("Compact JWS must be a string or Uint8Array");let{0:n,1:o,2:a,length:i}=r.split(".");if(i!==3)throw new _("Invalid Compact JWS");let s=await _n({payload:o,protected:n,signature:a},e,t),l={payload:s.payload,protectedHeader:s.protectedHeader};return typeof e=="function"?{...l,key:s.key}:l}var xn=r=>Math.floor(r.getTime()/1e3);var ba=/^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Ht=r=>{let e=ba.exec(r);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let t=parseFloat(e[2]),n=e[3].toLowerCase(),o;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(t);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(t*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(t*3600);break;case"day":case"days":case"d":o=Math.round(t*86400);break;case"week":case"weeks":case"w":o=Math.round(t*604800);break;default:o=Math.round(t*31557600);break}return e[1]==="-"||e[4]==="ago"?-o:o};var Cn=r=>r.includes("/")?r.toLowerCase():`application/${r.toLowerCase()}`,Ia=(r,e)=>typeof r=="string"?e.includes(r):Array.isArray(r)?e.some(Set.prototype.has.bind(new Set(r))):!1;function On(r,e,t={}){let n;try{n=JSON.parse(G.decode(e))}catch{}if(!K(n))throw new ie("JWT Claims Set must be a top-level JSON object");let{typ:o}=t;if(o&&(typeof r.typ!="string"||Cn(r.typ)!==Cn(o)))throw new $(\'unexpected "typ" JWT header value\',n,"typ","check_failed");let{requiredClaims:a=[],issuer:i,subject:s,audience:l,maxTokenAge:c}=t,d=[...a];c!==void 0&&d.push("iat"),l!==void 0&&d.push("aud"),s!==void 0&&d.push("sub"),i!==void 0&&d.push("iss");for(let g of new Set(d.reverse()))if(!(g in n))throw new $(`missing required "${g}" claim`,n,g,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(n.iss))throw new $(\'unexpected "iss" claim value\',n,"iss","check_failed");if(s&&n.sub!==s)throw new $(\'unexpected "sub" claim value\',n,"sub","check_failed");if(l&&!Ia(n.aud,typeof l=="string"?[l]:l))throw new $(\'unexpected "aud" claim value\',n,"aud","check_failed");let u;switch(typeof t.clockTolerance){case"string":u=Ht(t.clockTolerance);break;case"number":u=t.clockTolerance;break;case"undefined":u=0;break;default:throw new TypeError("Invalid clockTolerance option type")}let{currentDate:p}=t,h=xn(p||new Date);if((n.iat!==void 0||c)&&typeof n.iat!="number")throw new $(\'"iat" claim must be a number\',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new $(\'"nbf" claim must be a number\',n,"nbf","invalid");if(n.nbf>h+u)throw new $(\'"nbf" claim timestamp check failed\',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new $(\'"exp" claim must be a number\',n,"exp","invalid");if(n.exp<=h-u)throw new Ee(\'"exp" claim timestamp check failed\',n,"exp","check_failed")}if(c){let g=h-n.iat,S=typeof c=="number"?c:Ht(c);if(g-u>S)throw new Ee(\'"iat" claim timestamp check failed (too far in the past)\',n,"iat","check_failed");if(g<0-u)throw new $(\'"iat" claim timestamp check failed (it should be in the past)\',n,"iat","check_failed")}return n}async function Bt(r,e,t){let n=await An(r,e,t);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new ie("JWTs MUST NOT use unencoded payload");let a={payload:On(n.protectedHeader,n.payload,t),protectedHeader:n.protectedHeader};return typeof e=="function"?{...a,key:n.key}:a}function Ra(r){switch(typeof r=="string"&&r.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new N(\'Unsupported "alg" value for a JSON Web Key Set\')}}function va(r){return r&&typeof r=="object"&&Array.isArray(r.keys)&&r.keys.every(_a)}function _a(r){return K(r)}var Re,$e,Lt=class{constructor(e){He(this,Re);He(this,$e,new WeakMap);if(!va(e))throw new Te("JSON Web Key Set malformed");nt(this,Re,structuredClone(e))}jwks(){return ue(this,Re)}async getKey(e,t){let{alg:n,kid:o}={...e,...t?.header},a=Ra(n),i=ue(this,Re).keys.filter(c=>{let d=a===c.kty;if(d&&typeof o=="string"&&(d=o===c.kid),d&&typeof c.alg=="string"&&(d=n===c.alg),d&&typeof c.use=="string"&&(d=c.use==="sig"),d&&Array.isArray(c.key_ops)&&(d=c.key_ops.includes("verify")),d)switch(n){case"ES256":d=c.crv==="P-256";break;case"ES384":d=c.crv==="P-384";break;case"ES512":d=c.crv==="P-521";break;case"Ed25519":case"EdDSA":d=c.crv==="Ed25519";break}return d}),{0:s,length:l}=i;if(l===0)throw new Ue;if(l!==1){let c=new ke,d=ue(this,$e);throw c[Symbol.asyncIterator]=async function*(){for(let u of i)try{yield await Pn(d,u,n)}catch{}},c}return Pn(ue(this,$e),s,n)}};Re=new WeakMap,$e=new WeakMap;async function Pn(r,e,t){let n=r.get(e)||r.set(e,{}).get(e);if(n[t]===void 0){let o=await hn({...e,ext:!0},t);if(o instanceof Uint8Array||o.type!=="public")throw new Te("JSON Web Key Set members must be public keys");n[t]=o}return n[t]}function Ft(r){let e=new Lt(r),t=async(n,o)=>e.getKey(n,o);return Object.defineProperties(t,{jwks:{value:()=>structuredClone(e.jwks()),enumerable:!1,configurable:!1,writable:!1}}),t}var Hn=_e(Dn(),1),et=class{base64URLEncode(e){return zt.default.encode(e).replace(/\\+/g,"-").replace(/\\//g,"_").replace(/=/g,"")}base64URLDecode(e){return zt.default.decode(e).toString()}hashSha256(e){return Mn.Buffer.from((0,$n.default)(new TextEncoder().encode(e)))}generateRandomBytes(e){return(0,Hn.default)(e)}verifyJwt(e,t,n,o,a,i,s,l){let c={algorithms:n,audience:[o],clockTolerance:s,subject:i};return(l??!0)&&(c.issuer=a),Bt(e,Ft({keys:[t]}),c).then(()=>Promise.resolve(!0)).catch(d=>Promise.reject(new w("SPA-CRYPTO-UTILS-VJ-IV01",d?.reason??JSON.stringify(d),`${d?.code} ${d?.claim}`)))}};var Bn=async(r,e,t)=>{let n=new Ge,o=new et,a=new ae;await a.initialize(e,n,o,r);let i=new ze(a),s=t(a,i),l=a.getStorageManager(),c=async I=>{await s.attachTokenToRequestConfig(I)},d=qe.getInstance(r,!0,c);return{disableHttpHandler:()=>{s.disableHttpHandler(d)},enableHttpHandler:()=>{s.enableHttpHandler(d)},getAccessToken:()=>s.getAccessToken(),getSignInUrl:async I=>a.getSignInUrl(I).then(async X=>{let tt=new URL(X).searchParams.get(k.Params.STATE)??"",Kn=await a.getPKCECode(tt);return{authorizationURL:X,pkce:Kn}}).catch(X=>Promise.reject(X)),getUser:async()=>s.getUser(),getConfigData:async()=>l.getConfigData(),getCrypto:async()=>s.getCrypto(),getDecodedIDPIDToken:async()=>s.getDecodedIDPIDToken(),getDecodedIdToken:async I=>s.getDecodedIdToken(I),getIdToken:async()=>s.getIdToken(),getOpenIDProviderEndpoints:async()=>s.getOpenIDProviderEndpoints(),getSignOutUrl:async()=>await a.getSignOutUrl(),httpRequest:async I=>await s.httpRequest(d,I),httpRequestAll:async I=>await s.httpRequestAll(I,d),isSignedIn:()=>s.isSignedIn(),refreshAccessToken:async()=>{try{return await s.refreshAccessToken()}catch(I){return Promise.reject(I)}},requestAccessToken:async(I,X,qt,tt)=>await s.requestAccessToken(I,X,void 0,qt,tt),exchangeToken:async I=>await s.exchangeToken(I),revokeAccessToken:async()=>{let I=await i.getRefreshTimeoutTimer();return a.revokeAccessToken().then(()=>(i.clearRefreshTokenTimeout(I),Promise.resolve(!0))).catch(X=>Promise.reject(X))},setHttpRequestFinishCallback:I=>{d?.setHttpRequestFinishCallback&&d.setHttpRequestFinishCallback(I)},setHttpRequestStartCallback:I=>{d?.setHttpRequestStartCallback&&d.setHttpRequestStartCallback(I)},setHttpRequestSuccessCallback:I=>{d?.setHttpRequestSuccessCallback&&d.setHttpRequestSuccessCallback(I)},setSessionState:async I=>{await l.setSessionDataParameter(k.Params.SESSION_STATE,I)},signOut:async()=>(i.clearRefreshTokenTimeout(),await a.getSignOutUrl()),startAutoRefreshToken:async()=>{i.clearRefreshTokenTimeout(),i.refreshAccessTokenAutomatically(s)},reInitialize:async I=>{await a.reInitialize(I)}}};var Ln=r=>{let e=self,t;e.onmessage=async({data:i,ports:s})=>{let l=s[0];if(i.type!==yt&&!t){l.postMessage(m.generateFailureMessage(new w("SPA-CLIENT_WORKER-ONMSG-NF01","The web worker has not been initialized yet.","The initialize method needs to be called before the specified operation can be carried out.")));return}switch(i.type){case yt:try{let c=i.instanceId??0,d={...i.data};t=await Bn(c,d,r),t.setHttpRequestFinishCallback(a),t.setHttpRequestStartCallback(n),t.setHttpRequestSuccessCallback(o),l.postMessage(m.generateSuccessMessage())}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Fr:t.getSignInUrl(i?.data).then(c=>{l.postMessage(m.generateSuccessMessage(c))}).catch(c=>{l.postMessage(m.generateFailureMessage(c))});break;case Kr:t.requestAccessToken(i?.data?.code,i?.data?.sessionState,i?.data?.pkce,i?.data?.state).then(c=>{l.postMessage(m.generateSuccessMessage(c))}).catch(c=>{l.postMessage(m.generateFailureMessage(c))});break;case xr:{let c=i.data,d=c?.data;if(i.data?.data?.formData===!0){let u=new FormData;for(let p in d)p!=="formData"&&u.append(p,d[p]);c.data=u}t.httpRequest(c).then(u=>{l.postMessage(m.generateSuccessMessage(u))}).catch(u=>{l.postMessage(m.generateFailureMessage(u))});break}case Cr:t.httpRequestAll(i.data).then(c=>{l.postMessage(m.generateSuccessMessage(c))}).catch(c=>{l.postMessage(m.generateFailureMessage(c))});break;case Ar:try{l.postMessage(m.generateSuccessMessage(await t.signOut()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Or:t.exchangeToken(i.data).then(c=>{l.postMessage(m.generateSuccessMessage(c))}).catch(c=>{l.postMessage(m.generateFailureMessage(c))});break;case Pr:t.revokeAccessToken().then(c=>{l.postMessage(m.generateSuccessMessage(c))}).catch(c=>{l.postMessage(m.generateFailureMessage(c))});break;case Dr:try{l.postMessage(m.generateSuccessMessage(await t.getOpenIDProviderEndpoints()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Mr:try{l.postMessage(m.generateSuccessMessage(await t.getUser()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case $r:try{l.postMessage(m.generateSuccessMessage(await t.getDecodedIdToken()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Hr:try{l.postMessage(m.generateSuccessMessage(await t.getCrypto()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Xr:try{l.postMessage(m.generateSuccessMessage(await t.getIdToken()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Br:t.enableHttpHandler(),l.postMessage(m.generateSuccessMessage());break;case Lr:t.disableHttpHandler(),l.postMessage(m.generateSuccessMessage());break;case Wr:try{l.postMessage(m.generateSuccessMessage(await t.isSignedIn()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case jr:try{l.postMessage(m.generateSuccessMessage(await t.getSignOutUrl()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case zr:try{l.postMessage(m.generateSuccessMessage(await t.refreshAccessToken()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Gr:try{l.postMessage(m.generateSuccessMessage(t.startAutoRefreshToken()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Jr:try{l.postMessage(m.generateSuccessMessage(await t.setSessionState(i?.data)))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Vr:try{l.postMessage(m.generateSuccessMessage(await t.reInitialize(i?.data)))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;case Yr:try{l.postMessage(m.generateSuccessMessage(await t.getConfigData()))}catch(c){l.postMessage(m.generateFailureMessage(c))}break;default:l?.postMessage(m.generateFailureMessage(new w("SPA-CLIENT_WORKER-ONMSG-IV02","The message type is invalid.",`The message type provided, ${i.type}, is invalid.`)))}};let n=()=>{e.postMessage({type:Ur})},o=i=>{e.postMessage({data:JSON.stringify(i??""),type:kr})},a=()=>{e.postMessage({type:Nr})}};typeof self<"u"&&!self.Buffer&&(self.Buffer=Fn.Buffer);typeof self<"u"&&(self.global||(self.global=self));Ln((r,e)=>new je(r,e));var Tl={};})();\n/*! Bundled license information:\n\nieee754/index.js:\n (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n\nbuffer/index.js:\n (*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n *)\n\nsafe-buffer/index.js:\n (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)\n*/\n');
1963
1957
  }
1964
1958
 
1965
1959
  // src/__legacy__/clients/main-thread-client.ts
1966
- var import_javascript5 = require("@asgardeo/javascript");
1960
+ var import_javascript6 = require("@asgardeo/javascript");
1967
1961
 
1968
1962
  // src/__legacy__/constants/messages-types.ts
1969
1963
  var INIT = "init";
@@ -2519,207 +2513,81 @@ var SPAHelper = class {
2519
2513
  }
2520
2514
  };
2521
2515
 
2522
- // src/__legacy__/http-client/clients/axios-http-client.ts
2523
- var import_axios = __toESM(require("axios"), 1);
2524
-
2525
- // src/__legacy__/http-client/helpers/decorators.ts
2526
- function staticDecorator() {
2527
- return (constructor) => constructor;
2528
- }
2529
-
2530
- // src/__legacy__/http-client/clients/axios-http-client.ts
2531
- var HttpClient = class {
2532
- /**
2533
- * Private constructor to avoid object instantiation from outside
2534
- * the class.
2535
- *
2536
- * @hideconstructor
2537
- */
2538
- constructor() {
2539
- __publicField(this, "isHandlerEnabled", true);
2540
- __publicField(this, "attachToken", () => Promise.resolve());
2541
- __publicField(this, "requestStartCallback", () => null);
2542
- __publicField(this, "requestSuccessCallback", () => null);
2543
- __publicField(this, "requestErrorCallback", () => null);
2544
- __publicField(this, "requestFinishCallback", () => null);
2545
- this.init = this.init.bind(this);
2546
- this.enableHandler = this.enableHandler.bind(this);
2547
- this.disableHandler = this.disableHandler.bind(this);
2548
- this.disableHandlerWithTimeout = this.disableHandlerWithTimeout.bind(this);
2549
- this.setHttpRequestErrorCallback = this.setHttpRequestErrorCallback.bind(this);
2550
- this.setHttpRequestFinishCallback = this.setHttpRequestFinishCallback.bind(this);
2551
- this.setHttpRequestStartCallback = this.setHttpRequestStartCallback.bind(this);
2552
- this.setHttpRequestSuccessCallback = this.setHttpRequestSuccessCallback.bind(this);
2553
- }
2554
- /**
2555
- * Returns an instance-specific HttpClient instance.
2556
- * Each instance ID gets its own axios instance and HttpClient to avoid state conflicts.
2557
- *
2558
- * @param instanceId - The instance ID for multi-auth context support. Defaults to 0.
2559
- * @return {HttpClientInstance}
2560
- */
2561
- static getInstance(instanceId = 0) {
2562
- if (this.instances.has(instanceId)) {
2563
- return this.instances.get(instanceId);
2516
+ // src/FetchHttpClient.ts
2517
+ var import_javascript4 = require("@asgardeo/javascript");
2518
+ var _FetchHttpClient = class _FetchHttpClient extends import_javascript4.HttpClient {
2519
+ static getInstance(instanceId = 0, isHandlerEnabled = true, attachToken = () => Promise.resolve()) {
2520
+ if (!this.instances.has(instanceId)) {
2521
+ this.instances.set(instanceId, new _FetchHttpClient(isHandlerEnabled, attachToken));
2564
2522
  }
2565
- const axiosInstance = import_axios.default.create({
2566
- withCredentials: true
2567
- });
2568
- const clientInstance = new HttpClient();
2569
- this.clientInstances.set(instanceId, clientInstance);
2570
- axiosInstance.interceptors.request.use(async (request) => await clientInstance.requestHandler(request));
2571
- axiosInstance.interceptors.response.use(
2572
- (response) => clientInstance.successHandler(response),
2573
- (error) => clientInstance.errorHandler(error)
2574
- );
2575
- axiosInstance.all = import_axios.default.all;
2576
- axiosInstance.spread = import_axios.default.spread;
2577
- axiosInstance.init = clientInstance.init;
2578
- axiosInstance.enableHandler = clientInstance.enableHandler;
2579
- axiosInstance.disableHandler = clientInstance.disableHandler;
2580
- axiosInstance.disableHandlerWithTimeout = clientInstance.disableHandlerWithTimeout;
2581
- axiosInstance.setHttpRequestStartCallback = clientInstance.setHttpRequestStartCallback;
2582
- axiosInstance.setHttpRequestSuccessCallback = clientInstance.setHttpRequestSuccessCallback;
2583
- axiosInstance.setHttpRequestErrorCallback = clientInstance.setHttpRequestErrorCallback;
2584
- axiosInstance.setHttpRequestFinishCallback = clientInstance.setHttpRequestFinishCallback;
2585
- this.instances.set(instanceId, axiosInstance);
2586
- return axiosInstance;
2523
+ return this.instances.get(instanceId);
2587
2524
  }
2588
- /**
2589
- * Destroys and cleans up an HttpClient instance.
2590
- * This should be called during provider teardown to prevent memory leaks.
2591
- *
2592
- * @param instanceId - The instance ID to destroy. Defaults to 0.
2593
- */
2594
2525
  static destroyInstance(instanceId = 0) {
2595
- const axiosInstance = this.instances.get(instanceId);
2596
- if (axiosInstance) {
2597
- axiosInstance.interceptors.request.clear();
2598
- axiosInstance.interceptors.response.clear();
2599
- }
2600
2526
  this.instances.delete(instanceId);
2601
- this.clientInstances.delete(instanceId);
2602
2527
  }
2603
- /**
2604
- * Intercepts all the requests.
2605
- * If the `isHandlerEnabled` flag is set to true, fires the `requestStartCallback`
2606
- * and retrieves the access token from the server and attaches it to the request.
2607
- * Else, just returns the original request.
2608
- *
2609
- * @param {HttpRequestConfig} request - Original request.
2610
- * @return {HttpRequestConfig}
2611
- */
2612
- async requestHandler(request) {
2613
- await this.attachToken(request);
2614
- if (request?.shouldEncodeToFormData) {
2615
- const data = request?.data;
2616
- const formData = new FormData();
2617
- Object.keys(data).forEach((key) => {
2618
- formData.append(key, data[key]);
2619
- });
2620
- request.data = formData;
2621
- }
2622
- request.startTimeInMs = (/* @__PURE__ */ new Date()).getTime();
2623
- if (this.isHandlerEnabled) {
2624
- if (this.requestStartCallback && typeof this.requestStartCallback === "function") {
2625
- this.requestStartCallback(request);
2528
+ // eslint-disable-next-line class-methods-use-this
2529
+ async transport(config) {
2530
+ let url = config.url ?? "";
2531
+ if (config.params) {
2532
+ const qs = new URLSearchParams(config.params).toString();
2533
+ if (qs) {
2534
+ url = `${url}?${qs}`;
2626
2535
  }
2627
2536
  }
2628
- return request;
2629
- }
2630
- /**
2631
- * Handles response errors.
2632
- * If the `isHandlerEnabled` flag is set to true, fires the `requestErrorCallback`
2633
- * and the `requestFinishCallback` functions. Else, just returns the original error.
2634
- *
2635
- * @param {HttpError} error - Original error.
2636
- * @return {HttpError}
2637
- */
2638
- errorHandler(error) {
2639
- if (this.isHandlerEnabled) {
2640
- if (this.requestErrorCallback && typeof this.requestErrorCallback === "function") {
2641
- this.requestErrorCallback(error);
2642
- }
2643
- if (this.requestFinishCallback && typeof this.requestFinishCallback === "function") {
2644
- this.requestFinishCallback();
2537
+ const headers = { ...config.headers ?? {} };
2538
+ let body;
2539
+ if (config.data !== void 0) {
2540
+ if (config.data instanceof FormData) {
2541
+ body = config.data;
2542
+ } else {
2543
+ body = JSON.stringify(config.data);
2544
+ if (!headers["Content-Type"] && !headers["content-type"]) {
2545
+ headers["Content-Type"] = "application/json";
2546
+ }
2645
2547
  }
2646
2548
  }
2647
- throw error;
2648
- }
2649
- /**
2650
- * Handles response success.
2651
- * If the `isHandlerEnabled` flag is set to true, fires the `requestSuccessCallback`
2652
- * and the `requestFinishCallback` functions. Else, just returns the original response.
2653
- *
2654
- * @param {HttpResponse} response - Original response.
2655
- * @return {HttpResponse}
2656
- */
2657
- successHandler(response) {
2658
- if (this.isHandlerEnabled) {
2659
- if (this.requestSuccessCallback && typeof this.requestSuccessCallback === "function") {
2660
- this.requestSuccessCallback(response);
2661
- }
2662
- if (this.requestFinishCallback && typeof this.requestFinishCallback === "function") {
2663
- this.requestFinishCallback();
2664
- }
2549
+ let fetchResponse;
2550
+ try {
2551
+ fetchResponse = await fetch(url, {
2552
+ body,
2553
+ credentials: "include",
2554
+ headers,
2555
+ method: (config.method ?? "GET").toUpperCase()
2556
+ });
2557
+ } catch (networkError) {
2558
+ throw Object.assign(new Error(networkError.message), {
2559
+ code: "NETWORK_ERROR",
2560
+ config
2561
+ });
2665
2562
  }
2666
- return response;
2667
- }
2668
- /**
2669
- * Initializes the Http client.
2670
- *
2671
- * @param isHandlerEnabled - Flag to toggle handler enablement.
2672
- * @param requestStartCallback - Callback function to be triggered on request start.
2673
- * @param requestSuccessCallback - Callback function to be triggered on request success.
2674
- * @param requestErrorCallback - Callback function to be triggered on request error.
2675
- * @param requestFinishCallback - Callback function to be triggered on request error.
2676
- */
2677
- async init(isHandlerEnabled = true, attachToken) {
2678
- this.isHandlerEnabled = isHandlerEnabled;
2679
- this.attachToken = attachToken;
2680
- }
2681
- /**
2682
- * Enables the handler.
2683
- */
2684
- enableHandler() {
2685
- this.isHandlerEnabled = true;
2686
- }
2687
- /**
2688
- * Disables the handler.
2689
- */
2690
- disableHandler() {
2691
- this.isHandlerEnabled = false;
2692
- }
2693
- /**
2694
- * Disables the handler for a given period of time.
2695
- *
2696
- * @param {number} timeout - Timeout in milliseconds.
2697
- */
2698
- disableHandlerWithTimeout(timeout = HttpClient.DEFAULT_HANDLER_DISABLE_TIMEOUT) {
2699
- this.isHandlerEnabled = false;
2700
- setTimeout(() => {
2701
- this.isHandlerEnabled = true;
2702
- }, timeout);
2703
- }
2704
- setHttpRequestStartCallback(callback) {
2705
- this.requestStartCallback = callback;
2706
- }
2707
- setHttpRequestSuccessCallback(callback) {
2708
- this.requestSuccessCallback = callback;
2709
- }
2710
- setHttpRequestErrorCallback(callback) {
2711
- this.requestErrorCallback = callback;
2712
- }
2713
- setHttpRequestFinishCallback(callback) {
2714
- this.requestFinishCallback = callback;
2563
+ const contentType = fetchResponse.headers.get("content-type") ?? "";
2564
+ const data = contentType.includes("application/json") ? await fetchResponse.json() : await fetchResponse.text();
2565
+ const responseHeaders = {};
2566
+ fetchResponse.headers.forEach((value, key) => {
2567
+ responseHeaders[key] = value;
2568
+ });
2569
+ if (!fetchResponse.ok) {
2570
+ throw Object.assign(new Error(fetchResponse.statusText), {
2571
+ config,
2572
+ response: {
2573
+ data,
2574
+ headers: responseHeaders,
2575
+ status: fetchResponse.status,
2576
+ statusText: fetchResponse.statusText
2577
+ }
2578
+ });
2579
+ }
2580
+ return {
2581
+ config,
2582
+ data,
2583
+ headers: responseHeaders,
2584
+ status: fetchResponse.status,
2585
+ statusText: fetchResponse.statusText
2586
+ };
2715
2587
  }
2716
2588
  };
2717
- __publicField(HttpClient, "instances", /* @__PURE__ */ new Map());
2718
- __publicField(HttpClient, "clientInstances", /* @__PURE__ */ new Map());
2719
- __publicField(HttpClient, "DEFAULT_HANDLER_DISABLE_TIMEOUT", 1e3);
2720
- HttpClient = __decorateClass([
2721
- staticDecorator()
2722
- ], HttpClient);
2589
+ __publicField(_FetchHttpClient, "instances", /* @__PURE__ */ new Map());
2590
+ var FetchHttpClient = _FetchHttpClient;
2723
2591
 
2724
2592
  // src/__legacy__/stores/local-store.ts
2725
2593
  var LocalStore = class {
@@ -2766,7 +2634,7 @@ var SessionStore = class {
2766
2634
 
2767
2635
  // src/__legacy__/utils/crypto-utils.ts
2768
2636
  var import_buffer = __toESM(require_buffer(), 1);
2769
- var import_javascript4 = require("@asgardeo/javascript");
2637
+ var import_javascript5 = require("@asgardeo/javascript");
2770
2638
  var import_base64url = __toESM(require("base64url"), 1);
2771
2639
  var import_fast_sha256 = __toESM(require("fast-sha256"), 1);
2772
2640
  var import_jose = require("jose");
@@ -2809,7 +2677,7 @@ var SPACryptoUtils = class {
2809
2677
  return Promise.resolve(true);
2810
2678
  }).catch((error) => {
2811
2679
  return Promise.reject(
2812
- new import_javascript4.AsgardeoAuthException(
2680
+ new import_javascript5.AsgardeoAuthException(
2813
2681
  "SPA-CRYPTO-UTILS-VJ-IV01",
2814
2682
  error?.reason ?? JSON.stringify(error),
2815
2683
  `${error?.code} ${error?.claim}`
@@ -2835,7 +2703,7 @@ var initiateStore = (store) => {
2835
2703
  var MainThreadClient = async (instanceId, config, getAuthHelper) => {
2836
2704
  const _store = initiateStore(config.storage);
2837
2705
  const _cryptoUtils = new SPACryptoUtils();
2838
- const _authenticationClient = new import_javascript5.AsgardeoAuthClient();
2706
+ const _authenticationClient = new import_javascript6.AsgardeoAuthClient();
2839
2707
  await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceId);
2840
2708
  const _spaHelper = new SPAHelper(_authenticationClient);
2841
2709
  const _dataLayer = _authenticationClient.getStorageManager();
@@ -2843,20 +2711,19 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
2843
2711
  async () => _authenticationClient.getSignOutUrl(),
2844
2712
  config.storage ?? "sessionStorage" /* SessionStorage */,
2845
2713
  (sessionState) => _dataLayer.setSessionDataParameter(
2846
- import_javascript5.OIDCRequestConstants.Params.SESSION_STATE,
2714
+ import_javascript6.OIDCRequestConstants.Params.SESSION_STATE,
2847
2715
  sessionState ?? ""
2848
2716
  )
2849
2717
  );
2850
2718
  const _authenticationHelper = getAuthHelper(_authenticationClient, _spaHelper);
2851
2719
  let _getSignOutURLFromSessionStorage = false;
2852
- const _httpClient = HttpClient.getInstance(instanceId);
2853
- let _isHttpHandlerEnabled = true;
2854
- let _httpErrorCallback;
2855
- let _httpFinishCallback;
2856
2720
  const attachToken = async (request) => {
2857
2721
  await _authenticationHelper.attachTokenToRequestConfig(request);
2858
2722
  };
2859
- _httpClient?.init && await _httpClient.init(true, attachToken);
2723
+ const _httpClient = FetchHttpClient.getInstance(instanceId, true, attachToken);
2724
+ let _isHttpHandlerEnabled = true;
2725
+ let _httpErrorCallback;
2726
+ let _httpFinishCallback;
2860
2727
  const setHttpRequestStartCallback = (callback) => {
2861
2728
  _httpClient?.setHttpRequestStartCallback && _httpClient.setHttpRequestStartCallback(callback);
2862
2729
  };
@@ -2907,7 +2774,7 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
2907
2774
  };
2908
2775
  const shouldStopAuthn = async () => _sessionManagementHelper.receivePromptNoneResponse(async (sessionState) => {
2909
2776
  await _dataLayer.setSessionDataParameter(
2910
- import_javascript5.OIDCRequestConstants.Params.SESSION_STATE,
2777
+ import_javascript6.OIDCRequestConstants.Params.SESSION_STATE,
2911
2778
  sessionState ?? ""
2912
2779
  );
2913
2780
  });
@@ -2928,9 +2795,9 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
2928
2795
  resolvedSessionState = sessionState ?? "";
2929
2796
  resolvedState = state ?? "";
2930
2797
  } else {
2931
- resolvedAuthorizationCode = new URL(window.location.href).searchParams.get(import_javascript5.OIDCRequestConstants.Params.AUTHORIZATION_CODE) ?? "";
2932
- resolvedSessionState = new URL(window.location.href).searchParams.get(import_javascript5.OIDCRequestConstants.Params.SESSION_STATE) ?? "";
2933
- resolvedState = new URL(window.location.href).searchParams.get(import_javascript5.OIDCRequestConstants.Params.STATE) ?? "";
2798
+ resolvedAuthorizationCode = new URL(window.location.href).searchParams.get(import_javascript6.OIDCRequestConstants.Params.AUTHORIZATION_CODE) ?? "";
2799
+ resolvedSessionState = new URL(window.location.href).searchParams.get(import_javascript6.OIDCRequestConstants.Params.SESSION_STATE) ?? "";
2800
+ resolvedState = new URL(window.location.href).searchParams.get(import_javascript6.OIDCRequestConstants.Params.STATE) ?? "";
2934
2801
  SPAUtils.removeAuthorizationCode();
2935
2802
  }
2936
2803
  if (resolvedAuthorizationCode && resolvedState) {
@@ -2948,7 +2815,7 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
2948
2815
  }
2949
2816
  return _authenticationClient.getSignInUrl(signInConfig).then(async (url) => {
2950
2817
  if (config.storage === "browserMemory" /* BrowserMemory */ && config.enablePKCE) {
2951
- const pkceKey = (0, import_javascript5.extractPkceStorageKeyFromState)(resolvedState);
2818
+ const pkceKey = (0, import_javascript6.extractPkceStorageKeyFromState)(resolvedState);
2952
2819
  SPAUtils.setPKCE(pkceKey, await _authenticationClient.getPKCECode(resolvedState));
2953
2820
  }
2954
2821
  if (tokenRequestConfig) {
@@ -2956,7 +2823,7 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
2956
2823
  }
2957
2824
  if (signInConfig && signInConfig["response_mode"] === "direct") {
2958
2825
  const authorizeUrl = new URL(url);
2959
- return (0, import_javascript5.initializeEmbeddedSignInFlow)({
2826
+ return (0, import_javascript6.initializeEmbeddedSignInFlow)({
2960
2827
  url: `${authorizeUrl.origin}${authorizeUrl.pathname}`,
2961
2828
  payload: Object.fromEntries(authorizeUrl.searchParams.entries())
2962
2829
  });
@@ -3028,9 +2895,9 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
3028
2895
  urlObject.searchParams.set("response_mode", "query");
3029
2896
  const url = urlObject.toString();
3030
2897
  if (config2.storage === "browserMemory" /* BrowserMemory */ && config2.enablePKCE) {
3031
- const state = urlObject.searchParams.get(import_javascript5.OIDCRequestConstants.Params.STATE);
2898
+ const state = urlObject.searchParams.get(import_javascript6.OIDCRequestConstants.Params.STATE);
3032
2899
  SPAUtils.setPKCE(
3033
- (0, import_javascript5.extractPkceStorageKeyFromState)(state ?? ""),
2900
+ (0, import_javascript6.extractPkceStorageKeyFromState)(state ?? ""),
3034
2901
  await _authenticationClient.getPKCECode(state ?? "")
3035
2902
  );
3036
2903
  }
@@ -3098,10 +2965,10 @@ var MainThreadClient = async (instanceId, config, getAuthHelper) => {
3098
2965
  };
3099
2966
 
3100
2967
  // src/__legacy__/clients/web-worker-client.ts
3101
- var import_javascript7 = require("@asgardeo/javascript");
2968
+ var import_javascript8 = require("@asgardeo/javascript");
3102
2969
 
3103
2970
  // src/__legacy__/helpers/authentication-helper.ts
3104
- var import_javascript6 = require("@asgardeo/javascript");
2971
+ var import_javascript7 = require("@asgardeo/javascript");
3105
2972
  var AuthenticationHelper = class {
3106
2973
  constructor(authClient, spaHelper) {
3107
2974
  __publicField(this, "_authenticationClient");
@@ -3168,7 +3035,7 @@ var AuthenticationHelper = class {
3168
3035
  });
3169
3036
  } else {
3170
3037
  return Promise.reject(
3171
- new import_javascript6.AsgardeoAuthException(
3038
+ new import_javascript7.AsgardeoAuthException(
3172
3039
  "SPA-MAIN_THREAD_CLIENT-RCG-IV01",
3173
3040
  "Request to the provided endpoint is prohibited.",
3174
3041
  "Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified token endpoint in this request cannot be found among the `allowedExternalUrls`"
@@ -3269,7 +3136,7 @@ var AuthenticationHelper = class {
3269
3136
  httpFinishCallback();
3270
3137
  }
3271
3138
  }
3272
- throw new import_javascript6.AsgardeoAuthException(
3139
+ throw new import_javascript7.AsgardeoAuthException(
3273
3140
  "SPA-AUTH_HELPER-HR-SE01",
3274
3141
  refreshError?.name ?? "Refresh token request failed.",
3275
3142
  refreshError?.message ?? "An error occurred while trying to refresh the access token following a 401 response from the server."
@@ -3304,7 +3171,7 @@ var AuthenticationHelper = class {
3304
3171
  });
3305
3172
  } else {
3306
3173
  return Promise.reject(
3307
- new import_javascript6.AsgardeoAuthException(
3174
+ new import_javascript7.AsgardeoAuthException(
3308
3175
  "SPA-AUTH_HELPER-HR-IV02",
3309
3176
  "Request to the provided endpoint is prohibited.",
3310
3177
  "Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`"
@@ -3354,7 +3221,7 @@ var AuthenticationHelper = class {
3354
3221
  httpFinishCallback();
3355
3222
  }
3356
3223
  }
3357
- throw new import_javascript6.AsgardeoAuthException(
3224
+ throw new import_javascript7.AsgardeoAuthException(
3358
3225
  "SPA-AUTH_HELPER-HRA-SE01",
3359
3226
  refreshError?.name ?? "Refresh token request failed.",
3360
3227
  refreshError?.message ?? "An error occurred while trying to refresh the access token following a 401 response from the server."
@@ -3387,7 +3254,7 @@ var AuthenticationHelper = class {
3387
3254
  return Promise.reject(error);
3388
3255
  });
3389
3256
  } else {
3390
- throw new import_javascript6.AsgardeoAuthException(
3257
+ throw new import_javascript7.AsgardeoAuthException(
3391
3258
  "SPA-AUTH_HELPER-HRA-IV02",
3392
3259
  "Request to the provided endpoint is prohibited.",
3393
3260
  "Requests can only be sent to resource servers specified by the `allowedExternalUrls` attribute while initializing the SDK. The specified endpoint in this request cannot be found among the `allowedExternalUrls`"
@@ -3397,8 +3264,8 @@ var AuthenticationHelper = class {
3397
3264
  async requestAccessToken(authorizationCode, sessionState, checkSession, pkce, state, tokenRequestConfig) {
3398
3265
  const config = await this._storageManager.getConfigData();
3399
3266
  if (config.storage === "browserMemory" /* BrowserMemory */ && config.enablePKCE && sessionState) {
3400
- const pkce2 = SPAUtils.getPKCE((0, import_javascript6.extractPkceStorageKeyFromState)(sessionState));
3401
- await this._authenticationClient.setPKCECode((0, import_javascript6.extractPkceStorageKeyFromState)(sessionState), pkce2);
3267
+ const pkce2 = SPAUtils.getPKCE((0, import_javascript7.extractPkceStorageKeyFromState)(sessionState));
3268
+ await this._authenticationClient.setPKCECode((0, import_javascript7.extractPkceStorageKeyFromState)(sessionState), pkce2);
3402
3269
  } else if (config.storage === "webWorker" /* WebWorker */ && pkce) {
3403
3270
  await this._authenticationClient.setPKCECode(pkce, state ?? "");
3404
3271
  }
@@ -3424,7 +3291,7 @@ var AuthenticationHelper = class {
3424
3291
  });
3425
3292
  }
3426
3293
  return Promise.reject(
3427
- new import_javascript6.AsgardeoAuthException(
3294
+ new import_javascript7.AsgardeoAuthException(
3428
3295
  "SPA-AUTH_HELPER-RAT1-NF01",
3429
3296
  "No authorization code.",
3430
3297
  "No authorization code was found."
@@ -3510,7 +3377,7 @@ var AuthenticationHelper = class {
3510
3377
  url.searchParams.delete(ERROR);
3511
3378
  url.searchParams.delete(ERROR_DESCRIPTION);
3512
3379
  history.pushState(null, document.title, url.toString());
3513
- throw new import_javascript6.AsgardeoAuthException("SPA-AUTH_HELPER-SI-SE01", error, errorDescription ?? "");
3380
+ throw new import_javascript7.AsgardeoAuthException("SPA-AUTH_HELPER-SI-SE01", error, errorDescription ?? "");
3514
3381
  }
3515
3382
  if (config.storage === "webWorker" /* WebWorker */ && tryRetrievingUserInfo) {
3516
3383
  const basicUserInfo = await tryRetrievingUserInfo();
@@ -3588,7 +3455,7 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3588
3455
  let _getSignOutURLFromSessionStorage = false;
3589
3456
  const _store = initiateStore2(config.storage);
3590
3457
  const _cryptoUtils = new SPACryptoUtils();
3591
- const _authenticationClient = new import_javascript7.AsgardeoAuthClient();
3458
+ const _authenticationClient = new import_javascript8.AsgardeoAuthClient();
3592
3459
  await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceId);
3593
3460
  const _spaHelper = new SPAHelper(_authenticationClient);
3594
3461
  const _sessionManagementHelper = await SessionManagementHelper(
@@ -3617,7 +3484,7 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3617
3484
  return new Promise((resolve, reject) => {
3618
3485
  const timer = setTimeout(() => {
3619
3486
  reject(
3620
- new import_javascript7.AsgardeoAuthException(
3487
+ new import_javascript8.AsgardeoAuthException(
3621
3488
  "SPA-WEB_WORKER_CLIENT-COM-TO01",
3622
3489
  "Operation timed out.",
3623
3490
  "No response was received from the web worker for " + _requestTimeout / 1e3 + " since dispatching the request"
@@ -3640,14 +3507,14 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3640
3507
  try {
3641
3508
  error = JSON.parse(data.error);
3642
3509
  } catch (parseError) {
3643
- error = new import_javascript7.AsgardeoAuthException(
3510
+ error = new import_javascript8.AsgardeoAuthException(
3644
3511
  "SPA-WEB_WORKER_CLIENT-COM-PE01",
3645
3512
  "Worker communication error.",
3646
3513
  `Failed to parse worker error response: ${data.error}`
3647
3514
  );
3648
3515
  }
3649
3516
  } else {
3650
- error = new import_javascript7.AsgardeoAuthException(
3517
+ error = new import_javascript8.AsgardeoAuthException(
3651
3518
  "SPA-WEB_WORKER_CLIENT-COM-UE01",
3652
3519
  "Unknown worker error.",
3653
3520
  "An unknown error occurred in the web worker."
@@ -3805,8 +3672,8 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3805
3672
  const response = await communicate(
3806
3673
  message
3807
3674
  );
3808
- const pkceKey = (0, import_javascript7.extractPkceStorageKeyFromState)(
3809
- new URL(response.authorizationURL).searchParams.get(import_javascript7.OIDCRequestConstants.Params.STATE) ?? ""
3675
+ const pkceKey = (0, import_javascript8.extractPkceStorageKeyFromState)(
3676
+ new URL(response.authorizationURL).searchParams.get(import_javascript8.OIDCRequestConstants.Params.STATE) ?? ""
3810
3677
  );
3811
3678
  response.pkce && config2.enablePKCE && SPAUtils.setPKCE(pkceKey, response.pkce);
3812
3679
  const urlString = response.authorizationURL;
@@ -3832,8 +3699,8 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3832
3699
  };
3833
3700
  return communicate(message).then(async (response) => {
3834
3701
  if (response.pkce && config2.enablePKCE) {
3835
- const pkceKey = (0, import_javascript7.extractPkceStorageKeyFromState)(
3836
- new URL(response.authorizationURL).searchParams.get(import_javascript7.OIDCRequestConstants.Params.STATE) ?? ""
3702
+ const pkceKey = (0, import_javascript8.extractPkceStorageKeyFromState)(
3703
+ new URL(response.authorizationURL).searchParams.get(import_javascript8.OIDCRequestConstants.Params.STATE) ?? ""
3837
3704
  );
3838
3705
  SPAUtils.setPKCE(pkceKey, response.pkce);
3839
3706
  }
@@ -3844,7 +3711,7 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3844
3711
  };
3845
3712
  const requestAccessToken = async (resolvedAuthorizationCode, resolvedSessionState, resolvedState, tokenRequestConfig) => {
3846
3713
  const config2 = await getConfigData();
3847
- const pkceKey = (0, import_javascript7.extractPkceStorageKeyFromState)(resolvedState);
3714
+ const pkceKey = (0, import_javascript8.extractPkceStorageKeyFromState)(resolvedState);
3848
3715
  const message = {
3849
3716
  data: {
3850
3717
  code: resolvedAuthorizationCode,
@@ -3906,9 +3773,9 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
3906
3773
  resolvedSessionState = sessionState ?? "";
3907
3774
  resolvedState = state ?? "";
3908
3775
  } else {
3909
- resolvedAuthorizationCode = new URL(window.location.href).searchParams.get(import_javascript7.OIDCRequestConstants.Params.AUTHORIZATION_CODE) ?? "";
3910
- resolvedSessionState = new URL(window.location.href).searchParams.get(import_javascript7.OIDCRequestConstants.Params.SESSION_STATE) ?? "";
3911
- resolvedState = new URL(window.location.href).searchParams.get(import_javascript7.OIDCRequestConstants.Params.STATE) ?? "";
3776
+ resolvedAuthorizationCode = new URL(window.location.href).searchParams.get(import_javascript8.OIDCRequestConstants.Params.AUTHORIZATION_CODE) ?? "";
3777
+ resolvedSessionState = new URL(window.location.href).searchParams.get(import_javascript8.OIDCRequestConstants.Params.SESSION_STATE) ?? "";
3778
+ resolvedState = new URL(window.location.href).searchParams.get(import_javascript8.OIDCRequestConstants.Params.STATE) ?? "";
3912
3779
  SPAUtils.removeAuthorizationCode();
3913
3780
  }
3914
3781
  if (resolvedAuthorizationCode && resolvedState) {
@@ -4116,7 +3983,7 @@ var WebWorkerClient = async (instanceId, config, webWorker, getAuthHelper) => {
4116
3983
  };
4117
3984
 
4118
3985
  // src/__legacy__/client.ts
4119
- var logger = (0, import_javascript8.createPackageComponentLogger)(
3986
+ var logger = (0, import_javascript9.createPackageComponentLogger)(
4120
3987
  "@asgardeo/browser",
4121
3988
  "AsgardeoSPAClient"
4122
3989
  );
@@ -4200,7 +4067,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4200
4067
  async _validateMethod(validateAuthentication = true) {
4201
4068
  if (!await this.isInitialized()) {
4202
4069
  return Promise.reject(
4203
- new import_javascript8.AsgardeoAuthException(
4070
+ new import_javascript9.AsgardeoAuthException(
4204
4071
  "SPA-AUTH_CLIENT-VM-NF01",
4205
4072
  "The SDK is not initialized.",
4206
4073
  "The SDK must be initialized first."
@@ -4209,7 +4076,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4209
4076
  }
4210
4077
  if (validateAuthentication && !await this.isSignedIn()) {
4211
4078
  return Promise.reject(
4212
- new import_javascript8.AsgardeoAuthException(
4079
+ new import_javascript9.AsgardeoAuthException(
4213
4080
  "SPA-AUTH_CLIENT-VM-IV02",
4214
4081
  "The user is not authenticated.",
4215
4082
  "The user must be authenticated first."
@@ -4687,7 +4554,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4687
4554
  }
4688
4555
  if (!config.id) {
4689
4556
  return Promise.reject(
4690
- new import_javascript8.AsgardeoAuthException(
4557
+ new import_javascript9.AsgardeoAuthException(
4691
4558
  "SPA-AUTH_CLIENT-RCG-NF01",
4692
4559
  "The custom grant request id not found.",
4693
4560
  "The id attribute of the custom grant config object passed as an argument should have a value."
@@ -4752,7 +4619,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4752
4619
  /**
4753
4620
  * This methods returns the Axios http client.
4754
4621
  *
4755
- * @return {HttpClientInstance} - The Axios HTTP client.
4622
+ * @return {HttpClient} - The Axios HTTP client.
4756
4623
  *
4757
4624
  * @memberof AsgardeoSPAClient
4758
4625
  *
@@ -4764,13 +4631,13 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4764
4631
  const mainThreadClient = this._client;
4765
4632
  return mainThreadClient.getHttpClient();
4766
4633
  }
4767
- throw new import_javascript8.AsgardeoAuthException(
4634
+ throw new import_javascript9.AsgardeoAuthException(
4768
4635
  "SPA-AUTH_CLIENT-GHC-IV01",
4769
4636
  "Http client cannot be returned.",
4770
4637
  "The http client cannot be returned when the storage type is set to webWorker."
4771
4638
  );
4772
4639
  }
4773
- throw new import_javascript8.AsgardeoAuthException(
4640
+ throw new import_javascript9.AsgardeoAuthException(
4774
4641
  "SPA-AUTH_CLIENT-GHC-NF02",
4775
4642
  "The SDK is not initialized.",
4776
4643
  "The SDK has not been initialized yet. Initialize the SDK using the initialize method before calling this method."
@@ -4895,7 +4762,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4895
4762
  await this._validateMethod();
4896
4763
  if (this._storage && [("webWorker" /* WebWorker */, "browserMemory" /* BrowserMemory */)].includes(this._storage)) {
4897
4764
  return Promise.reject(
4898
- new import_javascript8.AsgardeoAuthException(
4765
+ new import_javascript9.AsgardeoAuthException(
4899
4766
  "SPA-AUTH_CLIENT-GAT-IV01",
4900
4767
  "The access token cannot be returned.",
4901
4768
  "The access token cannot be returned when the storage type is set to webWorker or browserMemory."
@@ -4931,7 +4798,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4931
4798
  await this._validateMethod();
4932
4799
  if (this._storage && [("webWorker" /* WebWorker */, "browserMemory" /* BrowserMemory */)].includes(this._storage)) {
4933
4800
  return Promise.reject(
4934
- new import_javascript8.AsgardeoAuthException(
4801
+ new import_javascript9.AsgardeoAuthException(
4935
4802
  "SPA-AUTH_CLIENT-GIAT-IV01",
4936
4803
  "The access token cannot be returned.",
4937
4804
  "The access token cannot be returned when the storage type is set to webWorker or browserMemory."
@@ -4966,7 +4833,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
4966
4833
  async getStorageManager() {
4967
4834
  if (this._storage && [("webWorker" /* WebWorker */, "browserMemory" /* BrowserMemory */)].includes(this._storage)) {
4968
4835
  return Promise.reject(
4969
- new import_javascript8.AsgardeoAuthException(
4836
+ new import_javascript9.AsgardeoAuthException(
4970
4837
  "SPA-AUTH_CLIENT-GDL-IV01",
4971
4838
  "The data layer cannot be returned.",
4972
4839
  "The data layer cannot be returned when the storage type is set to webWorker or browserMemory."
@@ -5050,7 +4917,7 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
5050
4917
  await this.isInitialized();
5051
4918
  if (this._storage && [("webWorker" /* WebWorker */, "browserMemory" /* BrowserMemory */)].includes(this._storage)) {
5052
4919
  return Promise.reject(
5053
- new import_javascript8.AsgardeoAuthException(
4920
+ new import_javascript9.AsgardeoAuthException(
5054
4921
  "SPA-AUTH_CLIENT-ISA-IV01",
5055
4922
  "The active session cannot be returned.",
5056
4923
  "The active session cannot be returned when the storage type is set to webWorker or browserMemory."
@@ -5103,10 +4970,10 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
5103
4970
  break;
5104
4971
  }
5105
4972
  default:
5106
- throw new import_javascript8.AsgardeoAuthException("SPA-AUTH_CLIENT-ON-IV01", "Invalid hook.", "The provided hook is invalid.");
4973
+ throw new import_javascript9.AsgardeoAuthException("SPA-AUTH_CLIENT-ON-IV01", "Invalid hook.", "The provided hook is invalid.");
5107
4974
  }
5108
4975
  } else {
5109
- throw new import_javascript8.AsgardeoAuthException(
4976
+ throw new import_javascript9.AsgardeoAuthException(
5110
4977
  "SPA-AUTH_CLIENT-ON-IV02",
5111
4978
  "Invalid callback function.",
5112
4979
  "The provided callback function is invalid."
@@ -5189,12 +5056,15 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
5189
5056
  * @param sessionId - The session ID of the session to be cleared. If not provided, the current session will be cleared.
5190
5057
  */
5191
5058
  clearSession(sessionId) {
5192
- import_javascript8.AsgardeoAuthClient.clearSession(sessionId);
5059
+ import_javascript9.AsgardeoAuthClient.clearSession(sessionId);
5193
5060
  }
5194
5061
  };
5195
5062
  __publicField(_AsgardeoSPAClient, "_instances", /* @__PURE__ */ new Map());
5196
5063
  var AsgardeoSPAClient = _AsgardeoSPAClient;
5197
5064
 
5065
+ // src/__legacy__/models/http-client.ts
5066
+ var import_javascript10 = require("@asgardeo/javascript");
5067
+
5198
5068
  // src/__legacy__/models/web-worker.ts
5199
5069
  var WebWorkerClass = class {
5200
5070
  constructor() {
@@ -5204,14 +5074,14 @@ var WebWorkerClass = class {
5204
5074
  };
5205
5075
 
5206
5076
  // src/__legacy__/worker/worker-receiver.ts
5207
- var import_javascript10 = require("@asgardeo/javascript");
5077
+ var import_javascript12 = require("@asgardeo/javascript");
5208
5078
 
5209
5079
  // src/__legacy__/worker/worker-core.ts
5210
- var import_javascript9 = require("@asgardeo/javascript");
5080
+ var import_javascript11 = require("@asgardeo/javascript");
5211
5081
  var WebWorkerCore = async (instanceId, config, getAuthHelper) => {
5212
5082
  const _store = new MemoryStore();
5213
5083
  const _cryptoUtils = new SPACryptoUtils();
5214
- const _authenticationClient = new import_javascript9.AsgardeoAuthClient();
5084
+ const _authenticationClient = new import_javascript11.AsgardeoAuthClient();
5215
5085
  await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceId);
5216
5086
  const _spaHelper = new SPAHelper(_authenticationClient);
5217
5087
  const _authenticationHelper = getAuthHelper(
@@ -5219,11 +5089,10 @@ var WebWorkerCore = async (instanceId, config, getAuthHelper) => {
5219
5089
  _spaHelper
5220
5090
  );
5221
5091
  const _dataLayer = _authenticationClient.getStorageManager();
5222
- const _httpClient = HttpClient.getInstance(instanceId);
5223
5092
  const attachToken = async (request) => {
5224
5093
  await _authenticationHelper.attachTokenToRequestConfig(request);
5225
5094
  };
5226
- _httpClient?.init && await _httpClient.init(true, attachToken);
5095
+ const _httpClient = FetchHttpClient.getInstance(instanceId, true, attachToken);
5227
5096
  const setHttpRequestStartCallback = (callback) => {
5228
5097
  _httpClient?.setHttpRequestStartCallback && _httpClient.setHttpRequestStartCallback(callback);
5229
5098
  };
@@ -5248,7 +5117,7 @@ var WebWorkerCore = async (instanceId, config, getAuthHelper) => {
5248
5117
  const getSignInUrl = async (params) => {
5249
5118
  return _authenticationClient.getSignInUrl(params).then(async (url) => {
5250
5119
  const urlObject = new URL(url);
5251
- const state = urlObject.searchParams.get(import_javascript9.OIDCRequestConstants.Params.STATE) ?? "";
5120
+ const state = urlObject.searchParams.get(import_javascript11.OIDCRequestConstants.Params.STATE) ?? "";
5252
5121
  const pkce = await _authenticationClient.getPKCECode(state);
5253
5122
  return { authorizationURL: url, pkce };
5254
5123
  }).catch((error) => Promise.reject(error));
@@ -5311,7 +5180,7 @@ var WebWorkerCore = async (instanceId, config, getAuthHelper) => {
5311
5180
  };
5312
5181
  const setSessionState = async (sessionState) => {
5313
5182
  await _dataLayer.setSessionDataParameter(
5314
- import_javascript9.OIDCRequestConstants.Params.SESSION_STATE,
5183
+ import_javascript11.OIDCRequestConstants.Params.SESSION_STATE,
5315
5184
  sessionState
5316
5185
  );
5317
5186
  return;
@@ -5362,7 +5231,7 @@ var workerReceiver = (getAuthHelper) => {
5362
5231
  if (data.type !== INIT && !webWorker) {
5363
5232
  port.postMessage(
5364
5233
  MessageUtils.generateFailureMessage(
5365
- new import_javascript10.AsgardeoAuthException(
5234
+ new import_javascript12.AsgardeoAuthException(
5366
5235
  "SPA-CLIENT_WORKER-ONMSG-NF01",
5367
5236
  "The web worker has not been initialized yet.",
5368
5237
  "The initialize method needs to be called before the specified operation can be carried out."
@@ -5542,7 +5411,7 @@ var workerReceiver = (getAuthHelper) => {
5542
5411
  default:
5543
5412
  port?.postMessage(
5544
5413
  MessageUtils.generateFailureMessage(
5545
- new import_javascript10.AsgardeoAuthException(
5414
+ new import_javascript12.AsgardeoAuthException(
5546
5415
  "SPA-CLIENT_WORKER-ONMSG-IV02",
5547
5416
  "The message type is invalid.",
5548
5417
  `The message type provided, ${data.type}, is invalid.`
@@ -5593,8 +5462,8 @@ var navigate = (url) => {
5593
5462
  var navigate_default = navigate;
5594
5463
 
5595
5464
  // src/AsgardeoBrowserClient.ts
5596
- var import_javascript11 = require("@asgardeo/javascript");
5597
- var AsgardeoBrowserClient = class extends import_javascript11.AsgardeoJavaScriptClient {
5465
+ var import_javascript13 = require("@asgardeo/javascript");
5466
+ var AsgardeoBrowserClient = class extends import_javascript13.AsgardeoJavaScriptClient {
5598
5467
  };
5599
5468
  var AsgardeoBrowserClient_default = AsgardeoBrowserClient;
5600
5469
 
@@ -5602,8 +5471,8 @@ var AsgardeoBrowserClient_default = AsgardeoBrowserClient;
5602
5471
  __reExport(index_exports, require("@asgardeo/javascript"), module.exports);
5603
5472
 
5604
5473
  // src/theme/themeDetection.ts
5605
- var import_javascript12 = require("@asgardeo/javascript");
5606
- var logger2 = (0, import_javascript12.createPackageComponentLogger)(
5474
+ var import_javascript14 = require("@asgardeo/javascript");
5475
+ var logger2 = (0, import_javascript14.createPackageComponentLogger)(
5607
5476
  "@asgardeo/browser",
5608
5477
  "ThemeDetection"
5609
5478
  );
@@ -5674,7 +5543,7 @@ var createMediaQueryListener = (callback) => {
5674
5543
  };
5675
5544
 
5676
5545
  // src/theme/getActiveTheme.ts
5677
- var import_javascript13 = require("@asgardeo/javascript");
5546
+ var import_javascript15 = require("@asgardeo/javascript");
5678
5547
  var getActiveTheme = (mode, config = {}) => {
5679
5548
  if (mode === "dark") {
5680
5549
  return "dark";
@@ -5686,24 +5555,24 @@ var getActiveTheme = (mode, config = {}) => {
5686
5555
  if (typeof window !== "undefined" && window.matchMedia) {
5687
5556
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
5688
5557
  }
5689
- return import_javascript13.DEFAULT_THEME;
5558
+ return import_javascript15.DEFAULT_THEME;
5690
5559
  }
5691
5560
  if (mode === "class") {
5692
5561
  return detectThemeMode(mode, config);
5693
5562
  }
5694
- return import_javascript13.DEFAULT_THEME;
5563
+ return import_javascript15.DEFAULT_THEME;
5695
5564
  };
5696
5565
  var getActiveTheme_default = getActiveTheme;
5697
5566
 
5698
5567
  // src/utils/handleWebAuthnAuthentication.ts
5699
- var import_javascript14 = require("@asgardeo/javascript");
5700
- var logger3 = (0, import_javascript14.createPackageComponentLogger)(
5568
+ var import_javascript16 = require("@asgardeo/javascript");
5569
+ var logger3 = (0, import_javascript16.createPackageComponentLogger)(
5701
5570
  "@asgardeo/browser",
5702
5571
  "WebAuthn"
5703
5572
  );
5704
5573
  var handleWebAuthnAuthentication = async (challengeData) => {
5705
5574
  if (!window.navigator.credentials || !window.navigator.credentials.get) {
5706
- throw new import_javascript14.AsgardeoRuntimeError(
5575
+ throw new import_javascript16.AsgardeoRuntimeError(
5707
5576
  "WebAuthn is not supported in this browser. Please use a modern browser or try a different authentication method.",
5708
5577
  "browser-webauthn-not-supported",
5709
5578
  "browser",
@@ -5711,7 +5580,7 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5711
5580
  );
5712
5581
  }
5713
5582
  if (window.location.protocol !== "https:" && window.location.hostname !== "localhost") {
5714
- throw new import_javascript14.AsgardeoRuntimeError(
5583
+ throw new import_javascript16.AsgardeoRuntimeError(
5715
5584
  "Passkey authentication requires a secure connection (HTTPS). Please ensure you are accessing this site over HTTPS.",
5716
5585
  "browser-webauthn-insecure-connection",
5717
5586
  "browser",
@@ -5730,7 +5599,7 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5730
5599
  }
5731
5600
  const adjustedOptions = {
5732
5601
  ...publicKeyCredentialRequestOptions,
5733
- challenge: (0, import_javascript14.base64urlToArrayBuffer)(publicKeyCredentialRequestOptions.challenge),
5602
+ challenge: (0, import_javascript16.base64urlToArrayBuffer)(publicKeyCredentialRequestOptions.challenge),
5734
5603
  rpId: rpIdToUse,
5735
5604
  ...publicKeyCredentialRequestOptions.userVerification && {
5736
5605
  userVerification: publicKeyCredentialRequestOptions.userVerification
@@ -5738,7 +5607,7 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5738
5607
  ...publicKeyCredentialRequestOptions.allowCredentials && {
5739
5608
  allowCredentials: publicKeyCredentialRequestOptions.allowCredentials.map((cred) => ({
5740
5609
  ...cred,
5741
- id: (0, import_javascript14.base64urlToArrayBuffer)(cred.id)
5610
+ id: (0, import_javascript16.base64urlToArrayBuffer)(cred.id)
5742
5611
  }))
5743
5612
  }
5744
5613
  };
@@ -5746,7 +5615,7 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5746
5615
  publicKey: adjustedOptions
5747
5616
  });
5748
5617
  if (!credential) {
5749
- throw new import_javascript14.AsgardeoRuntimeError(
5618
+ throw new import_javascript16.AsgardeoRuntimeError(
5750
5619
  "No credential returned from WebAuthn authentication",
5751
5620
  "browser-webauthn-no-credential",
5752
5621
  "browser",
@@ -5757,13 +5626,13 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5757
5626
  const tokenResponse = {
5758
5627
  credential: {
5759
5628
  id: credential.id,
5760
- rawId: (0, import_javascript14.arrayBufferToBase64url)(credential.rawId),
5629
+ rawId: (0, import_javascript16.arrayBufferToBase64url)(credential.rawId),
5761
5630
  response: {
5762
- authenticatorData: (0, import_javascript14.arrayBufferToBase64url)(authData.authenticatorData),
5763
- clientDataJSON: (0, import_javascript14.arrayBufferToBase64url)(authData.clientDataJSON),
5764
- signature: (0, import_javascript14.arrayBufferToBase64url)(authData.signature),
5631
+ authenticatorData: (0, import_javascript16.arrayBufferToBase64url)(authData.authenticatorData),
5632
+ clientDataJSON: (0, import_javascript16.arrayBufferToBase64url)(authData.clientDataJSON),
5633
+ signature: (0, import_javascript16.arrayBufferToBase64url)(authData.signature),
5765
5634
  ...authData.userHandle && {
5766
- userHandle: (0, import_javascript14.arrayBufferToBase64url)(authData.userHandle)
5635
+ userHandle: (0, import_javascript16.arrayBufferToBase64url)(authData.userHandle)
5767
5636
  }
5768
5637
  },
5769
5638
  type: credential.type
@@ -5773,13 +5642,13 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5773
5642
  return JSON.stringify(tokenResponse);
5774
5643
  } catch (error) {
5775
5644
  logger3.error("WebAuthn authentication failed:");
5776
- if (error instanceof import_javascript14.AsgardeoRuntimeError) {
5645
+ if (error instanceof import_javascript16.AsgardeoRuntimeError) {
5777
5646
  throw error;
5778
5647
  }
5779
5648
  if (error instanceof Error) {
5780
5649
  switch (error.name) {
5781
5650
  case "NotAllowedError":
5782
- throw new import_javascript14.AsgardeoRuntimeError(
5651
+ throw new import_javascript16.AsgardeoRuntimeError(
5783
5652
  "Passkey authentication was cancelled or timed out. Please try again.",
5784
5653
  "browser-webauthn-user-cancelled",
5785
5654
  "browser",
@@ -5787,49 +5656,49 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5787
5656
  );
5788
5657
  case "SecurityError":
5789
5658
  if (error.message.includes("relying party ID") || error.message.includes("RP ID")) {
5790
- throw new import_javascript14.AsgardeoRuntimeError(
5659
+ throw new import_javascript16.AsgardeoRuntimeError(
5791
5660
  "Domain mismatch error. The passkey was registered for a different domain. Please contact support or try a different authentication method.",
5792
5661
  "browser-webauthn-domain-mismatch",
5793
5662
  "browser",
5794
5663
  "The WebAuthn relying party ID does not match the current domain."
5795
5664
  );
5796
5665
  }
5797
- throw new import_javascript14.AsgardeoRuntimeError(
5666
+ throw new import_javascript16.AsgardeoRuntimeError(
5798
5667
  "Passkey authentication failed due to a security error. Please ensure you are using HTTPS and that your browser supports passkeys.",
5799
5668
  "browser-webauthn-security-error",
5800
5669
  "browser",
5801
5670
  "A security error occurred during WebAuthn authentication."
5802
5671
  );
5803
5672
  case "InvalidStateError":
5804
- throw new import_javascript14.AsgardeoRuntimeError(
5673
+ throw new import_javascript16.AsgardeoRuntimeError(
5805
5674
  "No valid passkey found for this account. Please register a passkey first or use a different authentication method.",
5806
5675
  "browser-webauthn-no-passkey",
5807
5676
  "browser",
5808
5677
  "No registered passkey credentials were found for the current user account."
5809
5678
  );
5810
5679
  case "NotSupportedError":
5811
- throw new import_javascript14.AsgardeoRuntimeError(
5680
+ throw new import_javascript16.AsgardeoRuntimeError(
5812
5681
  "Passkey authentication is not supported on this device or browser. Please use a different authentication method.",
5813
5682
  "browser-webauthn-not-supported",
5814
5683
  "browser",
5815
5684
  "WebAuthn is not supported on the current device or browser configuration."
5816
5685
  );
5817
5686
  case "NetworkError":
5818
- throw new import_javascript14.AsgardeoRuntimeError(
5687
+ throw new import_javascript16.AsgardeoRuntimeError(
5819
5688
  "Network error during passkey authentication. Please check your connection and try again.",
5820
5689
  "browser-webauthn-network-error",
5821
5690
  "browser",
5822
5691
  "A network error occurred while communicating with the authenticator."
5823
5692
  );
5824
5693
  case "UnknownError":
5825
- throw new import_javascript14.AsgardeoRuntimeError(
5694
+ throw new import_javascript16.AsgardeoRuntimeError(
5826
5695
  "An unknown error occurred during passkey authentication. Please try again or use a different authentication method.",
5827
5696
  "browser-webauthn-unknown-error",
5828
5697
  "browser",
5829
5698
  "An unidentified error occurred during the WebAuthn authentication process."
5830
5699
  );
5831
5700
  default:
5832
- throw new import_javascript14.AsgardeoRuntimeError(
5701
+ throw new import_javascript16.AsgardeoRuntimeError(
5833
5702
  `Passkey authentication failed: ${error.message}`,
5834
5703
  "browser-webauthn-general-error",
5835
5704
  "browser",
@@ -5837,7 +5706,7 @@ var handleWebAuthnAuthentication = async (challengeData) => {
5837
5706
  );
5838
5707
  }
5839
5708
  }
5840
- throw new import_javascript14.AsgardeoRuntimeError(
5709
+ throw new import_javascript16.AsgardeoRuntimeError(
5841
5710
  "Passkey authentication failed due to an unexpected error.",
5842
5711
  "browser-webauthn-unexpected-error",
5843
5712
  "browser",
@@ -5870,12 +5739,12 @@ var http = (instanceId = 0) => {
5870
5739
  var http_default = http();
5871
5740
 
5872
5741
  // src/utils/v2/resolveEmojiUrisInHtml.ts
5873
- var import_javascript15 = require("@asgardeo/javascript");
5742
+ var import_javascript17 = require("@asgardeo/javascript");
5874
5743
  var resolveEmojiUrisInHtml = (html) => {
5875
5744
  const withEmojiImages = html.replace(
5876
5745
  /<img([^>]*)src="(emoji:[^"]+)"([^>]*)\/?>/gi,
5877
5746
  (_match, pre, src, post) => {
5878
- const emoji = (0, import_javascript15.extractEmojiFromUri)(src);
5747
+ const emoji = (0, import_javascript17.extractEmojiFromUri)(src);
5879
5748
  if (!emoji) {
5880
5749
  return _match;
5881
5750
  }
@@ -5886,7 +5755,7 @@ var resolveEmojiUrisInHtml = (html) => {
5886
5755
  );
5887
5756
  return withEmojiImages.replace(
5888
5757
  /emoji:([^\s"<>&]+)/g,
5889
- (_, rest) => (0, import_javascript15.isEmojiUri)(`emoji:${rest}`) ? rest : `emoji:${rest}`
5758
+ (_, rest) => (0, import_javascript17.isEmojiUri)(`emoji:${rest}`) ? rest : `emoji:${rest}`
5890
5759
  );
5891
5760
  };
5892
5761
  var resolveEmojiUrisInHtml_default = resolveEmojiUrisInHtml;