onairos 0.1.201 → 0.1.203

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.
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["React"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,(t=>(()=>{var e,r,n,i,o={317:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={}},586:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(431);e.default=class{BigNum;constructor(){this.BigNum=(t,e)=>new(n.BigNumber.clone({DECIMAL_PLACES:e}))(t)}winstonToAr(t,{formatted:e=!1,decimals:r=12,trim:n=!0}={}){let i=this.stringToBigNum(t,r).shiftedBy(-12);return e?i.toFormat(r):i.toFixed(r)}arToWinston(t,{formatted:e=!1}={}){let r=this.stringToBigNum(t).shiftedBy(12);return e?r.toFormat():r.toFixed(0)}compare(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.comparedTo(n)}isEqual(t,e){return 0===this.compare(t,e)}isLessThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isLessThan(n)}isGreaterThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isGreaterThan(n)}add(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.plus(e).toFixed(0)}sub(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.minus(e).toFixed(0)}stringToBigNum(t,e=12){return this.BigNum(t,e)}}},759:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498);r(317);class i{api;network;static HASH_ENDPOINT="block/hash/";static HEIGHT_ENDPOINT="block/height/";constructor(t,e){this.api=t,this.network=e}async get(t){const e=await this.api.get(`${i.HASH_ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getByHeight(t){const e=await this.api.get(`${i.HEIGHT_ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getCurrent(){const{current:t}=await this.network.getInfo();return await this.get(t)}}e.default=i},879:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498),i=r(244);e.default=class{api;constructor(t){this.api=t}async getTransactionOffset(t){const e=await this.api.get(`tx/${t}/offset`);if(200===e.status)return e.data;throw new Error(`Unable to get transaction offset: ${(0,n.getError)(e)}`)}async getChunk(t){const e=await this.api.get(`chunk/${t}`);if(200===e.status)return e.data;throw new Error(`Unable to get chunk: ${(0,n.getError)(e)}`)}async getChunkData(t){const e=await this.getChunk(t);return i.b64UrlToBuffer(e.chunk)}firstChunkOffset(t){return parseInt(t.offset)-parseInt(t.size)+1}async downloadChunkedData(t){const e=await this.getTransactionOffset(t),r=parseInt(e.size),n=parseInt(e.offset)-r+1,i=new Uint8Array(r);let o=0;for(;o<r;){let t;this.api.config.logging&&console.log(`[chunk] ${o}/${r}`);try{t=await this.getChunkData(n+o)}catch(t){console.error(`[chunk] Failed to fetch chunk at offset ${n+o}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(!t)throw new Error(`Couldn't complete data download at ${o}/${r}`);i.set(t,o),o+=t.length}return i}}},536:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(586),i=r(874),o=r(363),s=r(248),a=r(935),c=r(927),u=r(825),l=r(244),h=r(243),f=r(879),d=r(759);class p{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new o.default;static utils=l;constructor(t){this.api=new i.default(t),this.wallets=new c.default(this.api,p.crypto),this.chunks=new f.default(this.api),this.transactions=new a.default(this.api,p.crypto,this.chunks),this.silo=new h.default(this.api,this.crypto,this.transactions),this.network=new s.default(this.api),this.blocks=new d.default(this.api,this.network),this.ar=new n.default}get crypto(){return p.crypto}get utils(){return p.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(t,e){const r={};if(Object.assign(r,t),!(t.data||t.target&&t.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(null==t.owner&&e&&"use_wallet"!==e&&(r.owner=e.n),null==t.last_tx&&(r.last_tx=await this.transactions.getTransactionAnchor()),"string"==typeof t.data&&(t.data=l.stringToBuffer(t.data)),t.data instanceof ArrayBuffer&&(t.data=new Uint8Array(t.data)),t.data&&!(t.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(null==t.reward){const e=t.data?t.data.byteLength:0;r.reward=await this.transactions.getPrice(e,r.target)}r.data_root="",r.data_size=t.data?t.data.byteLength.toString():"0",r.data=t.data||new Uint8Array(0);const n=new u.default(r);return await n.getSignatureData(),n}async createSiloTransaction(t,e,r){const n={};if(Object.assign(n,t),!t.data)throw new Error("Silo transactions must have a 'data' value");if(!r)throw new Error("No Silo URI specified.");if(t.target||t.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(null==t.owner){if(!e||!e.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");n.owner=e.n}null==t.last_tx&&(n.last_tx=await this.transactions.getTransactionAnchor());const i=await this.silo.parseUri(r);if("string"==typeof t.data){const e=await this.crypto.encrypt(l.stringToBuffer(t.data),i.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}if(t.data instanceof Uint8Array){const e=await this.crypto.encrypt(t.data,i.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}const o=new u.default(n);return o.addTag("Silo-Name",i.getAccessKey()),o.addTag("Silo-Version","0.1.0"),o}arql(t){return this.api.post("/arql",t).then((t=>t.data||[]))}}e.default=p},386:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0});const o=r(536),s=r(118);o.default.init=function(t={}){const e={host:"arweave.net",port:443,protocol:"https"};if("object"!=typeof location||!location.protocol||!location.hostname)return new o.default({...t,...e});const r=location.protocol.replace(":",""),n=location.hostname,i=location.port?parseInt(location.port):"https"==r?443:80,a=(0,s.getDefaultConfig)(r,n),c=t.protocol||a.protocol,u=t.host||a.host,l=t.port||a.port||i;return new o.default({...t,host:u,protocol:c,port:l})},"object"==typeof globalThis?globalThis.Arweave=o.default:"object"==typeof self&&(self.Arweave=o.default),i(r(536),e),e.default=o.default},874:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(t){this.applyConfig(t)}applyConfig(t){this.config=this.mergeDefaults(t)}getConfig(){return this.config}mergeDefaults(t){const e=t.protocol||"http",r=t.port||("https"===e?443:80);return{host:t.host||"127.0.0.1",protocol:e,port:r,timeout:t.timeout||2e4,logging:t.logging||!1,logger:t.logger||console.log,network:t.network}}async get(t,e){return await this.request(t,{...e,method:this.METHOD_GET})}async post(t,e,r){const n=new Headers(r?.headers||{});return n.get("content-type")?.includes("application/json")||n.append("content-type","application/json"),n.append("accept","application/json, text/plain, */*"),await this.request(t,{...r,method:this.METHOD_POST,body:"string"!=typeof e?JSON.stringify(e):e,headers:n})}async request(t,e){const n=new Headers(e?.headers||{}),i=`${this.config.protocol}://${this.config.host}:${this.config.port}`,o=e?.responseType;delete e?.responseType,t.startsWith("/")&&(t=t.slice(1)),this.config.network&&n.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${i}/${t}`);let s=await fetch(`${i}/${t}`,{...e||{},headers:n});this.config.logging&&this.config.logger(`Response: ${s.url} - ${s.status}`);const a=s.headers.get("content-type"),c=a?.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i)?.[1],u=s,l=async()=>{if(c)try{u.data=new TextDecoder(c).decode(await s.arrayBuffer())}catch(t){u.data=await s.text()}else u.data=await s.text()};if("arraybuffer"===o)u.data=await s.arrayBuffer();else if("text"===o)await l();else if("webstream"===o)u.data=r(s.body);else try{let t=await s.clone().json();"object"!=typeof t?await l():u.data=await s.json(),t=null}catch{await l()}return u}};const r=t=>{const e=t;return void 0===e[Symbol.asyncIterator]?(e[Symbol.asyncIterator]=n(t),e):t},n=function(t){return async function*(){const e=t.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}}},363:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(244);e.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let t=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),e=await this.driver.exportKey("jwk",t.privateKey);return{kty:e.kty,e:e.e,n:e.n,d:e.d,p:e.p,q:e.q,dp:e.dp,dq:e.dq,qi:e.qi}}async sign(t,e,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(n)}async hash(t,e="SHA-256"){let r=await this.driver.digest(e,t);return new Uint8Array(r)}async verify(t,e,r){const n={kty:"RSA",e:"AQAB",n:t},i=await this.jwkToPublicCryptoKey(n),o=await this.driver.digest("SHA-256",e),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},i,r,e),a=await this.driver.verify({name:"RSA-PSS",saltLength:32},i,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((i.algorithm.modulusLength-1)/8)-o.byteLength-2},i,r,e);return s||a||c}async jwkToCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if("undefined"==typeof crypto)return!1;const t=crypto?.subtle;if(void 0===t)return!1;return["generateKey","importKey","exportKey","digest","sign"].every((e=>"function"==typeof t[e]))}async encrypt(t,e,r){const i=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=new Uint8Array(16);crypto.getRandomValues(s);const a=await this.driver.encrypt({name:"AES-CBC",iv:s},o,t);return n.concatBuffers([s,a])}async decrypt(t,e,r){const i=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=t.slice(0,16),a=await this.driver.decrypt({name:"AES-CBC",iv:s},o,t.slice(16));return n.concatBuffers([a])}}},921:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(536);async function i(t){if(Array.isArray(t)){const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("list"),n.default.utils.stringToBuffer(t.length.toString())]);return await o(t,await n.default.crypto.hash(e,"SHA-384"))}const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("blob"),n.default.utils.stringToBuffer(t.byteLength.toString())]),r=n.default.utils.concatBuffers([await n.default.crypto.hash(e,"SHA-384"),await n.default.crypto.hash(t,"SHA-384")]);return await n.default.crypto.hash(r,"SHA-384")}async function o(t,e){if(t.length<1)return e;const r=n.default.utils.concatBuffers([e,await i(t[0])]),s=await n.default.crypto.hash(r,"SHA-384");return await o(t.slice(1),s)}e.default=i},498:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getError=void 0;class r extends Error{type;response;constructor(t,e={}){e.message?super(e.message):super(),this.type=t,this.response=e.response}getType(){return this.type}}e.default=r,e.getError=function(t){let e=t.data;if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch(t){}return e?e.error||e:t.statusText||"unknown"}},224:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.validatePath=e.arrayCompare=e.bufferToInt=e.intToBuffer=e.arrayFlatten=e.generateProofs=e.buildLayers=e.generateTransactionChunks=e.generateTree=e.computeRootHash=e.generateLeaves=e.chunkData=e.MIN_CHUNK_SIZE=e.MAX_CHUNK_SIZE=void 0;const n=r(536),i=r(244);e.MAX_CHUNK_SIZE=262144,e.MIN_CHUNK_SIZE=32768;const o=32,s=32;async function a(t){let r=[],i=t,o=0;for(;i.byteLength>=e.MAX_CHUNK_SIZE;){let t=e.MAX_CHUNK_SIZE,s=i.byteLength-e.MAX_CHUNK_SIZE;s>0&&s<e.MIN_CHUNK_SIZE&&(t=Math.ceil(i.byteLength/2));const a=i.slice(0,t),c=await n.default.crypto.hash(a);o+=a.byteLength,r.push({dataHash:c,minByteRange:o-a.byteLength,maxByteRange:o}),i=i.slice(t)}return r.push({dataHash:await n.default.crypto.hash(i),minByteRange:o,maxByteRange:o+i.byteLength}),r}async function c(t){return Promise.all(t.map((async({dataHash:t,minByteRange:e,maxByteRange:r})=>({type:"leaf",id:await g(await Promise.all([g(t),g(y(r))])),dataHash:t,minByteRange:e,maxByteRange:r}))))}async function u(t){return await l(await c(await a(t)))}async function l(t,e=0){if(t.length<2){return t[0]}const r=[];for(let e=0;e<t.length;e+=2)r.push(await p(t[e],t[e+1]));return l(r,e+1)}function h(t){const e=f(t);return Array.isArray(e)?d(e):[e]}function f(t,e=new Uint8Array,r=0){if("leaf"==t.type)return{offset:t.maxByteRange-1,proof:(0,i.concatBuffers)([e,t.dataHash,y(t.maxByteRange)])};if("branch"==t.type){const n=(0,i.concatBuffers)([e,t.leftChild.id,t.rightChild.id,y(t.byteRange)]);return[f(t.leftChild,n,r+1),f(t.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function d(t){const e=[];return t.forEach((t=>{Array.isArray(t)?e.push(...d(t)):e.push(t)})),e}async function p(t,e){if(!e)return t;return{type:"branch",id:await g([await g(t.id),await g(e.id),await g(y(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}}async function g(t){return Array.isArray(t)&&(t=n.default.utils.concatBuffers(t)),new Uint8Array(await n.default.crypto.hash(t))}function y(t){const e=new Uint8Array(o);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function w(t){let e=0;for(var r=0;r<t.length;r++)e*=256,e+=t[r];return e}e.chunkData=a,e.generateLeaves=c,e.computeRootHash=async function(t){return(await u(t)).id},e.generateTree=u,e.generateTransactionChunks=async function(t){const e=await a(t),r=await c(e),n=await l(r),i=await h(n),o=e.slice(-1)[0];return o.maxByteRange-o.minByteRange==0&&(e.splice(e.length-1,1),i.splice(i.length-1,1)),{data_root:n.id,chunks:e,proofs:i}},e.buildLayers=l,e.generateProofs=h,e.arrayFlatten=d,e.intToBuffer=y,e.bufferToInt=w;e.arrayCompare=(t,e)=>t.every(((t,r)=>e[r]===t)),e.validatePath=async function t(r,n,i,a,c){if(a<=0)return!1;if(n>=a)return t(r,0,a-1,a,c);if(n<0)return t(r,0,0,a,c);if(c.length==s+o){const t=c.slice(0,s),n=c.slice(t.length,t.length+o),u=await g([await g(t),await g(n)]);return!!(0,e.arrayCompare)(r,u)&&{offset:a-1,leftBound:i,rightBound:a,chunkSize:a-i}}const u=c.slice(0,s),l=c.slice(u.length,u.length+s),h=c.slice(u.length+l.length,u.length+l.length+o),f=w(h),d=c.slice(u.length+l.length+h.length),p=await g([await g(u),await g(l),await g(h)]);return!!(0,e.arrayCompare)(r,p)&&(n<f?await t(u,n,i,Math.min(a,f),d):await t(l,n,Math.max(i,f),a,d))},e.debug=async function t(e,r=""){if(e.byteLength<1)return r;const n=e.slice(0,s),i=e.slice(n.length,n.length+s),a=e.slice(n.length+i.length,n.length+i.length+o),c=w(a),u=e.slice(n.length+i.length+a.length),l=await g([await g(n),await g(i),await g(a)]);return t(u,`${r}\n${JSON.stringify(Buffer.from(n))},${JSON.stringify(Buffer.from(i))},${c} => ${JSON.stringify(l)}`)}},246:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionUploader=void 0;const n=r(825),i=r(244),o=r(498),s=r(224),a=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"];class c{api;chunkIndex=0;txPosted=!1;transaction;lastRequestTimeEnd=0;totalErrors=0;data;lastResponseStatus=0;lastResponseError="";get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(t,e){if(this.api=t,!e.id)throw new Error("Transaction is not signed");if(!e.chunks)throw new Error("Transaction chunks not prepared");this.data=e.data,this.transaction=new n.default(Object.assign({},e,{data:new Uint8Array(0)}))}async uploadChunk(t){if(this.isComplete)throw new Error("Upload is already complete");if(""!==this.lastResponseError?this.totalErrors++:this.totalErrors=0,100===this.totalErrors)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let e=""===this.lastResponseError?0:Math.max(this.lastRequestTimeEnd+4e4-Date.now(),4e4);if(e>0&&(e-=e*Math.random()*.3,await new Promise((t=>setTimeout(t,e)))),this.lastResponseError="",!this.txPosted)return void await this.postTransaction();t&&(this.chunkIndex=t);const r=this.transaction.getChunk(t||this.chunkIndex,this.data);if(!await(0,s.validatePath)(this.transaction.chunks.data_root,parseInt(r.offset),0,parseInt(r.data_size),i.b64UrlToBuffer(r.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);const n=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch((t=>(console.error(t.message),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,200==this.lastResponseStatus)this.chunkIndex++;else if(this.lastResponseError=(0,o.getError)(n),a.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(t,e,r){if(!e||"number"!=typeof e.chunkIndex||"object"!=typeof e.transaction)throw new Error("Serialized object does not match expected format.");var i=new n.default(e.transaction);i.chunks||await i.prepareChunks(r);const o=new c(t,i);if(o.chunkIndex=e.chunkIndex,o.lastRequestTimeEnd=e.lastRequestTimeEnd,o.lastResponseError=e.lastResponseError,o.lastResponseStatus=e.lastResponseStatus,o.txPosted=e.txPosted,o.data=r,o.transaction.data_root!==e.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return o}static async fromTransactionId(t,e){const r=await t.get(`tx/${e}`);if(200!==r.status)throw new Error(`Tx ${e} not found: ${r.status}`);const n=r.data;n.data=new Uint8Array(0);return{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:n}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=1){this.transaction.data=this.data;const t=await this.api.post("tx",this.transaction).catch((t=>(console.error(t),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,this.transaction.data=new Uint8Array(0),t.status>=200&&t.status<300)return this.txPosted=!0,void(this.chunkIndex=1);throw this.lastResponseError=(0,o.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`)}const t=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,!(t.status>=200&&t.status<300))throw this.lastResponseError=(0,o.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`);this.txPosted=!0}}e.TransactionUploader=c},825:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=void 0;const n=r(244),i=r(921),o=r(224);class s{get(t,e){if(!Object.getOwnPropertyNames(this).includes(t))throw new Error(`Field "${t}" is not a property of the Arweave Transaction class.`);if(this[t]instanceof Uint8Array)return e&&e.decode&&e.string?n.bufferToString(this[t]):e&&e.decode&&!e.string?this[t]:n.bufferTob64Url(this[t]);if(this[t]instanceof Array){if(void 0!==e?.decode||void 0!==e?.string)throw"tags"===t&&console.warn("Did you mean to use 'transaction[\"tags\"]' ?"),new Error("Cannot decode or stringify an array.");return this[t]}return e&&1==e.decode?e&&e.string?n.b64UrlToString(this[t]):n.b64UrlToBuffer(this[t]):this[t]}}class a extends s{name;value;constructor(t,e,r=!1){super(),this.name=t,this.value=e}}e.Tag=a;e.default=class extends s{format=2;id="";last_tx="";owner="";tags=[];target="";quantity="0";data_size="0";data=new Uint8Array;data_root="";reward="0";signature="";chunks;constructor(t={}){super(),Object.assign(this,t),"string"==typeof this.data&&(this.data=n.b64UrlToBuffer(this.data)),t.tags&&(this.tags=t.tags.map((t=>new a(t.name,t.value))))}addTag(t,e){this.tags.push(new a(n.stringToB64Url(t),n.stringToB64Url(e)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:n.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(t){this.owner=t}setSignature({id:t,owner:e,reward:r,tags:n,signature:i}){this.id=t,this.owner=e,r&&(this.reward=r),n&&(this.tags=n),this.signature=i}async prepareChunks(t){!this.chunks&&t.byteLength>0&&(this.chunks=await(0,o.generateTransactionChunks)(t),this.data_root=n.bufferTob64Url(this.chunks.data_root)),this.chunks||0!==t.byteLength||(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(t,e){if(!this.chunks)throw new Error("Chunks have not been prepared");const r=this.chunks.proofs[t],i=this.chunks.chunks[t];return{data_root:this.data_root,data_size:this.data_size,data_path:n.bufferTob64Url(r.proof),offset:r.offset.toString(),chunk:n.bufferTob64Url(e.slice(i.minByteRange,i.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let t=this.tags.reduce(((t,e)=>n.concatBuffers([t,e.get("name",{decode:!0,string:!1}),e.get("value",{decode:!0,string:!1})])),new Uint8Array);return n.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),t]);case 2:this.data_root||await this.prepareChunks(this.data);const e=this.tags.map((t=>[t.get("name",{decode:!0,string:!1}),t.get("value",{decode:!0,string:!1})]));return await(0,i.default)([n.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e,n.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}},244:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.b64UrlDecode=e.b64UrlEncode=e.bufferTob64Url=e.bufferTob64=e.b64UrlToBuffer=e.stringToB64Url=e.stringToBuffer=e.bufferToString=e.b64UrlToString=e.concatBuffers=void 0;const n=r(742);function i(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function o(t){return(new TextEncoder).encode(t)}function s(t){return new Uint8Array(n.toByteArray(l(t)))}function a(t){return n.fromByteArray(new Uint8Array(t))}function c(t){return u(a(t))}function u(t){try{return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}catch(t){throw new Error("Failed to encode string",{cause:t})}}function l(t){try{let e;return e=(t=t.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-t.length%4,t.concat("=".repeat(e))}catch(t){throw new Error("Failed to decode string",{cause:t})}}e.concatBuffers=function(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let e=1;e<t.length;e++)r.set(new Uint8Array(t[e]),n),n+=t[e].byteLength;return r},e.b64UrlToString=function(t){return i(s(t))},e.bufferToString=i,e.stringToBuffer=o,e.stringToB64Url=function(t){return c(o(t))},e.b64UrlToBuffer=s,e.bufferTob64=a,e.bufferTob64Url=c,e.b64UrlEncode=u,e.b64UrlDecode=l},118:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultConfig=void 0;e.getDefaultConfig=(t,e)=>{if(((t,e)=>{const r=/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,n=e.split("."),i=n[n.length-1],o=["localhost","[::1]"];return o.includes(e)||"file"==t||o.includes(i)||!!e.match(r)||!!i.match(r)})(t,e))return{protocol:"https",host:"arweave.net",port:443};if(!(t=>{const e="["===t.charAt(0);return!!t.match(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)||e})(e)){let r=e.split(".");if(r.length>=3){r.shift();return{protocol:t,host:r.join(".")}}}return{protocol:t,host:e}}},248:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{api;constructor(t){this.api=t}getInfo(){return this.api.get("info").then((t=>t.data))}getPeers(){return this.api.get("peers").then((t=>t.data))}}},243:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SiloResource=void 0;const n=r(244);e.default=class{api;crypto;transactions;constructor(t,e,r){this.api=t,this.crypto=e,this.transactions=r}async get(t){if(!t)throw new Error("No Silo URI specified");const e=await this.parseUri(t),r=await this.transactions.search("Silo-Name",e.getAccessKey());if(0==r.length)throw new Error(`No data could be found for the Silo URI: ${t}`);const n=await this.transactions.get(r[0]);if(!n)throw new Error(`No data could be found for the Silo URI: ${t}`);const i=n.get("data",{decode:!0,string:!1});return this.crypto.decrypt(i,e.getEncryptionKey())}async readTransactionData(t,e){if(!e)throw new Error("No Silo URI specified");const r=await this.parseUri(e),n=t.get("data",{decode:!0,string:!1});return this.crypto.decrypt(n,r.getEncryptionKey())}async parseUri(t){const e=t.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!e)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");const r=e[1],o=Math.pow(2,parseInt(e[2])),s=await this.hash(n.stringToBuffer(r),o),a=n.bufferTob64(s.slice(0,15)),c=await this.hash(s.slice(16,31),1);return new i(t,a,c)}async hash(t,e){let r=await this.crypto.hash(t);for(let t=0;t<e-1;t++)r=await this.crypto.hash(r);return r}};class i{uri;accessKey;encryptionKey;constructor(t,e,r){this.uri=t,this.accessKey=e,this.encryptionKey=r}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}e.SiloResource=i},935:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498),i=r(825),o=r(244),s=r(246);r(317);e.default=class{api;crypto;chunks;constructor(t,e,r){this.api=t,this.crypto=e,this.chunks=r}async getTransactionAnchor(){const t=await this.api.get("tx_anchor");if(!t.data.match(/^[a-z0-9_-]{43,}/i)||!t.ok)throw new Error(`Could not getTransactionAnchor. Received: ${t.data}. Status: ${t.status}, ${t.statusText}`);return t.data}async getPrice(t,e){let r=e?`price/${t}/${e}`:`price/${t}`;const n=await this.api.get(r);if(!/^\d+$/.test(n.data)||!n.ok)throw new Error(`Could not getPrice. Received: ${n.data}. Status: ${n.status}, ${n.statusText}`);return n.data}async get(t){const e=await this.api.get(`tx/${t}`);if(200==e.status){const r=parseInt(e.data.data_size);if(e.data.format>=2&&r>0&&r<=12582912){const r=await this.getData(t);return new i.default({...e.data,data:r})}return new i.default({...e.data,format:e.data.format||1})}if(404==e.status)throw new n.default("TX_NOT_FOUND");if(410==e.status)throw new n.default("TX_FAILED");throw new n.default("TX_INVALID")}fromRaw(t){return new i.default(t)}async search(t,e){return this.api.post("arql",{op:"equals",expr1:t,expr2:e}).then((t=>t.data?t.data:[]))}getStatus(t){return this.api.get(`tx/${t}/status`).then((t=>200==t.status?{status:200,confirmed:t.data}:{status:t.status,confirmed:null}))}async getData(t,e){let r;try{r=await this.chunks.downloadChunkedData(t)}catch(e){console.error(`Error while trying to download chunked data for ${t}`),console.error(e)}if(!r){console.warn(`Falling back to gateway cache for ${t}`);try{const{data:e,ok:n,status:i,statusText:o}=await this.api.get(`/${t}`,{responseType:"arraybuffer"});if(!n)throw new Error("Bad http status code",{cause:{status:i,statusText:o}});r=e}catch(e){console.error(`Error while trying to download contiguous data from gateway cache for ${t}`),console.error(e)}}if(!r)throw new Error(`${t} data was not found!`);return e&&e.decode&&!e.string?r:e&&e.decode&&e.string?o.bufferToString(r):o.bufferTob64Url(r)}async sign(t,e,r){const n="object"==typeof e&&(t=>{let e=!0;return["n","e","d","p","q","dp","dq","qi"].map((r=>!(r in t)&&(e=!1))),e})(e),i="object"==typeof arweaveWallet;if(!n&&!i)throw new Error("No valid JWK or external wallet found to sign transaction.");if(n){t.setOwner(e.n);let n=await t.getSignatureData(),i=await this.crypto.sign(e,n,r),s=await this.crypto.hash(i);t.setSignature({id:o.bufferTob64Url(s),owner:e.n,signature:o.bufferTob64Url(i)})}else{if(!i)throw new Error("An error occurred while signing. Check wallet is valid");{try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}const e=await arweaveWallet.sign(t,r);t.setSignature({id:e.id,owner:e.owner,reward:e.reward,tags:e.tags,signature:e.signature})}}}async verify(t){const e=await t.getSignatureData(),r=t.get("signature",{decode:!0,string:!1}),n=o.bufferTob64Url(await this.crypto.hash(r));if(t.id!==n)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(t.owner,e,r)}async post(t){if("string"==typeof t?t=new i.default(JSON.parse(t)):"function"==typeof t.readInt32BE?t=new i.default(JSON.parse(t.toString())):"object"!=typeof t||t instanceof i.default||(t=new i.default(t)),!(t instanceof i.default))throw new Error("Must be Transaction object");t.chunks||await t.prepareChunks(t.data);const e=await this.getUploader(t,t.data);try{for(;!e.isComplete;)await e.uploadChunk()}catch(t){if(e.lastResponseStatus>0)return{status:e.lastResponseStatus,statusText:e.lastResponseError,data:{error:e.lastResponseError}};throw t}return{status:200,statusText:"OK",data:{}}}async getUploader(t,e){let r;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),t instanceof i.default){if(e||(e=t.data),!(e instanceof Uint8Array))throw new Error("Data format is invalid");t.chunks||await t.prepareChunks(e),r=new s.TransactionUploader(this.api,t),r.data&&0!==r.data.length||(r.data=e)}else{if("string"==typeof t&&(t=await s.TransactionUploader.fromTransactionId(this.api,t)),!(e&&e instanceof Uint8Array))throw new Error("Must provide data when resuming upload");r=await s.TransactionUploader.fromSerialized(this.api,t,e)}return r}async*upload(t,e){const r=await this.getUploader(t,e);for(;!r.isComplete;)await r.uploadChunk(),yield r;return r}}},927:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(244);r(317);e.default=class{api;crypto;constructor(t,e){this.api=t,this.crypto=e}getBalance(t){return this.api.get(`wallet/${t}/balance`).then((t=>t.data))}getLastTransactionID(t){return this.api.get(`wallet/${t}/last_tx`).then((t=>t.data))}generate(){return this.crypto.generateJWK()}async jwkToAddress(t){return t&&"use_wallet"!==t?this.getAddress(t):this.getAddress()}async getAddress(t){if(t&&"use_wallet"!==t)return this.ownerToAddress(t.n);try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}async ownerToAddress(t){return n.bufferTob64Url(await this.crypto.hash(n.b64UrlToBuffer(t)))}}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),l=0,h=c>0?s-4:s;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;a<u;a+=s)o.push(c(t,a,a+s>u?u:a+s));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,s=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},431:function(t,e,r){var n;!function(i){"use strict";var o,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",h=1e14,f=14,d=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],g=1e7,y=1e9;function w(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,i=t.length,o=t[0]+"";n<i;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function b(t,e){var r,n,i=t.c,o=e.c,s=t.s,a=e.s,c=t.e,u=e.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=c==u,!i||!o)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=o.length)?c:u,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function E(t){var e=t.c.length-1;return w(t.e/f)==e&&t.c[e]%2!=0}function S(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function T(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}o=function t(e){var r,n,i,o,A,k,I,O,R,B,_=F.prototype={constructor:F,toString:null,valueOf:null},U=new F(1),C=20,P=4,x=-7,L=21,N=-1e7,j=1e7,D=!1,K=1,M=0,z={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},W="0123456789abcdefghijklmnopqrstuvwxyz",Z=!0;function F(t,e){var r,o,a,u,h,p,g,y,w=this;if(!(w instanceof F))return new F(t,e);if(null==e){if(t&&!0===t._isBigNumber)return w.s=t.s,void(!t.c||t.e>j?w.c=w.e=null:t.e<N?w.c=[w.e=0]:(w.e=t.e,w.c=t.c.slice()));if((p="number"==typeof t)&&0*t==0){if(w.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,h=t;h>=10;h/=10,u++);return void(u>j?w.c=w.e=null:(w.e=u,w.c=[t]))}y=String(t)}else{if(!s.test(y=String(t)))return i(w,y,p);w.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}(u=y.indexOf("."))>-1&&(y=y.replace(".","")),(h=y.search(/e/i))>0?(u<0&&(u=h),u+=+y.slice(h+1),y=y.substring(0,h)):u<0&&(u=y.length)}else{if(v(e,2,W.length,"Base"),10==e&&Z)return X(w=new F(t),C+w.e+1,P);if(y=String(t),p="number"==typeof t){if(0*t!=0)return i(w,y,p,e);if(w.s=1/t<0?(y=y.slice(1),-1):1,F.DEBUG&&y.replace(/^0\.0*|\./,"").length>15)throw Error(l+t)}else w.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1;for(r=W.slice(0,e),u=h=0,g=y.length;h<g;h++)if(r.indexOf(o=y.charAt(h))<0){if("."==o){if(h>u){u=g;continue}}else if(!a&&(y==y.toUpperCase()&&(y=y.toLowerCase())||y==y.toLowerCase()&&(y=y.toUpperCase()))){a=!0,h=-1,u=0;continue}return i(w,String(t),p,e)}p=!1,(u=(y=n(y,e,10,w.s)).indexOf("."))>-1?y=y.replace(".",""):u=y.length}for(h=0;48===y.charCodeAt(h);h++);for(g=y.length;48===y.charCodeAt(--g););if(y=y.slice(h,++g)){if(g-=h,p&&F.DEBUG&&g>15&&(t>d||t!==c(t)))throw Error(l+w.s*t);if((u=u-h-1)>j)w.c=w.e=null;else if(u<N)w.c=[w.e=0];else{if(w.e=u,w.c=[],h=(u+1)%f,u<0&&(h+=f),h<g){for(h&&w.c.push(+y.slice(0,h)),g-=f;h<g;)w.c.push(+y.slice(h,h+=f));h=f-(y=y.slice(h)).length}else h-=g;for(;h--;y+="0");w.c.push(+y)}}else w.c=[w.e=0]}function H(t,e,r,n){var i,o,s,a,c;if(null==r?r=P:v(r,0,8),!t.c)return t.toString();if(i=t.c[0],s=t.e,null==e)c=m(t.c),c=1==n||2==n&&(s<=x||s>=L)?S(c,s):T(c,s,"0");else if(o=(t=X(new F(t),e,r)).e,a=(c=m(t.c)).length,1==n||2==n&&(e<=o||o<=x)){for(;a<e;c+="0",a++);c=S(c,o)}else if(e-=s,c=T(c,o,"0"),o+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=o-a)>0)for(o+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function $(t,e){for(var r,n,i=1,o=new F(t[0]);i<t.length;i++)(!(n=new F(t[i])).s||(r=b(o,n))===e||0===r&&o.s===e)&&(o=n);return o}function G(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*f-1)>j?t.c=t.e=null:r<N?t.c=[t.e=0]:(t.e=r,t.c=e),t}function X(t,e,r,n){var i,o,s,u,l,d,g,y=t.c,w=p;if(y){t:{for(i=1,u=y[0];u>=10;u/=10,i++);if((o=e-i)<0)o+=f,s=e,l=y[d=0],g=c(l/w[i-s-1]%10);else if((d=a((o+1)/f))>=y.length){if(!n)break t;for(;y.length<=d;y.push(0));l=g=0,i=1,s=(o%=f)-f+1}else{for(l=u=y[d],i=1;u>=10;u/=10,i++);g=(s=(o%=f)-f+i)<0?0:c(l/w[i-s-1]%10)}if(n=n||e<0||null!=y[d+1]||(s<0?l:l%w[i-s-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(o>0?s>0?l/w[i-s]:0:y[d-1])%10&1||r==(t.s<0?8:7)),e<1||!y[0])return y.length=0,n?(e-=t.e+1,y[0]=w[(f-e%f)%f],t.e=-e||0):y[0]=t.e=0,t;if(0==o?(y.length=d,u=1,d--):(y.length=d+1,u=w[f-o],y[d]=s>0?c(l/w[i-s]%w[s])*u:0),n)for(;;){if(0==d){for(o=1,s=y[0];s>=10;s/=10,o++);for(s=y[0]+=u,u=1;s>=10;s/=10,u++);o!=u&&(t.e++,y[0]==h&&(y[0]=1));break}if(y[d]+=u,y[d]!=h)break;y[d--]=0,u=1}for(o=y.length;0===y[--o];y.pop());}t.e>j?t.c=t.e=null:t.e<N&&(t.c=[t.e=0])}return t}function V(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=x||r>=L?S(e,r):T(e,r,"0"),t.s<0?"-"+e:e)}return F.clone=t,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,y,e),C=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),P=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-y,0,e),v(r[1],0,y,e),x=r[0],L=r[1]):(v(r,-y,y,e),x=-(L=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-y,-1,e),v(r[1],1,y,e),N=r[0],j=r[1];else{if(v(r,-y,y,e),!r)throw Error(u+e+" cannot be zero: "+r);N=-(j=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw D=!r,Error(u+"crypto unavailable");D=r}else D=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),K=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,y,e),M=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);z=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);Z="0123456789"==r.slice(0,10),W=r}}return{DECIMAL_PLACES:C,ROUNDING_MODE:P,EXPONENTIAL_AT:[x,L],RANGE:[N,j],CRYPTO:D,MODULO_MODE:K,POW_PRECISION:M,FORMAT:z,ALPHABET:W}},F.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!F.DEBUG)return!0;var e,r,n=t.c,i=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-y&&i<=y&&i===c(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break t}if((e=(i+1)%f)<1&&(e+=f),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||r>=h||r!==c(r))break t;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(u+"Invalid BigNumber: "+t)},F.maximum=F.max=function(){return $(arguments,-1)},F.minimum=F.min=function(){return $(arguments,1)},F.random=(o=9007199254740992,A=Math.random()*o&2097151?function(){return c(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,i,o,s=0,l=[],h=new F(U);if(null==t?t=C:v(t,0,y),i=a(t/f),D)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)(o=131072*e[s]+(e[s+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[s]=r[0],e[s+1]=r[1]):(l.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw D=!1,Error(u+"crypto unavailable");for(e=crypto.randomBytes(i*=7);s<i;)(o=281474976710656*(31&e[s])+1099511627776*e[s+1]+4294967296*e[s+2]+16777216*e[s+3]+(e[s+4]<<16)+(e[s+5]<<8)+e[s+6])>=9e15?crypto.randomBytes(7).copy(e,s):(l.push(o%1e14),s+=7);s=i/7}if(!D)for(;s<i;)(o=A())<9e15&&(l[s++]=o%1e14);for(i=l[--s],t%=f,i&&t&&(o=p[f-t],l[s]=c(i/o)*o);0===l[s];l.pop(),s--);if(s<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=f);for(s=1,o=l[0];o>=10;o/=10,s++);s<f&&(n-=f-s)}return h.e=n,h.c=l,h}),F.sum=function(){for(var t=1,e=arguments,r=new F(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,o,s=[0],a=0,c=t.length;a<c;){for(o=s.length;o--;s[o]*=e);for(s[0]+=n.indexOf(t.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var c,u,l,h,f,d,p,g,y=n.indexOf("."),w=C,b=P;for(y>=0&&(h=M,M=0,n=n.replace(".",""),d=(g=new F(i)).pow(n.length-y),M=h,g.c=e(T(m(d.c),d.e,"0"),10,o,t),g.e=g.c.length),l=h=(p=e(n,i,o,a?(c=W,t):(c=t,W))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(y<0?--l:(d.c=p,d.e=l,d.s=s,p=(d=r(d,g,w,b,o)).c,f=d.r,l=d.e),y=p[u=l+w+1],h=o/2,f=f||u<0||null!=p[u+1],f=b<4?(null!=y||f)&&(0==b||b==(d.s<0?3:2)):y>h||y==h&&(4==b||f||6==b&&1&p[u-1]||b==(d.s<0?8:7)),u<1||!p[0])n=f?T(c.charAt(1),-w,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--o;++p[--u]>o;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=c.charAt(p[y++]));n=T(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,o,s,a=0,c=t.length,u=e%g,l=e/g|0;for(t=t.slice();c--;)a=((i=u*(o=t[c]%g)+(n=l*o+(s=t[c]/g|0)*u)%g*g+a)/r|0)+(n/g|0)+l*s,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,o,s,a){var u,l,d,p,g,y,m,b,v,E,S,T,A,k,I,O,R,B=n.s==i.s?1:-1,_=n.c,U=i.c;if(!(_&&_[0]&&U&&U[0]))return new F(n.s&&i.s&&(_?!U||_[0]!=U[0]:U)?_&&0==_[0]||!U?0*B:B/0:NaN);for(v=(b=new F(B)).c=[],B=o+(l=n.e-i.e)+1,a||(a=h,l=w(n.e/f)-w(i.e/f),B=B/f|0),d=0;U[d]==(_[d]||0);d++);if(U[d]>(_[d]||0)&&l--,B<0)v.push(1),p=!0;else{for(k=_.length,O=U.length,d=0,B+=2,(g=c(a/(U[0]+1)))>1&&(U=t(U,g,a),_=t(_,g,a),O=U.length,k=_.length),A=O,S=(E=_.slice(0,O)).length;S<O;E[S++]=0);R=U.slice(),R=[0].concat(R),I=U[0],U[1]>=a/2&&I++;do{if(g=0,(u=e(U,E,O,S))<0){if(T=E[0],O!=S&&(T=T*a+(E[1]||0)),(g=c(T/I))>1)for(g>=a&&(g=a-1),m=(y=t(U,g,a)).length,S=E.length;1==e(y,E,m,S);)g--,r(y,O<m?R:U,m,a),m=y.length,u=1;else 0==g&&(u=g=1),m=(y=U.slice()).length;if(m<S&&(y=[0].concat(y)),r(E,y,S,a),S=E.length,-1==u)for(;e(U,E,O,S)<1;)g++,r(E,O<S?R:U,S,a),S=E.length}else 0===u&&(g++,E=[0]);v[d++]=g,E[0]?E[S++]=_[A]||0:(E=[_[A]],S=1)}while((A++<k||null!=E[0])&&B--);p=null!=E[0],v[0]||v.splice(0,1)}if(a==h){for(d=1,B=v[0];B>=10;B/=10,d++);X(b,o+(b.e=d+l*f-1)+1,s,p)}else b.e=l,b.r=+p;return b}}(),k=/^(-?)0([xbo])(?=\w[\w.]*$)/i,I=/^([^.]+)\.$/,O=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,r,n){var i,o=r?e:e.replace(B,"");if(R.test(o))t.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(k,(function(t,e,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?t:e})),n&&(i=n,o=o.replace(I,"$1").replace(O,"0.$1")),e!=o))return new F(o,i);if(F.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},_.absoluteValue=_.abs=function(){var t=new F(this);return t.s<0&&(t.s=1),t},_.comparedTo=function(t,e){return b(this,new F(t,e))},_.decimalPlaces=_.dp=function(t,e){var r,n,i,o=this;if(null!=t)return v(t,0,y),null==e?e=P:v(e,0,8),X(new F(o),t+o.e+1,e);if(!(r=o.c))return null;if(n=((i=r.length-1)-w(this.e/f))*f,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(t,e){return r(this,new F(t,e),C,P)},_.dividedToIntegerBy=_.idiv=function(t,e){return r(this,new F(t,e),0,1)},_.exponentiatedBy=_.pow=function(t,e){var r,n,i,o,s,l,h,d,p=this;if((t=new F(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+V(t));if(null!=e&&(e=new F(e)),s=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new F(Math.pow(+V(p),s?t.s*(2-E(t)):+V(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new F(NaN);(n=!l&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||s&&p.c[1]>=24e7:p.c[0]<8e13||s&&p.c[0]<=9999975e7)))return o=p.s<0&&E(t)?-0:0,p.e>-1&&(o=1/o),new F(l?1/o:o);M&&(o=a(M/f+2))}for(s?(r=new F(.5),l&&(t.s=1),h=E(t)):h=(i=Math.abs(+V(t)))%2,d=new F(U);;){if(h){if(!(d=d.times(p)).c)break;o?d.c.length>o&&(d.c.length=o):n&&(d=d.mod(e))}if(i){if(0===(i=c(i/2)))break;h=i%2}else if(X(t=t.times(r),t.e+1,1),t.e>14)h=E(t);else{if(0===(i=+V(t)))break;h=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):n&&(p=p.mod(e))}return n?d:(l&&(d=U.div(d)),e?d.mod(e):o?X(d,M,P,undefined):d)},_.integerValue=function(t){var e=new F(this);return null==t?t=P:v(t,0,8),X(e,e.e+1,t)},_.isEqualTo=_.eq=function(t,e){return 0===b(this,new F(t,e))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(t,e){return b(this,new F(t,e))>0},_.isGreaterThanOrEqualTo=_.gte=function(t,e){return 1===(e=b(this,new F(t,e)))||0===e},_.isInteger=function(){return!!this.c&&w(this.e/f)>this.c.length-2},_.isLessThan=_.lt=function(t,e){return b(this,new F(t,e))<0},_.isLessThanOrEqualTo=_.lte=function(t,e){return-1===(e=b(this,new F(t,e)))||0===e},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(t,e){var r,n,i,o,s=this,a=s.s;if(e=(t=new F(t,e)).s,!a||!e)return new F(NaN);if(a!=e)return t.s=-e,s.plus(t);var c=s.e/f,u=t.e/f,l=s.c,d=t.c;if(!c||!u){if(!l||!d)return l?(t.s=-e,t):new F(d?s:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new F(l[0]?s:3==P?-0:0)}if(c=w(c),u=w(u),l=l.slice(),a=c-u){for((o=a<0)?(a=-a,i=l):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(o=(a=l.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(l[e]!=d[e]){o=l[e]<d[e];break}if(o&&(i=l,l=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=h-1;n>a;){if(l[--n]<d[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=h}l[n]-=d[n]}for(;0==l[0];l.splice(0,1),--u);return l[0]?G(t,l,u):(t.s=3==P?-1:1,t.c=[t.e=0],t)},_.modulo=_.mod=function(t,e){var n,i,o=this;return t=new F(t,e),!o.c||!t.s||t.c&&!t.c[0]?new F(NaN):!t.c||o.c&&!o.c[0]?new F(o):(9==K?(i=t.s,t.s=1,n=r(o,t,0,3),t.s=i,n.s*=i):n=r(o,t,0,K),(t=o.minus(n.times(t))).c[0]||1!=K||(t.s=o.s),t)},_.multipliedBy=_.times=function(t,e){var r,n,i,o,s,a,c,u,l,d,p,y,m,b,v,E=this,S=E.c,T=(t=new F(t,e)).c;if(!(S&&T&&S[0]&&T[0]))return!E.s||!t.s||S&&!S[0]&&!T||T&&!T[0]&&!S?t.c=t.e=t.s=null:(t.s*=E.s,S&&T?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=w(E.e/f)+w(t.e/f),t.s*=E.s,(c=S.length)<(d=T.length)&&(m=S,S=T,T=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(b=h,v=g,i=d;--i>=0;){for(r=0,p=T[i]%v,y=T[i]/v|0,o=i+(s=c);o>i;)r=((u=p*(u=S[--s]%v)+(a=y*u+(l=S[s]/v|0)*p)%v*v+m[o]+r)/b|0)+(a/v|0)+y*l,m[o--]=u%b;m[o]=r}return r?++n:m.splice(0,1),G(t,m,n)},_.negated=function(){var t=new F(this);return t.s=-t.s||null,t},_.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new F(t,e)).s,!i||!e)return new F(NaN);if(i!=e)return t.s=-e,n.minus(t);var o=n.e/f,s=t.e/f,a=n.c,c=t.c;if(!o||!s){if(!a||!c)return new F(i/0);if(!a[0]||!c[0])return c[0]?t:new F(a[0]?n:0*i)}if(o=w(o),s=w(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/h|0,a[e]=h===a[e]?0:a[e]%h;return i&&(a=[i].concat(a),++s),G(t,a,s)},_.precision=_.sd=function(t,e){var r,n,i,o=this;if(null!=t&&t!==!!t)return v(t,1,y),null==e?e=P:v(e,0,8),X(new F(o),t,e);if(!(r=o.c))return null;if(n=(i=r.length-1)*f+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&o.e+1>n&&(n=o.e+1),n},_.shiftedBy=function(t){return v(t,-9007199254740991,d),this.times("1e"+t)},_.squareRoot=_.sqrt=function(){var t,e,n,i,o,s=this,a=s.c,c=s.s,u=s.e,l=C+4,h=new F("0.5");if(1!==c||!a||!a[0])return new F(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+V(s)))||c==1/0?(((e=m(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=w((u+1)/2)-(u<0||u%2),n=new F(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new F(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(o=n,n=h.times(o.plus(r(s,o,l,1))),m(o.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(X(n,n.e+C+2,1),t=!n.times(n).eq(s));break}if(!i&&(X(o,o.e+C+2,0),o.times(o).eq(s))){n=o;break}l+=4,c+=4,i=1}return X(n,n.e+C+1,P,t)},_.toExponential=function(t,e){return null!=t&&(v(t,0,y),t++),H(this,t,e,1)},_.toFixed=function(t,e){return null!=t&&(v(t,0,y),t=t+this.e+1),H(this,t,e)},_.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=z;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var o,s=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=s[0],f=s[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(o=a,a=c,c=o,g-=o),a>0&&g>0){for(o=g%a||a,h=p.substr(0,o);o<g;o+=a)h+=l+p.substr(o,a);c>0&&(h+=l+p.slice(o)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(t){var e,n,i,o,s,a,c,l,h,d,g,y,w=this,b=w.c;if(null!=t&&(!(c=new F(t)).isInteger()&&(c.c||1!==c.s)||c.lt(U)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+V(c));if(!b)return new F(w);for(e=new F(U),h=n=new F(U),i=l=new F(U),y=m(b),s=e.e=y.length-w.e-1,e.c[0]=p[(a=s%f)<0?f+a:a],t=!t||c.comparedTo(e)>0?s>0?e:h:c,a=j,j=1/0,c=new F(y),l.c[0]=0;d=r(c,e,0,1),1!=(o=n.plus(d.times(i))).comparedTo(t);)n=i,i=o,h=l.plus(d.times(o=h)),l=o,e=c.minus(d.times(o=e)),c=o;return o=r(t.minus(n),i,0,1),l=l.plus(o.times(h)),n=n.plus(o.times(i)),l.s=h.s=w.s,g=r(h,i,s*=2,P).minus(w).abs().comparedTo(r(l,n,s,P).minus(w).abs())<1?[h,i]:[l,n],j=a,g},_.toNumber=function(){return+V(this)},_.toPrecision=function(t,e){return null!=t&&v(t,1,y),H(this,t,e,2)},_.toString=function(t){var e,r=this,i=r.s,o=r.e;return null===o?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=o<=x||o>=L?S(m(r.c),o):T(m(r.c),o,"0"):10===t&&Z?e=T(m((r=X(new F(r),C+o+1,P)).c),r.e,"0"):(v(t,2,W.length,"Base"),e=n(T(m(r.c),o,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},_.valueOf=_.toJSON=function(){return V(this)},_._isBigNumber=!0,null!=e&&F.set(e),F}(),o.default=o.BigNumber=o,void 0===(n=function(){return o}.call(e,r,e,t))||(t.exports=n)}()},764:(t,e,r)=>{"use strict";const n=r(742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=c,e.h2=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let n=a(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|p(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||J(t.length)?a(0):f(t);if("Buffer"===t.type&&Array.isArray(t.data))return f(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return l(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||V(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(t).length;default:if(i)return n?-1:$(t).length;e=(""+e).toLowerCase(),i=!0}}function y(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return I(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(J(n))return s;t[r+s]=n}return s}function E(t,e,r,n){return X($(e,t.length-r),t,r,n)}function S(t,e,r,n){return X(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function T(t,e,r,n){return X(G(e),t,r,n)}function A(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function I(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=O));return r}(n)}c.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},c.allocUnsafe=function(t){return h(t)},c.allocUnsafeSlow=function(t){return h(t)},c.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==c.prototype},c.compare=function(t,e){if(V(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),V(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).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}},c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=c.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(V(e,Uint8Array))i+e.length>n.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},c.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},c.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},c.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?I(this,0,t):y.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){let t="";const r=e.h2;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(V(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<a;++t)if(u[t]!==l[t]){o=u[t],s=l[t];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return S(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const O=4096;function R(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function B(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function _(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Y[t[n]];return i}function U(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function C(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i){W(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){W(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function N(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(t,e,r,n,o){return e=+e,r>>>=0,o||N(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,o){return e=+e,r>>>=0,o||N(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=q((function(t){Z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),c.prototype.readBigUInt64BE=q((function(t){Z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=q((function(t){Z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),c.prototype.readBigInt64BE=q((function(t){Z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),c.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){P(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){P(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=q((function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=q((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=q((function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=q((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=c.isBuffer(t)?t:c.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};const K={};function M(t,e,r){K[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function z(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function W(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new K.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){Z(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||F(e,t.length-(r+1))}(n,i,o)}function Z(t,e){if("number"!=typeof t)throw new K.ERR_INVALID_ARG_TYPE(e,"number",t)}function F(t,e,r){if(Math.floor(t)!==t)throw Z(t,r),new K.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new K.ERR_BUFFER_OUT_OF_BOUNDS;throw new K.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),M("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),M("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=z(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function $(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function G(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function q(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},470:t=>{"use strict";var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===r.call(t)},s=function(t){if(!t||"[object Object]"!==r.call(t))return!1;var n,i=e.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&e.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!i&&!o)return!1;for(n in t);return void 0===n||e.call(t,n)},a=function(t,e){n&&"__proto__"===e.name?n(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,r){if("__proto__"===r){if(!e.call(t,r))return;if(i)return i(t,r).value}return t[r]};t.exports=function t(){var e,r,n,i,u,l,h=arguments[0],f=1,d=arguments.length,p=!1;for("boolean"==typeof h&&(p=h,h=arguments[1]||{},f=2),(null==h||"object"!=typeof h&&"function"!=typeof h)&&(h={});f<d;++f)if(null!=(e=arguments[f]))for(r in e)n=c(h,r),h!==(i=c(e,r))&&(p&&i&&(s(i)||(u=o(i)))?(u?(u=!1,l=n&&o(n)?n:[]):l=n&&s(n)?n:{},a(h,{name:r,newValue:t(p,l,i)})):void 0!==i&&a(h,{name:r,newValue:i}));return h}},645:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+h],h+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+h],h+=f,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*g}},639:e=>{"use strict";e.exports=t}},s={};function a(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return o[t].call(r.exports,r,r.exports,a),r.exports}a.m=o,a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,a.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);a.r(i);var o={};e=e||[null,r({}),r([]),r(r)];for(var s=2&n&&t;"object"==typeof s&&!~e.indexOf(s);s=r(s))Object.getOwnPropertyNames(s).forEach((e=>o[e]=()=>t[e]));return o.default=()=>t,a.d(i,o),i},a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.f={},a.e=t=>Promise.all(Object.keys(a.f).reduce(((e,r)=>(a.f[r](t,e),e)),[])),a.u=t=>t+".onairos.bundle.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n={},i="onairos:",a.l=(t,e,r,o)=>{if(n[t])n[t].push(e);else{var s,c;if(void 0!==r)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var h=u[l];if(h.getAttribute("src")==t||h.getAttribute("data-webpack")==i+r){s=h;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",i+r),s.src=t),n[t]=[e];var f=(e,r)=>{s.onerror=s.onload=null,clearTimeout(d);var i=n[t];if(delete n[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((t=>t(r))),e)return e(r)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=f.bind(null,s.onerror),s.onload=f.bind(null,s.onload),c&&document.head.appendChild(s)}},a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;a.g.importScripts&&(t=a.g.location+"");var e=a.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&!t;)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=t})(),(()=>{var t={179:0};a.f.j=(e,r)=>{var n=a.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(((r,i)=>n=t[e]=[r,i]));r.push(n[2]=i);var o=a.p+a.u(e),s=new Error;a.l(o,(r=>{if(a.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;s.message="Loading chunk "+e+" failed.\n("+i+": "+o+")",s.name="ChunkLoadError",s.type=i,s.request=o,n[1](s)}}),"chunk-"+e,e)}};var e=(e,r)=>{var n,i,o=r[0],s=r[1],c=r[2],u=0;if(o.some((e=>0!==t[e]))){for(n in s)a.o(s,n)&&(a.m[n]=s[n]);if(c)c(a)}for(e&&e(r);u<o.length;u++)i=o[u],a.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=this.webpackChunkonairos=this.webpackChunkonairos||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();var c={};return(()=>{"use strict";a.r(c),a.d(c,{Onairos:()=>Yn});var t={};a.r(t),a.d(t,{hasBrowserEnv:()=>ee,hasStandardBrowserEnv:()=>re,hasStandardBrowserWebWorkerEnv:()=>ie});var e=a(639),r=a.n(e),n=a(764);function i(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}"function"==typeof SuppressedError&&SuppressedError;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==a.g?a.g:"undefined"!=typeof self?self:{};function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function u(t,e){return t(e={exports:{}},e.exports),e.exports}var l=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){var t=this;this.locked=new Map,this.addToLocked=function(e,r){var n=t.locked.get(e);void 0===n?void 0===r?t.locked.set(e,[]):t.locked.set(e,[r]):void 0!==r&&(n.unshift(r),t.locked.set(e,n))},this.isLocked=function(e){return t.locked.has(e)},this.lock=function(e){return new Promise((function(r,n){t.isLocked(e)?t.addToLocked(e,r):(t.addToLocked(e),r())}))},this.unlock=function(e){var r=t.locked.get(e);if(void 0!==r&&0!==r.length){var n=r.pop();t.locked.set(e,r),void 0!==n&&setTimeout(n,0)}else t.locked.delete(e)}}return t.getInstance=function(){return void 0===t.instance&&(t.instance=new t),t.instance},t}();e.default=function(){return r.getInstance()}}));s(l);var h=s(u((function(t,e){var r=o&&o.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new r((function(e){e(t.value)})).then(s,a)}c((n=n.apply(t,e||[])).next())}))},n=o&&o.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},i=o;Object.defineProperty(e,"__esModule",{value:!0});var s="browser-tabs-lock-key",a={key:function(t){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},getItem:function(t){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},clear:function(){return r(i,void 0,void 0,(function(){return n(this,(function(t){return[2,window.localStorage.clear()]}))}))},removeItem:function(t){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},setItem:function(t,e){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},keySync:function(t){return window.localStorage.key(t)},getItemSync:function(t){return window.localStorage.getItem(t)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(t){return window.localStorage.removeItem(t)},setItemSync:function(t,e){return window.localStorage.setItem(t,e)}};function c(t){return new Promise((function(e){return setTimeout(e,t)}))}function u(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",r="",n=0;n<t;n++)r+=e[Math.floor(61*Math.random())];return r}var h=function(){function t(e){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+u(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=e,void 0===t.waiters&&(t.waiters=[])}return t.prototype.acquireLock=function(e,i){return void 0===i&&(i=5e3),r(this,void 0,void 0,(function(){var r,o,l,h,f,d,p;return n(this,(function(n){switch(n.label){case 0:r=Date.now()+u(4),o=Date.now()+i,l=s+"-"+e,h=void 0===this.storageHandler?a:this.storageHandler,n.label=1;case 1:return Date.now()<o?[4,c(30)]:[3,8];case 2:return n.sent(),null!==h.getItemSync(l)?[3,5]:(f=this.id+"-"+e+"-"+r,[4,c(Math.floor(25*Math.random()))]);case 3:return n.sent(),h.setItemSync(l,JSON.stringify({id:this.id,iat:r,timeoutKey:f,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,c(30)];case 4:return n.sent(),null!==(d=h.getItemSync(l))&&(p=JSON.parse(d)).id===this.id&&p.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(l,r),[2,!0]):[3,7];case 5:return t.lockCorrector(void 0===this.storageHandler?a:this.storageHandler),[4,this.waitForSomethingToChange(o)];case 6:n.sent(),n.label=7;case 7:return r=Date.now()+u(4),[3,1];case 8:return[2,!1]}}))}))},t.prototype.refreshLockWhileAcquired=function(t,e){return r(this,void 0,void 0,(function(){var i=this;return n(this,(function(o){return setTimeout((function(){return r(i,void 0,void 0,(function(){var r,i,o;return n(this,(function(n){switch(n.label){case 0:return[4,l.default().lock(e)];case 1:return n.sent(),this.acquiredIatSet.has(e)?(r=void 0===this.storageHandler?a:this.storageHandler,null===(i=r.getItemSync(t))?(l.default().unlock(e),[2]):((o=JSON.parse(i)).timeRefreshed=Date.now(),r.setItemSync(t,JSON.stringify(o)),l.default().unlock(e),this.refreshLockWhileAcquired(t,e),[2])):(l.default().unlock(e),[2])}}))}))}),1e3),[2]}))}))},t.prototype.waitForSomethingToChange=function(e){return r(this,void 0,void 0,(function(){return n(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(r){var n=!1,i=Date.now(),o=!1;function s(){if(o||(window.removeEventListener("storage",s),t.removeFromWaiting(s),clearTimeout(a),o=!0),!n){n=!0;var e=50-(Date.now()-i);e>0?setTimeout(r,e):r(null)}}window.addEventListener("storage",s),t.addToWaiting(s);var a=setTimeout(s,Math.max(0,e-Date.now()))}))];case 1:return r.sent(),[2]}}))}))},t.addToWaiting=function(e){this.removeFromWaiting(e),void 0!==t.waiters&&t.waiters.push(e)},t.removeFromWaiting=function(e){void 0!==t.waiters&&(t.waiters=t.waiters.filter((function(t){return t!==e})))},t.notifyWaiters=function(){void 0!==t.waiters&&t.waiters.slice().forEach((function(t){return t()}))},t.prototype.releaseLock=function(t){return r(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this.releaseLock__private__(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.releaseLock__private__=function(e){return r(this,void 0,void 0,(function(){var r,i,o,c;return n(this,(function(n){switch(n.label){case 0:return r=void 0===this.storageHandler?a:this.storageHandler,i=s+"-"+e,null===(o=r.getItemSync(i))?[2]:(c=JSON.parse(o)).id!==this.id?[3,2]:[4,l.default().lock(c.iat)];case 1:n.sent(),this.acquiredIatSet.delete(c.iat),r.removeItemSync(i),l.default().unlock(c.iat),t.notifyWaiters(),n.label=2;case 2:return[2]}}))}))},t.lockCorrector=function(e){for(var r=Date.now()-5e3,n=e,i=[],o=0;;){var a=n.keySync(o);if(null===a)break;i.push(a),o++}for(var c=!1,u=0;u<i.length;u++){var l=i[u];if(l.includes(s)){var h=n.getItemSync(l);if(null!==h){var f=JSON.parse(h);(void 0===f.timeRefreshed&&f.timeAcquired<r||void 0!==f.timeRefreshed&&f.timeRefreshed<r)&&(n.removeItemSync(l),c=!0)}}}c&&t.notifyWaiters()},t.waiters=void 0,t}();e.default=h})));const f={timeoutInSeconds:60},d={name:"auth0-spa-js",version:"2.1.3"},p=()=>Date.now();class g extends Error{constructor(t,e){super(e),this.error=t,this.error_description=e,Object.setPrototypeOf(this,g.prototype)}static fromPayload({error:t,error_description:e}){return new g(t,e)}}class y extends g{constructor(t,e,r,n=null){super(t,e),this.state=r,this.appState=n,Object.setPrototypeOf(this,y.prototype)}}class w extends g{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,w.prototype)}}class m extends w{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,m.prototype)}}class b extends g{constructor(t){super("cancelled","Popup closed"),this.popup=t,Object.setPrototypeOf(this,b.prototype)}}class v extends g{constructor(t,e,r){super(t,e),this.mfa_token=r,Object.setPrototypeOf(this,v.prototype)}}class E extends g{constructor(t,e){super("missing_refresh_token",`Missing Refresh Token (audience: '${S(t,["default"])}', scope: '${S(e)}')`),this.audience=t,this.scope=e,Object.setPrototypeOf(this,E.prototype)}}function S(t,e=[]){return t&&!e.includes(t)?t:""}const T=()=>window.crypto,A=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(T().getRandomValues(new Uint8Array(43))).forEach((r=>e+=t[r%66])),e},k=t=>btoa(t),I=t=>{var{clientId:e}=t,r=i(t,["clientId"]);return new URLSearchParams((t=>Object.keys(t).filter((e=>void 0!==t[e])).reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:t[r]})),{}))(Object.assign({client_id:e},r))).toString()},O=t=>(t=>decodeURIComponent(atob(t).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),R=async(t,e)=>{const r=await fetch(t,e);return{ok:r.ok,json:await r.json()}},B=async(t,e,r,n,i,o,s=1e4)=>i?(async(t,e,r,n,i,o,s)=>{return a={auth:{audience:e,scope:r},timeout:i,fetchUrl:t,fetchOptions:n,useFormData:s},c=o,new Promise((function(t,e){const r=new MessageChannel;r.port1.onmessage=function(n){n.data.error?e(new Error(n.data.error)):t(n.data),r.port1.close()},c.postMessage(a,[r.port2])}));var a,c})(t,e,r,n,s,i,o):(async(t,e,r)=>{const n=new AbortController;let i;return e.signal=n.signal,Promise.race([R(t,e),new Promise(((t,e)=>{i=setTimeout((()=>{n.abort(),e(new Error("Timeout when executing 'fetch'"))}),r)}))]).finally((()=>{clearTimeout(i)}))})(t,n,s);async function _(t,e){var{baseUrl:r,timeout:n,audience:o,scope:s,auth0Client:a,useFormData:c}=t,u=i(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const l=c?I(u):JSON.stringify(u);return await async function(t,e,r,n,o,s,a){let c,u=null;for(let i=0;i<3;i++)try{c=await B(t,r,n,o,s,a,e),u=null;break}catch(t){u=t}if(u)throw u;const l=c.json,{error:h,error_description:f}=l,d=i(l,["error","error_description"]),{ok:p}=c;if(!p){const e=f||`HTTP error. Unable to fetch ${t}`;if("mfa_required"===h)throw new v(h,e,d.mfa_token);if("missing_refresh_token"===h)throw new E(r,n);throw new g(h||"request_error",e)}return d}(`${r}/oauth/token`,n,o||"default",s,{method:"POST",body:l,headers:{"Content-Type":c?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||d))}},e,c)}const U=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};class C{constructor(t,e="@@auth0spajs@@",r){this.prefix=e,this.suffix=r,this.clientId=t.clientId,this.scope=t.scope,this.audience=t.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(t){const[e,r,n,i]=t.split("::");return new C({clientId:r,scope:i,audience:n},e)}static fromCacheEntry(t){const{scope:e,audience:r,client_id:n}=t;return new C({scope:e,audience:r,clientId:n})}}class P{set(t,e){localStorage.setItem(t,JSON.stringify(e))}get(t){const e=window.localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch(t){return}}remove(t){localStorage.removeItem(t)}allKeys(){return Object.keys(window.localStorage).filter((t=>t.startsWith("@@auth0spajs@@")))}}class x{constructor(){this.enclosedCache=function(){let t={};return{set(e,r){t[e]=r},get(e){const r=t[e];if(r)return r},remove(e){delete t[e]},allKeys:()=>Object.keys(t)}}()}}class L{constructor(t,e,r){this.cache=t,this.keyManifest=e,this.nowProvider=r||p}async setIdToken(t,e,r){var n;const i=this.getIdTokenCacheKey(t);await this.cache.set(i,{id_token:e,decodedToken:r}),await(null===(n=this.keyManifest)||void 0===n?void 0:n.add(i))}async getIdToken(t){const e=await this.cache.get(this.getIdTokenCacheKey(t.clientId));if(!e&&t.scope&&t.audience){const e=await this.get(t);if(!e)return;if(!e.id_token||!e.decodedToken)return;return{id_token:e.id_token,decodedToken:e.decodedToken}}if(e)return{id_token:e.id_token,decodedToken:e.decodedToken}}async get(t,e=0){var r;let n=await this.cache.get(t.toKey());if(!n){const e=await this.getCacheKeys();if(!e)return;const r=this.matchExistingCacheKey(t,e);r&&(n=await this.cache.get(r))}if(!n)return;const i=await this.nowProvider(),o=Math.floor(i/1e3);return n.expiresAt-e<o?n.body.refresh_token?(n.body={refresh_token:n.body.refresh_token},await this.cache.set(t.toKey(),n),n.body):(await this.cache.remove(t.toKey()),void await(null===(r=this.keyManifest)||void 0===r?void 0:r.remove(t.toKey()))):n.body}async set(t){var e;const r=new C({clientId:t.client_id,scope:t.scope,audience:t.audience}),n=await this.wrapCacheEntry(t);await this.cache.set(r.toKey(),n),await(null===(e=this.keyManifest)||void 0===e?void 0:e.add(r.toKey()))}async clear(t){var e;const r=await this.getCacheKeys();r&&(await r.filter((e=>!t||e.includes(t))).reduce((async(t,e)=>{await t,await this.cache.remove(e)}),Promise.resolve()),await(null===(e=this.keyManifest)||void 0===e?void 0:e.clear()))}async wrapCacheEntry(t){const e=await this.nowProvider();return{body:t,expiresAt:Math.floor(e/1e3)+t.expires_in}}async getCacheKeys(){var t;return this.keyManifest?null===(t=await this.keyManifest.get())||void 0===t?void 0:t.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(t){return new C({clientId:t},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(t,e){return e.filter((e=>{var r;const n=C.fromKey(e),i=new Set(n.scope&&n.scope.split(" ")),o=(null===(r=t.scope)||void 0===r?void 0:r.split(" "))||[],s=n.scope&&o.reduce(((t,e)=>t&&i.has(e)),!0);return"@@auth0spajs@@"===n.prefix&&n.clientId===t.clientId&&n.audience===t.audience&&s}))[0]}}class N{constructor(t,e,r){this.storage=t,this.clientId=e,this.cookieDomain=r,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(t){this.storage.save(this.storageKey,t,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}}const j=t=>"number"==typeof t,D=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"];var K=u((function(t,e){var r=o&&o.__assign||function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};function n(t,e){if(!e)return"";var r="; "+t;return!0===e?r:r+"="+e}function i(t,e,r){return encodeURIComponent(t).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(e).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(t){if("number"==typeof t.expires){var e=new Date;e.setMilliseconds(e.getMilliseconds()+864e5*t.expires),t.expires=e}return n("Expires",t.expires?t.expires.toUTCString():"")+n("Domain",t.domain)+n("Path",t.path)+n("Secure",t.secure)+n("SameSite",t.sameSite)}(r)}function s(t){for(var e={},r=t?t.split("; "):[],n=/(%[\dA-F]{2})+/gi,i=0;i<r.length;i++){var o=r[i].split("="),s=o.slice(1).join("=");'"'===s.charAt(0)&&(s=s.slice(1,-1));try{e[o[0].replace(n,decodeURIComponent)]=s.replace(n,decodeURIComponent)}catch(t){}}return e}function a(){return s(document.cookie)}function c(t,e,n){document.cookie=i(t,e,r({path:"/"},n))}e.__esModule=!0,e.encode=i,e.parse=s,e.getAll=a,e.get=function(t){return a()[t]},e.set=c,e.remove=function(t,e){c(t,"",r(r({},e),{expires:-1}))}}));s(K),K.encode,K.parse,K.getAll;var M=K.get,z=K.set,W=K.remove;const Z={get(t){const e=M(t);if(void 0!==e)return JSON.parse(e)},save(t,e,r){let n={};"https:"===window.location.protocol&&(n={secure:!0,sameSite:"none"}),(null==r?void 0:r.daysUntilExpire)&&(n.expires=r.daysUntilExpire),(null==r?void 0:r.cookieDomain)&&(n.domain=r.cookieDomain),z(t,JSON.stringify(e),n)},remove(t,e){let r={};(null==e?void 0:e.cookieDomain)&&(r.domain=e.cookieDomain),W(t,r)}},F={get:t=>Z.get(t)||Z.get(`_legacy_${t}`),save(t,e,r){let n={};"https:"===window.location.protocol&&(n={secure:!0}),(null==r?void 0:r.daysUntilExpire)&&(n.expires=r.daysUntilExpire),(null==r?void 0:r.cookieDomain)&&(n.domain=r.cookieDomain),z(`_legacy_${t}`,JSON.stringify(e),n),Z.save(t,e,r)},remove(t,e){let r={};(null==e?void 0:e.cookieDomain)&&(r.domain=e.cookieDomain),W(t,r),Z.remove(t,e),Z.remove(`_legacy_${t}`,e)}},H={get(t){if("undefined"==typeof sessionStorage)return;const e=sessionStorage.getItem(t);return null!=e?JSON.parse(e):void 0},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};var $,G=("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,!1,function(t){return $=$||function(t,e,r){var n=void 0===e?null:e,i=function(t,e){var r=atob(t);if(e){for(var n=new Uint8Array(r.length),i=0,o=r.length;i<o;++i)n[i]=r.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(n.buffer))}return r}(t,void 0!==r&&r),o=i.indexOf("\n",10)+1,s=i.substring(o)+(n?"//# sourceMappingURL="+n:""),a=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(a)}("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,false),new Worker($,t)});const X={};class V{constructor(t,e){this.cache=t,this.clientId=e,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(t){var e;const r=new Set((null===(e=await this.cache.get(this.manifestKey))||void 0===e?void 0:e.keys)||[]);r.add(t),await this.cache.set(this.manifestKey,{keys:[...r]})}async remove(t){const e=await this.cache.get(this.manifestKey);if(e){const r=new Set(e.keys);return r.delete(t),r.size>0?await this.cache.set(this.manifestKey,{keys:[...r]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(t){return`@@auth0spajs@@::${t}`}}const J={memory:()=>(new x).enclosedCache,localstorage:()=>new P},Y=t=>J[t],q=t=>{const{openUrl:e,onRedirect:r}=t,n=i(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},n),{openUrl:!1===e||e?e:r})},Q=new h;class tt{constructor(t){let e,r;if(this.userCache=(new x).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await Q.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),t),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),t.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!T())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===T().subtle)throw new Error("\n auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.\n ")})(),t.cache&&t.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),t.cache)r=t.cache;else{if(e=t.cacheLocation||"memory",!Y(e))throw new Error(`Invalid cache location "${e}"`);r=Y(e)()}this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===t.legacySameSiteCookie?Z:F,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(t=>`auth0.${this.options.clientId}.is.authenticated`)(),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const n=t.useCookiesForTransactions?this.cookieStorage:H;var i;this.scope=U("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new N(n,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||p,this.cacheManager=new L(r,r.allKeys?void 0:new V(r,this.options.clientId),this.nowProvider),this.domainUrl=(i=this.options.domain,/^https?:\/\//.test(i)?i:`https://${i}`),this.tokenIssuer=((t,e)=>t?t.startsWith("https://")?t:`https://${t}/`:`${e}/`)(this.options.issuer,this.domainUrl),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&"memory"===e&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new G)}_url(t){const e=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||d)));return`${this.domainUrl}${t}&auth0Client=${e}`}_authorizeUrl(t){return this._url(`/authorize?${I(t)}`)}async _verifyIdToken(t,e,r){const n=await this.nowProvider();return(t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(t=>{const e=t.split("."),[r,n,i]=e;if(3!==e.length||!r||!n||!i)throw new Error("ID token could not be decoded");const o=JSON.parse(O(n)),s={__raw:t},a={};return Object.keys(o).forEach((t=>{s[t]=o[t],D.includes(t)||(a[t]=o[t])})),{encoded:{header:r,payload:n,signature:i},header:JSON.parse(O(r)),claims:s,user:a}})(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==e.header.alg)throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||"string"!=typeof e.claims.aud&&!Array.isArray(e.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!j(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(null==e.claims.exp||!j(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!j(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const r=t.leeway||60,n=new Date(t.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(e.claims.exp+r),n>i)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${n}) is after expiration time (${i})`);if(null!=e.claims.nbf&&j(e.claims.nbf)){const t=new Date(0);if(t.setUTCSeconds(e.claims.nbf-r),n<t)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${n}) is before ${t}`)}if(null!=e.claims.auth_time&&j(e.claims.auth_time)){const i=new Date(0);if(i.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+r),n>i)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${n}) is after last auth at ${i}`)}if(t.organization){const r=t.organization.trim();if(r.startsWith("org_")){const t=r;if(!e.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(t!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${t}", found "${e.claims.org_id}"`)}else{const t=r.toLowerCase();if(!e.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(t!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${t}", found "${e.claims.org_name}"`)}}return e})({iss:this.tokenIssuer,aud:this.options.clientId,id_token:t,nonce:e,organization:r,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,"string"!=typeof i?i:parseInt(i,10)||void 0),now:n});var i}_processOrgHint(t){t?this.cookieStorage.save(this.orgHintCookieName,t,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(t,e,r){const n=k(A()),i=k(A()),o=A(),s=(t=>{const e=new Uint8Array(t);return(t=>{const e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,(t=>e[t]))})(window.btoa(String.fromCharCode(...Array.from(e))))})(await(async t=>{const e=T().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(t));return await e})(o)),a=((t,e,r,n,i,o,s,a)=>Object.assign(Object.assign(Object.assign({client_id:t.clientId},t.authorizationParams),r),{scope:U(e,r.scope),response_type:"code",response_mode:a||"query",state:n,nonce:i,redirect_uri:s||t.authorizationParams.redirect_uri,code_challenge:o,code_challenge_method:"S256"}))(this.options,this.scope,t,n,i,s,t.redirect_uri||this.options.authorizationParams.redirect_uri||r,null==e?void 0:e.response_mode),c=this._authorizeUrl(a);return{nonce:i,code_verifier:o,scope:a.scope,audience:a.audience||"default",redirect_uri:a.redirect_uri,state:n,url:c}}async loginWithPopup(t,e){var r;if(t=t||{},!(e=e||{}).popup&&(e.popup=(t=>{const e=window.screenX+(window.innerWidth-400)/2,r=window.screenY+(window.innerHeight-600)/2;return window.open("","auth0:authorize:popup",`left=${e},top=${r},width=400,height=600,resizable,scrollbars=yes,status=1`)})(),!e.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const n=await this._prepareAuthorizeUrl(t.authorizationParams||{},{response_mode:"web_message"},window.location.origin);e.popup.location.href=n.url;const i=await(t=>new Promise(((e,r)=>{let n;const i=setInterval((()=>{t.popup&&t.popup.closed&&(clearInterval(i),clearTimeout(o),window.removeEventListener("message",n,!1),r(new b(t.popup)))}),1e3),o=setTimeout((()=>{clearInterval(i),r(new m(t.popup)),window.removeEventListener("message",n,!1)}),1e3*(t.timeoutInSeconds||60));n=function(s){if(s.data&&"authorization_response"===s.data.type){if(clearTimeout(o),clearInterval(i),window.removeEventListener("message",n,!1),t.popup.close(),s.data.response.error)return r(g.fromPayload(s.data.response));e(s.data.response)}},window.addEventListener("message",n)})))(Object.assign(Object.assign({},e),{timeoutInSeconds:e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(n.state!==i.state)throw new g("state_mismatch","Invalid state");const o=(null===(r=t.authorizationParams)||void 0===r?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:n.audience,scope:n.scope,code_verifier:n.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:n.redirect_uri},{nonceIn:n.nonce,organization:o})}async getUser(){var t;const e=await this._getIdTokenFromCache();return null===(t=null==e?void 0:e.decodedToken)||void 0===t?void 0:t.user}async getIdTokenClaims(){var t;const e=await this._getIdTokenFromCache();return null===(t=null==e?void 0:e.decodedToken)||void 0===t?void 0:t.claims}async loginWithRedirect(t={}){var e;const r=q(t),{openUrl:n,fragment:o,appState:s}=r,a=i(r,["openUrl","fragment","appState"]),c=(null===(e=a.authorizationParams)||void 0===e?void 0:e.organization)||this.options.authorizationParams.organization,u=await this._prepareAuthorizeUrl(a.authorizationParams||{}),{url:l}=u,h=i(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:s}),c&&{organization:c}));const f=o?`${l}#${o}`:l;n?await n(f):window.location.assign(f)}async handleRedirectCallback(t=window.location.href){const e=t.split("?").slice(1);if(0===e.length)throw new Error("There are no query params available for parsing.");const{state:r,code:n,error:i,error_description:o}=(t=>{t.indexOf("#")>-1&&(t=t.substring(0,t.indexOf("#")));const e=new URLSearchParams(t);return{state:e.get("state"),code:e.get("code")||void 0,error:e.get("error")||void 0,error_description:e.get("error_description")||void 0}})(e.join("")),s=this.transactionManager.get();if(!s)throw new g("missing_transaction","Invalid state");if(this.transactionManager.remove(),i)throw new y(i,o||i,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new g("state_mismatch","Invalid state");const a=s.organization,c=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:n},u?{redirect_uri:u}:{}),{nonceIn:c,organization:a}),{appState:s.appState}}async checkSession(t){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(t)}catch(t){}}async getTokenSilently(t={}){var e;const r=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:U(this.scope,null===(e=t.authorizationParams)||void 0===e?void 0:e.scope)})}),n=await((t,e)=>{let r=X[e];return r||(r=t().finally((()=>{delete X[e],r=null})),X[e]=r),r})((()=>this._getTokenSilently(r)),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return t.detailedResponse?n:null==n?void 0:n.access_token}async _getTokenSilently(t){const{cacheMode:e}=t,r=i(t,["cacheMode"]);if("off"!==e){const t=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(t)return t}if("cache-only"!==e){if(!await(async(t,e=3)=>{for(let r=0;r<e;r++)if(await t())return!0;return!1})((()=>Q.acquireLock("auth0.lock.getTokenSilently",5e3)),10))throw new w;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),"off"!==e){const t=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(t)return t}const t=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:n,access_token:i,oauthTokenScope:o,expires_in:s}=t;return Object.assign(Object.assign({id_token:n,access_token:i},o?{scope:o}:null),{expires_in:s})}finally{await Q.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(t={},e={}){var r;const n=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:U(this.scope,null===(r=t.authorizationParams)||void 0===r?void 0:r.scope)})});return e=Object.assign(Object.assign({},f),e),await this.loginWithPopup(n,e),(await this.cacheManager.get(new C({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(t){null!==t.clientId?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const e=t.logoutParams||{},{federated:r}=e,n=i(e,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${I(Object.assign({clientId:t.clientId},n))}`)+o}async logout(t={}){const e=q(t),{openUrl:r}=e,n=i(e,["openUrl"]);null===t.clientId?await this.cacheManager.clear():await this.cacheManager.clear(t.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(n);r?await r(o):!1!==r&&window.location.assign(o)}async _getTokenFromIFrame(t){const e=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!e.organization&&(e.organization=r);const{url:n,state:i,nonce:o,code_verifier:s,redirect_uri:a,scope:c,audience:u}=await this._prepareAuthorizeUrl(e,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new g("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const r=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,l=await((t,e,r=60)=>new Promise(((n,i)=>{const o=window.document.createElement("iframe");o.setAttribute("width","0"),o.setAttribute("height","0"),o.style.display="none";const s=()=>{window.document.body.contains(o)&&(window.document.body.removeChild(o),window.removeEventListener("message",a,!1))};let a;const c=setTimeout((()=>{i(new w),s()}),1e3*r);a=function(t){if(t.origin!=e)return;if(!t.data||"authorization_response"!==t.data.type)return;const r=t.source;r&&r.close(),t.data.response.error?i(g.fromPayload(t.data.response)):n(t.data.response),clearTimeout(c),window.removeEventListener("message",a,!1),setTimeout(s,2e3)},window.addEventListener("message",a,!1),window.document.body.appendChild(o),o.setAttribute("src",t)})))(n,this.domainUrl,r);if(i!==l.state)throw new g("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:s,code:l.code,grant_type:"authorization_code",redirect_uri:a,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:o,organization:e.organization});return Object.assign(Object.assign({},h),{scope:c,oauthTokenScope:h.scope,audience:u})}catch(t){throw"login_required"===t.error&&this.logout({openUrl:!1}),t}}async _getTokenUsingRefreshToken(t){const e=await this.cacheManager.get(new C({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(e&&e.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw new E(t.authorizationParams.audience||"default",t.authorizationParams.scope)}const r=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,n="number"==typeof t.timeoutInSeconds?1e3*t.timeoutInSeconds:null;try{const i=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:e&&e.refresh_token,redirect_uri:r}),n&&{timeout:n}));return Object.assign(Object.assign({},i),{scope:t.authorizationParams.scope,oauthTokenScope:i.scope,audience:t.authorizationParams.audience||"default"})}catch(e){if((e.message.indexOf("Missing Refresh Token")>-1||e.message&&e.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw e}}async _saveEntryInCache(t){const{id_token:e,decodedToken:r}=t,n=i(t,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:e,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(n)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||"default",e=await this.cacheManager.getIdToken(new C({clientId:this.options.clientId,audience:t,scope:this.scope})),r=this.userCache.get("@@user@@");return e&&e.id_token===(null==r?void 0:r.id_token)?r:(this.userCache.set("@@user@@",e),e)}async _getEntryFromCache({scope:t,audience:e,clientId:r}){const n=await this.cacheManager.get(new C({scope:t,audience:e,clientId:r}),60);if(n&&n.access_token){const{access_token:t,oauthTokenScope:e,expires_in:r}=n,i=await this._getIdTokenFromCache();return i&&Object.assign(Object.assign({id_token:i.id_token,access_token:t},e?{scope:e}:null),{expires_in:r})}}async _requestToken(t,e){const{nonceIn:r,organization:n}=e||{},i=await _(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},t),this.worker),o=await this._verifyIdToken(i.id_token,r,n);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},i),{decodedToken:o,scope:t.scope,audience:t.audience||"default"}),i.scope?{oauthTokenScope:i.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(n||o.claims.org_id),Object.assign(Object.assign({},i),{decodedToken:o})}}var et=a(470);function rt(t,e){return function(){return t.apply(e,arguments)}}const{toString:nt}=Object.prototype,{getPrototypeOf:it}=Object,ot=(st=Object.create(null),t=>{const e=nt.call(t);return st[e]||(st[e]=e.slice(8,-1).toLowerCase())});var st;const at=t=>(t=t.toLowerCase(),e=>ot(e)===t),ct=t=>e=>typeof e===t,{isArray:ut}=Array,lt=ct("undefined");const ht=at("ArrayBuffer");const ft=ct("string"),dt=ct("function"),pt=ct("number"),gt=t=>null!==t&&"object"==typeof t,yt=t=>{if("object"!==ot(t))return!1;const e=it(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},wt=at("Date"),mt=at("File"),bt=at("Blob"),vt=at("FileList"),Et=at("URLSearchParams");function St(t,e,{allOwnKeys:r=!1}={}){if(null==t)return;let n,i;if("object"!=typeof t&&(t=[t]),ut(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const i=r?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let s;for(n=0;n<o;n++)s=i[n],e.call(null,t[s],s,t)}}function Tt(t,e){e=e.toLowerCase();const r=Object.keys(t);let n,i=r.length;for(;i-- >0;)if(n=r[i],e===n.toLowerCase())return n;return null}const At="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,kt=t=>!lt(t)&&t!==At;const It=(Ot="undefined"!=typeof Uint8Array&&it(Uint8Array),t=>Ot&&t instanceof Ot);var Ot;const Rt=at("HTMLFormElement"),Bt=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),_t=at("RegExp"),Ut=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};St(r,((r,i)=>{let o;!1!==(o=e(r,i,t))&&(n[i]=o||r)})),Object.defineProperties(t,n)},Ct="abcdefghijklmnopqrstuvwxyz",Pt="0123456789",xt={DIGIT:Pt,ALPHA:Ct,ALPHA_DIGIT:Ct+Ct.toUpperCase()+Pt};const Lt=at("AsyncFunction"),Nt={isArray:ut,isArrayBuffer:ht,isBuffer:function(t){return null!==t&&!lt(t)&&null!==t.constructor&&!lt(t.constructor)&&dt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||dt(t.append)&&("formdata"===(e=ot(t))||"object"===e&&dt(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&ht(t.buffer),e},isString:ft,isNumber:pt,isBoolean:t=>!0===t||!1===t,isObject:gt,isPlainObject:yt,isUndefined:lt,isDate:wt,isFile:mt,isBlob:bt,isRegExp:_t,isFunction:dt,isStream:t=>gt(t)&&dt(t.pipe),isURLSearchParams:Et,isTypedArray:It,isFileList:vt,forEach:St,merge:function t(){const{caseless:e}=kt(this)&&this||{},r={},n=(n,i)=>{const o=e&&Tt(r,i)||i;yt(r[o])&&yt(n)?r[o]=t(r[o],n):yt(n)?r[o]=t({},n):ut(n)?r[o]=n.slice():r[o]=n};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&St(arguments[t],n);return r},extend:(t,e,r,{allOwnKeys:n}={})=>(St(e,((e,n)=>{r&&dt(e)?t[n]=rt(e,r):t[n]=e}),{allOwnKeys:n}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},toFlatObject:(t,e,r,n)=>{let i,o,s;const a={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),o=i.length;o-- >0;)s=i[o],n&&!n(s,t,e)||a[s]||(e[s]=t[s],a[s]=!0);t=!1!==r&&it(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:ot,kindOfTest:at,endsWith:(t,e,r)=>{t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return-1!==n&&n===r},toArray:t=>{if(!t)return null;if(ut(t))return t;let e=t.length;if(!pt(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},forEachEntry:(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let n;for(;(n=r.next())&&!n.done;){const r=n.value;e.call(t,r[0],r[1])}},matchAll:(t,e)=>{let r;const n=[];for(;null!==(r=t.exec(e));)n.push(r);return n},isHTMLForm:Rt,hasOwnProperty:Bt,hasOwnProp:Bt,reduceDescriptors:Ut,freezeMethods:t=>{Ut(t,((e,r)=>{if(dt(t)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=t[r];dt(n)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(t,e)=>{const r={},n=t=>{t.forEach((t=>{r[t]=!0}))};return ut(t)?n(t):n(String(t).split(e)),r},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,r){return e.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(t,e)=>(t=+t,Number.isFinite(t)?t:e),findKey:Tt,global:At,isContextDefined:kt,ALPHABET:xt,generateString:(t=16,e=xt.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r},isSpecCompliantForm:function(t){return!!(t&&dt(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),r=(t,n)=>{if(gt(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[n]=t;const i=ut(t)?[]:{};return St(t,((t,e)=>{const o=r(t,n+1);!lt(o)&&(i[e]=o)})),e[n]=void 0,i}}return t};return r(t,0)},isAsyncFn:Lt,isThenable:t=>t&&(gt(t)||dt(t))&&dt(t.then)&&dt(t.catch)};function jt(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}Nt.inherits(jt,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Nt.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Dt=jt.prototype,Kt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{Kt[t]={value:t}})),Object.defineProperties(jt,Kt),Object.defineProperty(Dt,"isAxiosError",{value:!0}),jt.from=(t,e,r,n,i,o)=>{const s=Object.create(Dt);return Nt.toFlatObject(t,s,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),jt.call(s,t.message,e,r,n,i),s.cause=t,s.name=t.name,o&&Object.assign(s,o),s};const Mt=jt;function zt(t){return Nt.isPlainObject(t)||Nt.isArray(t)}function Wt(t){return Nt.endsWith(t,"[]")?t.slice(0,-2):t}function Zt(t,e,r){return t?t.concat(e).map((function(t,e){return t=Wt(t),!r&&e?"["+t+"]":t})).join(r?".":""):e}const Ft=Nt.toFlatObject(Nt,{},null,(function(t){return/^is[A-Z]/.test(t)}));const Ht=function(t,e,r){if(!Nt.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const n=(r=Nt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!Nt.isUndefined(e[t])}))).metaTokens,i=r.visitor||u,o=r.dots,s=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Nt.isSpecCompliantForm(e);if(!Nt.isFunction(i))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(Nt.isDate(t))return t.toISOString();if(!a&&Nt.isBlob(t))throw new Mt("Blob is not supported. Use a Buffer instead.");return Nt.isArrayBuffer(t)||Nt.isTypedArray(t)?a&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function u(t,r,i){let a=t;if(t&&!i&&"object"==typeof t)if(Nt.endsWith(r,"{}"))r=n?r:r.slice(0,-2),t=JSON.stringify(t);else if(Nt.isArray(t)&&function(t){return Nt.isArray(t)&&!t.some(zt)}(t)||(Nt.isFileList(t)||Nt.endsWith(r,"[]"))&&(a=Nt.toArray(t)))return r=Wt(r),a.forEach((function(t,n){!Nt.isUndefined(t)&&null!==t&&e.append(!0===s?Zt([r],n,o):null===s?r:r+"[]",c(t))})),!1;return!!zt(t)||(e.append(Zt(i,r,o),c(t)),!1)}const l=[],h=Object.assign(Ft,{defaultVisitor:u,convertValue:c,isVisitable:zt});if(!Nt.isObject(t))throw new TypeError("data must be an object");return function t(r,n){if(!Nt.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),Nt.forEach(r,(function(r,o){!0===(!(Nt.isUndefined(r)||null===r)&&i.call(e,r,Nt.isString(o)?o.trim():o,n,h))&&t(r,n?n.concat(o):[o])})),l.pop()}}(t),e};function $t(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function Gt(t,e){this._pairs=[],t&&Ht(t,this,e)}const Xt=Gt.prototype;Xt.append=function(t,e){this._pairs.push([t,e])},Xt.toString=function(t){const e=t?function(e){return t.call(this,e,$t)}:$t;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const Vt=Gt;function Jt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Yt(t,e,r){if(!e)return t;const n=r&&r.encode||Jt,i=r&&r.serialize;let o;if(o=i?i(e,r):Nt.isURLSearchParams(e)?e.toString():new Vt(e,r).toString(n),o){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+o}return t}const qt=class{constructor(){this.handlers=[]}use(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Nt.forEach(this.handlers,(function(e){null!==e&&t(e)}))}},Qt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},te={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Vt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ee="undefined"!=typeof window&&"undefined"!=typeof document,re=(ne="undefined"!=typeof navigator&&navigator.product,ee&&["ReactNative","NativeScript","NS"].indexOf(ne)<0);var ne;const ie="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,oe={...t,...te};const se=function(t){function e(t,r,n,i){let o=t[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=t.length;if(o=!o&&Nt.isArray(n)?n.length:o,a)return Nt.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!s;n[o]&&Nt.isObject(n[o])||(n[o]=[]);return e(t,r,n[o],i)&&Nt.isArray(n[o])&&(n[o]=function(t){const e={},r=Object.keys(t);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],e[o]=t[o];return e}(n[o])),!s}if(Nt.isFormData(t)&&Nt.isFunction(t.entries)){const r={};return Nt.forEachEntry(t,((t,n)=>{e(function(t){return Nt.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),n,r,0)})),r}return null};const ae={transitional:Qt,adapter:["xhr","http"],transformRequest:[function(t,e){const r=e.getContentType()||"",n=r.indexOf("application/json")>-1,i=Nt.isObject(t);i&&Nt.isHTMLForm(t)&&(t=new FormData(t));if(Nt.isFormData(t))return n&&n?JSON.stringify(se(t)):t;if(Nt.isArrayBuffer(t)||Nt.isBuffer(t)||Nt.isStream(t)||Nt.isFile(t)||Nt.isBlob(t))return t;if(Nt.isArrayBufferView(t))return t.buffer;if(Nt.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Ht(t,new oe.classes.URLSearchParams,Object.assign({visitor:function(t,e,r,n){return oe.isNode&&Nt.isBuffer(t)?(this.append(e,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((o=Nt.isFileList(t))||r.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Ht(o?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||n?(e.setContentType("application/json",!1),function(t,e,r){if(Nt.isString(t))try{return(e||JSON.parse)(t),Nt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||ae.transitional,r=e&&e.forcedJSONParsing,n="json"===this.responseType;if(t&&Nt.isString(t)&&(r&&!this.responseType||n)){const r=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(t){if(r){if("SyntaxError"===t.name)throw Mt.from(t,Mt.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:oe.classes.FormData,Blob:oe.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Nt.forEach(["delete","get","head","post","put","patch"],(t=>{ae.headers[t]={}}));const ce=ae,ue=Nt.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"]),le=Symbol("internals");function he(t){return t&&String(t).trim().toLowerCase()}function fe(t){return!1===t||null==t?t:Nt.isArray(t)?t.map(fe):String(t)}function de(t,e,r,n,i){return Nt.isFunction(n)?n.call(this,e,r):(i&&(e=r),Nt.isString(e)?Nt.isString(n)?-1!==e.indexOf(n):Nt.isRegExp(n)?n.test(e):void 0:void 0)}class pe{constructor(t){t&&this.set(t)}set(t,e,r){const n=this;function i(t,e,r){const i=he(e);if(!i)throw new Error("header name must be a non-empty string");const o=Nt.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||e]=fe(t))}const o=(t,e)=>Nt.forEach(t,((t,r)=>i(t,r,e)));return Nt.isPlainObject(t)||t instanceof this.constructor?o(t,e):Nt.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim())?o((t=>{const e={};let r,n,i;return t&&t.split("\n").forEach((function(t){i=t.indexOf(":"),r=t.substring(0,i).trim().toLowerCase(),n=t.substring(i+1).trim(),!r||e[r]&&ue[r]||("set-cookie"===r?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)})),e})(t),e):null!=t&&i(e,t,r),this}get(t,e){if(t=he(t)){const r=Nt.findKey(this,t);if(r){const t=this[r];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}(t);if(Nt.isFunction(e))return e.call(this,t,r);if(Nt.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=he(t)){const r=Nt.findKey(this,t);return!(!r||void 0===this[r]||e&&!de(0,this[r],r,e))}return!1}delete(t,e){const r=this;let n=!1;function i(t){if(t=he(t)){const i=Nt.findKey(r,t);!i||e&&!de(0,r[i],i,e)||(delete r[i],n=!0)}}return Nt.isArray(t)?t.forEach(i):i(t),n}clear(t){const e=Object.keys(this);let r=e.length,n=!1;for(;r--;){const i=e[r];t&&!de(0,this[i],i,t,!0)||(delete this[i],n=!0)}return n}normalize(t){const e=this,r={};return Nt.forEach(this,((n,i)=>{const o=Nt.findKey(r,i);if(o)return e[o]=fe(n),void delete e[i];const s=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,r)=>e.toUpperCase()+r))}(i):String(i).trim();s!==i&&delete e[i],e[s]=fe(n),r[s]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return Nt.forEach(this,((r,n)=>{null!=r&&!1!==r&&(e[n]=t&&Nt.isArray(r)?r.join(", "):r)})),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const r=new this(t);return e.forEach((t=>r.set(t))),r}static accessor(t){const e=(this[le]=this[le]={accessors:{}}).accessors,r=this.prototype;function n(t){const n=he(t);e[n]||(!function(t,e){const r=Nt.toCamelCase(" "+e);["get","set","has"].forEach((n=>{Object.defineProperty(t,n+r,{value:function(t,r,i){return this[n].call(this,e,t,r,i)},configurable:!0})}))}(r,t),e[n]=!0)}return Nt.isArray(t)?t.forEach(n):n(t),this}}pe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Nt.reduceDescriptors(pe.prototype,(({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[r]=t}}})),Nt.freezeMethods(pe);const ge=pe;function ye(t,e){const r=this||ce,n=e||r,i=ge.from(n.headers);let o=n.data;return Nt.forEach(t,(function(t){o=t.call(r,o,i.normalize(),e?e.status:void 0)})),i.normalize(),o}function we(t){return!(!t||!t.__CANCEL__)}function me(t,e,r){Mt.call(this,null==t?"canceled":t,Mt.ERR_CANCELED,e,r),this.name="CanceledError"}Nt.inherits(me,Mt,{__CANCEL__:!0});const be=me;const ve=oe.hasStandardBrowserEnv?{write(t,e,r,n,i,o){const s=[t+"="+encodeURIComponent(e)];Nt.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),Nt.isString(n)&&s.push("path="+n),Nt.isString(i)&&s.push("domain="+i),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ee(t,e){return t&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const Se=oe.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let r;function n(r){let n=r;return t&&(e.setAttribute("href",n),n=e.href),e.setAttribute("href",n),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname}}return r=n(window.location.href),function(t){const e=Nt.isString(t)?n(t):t;return e.protocol===r.protocol&&e.host===r.host}}():function(){return!0};const Te=function(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i,o=0,s=0;return e=void 0!==e?e:1e3,function(a){const c=Date.now(),u=n[s];i||(i=c),r[o]=a,n[o]=c;let l=s,h=0;for(;l!==o;)h+=r[l++],l%=t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),c-i<e)return;const f=u&&c-u;return f?Math.round(1e3*h/f):void 0}};function Ae(t,e){let r=0;const n=Te(50,250);return i=>{const o=i.loaded,s=i.lengthComputable?i.total:void 0,a=o-r,c=n(a);r=o;const u={loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&o<=s?(s-o)/c:void 0,event:i};u[e?"download":"upload"]=!0,t(u)}}const ke={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,r){let n=t.data;const i=ge.from(t.headers).normalize();let o,s,{responseType:a,withXSRFToken:c}=t;function u(){t.cancelToken&&t.cancelToken.unsubscribe(o),t.signal&&t.signal.removeEventListener("abort",o)}if(Nt.isFormData(n))if(oe.hasStandardBrowserEnv||oe.hasStandardBrowserWebWorkerEnv)i.setContentType(!1);else if(!1!==(s=i.getContentType())){const[t,...e]=s?s.split(";").map((t=>t.trim())).filter(Boolean):[];i.setContentType([t||"multipart/form-data",...e].join("; "))}let l=new XMLHttpRequest;if(t.auth){const e=t.auth.username||"",r=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";i.set("Authorization","Basic "+btoa(e+":"+r))}const h=Ee(t.baseURL,t.url);function f(){if(!l)return;const n=ge.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders());!function(t,e,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?e(new Mt("Request failed with status code "+r.status,[Mt.ERR_BAD_REQUEST,Mt.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}((function(t){e(t),u()}),(function(t){r(t),u()}),{data:a&&"text"!==a&&"json"!==a?l.response:l.responseText,status:l.status,statusText:l.statusText,headers:n,config:t,request:l}),l=null}if(l.open(t.method.toUpperCase(),Yt(h,t.params,t.paramsSerializer),!0),l.timeout=t.timeout,"onloadend"in l?l.onloadend=f:l.onreadystatechange=function(){l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))&&setTimeout(f)},l.onabort=function(){l&&(r(new Mt("Request aborted",Mt.ECONNABORTED,t,l)),l=null)},l.onerror=function(){r(new Mt("Network Error",Mt.ERR_NETWORK,t,l)),l=null},l.ontimeout=function(){let e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const n=t.transitional||Qt;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(new Mt(e,n.clarifyTimeoutError?Mt.ETIMEDOUT:Mt.ECONNABORTED,t,l)),l=null},oe.hasStandardBrowserEnv&&(c&&Nt.isFunction(c)&&(c=c(t)),c||!1!==c&&Se(h))){const e=t.xsrfHeaderName&&t.xsrfCookieName&&ve.read(t.xsrfCookieName);e&&i.set(t.xsrfHeaderName,e)}void 0===n&&i.setContentType(null),"setRequestHeader"in l&&Nt.forEach(i.toJSON(),(function(t,e){l.setRequestHeader(e,t)})),Nt.isUndefined(t.withCredentials)||(l.withCredentials=!!t.withCredentials),a&&"json"!==a&&(l.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&l.addEventListener("progress",Ae(t.onDownloadProgress,!0)),"function"==typeof t.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",Ae(t.onUploadProgress)),(t.cancelToken||t.signal)&&(o=e=>{l&&(r(!e||e.type?new be(null,t,l):e),l.abort(),l=null)},t.cancelToken&&t.cancelToken.subscribe(o),t.signal&&(t.signal.aborted?o():t.signal.addEventListener("abort",o)));const d=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(h);d&&-1===oe.protocols.indexOf(d)?r(new Mt("Unsupported protocol "+d+":",Mt.ERR_BAD_REQUEST,t)):l.send(n||null)}))}};Nt.forEach(ke,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const Ie=t=>`- ${t}`,Oe=t=>Nt.isFunction(t)||null===t||!1===t,Re=t=>{t=Nt.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let o=0;o<e;o++){let e;if(r=t[o],n=r,!Oe(r)&&(n=ke[(e=String(r)).toLowerCase()],void 0===n))throw new Mt(`Unknown adapter '${e}'`);if(n)break;i[e||"#"+o]=n}if(!n){const t=Object.entries(i).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let r=e?t.length>1?"since :\n"+t.map(Ie).join("\n"):" "+Ie(t[0]):"as no adapter specified";throw new Mt("There is no suitable adapter to dispatch the request "+r,"ERR_NOT_SUPPORT")}return n};function Be(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new be(null,t)}function _e(t){Be(t),t.headers=ge.from(t.headers),t.data=ye.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1);return Re(t.adapter||ce.adapter)(t).then((function(e){return Be(t),e.data=ye.call(t,t.transformResponse,e),e.headers=ge.from(e.headers),e}),(function(e){return we(e)||(Be(t),e&&e.response&&(e.response.data=ye.call(t,t.transformResponse,e.response),e.response.headers=ge.from(e.response.headers))),Promise.reject(e)}))}const Ue=t=>t instanceof ge?t.toJSON():t;function Ce(t,e){e=e||{};const r={};function n(t,e,r){return Nt.isPlainObject(t)&&Nt.isPlainObject(e)?Nt.merge.call({caseless:r},t,e):Nt.isPlainObject(e)?Nt.merge({},e):Nt.isArray(e)?e.slice():e}function i(t,e,r){return Nt.isUndefined(e)?Nt.isUndefined(t)?void 0:n(void 0,t,r):n(t,e,r)}function o(t,e){if(!Nt.isUndefined(e))return n(void 0,e)}function s(t,e){return Nt.isUndefined(e)?Nt.isUndefined(t)?void 0:n(void 0,t):n(void 0,e)}function a(r,i,o){return o in e?n(r,i):o in t?n(void 0,r):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(t,e)=>i(Ue(t),Ue(e),!0)};return Nt.forEach(Object.keys(Object.assign({},t,e)),(function(n){const o=c[n]||i,s=o(t[n],e[n],n);Nt.isUndefined(s)&&o!==a||(r[n]=s)})),r}const Pe="1.6.5",xe={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{xe[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));const Le={};xe.transitional=function(t,e,r){function n(t,e){return"[Axios v1.6.5] Transitional option '"+t+"'"+e+(r?". "+r:"")}return(r,i,o)=>{if(!1===t)throw new Mt(n(i," has been removed"+(e?" in "+e:"")),Mt.ERR_DEPRECATED);return e&&!Le[i]&&(Le[i]=!0,console.warn(n(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,i,o)}};const Ne={assertOptions:function(t,e,r){if("object"!=typeof t)throw new Mt("options must be an object",Mt.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const o=n[i],s=e[o];if(s){const e=t[o],r=void 0===e||s(e,o,t);if(!0!==r)throw new Mt("option "+o+" must be "+r,Mt.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new Mt("Unknown option "+o,Mt.ERR_BAD_OPTION)}},validators:xe},je=Ne.validators;class De{constructor(t){this.defaults=t,this.interceptors={request:new qt,response:new qt}}request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Ce(this.defaults,e);const{transitional:r,paramsSerializer:n,headers:i}=e;void 0!==r&&Ne.assertOptions(r,{silentJSONParsing:je.transitional(je.boolean),forcedJSONParsing:je.transitional(je.boolean),clarifyTimeoutError:je.transitional(je.boolean)},!1),null!=n&&(Nt.isFunction(n)?e.paramsSerializer={serialize:n}:Ne.assertOptions(n,{encode:je.function,serialize:je.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=i&&Nt.merge(i.common,i[e.method]);i&&Nt.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete i[t]})),e.headers=ge.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,s.unshift(t.fulfilled,t.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let l,h=0;if(!a){const t=[_e.bind(this),void 0];for(t.unshift.apply(t,s),t.push.apply(t,c),l=t.length,u=Promise.resolve(e);h<l;)u=u.then(t[h++],t[h++]);return u}l=s.length;let f=e;for(h=0;h<l;){const t=s[h++],e=s[h++];try{f=t(f)}catch(t){e.call(this,t);break}}try{u=_e.call(this,f)}catch(t){return Promise.reject(t)}for(h=0,l=c.length;h<l;)u=u.then(c[h++],c[h++]);return u}getUri(t){return Yt(Ee((t=Ce(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}Nt.forEach(["delete","get","head","options"],(function(t){De.prototype[t]=function(e,r){return this.request(Ce(r||{},{method:t,url:e,data:(r||{}).data}))}})),Nt.forEach(["post","put","patch"],(function(t){function e(e){return function(r,n,i){return this.request(Ce(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}De.prototype[t]=e(),De.prototype[t+"Form"]=e(!0)}));const Ke=De;class Me{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise((function(t){e=t}));const r=this;this.promise.then((t=>{if(!r._listeners)return;let e=r._listeners.length;for(;e-- >0;)r._listeners[e](t);r._listeners=null})),this.promise.then=t=>{let e;const n=new Promise((t=>{r.subscribe(t),e=t})).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t((function(t,n,i){r.reason||(r.reason=new be(t,n,i),e(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}static source(){let t;const e=new Me((function(e){t=e}));return{token:e,cancel:t}}}const ze=Me;const We={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};Object.entries(We).forEach((([t,e])=>{We[e]=t}));const Ze=We;const Fe=function t(e){const r=new Ke(e),n=rt(Ke.prototype.request,r);return Nt.extend(n,Ke.prototype,r,{allOwnKeys:!0}),Nt.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return t(Ce(e,r))},n}(ce);Fe.Axios=Ke,Fe.CanceledError=be,Fe.CancelToken=ze,Fe.isCancel=we,Fe.VERSION=Pe,Fe.toFormData=Ht,Fe.AxiosError=Mt,Fe.Cancel=Fe.CanceledError,Fe.all=function(t){return Promise.all(t)},Fe.spread=function(t){return function(e){return t.apply(null,e)}},Fe.isAxiosError=function(t){return Nt.isObject(t)&&!0===t.isAxiosError},Fe.mergeConfig=Ce,Fe.AxiosHeaders=ge,Fe.formToJSON=t=>se(Nt.isHTMLForm(t)?new FormData(t):t),Fe.getAdapter=Re,Fe.HttpStatusCode=Ze,Fe.default=Fe;const He=Fe;var $e=a(742),Ge=Object.create,Xe=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Je=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty,Qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tr=(t,e,r)=>(r=null!=t?Ge(Ye(t)):{},((t,e,r,n)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let i of Je(e))!qe.call(t,i)&&i!==r&&Xe(t,i,{get:()=>e[i],enumerable:!(n=Ve(e,i))||n.enumerable});return t})(!e&&t&&t.__esModule?r:Xe(r,"default",{value:t,enumerable:!0}),t)),er=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){var e=t.length,r=e%4;if(!r)return t;var n=e,i=4-r,o=e+i,s=Buffer.alloc(o);for(s.write(t);i--;)s.write("=",n++);return s.toString()}})),rr=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=er();function r(t,e){return void 0===e&&(e="utf8"),Buffer.isBuffer(t)?i(t.toString("base64")):i(Buffer.from(t,e).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var o=r;o.encode=r,o.decode=function(t,e){return void 0===e&&(e="utf8"),Buffer.from(n(t),"base64").toString(e)},o.toBase64=n,o.fromBase64=i,o.toBuffer=function(t){return Buffer.from(n(t),"base64")},t.default=o})),nr=Qe(((t,e)=>{e.exports=rr().default,e.exports.default=e.exports})),ir=Qe((t=>{t.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},t.toByteArray=function(t){var e,r,o=s(t),a=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,c)),l=0,h=c>0?a-4:a;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},t.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;a<u;a+=s)o.push(c(t,a,a+s>u?u:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};var e,r=[],n=[],i=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(e=0,64;e<64;++e)r[e]=o[e],n[o.charCodeAt(e)]=e;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function a(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function c(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(a(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63})),or=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;var e=ir();function r(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function n(t){return(new TextEncoder).encode(t)}function i(t){return new Uint8Array(e.toByteArray(c(t)))}function o(t){return e.fromByteArray(new Uint8Array(t))}function s(t){return a(o(t))}function a(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}function c(t){let e;return e=(t=t.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-t.length%4,t.concat("=".repeat(e))}t.concatBuffers=function(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let e=1;e<t.length;e++)r.set(new Uint8Array(t[e]),n),n+=t[e].byteLength;return r},t.b64UrlToString=function(t){return r(i(t))},t.bufferToString=r,t.stringToBuffer=n,t.stringToB64Url=function(t){return s(n(t))},t.b64UrlToBuffer=i,t.bufferTob64=o,t.bufferTob64Url=s,t.b64UrlEncode=a,t.b64UrlDecode=c})),sr=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=or();t.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let t=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),e=await this.driver.exportKey("jwk",t.privateKey);return{kty:e.kty,e:e.e,n:e.n,d:e.d,p:e.p,q:e.q,dp:e.dp,dq:e.dq,qi:e.qi}}async sign(t,e,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(n)}async hash(t,e="SHA-256"){let r=await this.driver.digest(e,t);return new Uint8Array(r)}async verify(t,e,r){let n={kty:"RSA",e:"AQAB",n:t},i=await this.jwkToPublicCryptoKey(n),o=await this.driver.digest("SHA-256",e),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},i,r,e),a=await this.driver.verify({name:"RSA-PSS",saltLength:32},i,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((i.algorithm.modulusLength-1)/8)-o.byteLength-2},i,r,e);return s||a||c}async jwkToCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let t=crypto?.subtle;return void 0!==t&&["generateKey","importKey","exportKey","digest","sign"].every((e=>"function"==typeof t[e]))}async encrypt(t,r,n){let i=await this.driver.importKey("raw","string"==typeof r?e.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:n?e.stringToBuffer(n):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=new Uint8Array(16);crypto.getRandomValues(s);let a=await this.driver.encrypt({name:"AES-CBC",iv:s},o,t);return e.concatBuffers([s,a])}async decrypt(t,r,n){let i=await this.driver.importKey("raw","string"==typeof r?e.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:n?e.stringToBuffer(n):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=t.slice(0,16),a=await this.driver.decrypt({name:"AES-CBC",iv:s},o,t.slice(16));return e.concatBuffers([a])}}})),ar=Qe((t=>{t.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+h],h+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+h],h+=f,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},t.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*g}})),cr=Qe((t=>{var e=ir(),r=ar(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){return+t!=t&&(t=0),s.alloc(+t)},t.INSPECT_MAX_BYTES=50;var i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){if(("string"!=typeof e||""===e)&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=0|d(t,e),n=o(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(G(t,Uint8Array)){let e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(G(t,ArrayBuffer)||t&&G(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(t,SharedArrayBuffer)||t&&G(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);let i=function(t){if(s.isBuffer(t)){let e=0|f(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||X(t.length)?o(0):l(t);if("Buffer"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if(typeof Symbol<"u"&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return c(t),o(t<0?0:0|f(t))}function l(t){let e=t.length<0?0:0|f(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function h(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function f(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||G(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(i)return n?-1:F(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0)||(r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),X(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;let o,s=e.length;for(n>s/2&&(n=s/2),o=0;o<n;++o){let n=parseInt(e.substr(2*o,2),16);if(X(n))return o;t[r+o]=n}return o}function b(t,e,r,n){return $(F(e,t.length-r),t,r,n)}function v(t,e,r,n){return $(function(t){let e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return $(H(e),t,r,n)}function S(t,e,r,n){return $(function(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function A(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let e=t[i],o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){let e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=k));return r}(n)}t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=function(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch{return!1}}(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&"function"==typeof console.error&&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."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},s.allocUnsafe=function(t){return u(t)},s.allocUnsafeSlow=function(t){return u(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(G(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),G(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(t){switch(String(t).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}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;let n=s.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){let e=t[r];if(G(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},s.byteLength=d,s.prototype._isBuffer=!0,s.prototype.swap16=function(){let t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},s.prototype.swap32=function(){let t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},s.prototype.swap64=function(){let t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},s.prototype.toString=function(){let t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if(G(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),c=Math.min(o,a),u=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<c;++t)if(u[t]!==l[t]){o=u[t],a=l[t];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}let i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=V[t[n]];return i}function B(t,e,r){let n=t.slice(e,r),i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function _(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i){M(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function P(t,e,r,n,i){M(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function x(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,n,i,o){return e=+e,n>>>=0,o||x(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function N(t,e,n,i,o){return e=+e,n>>>=0,o||x(t,0,n,8),r.write(t,e,n,i,52,8),n+8}s.prototype.slice=function(t,e){let r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);let n=this.subarray(t,e);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),s.prototype.readBigUInt64BE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||_(t,2,this.length);let r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||_(t,2,this.length);let r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||_(t,4,this.length),r.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||_(t,4,this.length),r.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||_(t,8,this.length),r.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||_(t,8,this.length),r.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=J((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=J((function(t,e=0){return P(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){let n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){let n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=J((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=J((function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!n&&0!==n&&(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r||0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);let i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){let e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{let o=s.isBuffer(t)?t:s.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};var j={};function D(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function K(t){let e="",r=t.length,n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function M(t,e,r,n,i,o){if(t>r||t<e){let n,i="bigint"==typeof e?"n":"";throw n=o>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){z(e,"offset"),(void 0===t[e]||void 0===t[e+r])&&W(e,t.length-(r+1))}(n,i,o)}function z(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){throw Math.floor(t)!==t?(z(t,r),new j.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=K(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=K(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);var Z=/[^+/0-9A-Za-z-_]/g;function F(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(Z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function $(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function G(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function X(t){return t!=t}var V=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return typeof BigInt>"u"?Y:t}function Y(){throw new Error("BigInt not supported")}})),ur=Qe(((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:cr().Buffer,Crypto:window.crypto}):e.exports={Buffer:cr().Buffer,Crypto:crypto}})),lr={};((t,e)=>{for(var r in e)Xe(t,r,{get:e[r],enumerable:!0})})(lr,{AVSCTap:()=>Rr,ArweaveSigner:()=>Tr,DataItem:()=>Dr,MAX_TAG_BYTES:()=>Nr,MIN_BINARY_SIZE:()=>jr,SIG_CONFIG:()=>Sr,SignatureConfig:()=>wr,Signer:()=>hr,createData:()=>Mr,deserializeTags:()=>Ur,indexToType:()=>Ar,serializeTags:()=>Br,tagsExceedLimit:()=>_r});var hr=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,r,n){throw new Error("You must implement verify method on child")}},fr=tr(nr(),1),dr=tr(or(),1);async function pr(t){if(Array.isArray(t)){let e=(0,dr.concatBuffers)([(0,dr.stringToBuffer)("list"),(0,dr.stringToBuffer)(t.length.toString())]);return await gr(t,await Er().hash(e,"SHA-384"))}let e=t,r=(0,dr.concatBuffers)([(0,dr.stringToBuffer)("blob"),(0,dr.stringToBuffer)(e.byteLength.toString())]),n=(0,dr.concatBuffers)([await Er().hash(r,"SHA-384"),await Er().hash(e,"SHA-384")]);return await Er().hash(n,"SHA-384")}async function gr(t,e){if(t.length<1)return e;let r=(0,dr.concatBuffers)([e,await pr(t[0])]),n=await Er().hash(r,"SHA-384");return await gr(t.slice(1),n)}var yr,wr,mr=tr(sr(),1),br=mr.default.default?mr.default.default:mr.default,vr=class extends br{getPublicKey(t){throw new Error("Unimplemented")}};function Er(){return yr??=new vr}!function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM"}(wr||(wr={}));var Sr={[wr.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[wr.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[wr.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[wr.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[wr.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[wr.MULTIAPTOS]:{sigLength:2052,pubLength:1025,sigName:"multiAptos"},[wr.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},Tr=class{signatureType=1;ownerLength=Sr[1].pubLength;signatureLength=Sr[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return fr.default.toBuffer(this.pk)}sign(t){return Er().sign(this.jwk,t)}static async verify(t,e,r){return await Er().verify(t,e,r)}},Ar={1:Tr},kr=tr(nr(),1);async function Ir(t){return pr([(0,dr.stringToBuffer)("dataitem"),(0,dr.stringToBuffer)("1"),(0,dr.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function Or(t,e){let{signature:r,id:n}=await async function(t,e){let r=await Ir(t),n=await e.sign(r),i=await Er().hash(n);return{signature:Buffer.from(n),id:Buffer.from(i)}}(t,e);return t.getRaw().set(r,2),n}var Rr=class{buf;pos;constructor(t=Buffer.alloc(Nr),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e,r=t.length;if(r)for(this.writeLong(r),e=0;e<r;e++){let r=t[e];if(void 0===r?.name||void 0===r?.value)throw new Error(`Invalid tag format for ${r}, expected {name:string, value: string}`);this.writeString(r.name),this.writeString(r.value)}this.writeLong(0)}toBuffer(){let t=Buffer.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(t,0,0,this.pos),t}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(t){let e,r,n=this.buf;if(t>=-1073741824&&t<1073741824){r=t>=0?t<<1:~t<<1|1;do{n[this.pos]=127&r,r>>=7}while(r&&(n[this.pos++]|=128))}else{e=t>=0?2*t:2*-t-1;do{n[this.pos]=127&e,e/=128}while(e>=1&&(n[this.pos++]|=128))}this.pos++,this.buf=n}writeString(t){let e=Buffer.byteLength(t),r=this.buf;this.writeLong(e);let n=this.pos;if(this.pos+=e,!(this.pos>r.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let i,o,s,a;for(i=0,o=e;i<o;i++)s=t.charCodeAt(i),s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=63&s|128):55296==(64512&s)&&56320==(64512&(a=t.charCodeAt(i+1)))?(s=65536+((1023&s)<<10)+(1023&a),i++,r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}this.buf=r}}readLong(){let t,e,r,n,i=0,o=0,s=this.buf;do{t=s[this.pos++],e=128&t,i|=(127&t)<<o,o+=7}while(e&&o<28);if(e){r=i,n=268435456;do{t=s[this.pos++],r+=(127&t)*n,n*=128}while(128&t);return(r%2?-(r+1):r)/2}return i>>1^-(1&i)}skipLong(){let t=this.buf;for(;128&t[this.pos++];);}readTags(){let t,e=[];for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let t=this.readString(),r=this.readString();e.push({name:t,value:r})}return e}readString(){let t=this.readLong(),e=this.pos,r=this.buf;if(this.pos+=t,!(this.pos>r.length))return this.buf.slice(e,e+t).toString()}};function Br(t){let e=new Rr;return e.writeTags(t),e.toBuffer()}function _r(t){let e=new Rr;return e.writeTags(t),e.tagsExceedLimit()}function Ur(t){return new Rr(t).readTags()}function Cr(t){let e=0;for(let r=t.length-1;r>=0;r--)e=256*e+t[r];return e}function Pr(t){let e=[0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++){let n=255&t;e[r]=n,t=(t-n)/256}return Uint8Array.from(e)}var xr=tr(ur(),1),Lr=tr(cr(),1),Nr=4096,jr=80,Dr=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return void 0!==t.binary}get signatureType(){let t=Cr(this.binary.subarray(0,2));if(void 0!==wr?.[t])return t;throw new Error("Unknown signature type: "+t)}async isValid(){return Dr.verify(this.binary)}get id(){return(async()=>kr.default.encode(await this.rawId))()}set id(t){this._id=kr.default.toBuffer(t)}get rawId(){return(async()=>Lr.Buffer.from(await xr.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(t){this._id=t}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return kr.default.encode(this.rawSignature)}set rawOwner(t){if(t.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${t.byteLength} bytes.`);this.binary.set(t,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Sr[this.signatureType].sigLength}get owner(){return kr.default.encode(this.rawOwner)}get ownerLength(){return Sr[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):Lr.Buffer.alloc(0)}get target(){return kr.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):Lr.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=Cr(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(0==Cr(this.binary.subarray(t,t+8)))return[];let e=Cr(this.binary.subarray(t+8,t+16));return Ur(Lr.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map((t=>({name:kr.default.encode(t.name),value:kr.default.encode(t.value)})))}getStartOfData(){let t=this.getTagsStart();return t+16+Cr(this.binary.subarray(t+8,t+16))}get rawData(){let t=this.getTagsStart(),e=t+16+Cr(this.binary.subarray(t+8,t+16));return this.binary.subarray(e,this.binary.length)}get data(){return kr.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await Or(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=Lr.Buffer.from(await Er().hash(t))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map((t=>({name:kr.default.encode(t.name),value:kr.default.encode(t.value)}))),data:this.data}}static async verify(t){if(t.byteLength<jr)return!1;let e=new Dr(t),r=e.signatureType,n=e.getTagsStart(),i=Cr(t.subarray(n,n+8)),o=Cr(t.subarray(n+8,n+16));if(o>Nr)return!1;if(i>0)try{if(Ur(Lr.Buffer.from(t.subarray(n+16,n+16+o))).length!==i)return!1}catch{return!1}let s=Ar[r],a=await Ir(e);return await s.verify(e.rawOwner,a,e.rawSignature)}async getSignatureData(){return Ir(this)}getTagsStart(){let t=this.getTargetStart(),e=t+(1==this.binary[t]?33:1);return e+=1==this.binary[e]?33:1,e}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let t=this.getTargetStart()+1;return t+=1==this.binary[this.getTargetStart()]?32:0,t}},Kr=tr(nr(),1);function Mr(t,e,r){let n=e.publicKey,i=r?.target?Kr.default.toBuffer(r.target):null,o=1+(i?.byteLength??0),s=r?.anchor?Buffer.from(r.anchor):null,a=1+(s?.byteLength??0),c=(r?.tags?.length??0)>0?Br(r.tags):null,u=16+(c?c.byteLength:0),l=Buffer.from(t),h=l.byteLength,f=2+e.signatureLength+e.ownerLength+o+a+u+h,d=Buffer.alloc(f);if(d.set(function(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let r=0;r<e.length;r++){let n=255&t;e[r]=n,t=(t-n)/256}return Uint8Array.from(e)}(e.signatureType),0),d.set(new Uint8Array(e.signatureLength).fill(0),2),n.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${n.byteLength}`);d.set(n,2+e.signatureLength);let p=2+e.signatureLength+e.ownerLength;if(d[p]=i?1:0,i){if(32!==i.byteLength)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);d.set(i,p+1)}let g=p+o,y=g+1;if(d[g]=s?1:0,s){if(y+=s.byteLength,32!==s.byteLength)throw new Error("Anchor must be 32 bytes");d.set(s,g+1)}d.set(Pr(r?.tags?.length??0),y);let w=Pr(c?.byteLength??0);d.set(w,y+8),c&&d.set(c,y+16);let m=y+u;return d.set(l,m),new Dr(d)}var zr={...lr};globalThis.arbundles??=zr;const{Axios:Wr,AxiosError:Zr,CanceledError:Fr,isCancel:Hr,CancelToken:$r,VERSION:Gr,all:Xr,Cancel:Vr,isAxiosError:Jr,spread:Yr,toFormData:qr,AxiosHeaders:Qr,HttpStatusCode:tn,formToJSON:en,getAdapter:rn,mergeConfig:nn}=He;var on=a(386),sn={debug:!1,inject:!1,auth0Domain:"auth.othent.io",auth0ClientId:"uXkRmJoIa0NfzYgYEDAgj6Rss4wR1tIc",auth0Strategy:"refresh-tokens",auth0Cache:"memory",auth0RefreshTokenExpirationMs:1296e6,auth0LogInMethod:"popup",auth0RedirectURI:null,auth0ReturnToURI:null,serverBaseURL:"https://kms-server.othent.io",autoConnect:"lazy",cookieKey:null,localStorageKey:null,throwErrors:!0,tags:[]},an={...sn,appName:"",appVersion:"",persistCookie:!1,persistLocalStorage:!1,auth0Cache:"memory"},cn={host:"arweave.net",protocol:"https",port:443},un="othentUserDetails",ln="Othent KMS",hn="2.0.0-beta.10",fn=[{name:"Client",value:ln},{name:"Client-Version",value:hn}],dn=class{constructor(t){this.listeners=new Set,this.initializedListeners=new Set,this.lastEmittedUpdateId="",this.lastEmittedParams=null,this.options={diffParams:!1,replyOnListen:!1},this.options={...this.options,...t}}getUpdateId(t){const{getUpdateIdTransform:e}=this.options,r=e?e(t):t;return JSON.stringify(r,((t,e)=>e&&"oject"===e&&!Array.isArray(e)?Object.entries(e).sort(((t,e)=>t[0].localeCompare(e[0]))):e))}get hasListeners(){return this.listeners.size>0}add(t){this.listeners.add(t),this.options.replyOnListen&&this.lastEmittedParams&&this.emit(...this.lastEmittedParams)}delete(t){this.listeners.add(t)}emit(...t){const{initializedListeners:e,lastEmittedUpdateId:r}=this,n=this.getUpdateId(t),i=r===n;return this.lastEmittedUpdateId=n,this.lastEmittedParams=t,this.listeners.forEach((r=>{if(!i||!e.has(r)){e.add(r);try{r(...t)}catch(t){}}})),i}};function pn(t,e){return et(!0,{},e,t)}var gn={secure:!0,domain:!0,ttlHours:360},yn=class t{constructor(e=gn){this.secureParam=null,this.domainParam=null,this.ttlMs=1296e6;const{secureParam:r,domainParam:n,ttlMs:i}=this.parseCookieOptions(pn(e,gn));return this.secureParam=r,this.domainParam=n,this.ttlMs=i,new Proxy(this,{get:(t,e)=>e in t||"string"!=typeof e?t[e]:t.getItem(e),ownKeys:e=>document.cookie.split(t.COOKIE_SEPARATOR).map((e=>e.split(t.COOKIE_VALUE_SEPARATOR)[0])),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}parseCookieOptions({secure:t,domain:e,ttlHours:r}={}){return{secureParam:t?"secure":void 0===t?this.secureParam:null,domainParam:e?`domain=${!0===e?location.host:e}`:void 0===e?this.domainParam:null,ttlMs:r?36e5*r:void 0===r?this.ttlMs:0}}getCookieParams(t){const{secureParam:e,domainParam:r,ttlMs:n}=this.parseCookieOptions(t),i=[`expires=${new Date(Date.now()+n).toUTCString()}`,e,r,"path=/"].filter(Boolean).join("; ");return i?` ${i};`:""}get length(){return document.cookie?document.cookie.split(t.COOKIE_SEPARATOR).length:0}key(e){return(document.cookie.split(t.COOKIE_SEPARATOR)[e]||"").split(t.COOKIE_VALUE_SEPARATOR)[0]||null}getItem(e){const r=document.cookie.split(t.COOKIE_SEPARATOR).find((r=>r.split(t.COOKIE_VALUE_SEPARATOR)[0]===e));return r&&r.split(t.COOKIE_VALUE_SEPARATOR)[1]||null}setItem(t,e,r){const n=`${t}=${"string"==typeof e?e:JSON.stringify(e)};${this.getCookieParams(r)}`;return document.cookie=n,n}removeItem(t,e){return this.setItem(t,"",{...e,ttlHours:-1})}clear(){document.cookie.split(t.COOKIE_SEPARATOR).forEach((e=>{this.removeItem(e.split(t.COOKIE_VALUE_SEPARATOR)[0])}))}};yn.COOKIE_SEPARATOR=/\s*;\s*/,yn.COOKIE_VALUE_SEPARATOR=/\s*=\s*/;var wn=yn,mn=null;var bn=class t{constructor({debug:t,domain:e,clientId:r,strategy:n,cache:i,refreshTokenExpirationMs:o,loginMethod:s,redirectURI:a,returnToURI:c,appInfo:u,initialUserDetails:l,cookieKey:h,localStorageKey:f}){this.debug=!1,this.auth0ClientPromise=Promise.resolve(null),this.authEventListenerHandler=new dn({diffParams:!0,replyOnListen:!0}),this.userDetails=null,this.userDetailsExpirationTimeoutID=0,this.cookieKey=null,this.localStorageKey=null,this.refreshTokenExpirationMs=+sn.auth0RefreshTokenExpirationMs,this.appInfo={name:"",version:""},this.isReady=!1,this.isAuthenticated=!1,this.debug=t,this.loginMethod=s,this.redirectURI=a,this.returnToURI=c,this.auth0ClientPromise=async function(t){const e=new tt(t);return await e.checkSession(),e}({domain:e,clientId:r,useRefreshTokens:"refresh-tokens"===n,cacheLocation:"string"==typeof i?i:void 0,cache:"object"==typeof i?i:void 0,authorizationParams:{redirect_uri:this.redirectURI}}).then((t=>(this.isReady=!0,t))),this.cookieKey=h,this.localStorageKey=f,this.refreshTokenExpirationMs=o,this.appInfo=u,this.restoreUserDetails(l||null),this.handleStorage=this.handleStorage.bind(this)}static isIdTokenValidUser(t){return!!(t&&t.sub&&t.owner&&t.walletAddress&&"KMS"===t.authSystem)}static async getUserDetails(e){const{email:r="",walletAddress:n}=e,i=e.sub||"",o=i.split("|")[0];let s=await async function(t){try{const e=(await He.get("https://api.mem.tech/api/state/Tih8T1uESATJNzdwBIY3rpe25kWTzjw8uNiMRYe9I5M",{timeout:2e3})).data.balances.find((e=>e.address===t)),r=e&&(e.primary_domain||e.ownedDomains[0].domain)||null;return r?`${r}.ar`:null}catch(e){return console.warn(`Error resolving ANS domain for ${t} =\n`,e),null}}(n);if(!s){s=`${t.PROVIDER_LABELS[o]||"Unknown Provider"} (${r})`}return{sub:i,name:e.name||"",givenName:e.given_name||"",middleName:e.middle_name||"",familyName:e.family_name||"",nickname:e.nickname||"",preferredUsername:e.preferred_username||"",profile:e.profile||"",picture:e.picture||"",website:e.website||"",locale:e.locale||"",updatedAt:e.updated_at||"",email:r,emailVerified:!!e.email_verified,owner:e.owner,walletAddress:e.walletAddress,walletAddressLabel:s,authSystem:e.authSystem,authProvider:o}}getAuthEventListenerHandler(){return this.authEventListenerHandler}setAppInfo(t){this.appInfo=t}initStorageSyncing(){this.localStorageKey&&window.addEventListener("storage",this.handleStorage)}stopStorageSyncing(){window.removeEventListener("storage",this.handleStorage)}handleStorage(t){t.key===this.localStorageKey&&(t.newValue?this.restoreUserDetails():this.logOut())}persistUserDetails(t){const{cookieKey:e,localStorageKey:r}=this;if(e){const r=function(){if(!mn){const t=!1;mn=new wn({secure:!t&&void 0,domain:!t&&void 0})}return mn}();t?r.setItem(e,JSON.stringify(t)):null!==r.getItem(e)&&r.removeItem(e)}if(r)if(t){const e=new Date,n=JSON.stringify({userDetails:t,createdAt:e.toUTCString(),expiredBy:new Date(e.getTime()+this.refreshTokenExpirationMs).toUTCString()});localStorage.setItem(r,n)}else this.clearStoredUserDetails()}setUserDetails(t,e=!0){window.clearTimeout(this.userDetailsExpirationTimeoutID),t&&(this.userDetailsExpirationTimeoutID=window.setTimeout(this.logOut,this.refreshTokenExpirationMs));return this.authEventListenerHandler.emit(t,e?!!t:this.isAuthenticated)||(this.userDetails=t),e&&(this.isAuthenticated=!!t,this.persistUserDetails(t)),t}restoreUserDetails(t){let e=t||null;if(!e&&this.localStorageKey)try{const t=JSON.parse(localStorage.getItem(this.localStorageKey)||"null");if(t){const r=new Date(t.expiredBy).getTime();!isNaN(r)&&r>Date.now()?e=t.userDetails:this.clearStoredUserDetails()}}catch(t){}this.setUserDetails(e,!1)}clearStoredUserDetails(){Object.keys(localStorage).forEach((t=>{t.startsWith("othent")&&localStorage.removeItem(t)}))}async updateUserDetails(e){const r=e&&t.isIdTokenValidUser(e)?await t.getUserDetails(e):null;return this.setUserDetails(r)}getAuthorizationParams(t={}){const{authorizationParams:e,data:r}=t.hasOwnProperty("keyName")?{authorizationParams:null,data:t}:{authorizationParams:t,data:null},n={othentFunction:"KMS",othentSDKVersion:ln,othentAPIVersion:hn,appName:this.appInfo.name,appVersion:this.appInfo.version};return r&&(n.data=r),{...e,transaction_input:JSON.stringify(n,((t,e)=>{let r=[];if(e instanceof Buffer||e instanceof DataView||ArrayBuffer.isView(e))r=Array.from(new Uint8Array(e.buffer));else{if(!(e instanceof ArrayBuffer))return e;r=Array.from(new Uint8Array(e))}return"data"===t?Object.fromEntries(Object.entries(r)):{type:"Buffer",data:r}}))}}async getTokenSilently(t){const e=await this.auth0ClientPromise;if(!e)throw new Error("Missing Auth0 Client");const r=this.getAuthorizationParams(t);if(this.debug)try{console.log("getTokenSilently() =",{...r,transaction_input:JSON.parse(r.transaction_input)})}catch(t){console.error("Error logging/parsing `authorizationParams`:",t)}try{const t=await e.getTokenSilently({detailedResponse:!0,authorizationParams:r,cacheMode:"off"}),n=await e.getUser();if(!n)throw new Error("Could not get the user's details");const i=await this.updateUserDetails(n);return{...t,idToken:n,userDetails:i}}catch(t){throw t}}async logIn(){const t=await this.auth0ClientPromise;if(!t)throw new Error("Missing Auth0 Client");this.debug&&console.log("logIn()");if(await t.isAuthenticated())throw new Error("Already logged in");const e=this.getAuthorizationParams({redirect_uri:this.redirectURI});if("popup"!==this.loginMethod)throw t.loginWithRedirect({authorizationParams:e}),new Error("Redirecting...");return await t.loginWithPopup({authorizationParams:e},{}),this.getTokenSilently()}async handleRedirectCallback(t){this.debug&&console.log(`handleRedirectCallback(${t})`);const e=await this.auth0ClientPromise;if(!e)throw new Error("Missing Auth0 Client");await e.handleRedirectCallback(t);const r=await e.getUser();if(!r)throw new Error("Could not get the user's details");return this.updateUserDetails(r)}async logOut(){this.setUserDetails(null);const t=await this.auth0ClientPromise;if(!t)throw new Error("Missing Auth0 Client");return t.logout({logoutParams:{returnTo:this.returnToURI}}).catch((t=>{console.warn(t instanceof Error?t.message:t),"undefined"!=typeof location&&location.reload()}))}async encodeToken(t){return(await this.getTokenSilently(t)).id_token}getCachedUserDetails(){return this.userDetails}getCachedUserPublicKey(){var t;return(null==(t=this.userDetails)?void 0:t.owner)||null}getCachedUserSub(){var t;return(null==(t=this.userDetails)?void 0:t.sub)||null}getCachedUserAddress(){var t;return(null==(t=this.userDetails)?void 0:t.walletAddress)||null}getCachedUserAddressLabel(){var t;return(null==(t=this.userDetails)?void 0:t.walletAddressLabel)||null}getCachedUserEmail(){var t;return(null==(t=this.userDetails)?void 0:t.email)||null}};bn.PROVIDER_LABELS={apple:"Apple",auth0:"E-Mail","google-oauth2":"Google","<LinkedIn>":"LinkedIn","<X>":"X","<Meta>":"Meta","<Twitch>":"Twitch",github:"GitHub"};var vn=bn;function En(t){return"string"==typeof t?Sn(t):t}function Sn(t){return(new TextEncoder).encode(t)}function Tn(t){return e=function(t){return $e.fromByteArray(new Uint8Array(t))}(t),e.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"");var e}async function An(t,e="SHA-256"){let r=await crypto.subtle.digest(e,t);return new Uint8Array(r)}var kn=(t=>(t.Unexpected="Unexpected",t.Validation="Validation",t.UserCreation="UserCreation",t.Encryption="Encryption",t.Decryption="Decryption",t.Signing="Signing",t.PublicKey="PublicKey",t))(kn||{}),In=class extends Error{constructor(t,e,r,n=!1){super(),this.name=t,this.message=e||"",n?this.stack=`${t} (from server): ${e}\n`:Error.captureStackTrace(this),this.id=t,this.developerMessage=e,r instanceof Error?this.cause=r:"string"!=typeof r&&"number"!=typeof r||(this.cause=new Error(`${r}`))}};function On(t){var e;if(Jr(t)){const r=null==(e=t.response)?void 0:e.data;if(!function(t){return"object"==typeof t&&!0===t.error&&!!t.id&&!!kn[t.id]}(r))return t;const{id:n,developerMessage:i,cause:o}=r;let s;return o&&(s=new Error(o.message),s.name=o.name,s.stack=o.stack),new In(n,i||"",s,!0)}return t instanceof Error?t:new Error("Unknown error")}async function Rn(t,e,r,n){var i;const o=await e.encodeToken({ciphertext:r,keyName:n});let s=null;try{s=null!=(i=(await t.post("/decrypt",{encodedData:o})).data.data)?i:null}catch(t){throw On(t)}if(null===s)throw new Error("Error decrypting on server.");return"string"==typeof s?s:(a=new Uint8Array(s.data),(new TextDecoder).decode(a));var a}var Bn=class{constructor(t,e){this.api=He.create({baseURL:t}),this.auth0=e}async createUser(t){return async function(t,e){let r=!1;try{r=(await t.post("/create-user",{encodedData:e})).data.data}catch(t){throw On(t)}if(!r)throw new Error("Error creating user on server.");return!0}(this.api,t)}async decrypt(t,e){return Rn(this.api,this.auth0,t,e)}async encrypt(t,e){return async function(t,e,r,n){var i;const o=await e.encodeToken({plaintext:r,keyName:n});let s=null;try{s=null!=(i=(await t.post("/encrypt",{encodedData:o})).data.data)?i:null}catch(t){throw On(t)}if(null===s)throw new Error("Error encrypting on server.");return"string"==typeof s?Sn(s):new Uint8Array(s.data)}(this.api,this.auth0,t,e)}async sign(t,e){return async function(t,e,r,n){const i=await e.encodeToken({data:r,keyName:n});let o=null;try{o=(await t.post("/sign",{encodedData:i})).data.data}catch(t){throw On(t)}if(null===o)throw new Error("Error signing data on server.");return"string"==typeof o?Sn(o):new Uint8Array(o.data)}(this.api,this.auth0,t,e)}getSignerSignFn(t){return async e=>await this.sign(e,t)}};function _n(t,e="utf8"){return n.lW.isBuffer(t)?Cn(t.toString("base64")):Cn(n.lW.from(t,e).toString("base64"))}function Un(t){return function(t){let e=t.length,r=e%4;if(!r)return t;let i=e,o=4-r,s=e+o,a=n.lW.alloc(s);for(a.write(t);o--;)a.write("=",i++);return a.toString()}(t=t.toString()).replace(/\-/g,"+").replace(/_/g,"/")}function Cn(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Pn(t){return n.lW.from(Un(t),"base64")}var xn=_n;function Ln(t){return on.default.init(t)}xn.encode=_n,xn.decode=function(t,e="utf8"){return n.lW.from(Un(t),"base64").toString(e)},xn.toBase64=Un,xn.fromBase64=Cn,xn.toBuffer=Pn;var Nn=class t{constructor(t=an){this.errorEventListenerHandler=new dn,this.tokens=new Set,this.walletName=ln,this.walletVersion=hn,this.config=sn,this.appInfo={name:"",version:""},this.gatewayConfig=cn;let{appName:e,appVersion:r,persistCookie:n,persistLocalStorage:i,auth0Cache:o=sn.auth0Cache,auth0RedirectURI:s,auth0ReturnToURI:a,gatewayConfig:c,initialUserDetails:u,...l}=t;const h="undefined"==typeof location?null:location.origin;this.config={...pn(l,sn),cookieKey:"string"==typeof n?n:n?un:null,localStorageKey:"string"==typeof i?i:i?un:null,auth0Cache:"object"==typeof o?"custom":o,auth0RedirectURI:s||h,auth0ReturnToURI:a||h};const{config:f}=this,{cookieKey:d,localStorageKey:p}=f;if("string"==typeof d&&!d.startsWith("othent"))throw new Error('`persistCookie` / `cookieKey` must start with "othent".');if("string"==typeof p&&!p.startsWith("othent"))throw new Error('`persistLocalStorage` / `localStorageKey` must start with "othent".');if(!f.auth0RedirectURI)throw new Error("`auth0RedirectURI` is required.");if(!f.auth0ReturnToURI)throw new Error("`auth0ReturnToURI` is required.");this.appInfo={name:e,version:r},this.gatewayConfig=c||cn;let g=null;if("undefined"!=typeof window)g=window.crypto;else{if("undefined"==typeof global)throw new Error("A Crypto module is needed for Othent to work. If your environment doesn't natively provide one, you should polyfill it.");g=global.crypto}if(this.crypto=g,"eager"===f.autoConnect&&"popup"===f.auth0LogInMethod&&"refresh-tokens"===f.auth0Strategy&&"memory"===o)throw new Error('The browser cannot open the authentication modal automatically before an user interaction. Use `autoConnect = "lazy"` or change any of these other options: `auth0LogInMethod`, `auth0Strategy` or `auth0Cache`.');if(this.auth0=new vn({debug:f.debug,domain:f.auth0Domain,clientId:f.auth0ClientId,strategy:f.auth0Strategy,cache:o,refreshTokenExpirationMs:f.auth0RefreshTokenExpirationMs,redirectURI:f.auth0RedirectURI,returnToURI:f.auth0ReturnToURI,loginMethod:f.auth0LogInMethod,appInfo:this.appInfo,initialUserDetails:u,cookieKey:f.cookieKey,localStorageKey:f.localStorageKey}),"eager"===this.config.autoConnect){let t="undefined"==typeof location;if(!t){const e=new URL(location.href),{searchParams:r}=e;r.has("code")||r.has("state")||(t=!0)}t&&this.connect()}if(f.inject&&(window.arweaveWallet=this),!f.throwErrors){["connect","disconnect","getActiveAddress","getActivePublicKey","getAllAddresses","getWalletNames","getUserDetails","getSyncActiveAddress","getSyncActivePublicKey","getSyncAllAddresses","getSyncWalletNames","getSyncUserDetails","sign","dispatch","encrypt","decrypt","signature","signDataItem","signMessage","verifyMessage","privateHash","getArweaveConfig","getPermissions"].forEach((t=>{let e=this[t];"function"==typeof e&&(e=e.bind(this),this[t]=(...t)=>{try{let n=e(...t);return!(r=n)||"object"!=typeof r&&"function"!=typeof r||"function"!=typeof r.then||(n=n.catch((t=>(this.onError(t),null)))),n}catch(t){this.onError(t)}var r;return null})}))}this.api=new Bn(this.config.serverBaseURL,this.auth0)}startTabSynching(){return this.config.localStorageKey||console.warn("Calling `Othent.startTabSynching()` is a NOOP unless the `persistLocalStorage` option is used."),this.auth0.initStorageSyncing(),()=>{this.auth0.stopStorageSyncing()}}async completeConnectionAfterRedirect(t){"redirect"!==this.config.auth0LogInMethod&&console.warn('Calling `Othent.completeConnectionAfterRedirect()` is a NOOP unless the `auth0LogInMethod` options is `"redirect"`.');const e=t||("undefined"==typeof location?"":location.href),r=new URL(e.replace(/.+\.auth0:\/\//,"https://")),{searchParams:n}=r;if(!n.has("code")||!n.has("state")||!e)return null;let i=null;try{i=await this.auth0.handleRedirectCallback(e)}finally{"undefined"!=typeof location&&"undefined"!=typeof history&&(n.delete("code"),n.delete("state"),history.replaceState(null,"",r))}return i}get isReady(){return this.auth0.isReady}onError(t){t instanceof Error?this.errorEventListenerHandler.hasListeners?this.errorEventListenerHandler.emit(t):console.warn("Unhandled unthrown error:\n",t,'\nWhen using `throwErrors = false`, you must add at least one error event listener with `othent.addEventListener("error", () => { ... })`'):console.warn("Unknown error type",t)}addEventListener(t,e){let r=null;if("auth"===t)r=this.auth0.getAuthEventListenerHandler();else if("error"===t){if(this.config.throwErrors)throw new Error("You can only listen for `error` events if `throwErrors = false`.");r=this.errorEventListenerHandler}if(!r)throw new Error("Unknown event type");return r.add(e),()=>{r.delete(e)}}removeEventListener(t,e){let r=null;if("auth"===t?r=this.auth0.getAuthEventListenerHandler():"error"===t&&(r=this.errorEventListenerHandler),!r)throw new Error("Unknown event type");r.delete(e)}get isAuthenticated(){return this.auth0.isAuthenticated}requireAuth(){return this.requireUserDataOrThrow().then((()=>{}))}async requireUserDataOrThrow(){"off"===this.config.autoConnect||this.auth0.isAuthenticated||await this.connect(void 0,void 0,this.gatewayConfig);const{sub:t,owner:e}=this.auth0.getCachedUserDetails()||{};if(!t||!e)throw new Error("Missing cached user.");return{sub:t,publicKey:e}}async connect(e,r,n){if(e&&e.toSorted().join("-")!==t.ALL_PERMISSIONS.join("-"))throw new Error("Othent implicitly has access to all available permissions. You should pass `permissions = undefined` or include all of them.");r&&(this.appInfo=r,this.auth0.setAppInfo(r)),this.gatewayConfig=n||cn;let i="",o=null;try{const t=await this.auth0.getTokenSilently();i=t.id_token,o=t.userDetails}catch(t){if(!(t instanceof Error))throw t;if("Login required"!==t.message&&!(t instanceof E))throw t;console.warn(t.message)}if(!i)try{const t=await this.auth0.logIn();i=t.id_token,o=t.userDetails}catch(t){if(!(t instanceof Error))throw t;if("Redirecting..."===t.message&&await new Promise((()=>{})),t.message.startsWith("Unable to open a popup")||t instanceof b||t instanceof m)return t instanceof m&&t.popup.close(),console.warn(t.message),null;throw t}if(i&&!o){await this.api.createUser(i);const t=await this.auth0.getTokenSilently();i=t.id_token,o=t.userDetails}if(i&&o)return o;throw this.auth0.logOut(),new Error("Unexpected authentication error")}async disconnect(){return this.auth0.logOut()}getActiveAddress(){return Promise.resolve(this.getSyncActiveAddress())}getActivePublicKey(){return Promise.resolve(this.getSyncActivePublicKey())}getAllAddresses(){return Promise.resolve(this.getSyncAllAddresses())}getWalletNames(){return Promise.resolve(this.getSyncWalletNames())}getUserDetails(){return Promise.resolve(this.getSyncUserDetails())}getSyncActiveAddress(){return this.auth0.getCachedUserAddress()||""}getSyncActivePublicKey(){return this.auth0.getCachedUserPublicKey()||""}getSyncAllAddresses(){const t=this.auth0.getCachedUserAddress();return t?[t]:[]}getSyncWalletNames(){const t=this.auth0.getCachedUserAddress(),e=this.auth0.getCachedUserAddressLabel();return Promise.resolve(t&&e?{[t]:e}:{})}getSyncUserDetails(){return this.auth0.getCachedUserDetails()}addCommonTags(t=[]){if(Array.isArray(t)){const e=[{name:"App-Name",value:this.appInfo.name},{name:"App-Version",value:this.appInfo.version}];return[...t,...this.config.tags,...e,...fn]}for(const{name:e,value:r}of this.config.tags)t.addTag(e,r);t.addTag("App-Name",this.appInfo.name),t.addTag("App-Version",this.appInfo.version);for(const{name:e,value:r}of fn)t.addTag(e,r)}async sign(t){const{sub:e,publicKey:r}=await this.requireUserDataOrThrow(),n=Ln(this.gatewayConfig),i=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),o=this.addCommonTags(i),s=await n.createTransaction({data:t.data,owner:r,reward:t.reward});o.forEach((t=>{s.addTag(t.name,t.value)}));const a=await s.getSignatureData(),c=await this.api.sign(a,e),u=await An(c);return s.setSignature({id:Tn(u),owner:r,signature:Tn(c),tags:s.tags,reward:s.reward}),s}async dispatch(t,e){var r;const n=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),i=await this.signDataItem({data:t.data,tags:n,target:t.target}),o=`${(null==e?void 0:e.node)||"https://turbo.ardrive.io"}/tx`;try{const t=await He.post(o,i,{headers:{"Content-Type":"application/octet-stream"},maxBodyLength:1/0,maxContentLength:1/0,responseType:"json"});if(t.status>=400)throw new Error(`${t.status} - ${JSON.stringify(t.data)}`);return{...t.data,type:"BUNDLED"}}catch(n){console.warn(`Error dispatching transaction to ${o} =\n`,n);const i=await this.sign(t),s=null!=(r=null==e?void 0:e.arweave)?r:Ln(this.gatewayConfig),a=await s.transactions.getUploader(i);for(;!a.isComplete;)await a.uploadChunk();return{id:i.id,signature:i.signature,owner:i.owner,type:"BASE"}}}async encrypt(t){const{sub:e}=await this.requireUserDataOrThrow();return await this.api.encrypt(t,e)}async decrypt(t){const{sub:e}=await this.requireUserDataOrThrow();return await this.api.decrypt(t,e)}async signature(t){const{sub:e}=await this.requireUserDataOrThrow();return await this.api.sign(t,e)}async signDataItem(t){const{sub:e,publicKey:r}=await this.requireUserDataOrThrow(),{data:n,tags:i,...o}=t,s={publicKey:Pn(r),signatureType:1,signatureLength:512,ownerLength:512,sign:this.api.getSignerSignFn(e)},a=Mr(n,s,{...o,tags:this.addCommonTags(i)});return await a.sign(s),a.getRaw().buffer}async signMessage(t,e){const{sub:r}=await this.requireUserDataOrThrow(),n=(null==e?void 0:e.hashAlgorithm)||"SHA-256",i=await this.crypto.subtle.digest(n,En(t));return await this.api.sign(i,r)}async verifyMessage(t,e,r,n={hashAlgorithm:"SHA-256"}){if(!r){const t=await this.requireUserDataOrThrow();r||(r=t.publicKey)}const i=(null==n?void 0:n.hashAlgorithm)||"SHA-256",o=await this.crypto.subtle.digest(i,En(t)),s={e:"AQAB",ext:!0,kty:"RSA",n:r},a=await this.crypto.subtle.importKey("jwk",s,{name:"RSA-PSS",hash:n.hashAlgorithm},!1,["verify"]);return await this.crypto.subtle.verify({name:"RSA-PSS",saltLength:32},a,En(e),o)}async privateHash(t,e){return An(En(t),null==e?void 0:e.hashAlgorithm)}getArweaveConfig(){return Promise.resolve(this.gatewayConfig)}getPermissions(){return Promise.resolve(t.ALL_PERMISSIONS)}addToken(t,e,r){return console.warn("Othent doesn't currently support this feature and only tracks added tokens temporarily in memory."),this.tokens.add(t),Promise.resolve()}isTokenAdded(t){return console.warn("Othent doesn't currently support this feature and only tracks added tokens temporarily in memory."),Promise.resolve(this.tokens.has(t))}};Nn.walletName=ln,Nn.walletVersion=hn,Nn.ALL_PERMISSIONS=["ACCESS_ADDRESS","ACCESS_ALL_ADDRESSES","ACCESS_ARWEAVE_CONFIG","ACCESS_PUBLIC_KEY","DECRYPT","DISPATCH","ENCRYPT","SIGN_TRANSACTION","SIGNATURE"];var jn=Nn;async function Dn(t,e){try{const r=function(t){const e=t.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),r=window.atob(e),n=new Uint8Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n.buffer}(t),n=await window.crypto.subtle.importKey("spki",r,{name:"RSA-OAEP",hash:{name:"SHA-256"}},!0,["encrypt"]);return function(t){try{let e="";const r=new Uint8Array(t),n=r.byteLength;for(let t=0;t<n;t++)e+=String.fromCharCode(r[t]);return window.btoa(e)}catch(t){console.error("Eror in buffertoBase64 : ",t)}}(await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,(new TextEncoder).encode(e)))}catch(t){return console.error("rsaEncrypt error:",t),null}}async function Kn(t){const e={Info:{hashedOthentSub:t},request:"PIN"};return await fetch("https://api2.onairos.uk/getAccountInfoFromOthentSub",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t)).catch((t=>console.error(t)))}window.Buffer=n.lW;const Mn=(0,e.createContext)(null);function zn({clientId:t,nonce:n,onScriptLoadSuccess:i,onScriptLoadError:o,children:s}){const a=function(t={}){const{nonce:r,onScriptLoadSuccess:n,onScriptLoadError:i}=t,[o,s]=(0,e.useState)(!1),a=(0,e.useRef)(n);a.current=n;const c=(0,e.useRef)(i);return c.current=i,(0,e.useEffect)((()=>{const t=document.createElement("script");return t.src="https://accounts.google.com/gsi/client",t.async=!0,t.defer=!0,t.nonce=r,t.onload=()=>{var t;s(!0),null===(t=a.current)||void 0===t||t.call(a)},t.onerror=()=>{var t;s(!1),null===(t=c.current)||void 0===t||t.call(c)},document.body.appendChild(t),()=>{document.body.removeChild(t)}}),[r]),o}({nonce:n,onScriptLoadSuccess:i,onScriptLoadError:o}),c=(0,e.useMemo)((()=>({clientId:t,scriptLoadedSuccessfully:a})),[t,a]);return r().createElement(Mn.Provider,{value:c},s)}function Wn(){const t=(0,e.useContext)(Mn);if(!t)throw new Error("Google OAuth components must be used within GoogleOAuthProvider");return t}function Zn(t){var e;return null!==(e=null==t?void 0:t.clientId)&&void 0!==e?e:null==t?void 0:t.client_id}const Fn={large:40,medium:32,small:20};function Hn({onSuccess:t,onError:n,useOneTap:i,promptMomentNotification:o,type:s="standard",theme:a="outline",size:c="large",text:u,shape:l,logo_alignment:h,width:f,locale:d,click_listener:p,containerProps:g,...y}){const w=(0,e.useRef)(null),{clientId:m,scriptLoadedSuccessfully:b}=Wn(),v=(0,e.useRef)(t);v.current=t;const E=(0,e.useRef)(n);E.current=n;const S=(0,e.useRef)(o);return S.current=o,(0,e.useEffect)((()=>{var t,e,r,n,o,g,T,A,k;if(b)return null===(r=null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.accounts)||void 0===e?void 0:e.id)||void 0===r||r.initialize({client_id:m,callback:t=>{var e;if(!(null==t?void 0:t.credential))return null===(e=E.current)||void 0===e?void 0:e.call(E);const{credential:r,select_by:n}=t;v.current({credential:r,clientId:Zn(t),select_by:n})},...y}),null===(g=null===(o=null===(n=null===window||void 0===window?void 0:window.google)||void 0===n?void 0:n.accounts)||void 0===o?void 0:o.id)||void 0===g||g.renderButton(w.current,{type:s,theme:a,size:c,text:u,shape:l,logo_alignment:h,width:f,locale:d,click_listener:p}),i&&(null===(k=null===(A=null===(T=null===window||void 0===window?void 0:window.google)||void 0===T?void 0:T.accounts)||void 0===A?void 0:A.id)||void 0===k||k.prompt(S.current)),()=>{var t,e,r;i&&(null===(r=null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.accounts)||void 0===e?void 0:e.id)||void 0===r||r.cancel())}}),[m,b,i,s,a,c,u,l,h,f,d]),r().createElement("div",{...g,ref:w,style:{height:Fn[c],...null==g?void 0:g.style}})}class $n extends Error{}function Gn(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,((t,e)=>{let r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return atob(e)}}$n.prototype.name="InvalidTokenError";const Xn=process.env.REACT_APP_API_URL||"https://api.onairos.com";function Vn(t){let{dataRequester:r,NoAccount:n,NoModel:i,activeModels:o,requestData:s,handleConnectionSelection:a,changeGranted:c,granted:u,allowSubmit:l,rejectDataRequest:h,sendDataRequest:f,avatar:d,traits:p}=t;const[g,y]=(0,e.useState)(!1),[w,m]=(0,e.useState)(null),[b,v]=(0,e.useState)(!0),[E,S]=(0,e.useState)(null),[T,A]=(0,e.useState)({email:"",password:""});(0,e.useEffect)((()=>{k()}),[]);const k=async()=>{try{const t=localStorage.getItem("onairosToken");if(t){(await fetch("".concat(Xn,"/auth/verify"),{headers:{Authorization:"Bearer ".concat(t)}})).ok?(m(t),y(!0)):localStorage.removeItem("onairosToken")}}catch(t){console.error("Token verification failed:",t)}finally{v(!1)}},I=async t=>{try{v(!0),S(null);const e=function(t,e){if("string"!=typeof t)throw new $n("Invalid token specified: must be a string");e||(e={});const r=!0===e.header?0:1,n=t.split(".")[r];if("string"!=typeof n)throw new $n(`Invalid token specified: missing part #${r+1}`);let i;try{i=Gn(n)}catch(t){throw new $n(`Invalid token specified: invalid base64 for part #${r+1} (${t.message})`)}try{return JSON.parse(i)}catch(t){throw new $n(`Invalid token specified: invalid json for part #${r+1} (${t.message})`)}}(t.credential),r=await fetch("".concat(Xn,"/auth/google"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t.credential,email:e.email})});if(!r.ok)throw new Error("Google authentication failed");const{token:n}=await r.json();localStorage.setItem("onairosToken",n),m(n),y(!0)}catch(t){console.error("Google login failed:",t),S("Google login failed. Please try again.")}finally{v(!1)}},O=()=>{S("Google login failed. Please try again.")},R=t=>{A({...T,[t.target.name]:t.target.value})},B=async t=>{t.preventDefault();try{v(!0),S(null);const t=await fetch("".concat(Xn,"/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)});if(!t.ok)throw new Error("Invalid credentials");const{token:e}=await t.json();localStorage.setItem("onairosToken",e),m(e),y(!0)}catch(t){console.error("Login failed:",t),S("Invalid email or password")}finally{v(!1)}};return b?React.createElement("div",{className:"fixed inset-x-0 bottom-0 h-[50vh] bg-white rounded-t-lg shadow-lg flex items-center justify-center"},React.createElement("div",{className:"flex flex-col items-center space-y-2"},React.createElement("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}))):g?React.createElement("div",{className:"fixed inset-x-0 bottom-0 h-[50vh] bg-white rounded-t-lg shadow-lg"},React.createElement("div",{className:"w-full h-full overflow-y-auto"},React.createElement("div",{className:"px-4 py-6"},React.createElement("h1",{className:"text-lg font-semibold text-gray-900 mb-6"},"Data Requests from ",r),React.createElement("div",{className:"flex items-center justify-between mb-6"},React.createElement("button",{className:"bg-gray-500 hover:bg-gray-600 text-white font-bold py-2 px-8 rounded",onClick:h},"Reject All"),React.createElement("button",{disabled:!l,className:"bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-8 rounded ".concat(l?"":"opacity-50 cursor-not-allowed"),onClick:f},"Confirm (",u,")")),0===o.length?React.createElement("div",{className:"flex flex-col items-center justify-center py-8"},React.createElement("img",{src:"https://onairos.sirv.com/Images/OnairosWhite.png",alt:"Onairos Logo",className:"w-24 h-24 mb-4"}),React.createElement("p",{className:"text-center text-gray-800 font-medium"},"Please connect ",React.createElement("a",{href:"https://onairos.uk/connections",className:"text-blue-500 hover:underline"},"Onairos")," Personality to send ",r," your data")):React.createElement("div",{className:"space-y-4"},Object.keys(s).sort(((t,e)=>{const r=o.includes(s[t].type),n=o.includes(s[e].type);return"Avatar"===s[t].type?1:"Avatar"===s[e].type?-1:"Traits"===s[e].type?1:"Traits"===s[t].type||r&&!n?-1:n&&!r?1:0})).map(((t,e)=>{const n=s[t],i="Personality"==n.type?o.includes(n.type):"Avatar"==n.type?d:"Traits"==n.type&&p;return React.createElement("div",{key:t},React.createElement(IndividualConnection,{active:i,title:n.type,id:n,number:e,descriptions:n.descriptions,rewards:n.reward,size:t,changeGranted:c,onSelectionChange:i=>a(r,t,e,n.type,n.reward,i)}))})))))):React.createElement("div",{className:"fixed inset-x-0 bottom-0 h-[50vh] bg-white rounded-t-lg shadow-lg"},React.createElement("div",{className:"w-full h-full overflow-y-auto px-4 py-6"},React.createElement("div",{className:"flex flex-col items-center justify-start max-w-sm mx-auto space-y-6"},E&&React.createElement("div",{className:"w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded"},E),React.createElement(Hn,{onSuccess:I,onError:O,useOneTap:!0,theme:"outline",size:"large",text:"continue_with",shape:"rectangular",width:"320"}),React.createElement("div",{className:"w-full flex items-center justify-center space-x-4"},React.createElement("hr",{className:"flex-grow border-gray-300"}),React.createElement("span",{className:"text-gray-500"},"or"),React.createElement("hr",{className:"flex-grow border-gray-300"})),React.createElement("form",{onSubmit:B,className:"w-full space-y-4"},React.createElement("input",{type:"email",name:"email",value:T.email,onChange:R,placeholder:"Email",className:"w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),React.createElement("input",{type:"password",name:"password",value:T.password,onChange:R,placeholder:"Password",className:"w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),React.createElement("button",{type:"submit",className:"w-full bg-blue-500 text-white font-semibold py-2 px-4 rounded hover:bg-blue-600 transition-colors",disabled:b},b?"Signing in...":"Sign In")))))}const Jn=async()=>(await a.e(423).then(a.t.bind(a,153,23))).default;function Yn(t){let{requestData:n,webpageName:i,inferenceData:o=null,onComplete:s=null,autoFetch:a=!0,proofMode:c=!1,textLayout:u="below",textColor:l="white",login:h=!1,buttonType:f="pill",loginReturn:d=null,loginType:p="signIn",visualType:g="full"}=t;const[y,w]=(0,e.useState)(null),[m,b]=(0,e.useState)(!1),[v,E]=(0,e.useState)([]),[S,T]=(0,e.useState)(0),[A,k]=(0,e.useState)({}),[I,O]=(0,e.useState)(!1),[R,B]=(0,e.useState)(!1),_=(0,e.useRef)(!1),U=(0,e.useRef)(!1),C=()=>{const t=navigator.userAgent||navigator.vendor||window.opera;return/android|iphone|ipad|ipod|windows phone/i.test(t)};(0,e.useEffect)((()=>{if(a&&o&&"function"==typeof s){const t=async t=>{if(t.data&&"content-script"===t.data.source&&"API_URL_RESPONSE"===t.data.type&&"Onairos-Response"===t.data.unique){const{APIurl:e,approved:r,accessToken:n}=t.data,i=(t=>{const e={Small:16,Medium:32,Large:64};let r=null,n=0;return t.forEach((t=>{const i=e[t.data];i>n&&(n=i,r=t)})),n})(r),a={Input:o.slice(0,i)};try{const t=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)},body:JSON.stringify(a)}),r=await t.json();s(r)}catch(t){console.error(t),s(null,t)}}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}}),[]);const P=(t,e,r,n,i,o)=>{k((s=>({...s,["".concat(t,"-").concat(e,"-").concat(r)]:{type:n,reward:i,isSelected:o}})))},x=t=>{T((e=>e+t))},L=async()=>{if(C())b(!0);else if(a){const t=(t=>{const e=t=>Array.isArray(t)?t.map((t=>e(t))):null!==t&&"object"==typeof t?Object.keys(t).reduce(((r,n)=>(r[n]=e(t[n]),r)),{}):Math.random();return e(t)})(o);s(t)}else window.postMessage({type:"API_URL_RESPONSE",APIurl:"https://onairos.uk/capx",source:"content-script",approved:"message.approved",accessToken:"message.accessToken",unique:"Onairos-Response",username:"CapX-Telegram"},"*")},N=()=>{b(!1),s&&s(null,"rejected")},j=async()=>{if(S>0){const t=Object.values(A).filter((t=>t.isSelected)).map((t=>({type:t.type,reward:t.reward})));try{const e=await fetch("https://onairos.uk/capx",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(localStorage.getItem("onairosToken"))},body:JSON.stringify({Input:o?o.slice(0,S):null,approvedRequests:t})}),r=await e.json();s&&s(r)}catch(t){console.error(t),s&&s(null,t)}}b(!1)},D=window.location.href,K=async()=>{try{if(C()){console.log("Connecting to Onairos");return void await L()}console.log("Connecting to Onairos");const t=new jn({appInfo:{name:"Onairos",version:"1.0.0",env:"production"},throwErrors:!1}),e=await t.connect(),r=(await Jn())(e.sub).toString();function o(t){try{const e=window.atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r.buffer}catch(t){console.error("Error converting to Buffer :",t)}}const s=o((await Kn(r)).result),a=await t.decrypt(s);console.log("Retrieved PIN Working"),Dn("\n -----BEGIN PUBLIC KEY-----\n MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4wkWvRPaJiY8CwQ5BoJI\n amcGAYV91Bk8NrvWq4PXM+J/RJugfgTNCYKQ/c6g4xa1YES/tJEzFS7nf0Kdoqxm\n 5aav0ru5vS4fc4vCOLTI9W1T7nj02NY91rogsQm2/KMxUQ8DaLeTZKi+0Wjsa9YO\n 6XGGd1wh4azgQkj04MWW5J1EBCcBavKoY+C85oA9jkkklQ8nGWgbugmZs7eXHNQb\n qH8/ZHcB9Kx1CZ6XjQuVd6YE/A+swV+DksbkXANcYjr6SY/2TbB8GfpcOMM3bkyN\n Q8e0A51q5a8abfuAkDZXe67MwKMWu/626abwPZhJrKr5HhRZZDwPtnXlktYHhOK6\n lQIDAQAB\n -----END PUBLIC KEY-----\n ",a).then((t=>{window.postMessage({source:"webpage",type:"GET_API_URL",webpageName:i,domain:D,requestData:n,proofMode:c,HashedOthentSub:r,EncryptedUserPin:t})})).catch((t=>{console.error("Encryption failed:",t)}))}catch(u){console.error({fix:"Please ensure you have stored your model"}),console.error("Error Sending Data to Terminal: ",u)}},M="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===f?"px-4 py-2":"w-12 h-12"," ").concat(h?"bg-white border border-gray-300":"bg-transparent","\n ").concat(C()?"":"OnairosConnect","\n "),z={flexDirection:"below"===u?"column":"row",backgroundColor:h?"#ffffff":"transparent",color:h?"black":l,border:h?"1px solid #ddd":"1px solid transparent"},W={width:"20px",height:"20px",marginRight:"full"===g?"12px":"0"},Z=process.env.REACT_APP_GOOGLE_CLIENT_ID;return m&&C()?r().createElement(zn,{clientId:Z},r().createElement(Vn,{dataRequester:i,NoAccount:_,NoModel:U,activeModels:v,requestData:n,handleConnectionSelection:P,changeGranted:x,granted:S,allowSubmit:S>0,rejectDataRequest:N,sendDataRequest:j,avatar:I,traits:R})):r().createElement("div",{className:"flex items-center justify-center"},r().createElement("button",{className:M,onClick:K,style:z},("full"===g||"icon"===g)&&r().createElement("img",{src:h?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:W,className:"".concat("pill"===f?"w-6 h-6":"w-8 h-8"," object-contain")}),("full"===g||"textOnly"===g)&&r().createElement("span",{className:"".concat(h||"black"===l?"text-black":"text-white"," ").concat("icon"===g?"sr-only":""," ").concat("right"===u?"ml-2":"left"===u?"mr-2":"")},(()=>{switch(p){case"signUp":return"Sign Up with Onairos";case"signOut":return"Sign Out of Onairos";default:return"Sign In with Onairos"}})())))}})(),c})()));
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["React"],e);else{var r="object"==typeof exports?e(require("react")):e(t.React);for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,(t=>(()=>{var e,r,n,i,o={317:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={}},586:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(431);e.default=class{BigNum;constructor(){this.BigNum=(t,e)=>new(n.BigNumber.clone({DECIMAL_PLACES:e}))(t)}winstonToAr(t,{formatted:e=!1,decimals:r=12,trim:n=!0}={}){let i=this.stringToBigNum(t,r).shiftedBy(-12);return e?i.toFormat(r):i.toFixed(r)}arToWinston(t,{formatted:e=!1}={}){let r=this.stringToBigNum(t).shiftedBy(12);return e?r.toFormat():r.toFixed(0)}compare(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.comparedTo(n)}isEqual(t,e){return 0===this.compare(t,e)}isLessThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isLessThan(n)}isGreaterThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isGreaterThan(n)}add(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.plus(e).toFixed(0)}sub(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.minus(e).toFixed(0)}stringToBigNum(t,e=12){return this.BigNum(t,e)}}},759:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498);r(317);class i{api;network;static HASH_ENDPOINT="block/hash/";static HEIGHT_ENDPOINT="block/height/";constructor(t,e){this.api=t,this.network=e}async get(t){const e=await this.api.get(`${i.HASH_ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getByHeight(t){const e=await this.api.get(`${i.HEIGHT_ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getCurrent(){const{current:t}=await this.network.getInfo();return await this.get(t)}}e.default=i},879:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498),i=r(244);e.default=class{api;constructor(t){this.api=t}async getTransactionOffset(t){const e=await this.api.get(`tx/${t}/offset`);if(200===e.status)return e.data;throw new Error(`Unable to get transaction offset: ${(0,n.getError)(e)}`)}async getChunk(t){const e=await this.api.get(`chunk/${t}`);if(200===e.status)return e.data;throw new Error(`Unable to get chunk: ${(0,n.getError)(e)}`)}async getChunkData(t){const e=await this.getChunk(t);return i.b64UrlToBuffer(e.chunk)}firstChunkOffset(t){return parseInt(t.offset)-parseInt(t.size)+1}async downloadChunkedData(t){const e=await this.getTransactionOffset(t),r=parseInt(e.size),n=parseInt(e.offset)-r+1,i=new Uint8Array(r);let o=0;for(;o<r;){let t;this.api.config.logging&&console.log(`[chunk] ${o}/${r}`);try{t=await this.getChunkData(n+o)}catch(t){console.error(`[chunk] Failed to fetch chunk at offset ${n+o}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(!t)throw new Error(`Couldn't complete data download at ${o}/${r}`);i.set(t,o),o+=t.length}return i}}},536:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(586),i=r(874),o=r(363),a=r(248),s=r(935),c=r(927),u=r(825),l=r(244),h=r(243),f=r(879),d=r(759);class p{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new o.default;static utils=l;constructor(t){this.api=new i.default(t),this.wallets=new c.default(this.api,p.crypto),this.chunks=new f.default(this.api),this.transactions=new s.default(this.api,p.crypto,this.chunks),this.silo=new h.default(this.api,this.crypto,this.transactions),this.network=new a.default(this.api),this.blocks=new d.default(this.api,this.network),this.ar=new n.default}get crypto(){return p.crypto}get utils(){return p.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(t,e){const r={};if(Object.assign(r,t),!(t.data||t.target&&t.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(null==t.owner&&e&&"use_wallet"!==e&&(r.owner=e.n),null==t.last_tx&&(r.last_tx=await this.transactions.getTransactionAnchor()),"string"==typeof t.data&&(t.data=l.stringToBuffer(t.data)),t.data instanceof ArrayBuffer&&(t.data=new Uint8Array(t.data)),t.data&&!(t.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(null==t.reward){const e=t.data?t.data.byteLength:0;r.reward=await this.transactions.getPrice(e,r.target)}r.data_root="",r.data_size=t.data?t.data.byteLength.toString():"0",r.data=t.data||new Uint8Array(0);const n=new u.default(r);return await n.getSignatureData(),n}async createSiloTransaction(t,e,r){const n={};if(Object.assign(n,t),!t.data)throw new Error("Silo transactions must have a 'data' value");if(!r)throw new Error("No Silo URI specified.");if(t.target||t.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(null==t.owner){if(!e||!e.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");n.owner=e.n}null==t.last_tx&&(n.last_tx=await this.transactions.getTransactionAnchor());const i=await this.silo.parseUri(r);if("string"==typeof t.data){const e=await this.crypto.encrypt(l.stringToBuffer(t.data),i.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}if(t.data instanceof Uint8Array){const e=await this.crypto.encrypt(t.data,i.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}const o=new u.default(n);return o.addTag("Silo-Name",i.getAccessKey()),o.addTag("Silo-Version","0.1.0"),o}arql(t){return this.api.post("/arql",t).then((t=>t.data||[]))}}e.default=p},386:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0});const o=r(536),a=r(118);o.default.init=function(t={}){const e={host:"arweave.net",port:443,protocol:"https"};if("object"!=typeof location||!location.protocol||!location.hostname)return new o.default({...t,...e});const r=location.protocol.replace(":",""),n=location.hostname,i=location.port?parseInt(location.port):"https"==r?443:80,s=(0,a.getDefaultConfig)(r,n),c=t.protocol||s.protocol,u=t.host||s.host,l=t.port||s.port||i;return new o.default({...t,host:u,protocol:c,port:l})},"object"==typeof globalThis?globalThis.Arweave=o.default:"object"==typeof self&&(self.Arweave=o.default),i(r(536),e),e.default=o.default},874:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(t){this.applyConfig(t)}applyConfig(t){this.config=this.mergeDefaults(t)}getConfig(){return this.config}mergeDefaults(t){const e=t.protocol||"http",r=t.port||("https"===e?443:80);return{host:t.host||"127.0.0.1",protocol:e,port:r,timeout:t.timeout||2e4,logging:t.logging||!1,logger:t.logger||console.log,network:t.network}}async get(t,e){return await this.request(t,{...e,method:this.METHOD_GET})}async post(t,e,r){const n=new Headers(r?.headers||{});return n.get("content-type")?.includes("application/json")||n.append("content-type","application/json"),n.append("accept","application/json, text/plain, */*"),await this.request(t,{...r,method:this.METHOD_POST,body:"string"!=typeof e?JSON.stringify(e):e,headers:n})}async request(t,e){const n=new Headers(e?.headers||{}),i=`${this.config.protocol}://${this.config.host}:${this.config.port}`,o=e?.responseType;delete e?.responseType,t.startsWith("/")&&(t=t.slice(1)),this.config.network&&n.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${i}/${t}`);let a=await fetch(`${i}/${t}`,{...e||{},headers:n});this.config.logging&&this.config.logger(`Response: ${a.url} - ${a.status}`);const s=a.headers.get("content-type"),c=s?.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i)?.[1],u=a,l=async()=>{if(c)try{u.data=new TextDecoder(c).decode(await a.arrayBuffer())}catch(t){u.data=await a.text()}else u.data=await a.text()};if("arraybuffer"===o)u.data=await a.arrayBuffer();else if("text"===o)await l();else if("webstream"===o)u.data=r(a.body);else try{let t=await a.clone().json();"object"!=typeof t?await l():u.data=await a.json(),t=null}catch{await l()}return u}};const r=t=>{const e=t;return void 0===e[Symbol.asyncIterator]?(e[Symbol.asyncIterator]=n(t),e):t},n=function(t){return async function*(){const e=t.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}}},363:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(244);e.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let t=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),e=await this.driver.exportKey("jwk",t.privateKey);return{kty:e.kty,e:e.e,n:e.n,d:e.d,p:e.p,q:e.q,dp:e.dp,dq:e.dq,qi:e.qi}}async sign(t,e,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(n)}async hash(t,e="SHA-256"){let r=await this.driver.digest(e,t);return new Uint8Array(r)}async verify(t,e,r){const n={kty:"RSA",e:"AQAB",n:t},i=await this.jwkToPublicCryptoKey(n),o=await this.driver.digest("SHA-256",e),a=await this.driver.verify({name:"RSA-PSS",saltLength:0},i,r,e),s=await this.driver.verify({name:"RSA-PSS",saltLength:32},i,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((i.algorithm.modulusLength-1)/8)-o.byteLength-2},i,r,e);return a||s||c}async jwkToCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if("undefined"==typeof crypto)return!1;const t=crypto?.subtle;if(void 0===t)return!1;return["generateKey","importKey","exportKey","digest","sign"].every((e=>"function"==typeof t[e]))}async encrypt(t,e,r){const i=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),a=new Uint8Array(16);crypto.getRandomValues(a);const s=await this.driver.encrypt({name:"AES-CBC",iv:a},o,t);return n.concatBuffers([a,s])}async decrypt(t,e,r){const i=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),a=t.slice(0,16),s=await this.driver.decrypt({name:"AES-CBC",iv:a},o,t.slice(16));return n.concatBuffers([s])}}},921:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(536);async function i(t){if(Array.isArray(t)){const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("list"),n.default.utils.stringToBuffer(t.length.toString())]);return await o(t,await n.default.crypto.hash(e,"SHA-384"))}const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("blob"),n.default.utils.stringToBuffer(t.byteLength.toString())]),r=n.default.utils.concatBuffers([await n.default.crypto.hash(e,"SHA-384"),await n.default.crypto.hash(t,"SHA-384")]);return await n.default.crypto.hash(r,"SHA-384")}async function o(t,e){if(t.length<1)return e;const r=n.default.utils.concatBuffers([e,await i(t[0])]),a=await n.default.crypto.hash(r,"SHA-384");return await o(t.slice(1),a)}e.default=i},498:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getError=void 0;class r extends Error{type;response;constructor(t,e={}){e.message?super(e.message):super(),this.type=t,this.response=e.response}getType(){return this.type}}e.default=r,e.getError=function(t){let e=t.data;if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch(t){}return e?e.error||e:t.statusText||"unknown"}},224:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.validatePath=e.arrayCompare=e.bufferToInt=e.intToBuffer=e.arrayFlatten=e.generateProofs=e.buildLayers=e.generateTransactionChunks=e.generateTree=e.computeRootHash=e.generateLeaves=e.chunkData=e.MIN_CHUNK_SIZE=e.MAX_CHUNK_SIZE=void 0;const n=r(536),i=r(244);e.MAX_CHUNK_SIZE=262144,e.MIN_CHUNK_SIZE=32768;const o=32,a=32;async function s(t){let r=[],i=t,o=0;for(;i.byteLength>=e.MAX_CHUNK_SIZE;){let t=e.MAX_CHUNK_SIZE,a=i.byteLength-e.MAX_CHUNK_SIZE;a>0&&a<e.MIN_CHUNK_SIZE&&(t=Math.ceil(i.byteLength/2));const s=i.slice(0,t),c=await n.default.crypto.hash(s);o+=s.byteLength,r.push({dataHash:c,minByteRange:o-s.byteLength,maxByteRange:o}),i=i.slice(t)}return r.push({dataHash:await n.default.crypto.hash(i),minByteRange:o,maxByteRange:o+i.byteLength}),r}async function c(t){return Promise.all(t.map((async({dataHash:t,minByteRange:e,maxByteRange:r})=>({type:"leaf",id:await g(await Promise.all([g(t),g(y(r))])),dataHash:t,minByteRange:e,maxByteRange:r}))))}async function u(t){return await l(await c(await s(t)))}async function l(t,e=0){if(t.length<2){return t[0]}const r=[];for(let e=0;e<t.length;e+=2)r.push(await p(t[e],t[e+1]));return l(r,e+1)}function h(t){const e=f(t);return Array.isArray(e)?d(e):[e]}function f(t,e=new Uint8Array,r=0){if("leaf"==t.type)return{offset:t.maxByteRange-1,proof:(0,i.concatBuffers)([e,t.dataHash,y(t.maxByteRange)])};if("branch"==t.type){const n=(0,i.concatBuffers)([e,t.leftChild.id,t.rightChild.id,y(t.byteRange)]);return[f(t.leftChild,n,r+1),f(t.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function d(t){const e=[];return t.forEach((t=>{Array.isArray(t)?e.push(...d(t)):e.push(t)})),e}async function p(t,e){if(!e)return t;return{type:"branch",id:await g([await g(t.id),await g(e.id),await g(y(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}}async function g(t){return Array.isArray(t)&&(t=n.default.utils.concatBuffers(t)),new Uint8Array(await n.default.crypto.hash(t))}function y(t){const e=new Uint8Array(o);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function w(t){let e=0;for(var r=0;r<t.length;r++)e*=256,e+=t[r];return e}e.chunkData=s,e.generateLeaves=c,e.computeRootHash=async function(t){return(await u(t)).id},e.generateTree=u,e.generateTransactionChunks=async function(t){const e=await s(t),r=await c(e),n=await l(r),i=await h(n),o=e.slice(-1)[0];return o.maxByteRange-o.minByteRange==0&&(e.splice(e.length-1,1),i.splice(i.length-1,1)),{data_root:n.id,chunks:e,proofs:i}},e.buildLayers=l,e.generateProofs=h,e.arrayFlatten=d,e.intToBuffer=y,e.bufferToInt=w;e.arrayCompare=(t,e)=>t.every(((t,r)=>e[r]===t)),e.validatePath=async function t(r,n,i,s,c){if(s<=0)return!1;if(n>=s)return t(r,0,s-1,s,c);if(n<0)return t(r,0,0,s,c);if(c.length==a+o){const t=c.slice(0,a),n=c.slice(t.length,t.length+o),u=await g([await g(t),await g(n)]);return!!(0,e.arrayCompare)(r,u)&&{offset:s-1,leftBound:i,rightBound:s,chunkSize:s-i}}const u=c.slice(0,a),l=c.slice(u.length,u.length+a),h=c.slice(u.length+l.length,u.length+l.length+o),f=w(h),d=c.slice(u.length+l.length+h.length),p=await g([await g(u),await g(l),await g(h)]);return!!(0,e.arrayCompare)(r,p)&&(n<f?await t(u,n,i,Math.min(s,f),d):await t(l,n,Math.max(i,f),s,d))},e.debug=async function t(e,r=""){if(e.byteLength<1)return r;const n=e.slice(0,a),i=e.slice(n.length,n.length+a),s=e.slice(n.length+i.length,n.length+i.length+o),c=w(s),u=e.slice(n.length+i.length+s.length),l=await g([await g(n),await g(i),await g(s)]);return t(u,`${r}\n${JSON.stringify(Buffer.from(n))},${JSON.stringify(Buffer.from(i))},${c} => ${JSON.stringify(l)}`)}},246:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionUploader=void 0;const n=r(825),i=r(244),o=r(498),a=r(224),s=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"];class c{api;chunkIndex=0;txPosted=!1;transaction;lastRequestTimeEnd=0;totalErrors=0;data;lastResponseStatus=0;lastResponseError="";get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(t,e){if(this.api=t,!e.id)throw new Error("Transaction is not signed");if(!e.chunks)throw new Error("Transaction chunks not prepared");this.data=e.data,this.transaction=new n.default(Object.assign({},e,{data:new Uint8Array(0)}))}async uploadChunk(t){if(this.isComplete)throw new Error("Upload is already complete");if(""!==this.lastResponseError?this.totalErrors++:this.totalErrors=0,100===this.totalErrors)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let e=""===this.lastResponseError?0:Math.max(this.lastRequestTimeEnd+4e4-Date.now(),4e4);if(e>0&&(e-=e*Math.random()*.3,await new Promise((t=>setTimeout(t,e)))),this.lastResponseError="",!this.txPosted)return void await this.postTransaction();t&&(this.chunkIndex=t);const r=this.transaction.getChunk(t||this.chunkIndex,this.data);if(!await(0,a.validatePath)(this.transaction.chunks.data_root,parseInt(r.offset),0,parseInt(r.data_size),i.b64UrlToBuffer(r.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);const n=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch((t=>(console.error(t.message),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,200==this.lastResponseStatus)this.chunkIndex++;else if(this.lastResponseError=(0,o.getError)(n),s.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(t,e,r){if(!e||"number"!=typeof e.chunkIndex||"object"!=typeof e.transaction)throw new Error("Serialized object does not match expected format.");var i=new n.default(e.transaction);i.chunks||await i.prepareChunks(r);const o=new c(t,i);if(o.chunkIndex=e.chunkIndex,o.lastRequestTimeEnd=e.lastRequestTimeEnd,o.lastResponseError=e.lastResponseError,o.lastResponseStatus=e.lastResponseStatus,o.txPosted=e.txPosted,o.data=r,o.transaction.data_root!==e.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return o}static async fromTransactionId(t,e){const r=await t.get(`tx/${e}`);if(200!==r.status)throw new Error(`Tx ${e} not found: ${r.status}`);const n=r.data;n.data=new Uint8Array(0);return{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:n}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=1){this.transaction.data=this.data;const t=await this.api.post("tx",this.transaction).catch((t=>(console.error(t),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,this.transaction.data=new Uint8Array(0),t.status>=200&&t.status<300)return this.txPosted=!0,void(this.chunkIndex=1);throw this.lastResponseError=(0,o.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`)}const t=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,!(t.status>=200&&t.status<300))throw this.lastResponseError=(0,o.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`);this.txPosted=!0}}e.TransactionUploader=c},825:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=void 0;const n=r(244),i=r(921),o=r(224);class a{get(t,e){if(!Object.getOwnPropertyNames(this).includes(t))throw new Error(`Field "${t}" is not a property of the Arweave Transaction class.`);if(this[t]instanceof Uint8Array)return e&&e.decode&&e.string?n.bufferToString(this[t]):e&&e.decode&&!e.string?this[t]:n.bufferTob64Url(this[t]);if(this[t]instanceof Array){if(void 0!==e?.decode||void 0!==e?.string)throw"tags"===t&&console.warn("Did you mean to use 'transaction[\"tags\"]' ?"),new Error("Cannot decode or stringify an array.");return this[t]}return e&&1==e.decode?e&&e.string?n.b64UrlToString(this[t]):n.b64UrlToBuffer(this[t]):this[t]}}class s extends a{name;value;constructor(t,e,r=!1){super(),this.name=t,this.value=e}}e.Tag=s;e.default=class extends a{format=2;id="";last_tx="";owner="";tags=[];target="";quantity="0";data_size="0";data=new Uint8Array;data_root="";reward="0";signature="";chunks;constructor(t={}){super(),Object.assign(this,t),"string"==typeof this.data&&(this.data=n.b64UrlToBuffer(this.data)),t.tags&&(this.tags=t.tags.map((t=>new s(t.name,t.value))))}addTag(t,e){this.tags.push(new s(n.stringToB64Url(t),n.stringToB64Url(e)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:n.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(t){this.owner=t}setSignature({id:t,owner:e,reward:r,tags:n,signature:i}){this.id=t,this.owner=e,r&&(this.reward=r),n&&(this.tags=n),this.signature=i}async prepareChunks(t){!this.chunks&&t.byteLength>0&&(this.chunks=await(0,o.generateTransactionChunks)(t),this.data_root=n.bufferTob64Url(this.chunks.data_root)),this.chunks||0!==t.byteLength||(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(t,e){if(!this.chunks)throw new Error("Chunks have not been prepared");const r=this.chunks.proofs[t],i=this.chunks.chunks[t];return{data_root:this.data_root,data_size:this.data_size,data_path:n.bufferTob64Url(r.proof),offset:r.offset.toString(),chunk:n.bufferTob64Url(e.slice(i.minByteRange,i.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let t=this.tags.reduce(((t,e)=>n.concatBuffers([t,e.get("name",{decode:!0,string:!1}),e.get("value",{decode:!0,string:!1})])),new Uint8Array);return n.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),t]);case 2:this.data_root||await this.prepareChunks(this.data);const e=this.tags.map((t=>[t.get("name",{decode:!0,string:!1}),t.get("value",{decode:!0,string:!1})]));return await(0,i.default)([n.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e,n.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}},244:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.b64UrlDecode=e.b64UrlEncode=e.bufferTob64Url=e.bufferTob64=e.b64UrlToBuffer=e.stringToB64Url=e.stringToBuffer=e.bufferToString=e.b64UrlToString=e.concatBuffers=void 0;const n=r(742);function i(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function o(t){return(new TextEncoder).encode(t)}function a(t){return new Uint8Array(n.toByteArray(l(t)))}function s(t){return n.fromByteArray(new Uint8Array(t))}function c(t){return u(s(t))}function u(t){try{return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}catch(t){throw new Error("Failed to encode string",{cause:t})}}function l(t){try{let e;return e=(t=t.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-t.length%4,t.concat("=".repeat(e))}catch(t){throw new Error("Failed to decode string",{cause:t})}}e.concatBuffers=function(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let e=1;e<t.length;e++)r.set(new Uint8Array(t[e]),n),n+=t[e].byteLength;return r},e.b64UrlToString=function(t){return i(a(t))},e.bufferToString=i,e.stringToBuffer=o,e.stringToB64Url=function(t){return c(o(t))},e.b64UrlToBuffer=a,e.bufferTob64=s,e.bufferTob64Url=c,e.b64UrlEncode=u,e.b64UrlDecode=l},118:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultConfig=void 0;e.getDefaultConfig=(t,e)=>{if(((t,e)=>{const r=/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,n=e.split("."),i=n[n.length-1],o=["localhost","[::1]"];return o.includes(e)||"file"==t||o.includes(i)||!!e.match(r)||!!i.match(r)})(t,e))return{protocol:"https",host:"arweave.net",port:443};if(!(t=>{const e="["===t.charAt(0);return!!t.match(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)||e})(e)){let r=e.split(".");if(r.length>=3){r.shift();return{protocol:t,host:r.join(".")}}}return{protocol:t,host:e}}},248:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{api;constructor(t){this.api=t}getInfo(){return this.api.get("info").then((t=>t.data))}getPeers(){return this.api.get("peers").then((t=>t.data))}}},243:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SiloResource=void 0;const n=r(244);e.default=class{api;crypto;transactions;constructor(t,e,r){this.api=t,this.crypto=e,this.transactions=r}async get(t){if(!t)throw new Error("No Silo URI specified");const e=await this.parseUri(t),r=await this.transactions.search("Silo-Name",e.getAccessKey());if(0==r.length)throw new Error(`No data could be found for the Silo URI: ${t}`);const n=await this.transactions.get(r[0]);if(!n)throw new Error(`No data could be found for the Silo URI: ${t}`);const i=n.get("data",{decode:!0,string:!1});return this.crypto.decrypt(i,e.getEncryptionKey())}async readTransactionData(t,e){if(!e)throw new Error("No Silo URI specified");const r=await this.parseUri(e),n=t.get("data",{decode:!0,string:!1});return this.crypto.decrypt(n,r.getEncryptionKey())}async parseUri(t){const e=t.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!e)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");const r=e[1],o=Math.pow(2,parseInt(e[2])),a=await this.hash(n.stringToBuffer(r),o),s=n.bufferTob64(a.slice(0,15)),c=await this.hash(a.slice(16,31),1);return new i(t,s,c)}async hash(t,e){let r=await this.crypto.hash(t);for(let t=0;t<e-1;t++)r=await this.crypto.hash(r);return r}};class i{uri;accessKey;encryptionKey;constructor(t,e,r){this.uri=t,this.accessKey=e,this.encryptionKey=r}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}e.SiloResource=i},935:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(498),i=r(825),o=r(244),a=r(246);r(317);e.default=class{api;crypto;chunks;constructor(t,e,r){this.api=t,this.crypto=e,this.chunks=r}async getTransactionAnchor(){const t=await this.api.get("tx_anchor");if(!t.data.match(/^[a-z0-9_-]{43,}/i)||!t.ok)throw new Error(`Could not getTransactionAnchor. Received: ${t.data}. Status: ${t.status}, ${t.statusText}`);return t.data}async getPrice(t,e){let r=e?`price/${t}/${e}`:`price/${t}`;const n=await this.api.get(r);if(!/^\d+$/.test(n.data)||!n.ok)throw new Error(`Could not getPrice. Received: ${n.data}. Status: ${n.status}, ${n.statusText}`);return n.data}async get(t){const e=await this.api.get(`tx/${t}`);if(200==e.status){const r=parseInt(e.data.data_size);if(e.data.format>=2&&r>0&&r<=12582912){const r=await this.getData(t);return new i.default({...e.data,data:r})}return new i.default({...e.data,format:e.data.format||1})}if(404==e.status)throw new n.default("TX_NOT_FOUND");if(410==e.status)throw new n.default("TX_FAILED");throw new n.default("TX_INVALID")}fromRaw(t){return new i.default(t)}async search(t,e){return this.api.post("arql",{op:"equals",expr1:t,expr2:e}).then((t=>t.data?t.data:[]))}getStatus(t){return this.api.get(`tx/${t}/status`).then((t=>200==t.status?{status:200,confirmed:t.data}:{status:t.status,confirmed:null}))}async getData(t,e){let r;try{r=await this.chunks.downloadChunkedData(t)}catch(e){console.error(`Error while trying to download chunked data for ${t}`),console.error(e)}if(!r){console.warn(`Falling back to gateway cache for ${t}`);try{const{data:e,ok:n,status:i,statusText:o}=await this.api.get(`/${t}`,{responseType:"arraybuffer"});if(!n)throw new Error("Bad http status code",{cause:{status:i,statusText:o}});r=e}catch(e){console.error(`Error while trying to download contiguous data from gateway cache for ${t}`),console.error(e)}}if(!r)throw new Error(`${t} data was not found!`);return e&&e.decode&&!e.string?r:e&&e.decode&&e.string?o.bufferToString(r):o.bufferTob64Url(r)}async sign(t,e,r){const n="object"==typeof e&&(t=>{let e=!0;return["n","e","d","p","q","dp","dq","qi"].map((r=>!(r in t)&&(e=!1))),e})(e),i="object"==typeof arweaveWallet;if(!n&&!i)throw new Error("No valid JWK or external wallet found to sign transaction.");if(n){t.setOwner(e.n);let n=await t.getSignatureData(),i=await this.crypto.sign(e,n,r),a=await this.crypto.hash(i);t.setSignature({id:o.bufferTob64Url(a),owner:e.n,signature:o.bufferTob64Url(i)})}else{if(!i)throw new Error("An error occurred while signing. Check wallet is valid");{try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}const e=await arweaveWallet.sign(t,r);t.setSignature({id:e.id,owner:e.owner,reward:e.reward,tags:e.tags,signature:e.signature})}}}async verify(t){const e=await t.getSignatureData(),r=t.get("signature",{decode:!0,string:!1}),n=o.bufferTob64Url(await this.crypto.hash(r));if(t.id!==n)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(t.owner,e,r)}async post(t){if("string"==typeof t?t=new i.default(JSON.parse(t)):"function"==typeof t.readInt32BE?t=new i.default(JSON.parse(t.toString())):"object"!=typeof t||t instanceof i.default||(t=new i.default(t)),!(t instanceof i.default))throw new Error("Must be Transaction object");t.chunks||await t.prepareChunks(t.data);const e=await this.getUploader(t,t.data);try{for(;!e.isComplete;)await e.uploadChunk()}catch(t){if(e.lastResponseStatus>0)return{status:e.lastResponseStatus,statusText:e.lastResponseError,data:{error:e.lastResponseError}};throw t}return{status:200,statusText:"OK",data:{}}}async getUploader(t,e){let r;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),t instanceof i.default){if(e||(e=t.data),!(e instanceof Uint8Array))throw new Error("Data format is invalid");t.chunks||await t.prepareChunks(e),r=new a.TransactionUploader(this.api,t),r.data&&0!==r.data.length||(r.data=e)}else{if("string"==typeof t&&(t=await a.TransactionUploader.fromTransactionId(this.api,t)),!(e&&e instanceof Uint8Array))throw new Error("Must provide data when resuming upload");r=await a.TransactionUploader.fromSerialized(this.api,t,e)}return r}async*upload(t,e){const r=await this.getUploader(t,e);for(;!r.isComplete;)await r.uploadChunk(),yield r;return r}}},927:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(244);r(317);e.default=class{api;crypto;constructor(t,e){this.api=t,this.crypto=e}getBalance(t){return this.api.get(`wallet/${t}/balance`).then((t=>t.data))}getLastTransactionID(t){return this.api.get(`wallet/${t}/last_tx`).then((t=>t.data))}generate(){return this.crypto.generateJWK()}async jwkToAddress(t){return t&&"use_wallet"!==t?this.getAddress(t):this.getAddress()}async getAddress(t){if(t&&"use_wallet"!==t)return this.ownerToAddress(t.n);try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}async ownerToAddress(t){return n.bufferTob64Url(await this.crypto.hash(n.b64UrlToBuffer(t)))}}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,c)),l=0,h=c>0?a-4:a;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,u=n-i;s<u;s+=a)o.push(c(t,s,s+a>u?u:s+a));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},431:function(t,e,r){var n;!function(i){"use strict";var o,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",h=1e14,f=14,d=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],g=1e7,y=1e9;function w(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,i=t.length,o=t[0]+"";n<i;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function b(t,e){var r,n,i=t.c,o=e.c,a=t.s,s=e.s,c=t.e,u=e.e;if(!a||!s)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=c==u,!i||!o)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(s=(c=i.length)<(u=o.length)?c:u,a=0;a<s;a++)if(i[a]!=o[a])return i[a]>o[a]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function E(t){var e=t.c.length-1;return w(t.e/f)==e&&t.c[e]%2!=0}function S(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function T(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}o=function t(e){var r,n,i,o,A,k,I,O,R,B,_=Z.prototype={constructor:Z,toString:null,valueOf:null},U=new Z(1),C=20,P=4,x=-7,L=21,N=-1e7,j=1e7,D=!1,K=1,M=0,z={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},W="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function Z(t,e){var r,o,s,u,h,p,g,y,w=this;if(!(w instanceof Z))return new Z(t,e);if(null==e){if(t&&!0===t._isBigNumber)return w.s=t.s,void(!t.c||t.e>j?w.c=w.e=null:t.e<N?w.c=[w.e=0]:(w.e=t.e,w.c=t.c.slice()));if((p="number"==typeof t)&&0*t==0){if(w.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,h=t;h>=10;h/=10,u++);return void(u>j?w.c=w.e=null:(w.e=u,w.c=[t]))}y=String(t)}else{if(!a.test(y=String(t)))return i(w,y,p);w.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}(u=y.indexOf("."))>-1&&(y=y.replace(".","")),(h=y.search(/e/i))>0?(u<0&&(u=h),u+=+y.slice(h+1),y=y.substring(0,h)):u<0&&(u=y.length)}else{if(v(e,2,W.length,"Base"),10==e&&F)return X(w=new Z(t),C+w.e+1,P);if(y=String(t),p="number"==typeof t){if(0*t!=0)return i(w,y,p,e);if(w.s=1/t<0?(y=y.slice(1),-1):1,Z.DEBUG&&y.replace(/^0\.0*|\./,"").length>15)throw Error(l+t)}else w.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1;for(r=W.slice(0,e),u=h=0,g=y.length;h<g;h++)if(r.indexOf(o=y.charAt(h))<0){if("."==o){if(h>u){u=g;continue}}else if(!s&&(y==y.toUpperCase()&&(y=y.toLowerCase())||y==y.toLowerCase()&&(y=y.toUpperCase()))){s=!0,h=-1,u=0;continue}return i(w,String(t),p,e)}p=!1,(u=(y=n(y,e,10,w.s)).indexOf("."))>-1?y=y.replace(".",""):u=y.length}for(h=0;48===y.charCodeAt(h);h++);for(g=y.length;48===y.charCodeAt(--g););if(y=y.slice(h,++g)){if(g-=h,p&&Z.DEBUG&&g>15&&(t>d||t!==c(t)))throw Error(l+w.s*t);if((u=u-h-1)>j)w.c=w.e=null;else if(u<N)w.c=[w.e=0];else{if(w.e=u,w.c=[],h=(u+1)%f,u<0&&(h+=f),h<g){for(h&&w.c.push(+y.slice(0,h)),g-=f;h<g;)w.c.push(+y.slice(h,h+=f));h=f-(y=y.slice(h)).length}else h-=g;for(;h--;y+="0");w.c.push(+y)}}else w.c=[w.e=0]}function H(t,e,r,n){var i,o,a,s,c;if(null==r?r=P:v(r,0,8),!t.c)return t.toString();if(i=t.c[0],a=t.e,null==e)c=m(t.c),c=1==n||2==n&&(a<=x||a>=L)?S(c,a):T(c,a,"0");else if(o=(t=X(new Z(t),e,r)).e,s=(c=m(t.c)).length,1==n||2==n&&(e<=o||o<=x)){for(;s<e;c+="0",s++);c=S(c,o)}else if(e-=a,c=T(c,o,"0"),o+1>s){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=o-s)>0)for(o+1==s&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function $(t,e){for(var r,n,i=1,o=new Z(t[0]);i<t.length;i++)(!(n=new Z(t[i])).s||(r=b(o,n))===e||0===r&&o.s===e)&&(o=n);return o}function G(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*f-1)>j?t.c=t.e=null:r<N?t.c=[t.e=0]:(t.e=r,t.c=e),t}function X(t,e,r,n){var i,o,a,u,l,d,g,y=t.c,w=p;if(y){t:{for(i=1,u=y[0];u>=10;u/=10,i++);if((o=e-i)<0)o+=f,a=e,l=y[d=0],g=c(l/w[i-a-1]%10);else if((d=s((o+1)/f))>=y.length){if(!n)break t;for(;y.length<=d;y.push(0));l=g=0,i=1,a=(o%=f)-f+1}else{for(l=u=y[d],i=1;u>=10;u/=10,i++);g=(a=(o%=f)-f+i)<0?0:c(l/w[i-a-1]%10)}if(n=n||e<0||null!=y[d+1]||(a<0?l:l%w[i-a-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(o>0?a>0?l/w[i-a]:0:y[d-1])%10&1||r==(t.s<0?8:7)),e<1||!y[0])return y.length=0,n?(e-=t.e+1,y[0]=w[(f-e%f)%f],t.e=-e||0):y[0]=t.e=0,t;if(0==o?(y.length=d,u=1,d--):(y.length=d+1,u=w[f-o],y[d]=a>0?c(l/w[i-a]%w[a])*u:0),n)for(;;){if(0==d){for(o=1,a=y[0];a>=10;a/=10,o++);for(a=y[0]+=u,u=1;a>=10;a/=10,u++);o!=u&&(t.e++,y[0]==h&&(y[0]=1));break}if(y[d]+=u,y[d]!=h)break;y[d--]=0,u=1}for(o=y.length;0===y[--o];y.pop());}t.e>j?t.c=t.e=null:t.e<N&&(t.c=[t.e=0])}return t}function V(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=x||r>=L?S(e,r):T(e,r,"0"),t.s<0?"-"+e:e)}return Z.clone=t,Z.ROUND_UP=0,Z.ROUND_DOWN=1,Z.ROUND_CEIL=2,Z.ROUND_FLOOR=3,Z.ROUND_HALF_UP=4,Z.ROUND_HALF_DOWN=5,Z.ROUND_HALF_EVEN=6,Z.ROUND_HALF_CEIL=7,Z.ROUND_HALF_FLOOR=8,Z.EUCLID=9,Z.config=Z.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,y,e),C=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),P=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-y,0,e),v(r[1],0,y,e),x=r[0],L=r[1]):(v(r,-y,y,e),x=-(L=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-y,-1,e),v(r[1],1,y,e),N=r[0],j=r[1];else{if(v(r,-y,y,e),!r)throw Error(u+e+" cannot be zero: "+r);N=-(j=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw D=!r,Error(u+"crypto unavailable");D=r}else D=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),K=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,y,e),M=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);z=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);F="0123456789"==r.slice(0,10),W=r}}return{DECIMAL_PLACES:C,ROUNDING_MODE:P,EXPONENTIAL_AT:[x,L],RANGE:[N,j],CRYPTO:D,MODULO_MODE:K,POW_PRECISION:M,FORMAT:z,ALPHABET:W}},Z.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!Z.DEBUG)return!0;var e,r,n=t.c,i=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-y&&i<=y&&i===c(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break t}if((e=(i+1)%f)<1&&(e+=f),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||r>=h||r!==c(r))break t;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(u+"Invalid BigNumber: "+t)},Z.maximum=Z.max=function(){return $(arguments,-1)},Z.minimum=Z.min=function(){return $(arguments,1)},Z.random=(o=9007199254740992,A=Math.random()*o&2097151?function(){return c(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,i,o,a=0,l=[],h=new Z(U);if(null==t?t=C:v(t,0,y),i=s(t/f),D)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));a<i;)(o=131072*e[a]+(e[a+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[a]=r[0],e[a+1]=r[1]):(l.push(o%1e14),a+=2);a=i/2}else{if(!crypto.randomBytes)throw D=!1,Error(u+"crypto unavailable");for(e=crypto.randomBytes(i*=7);a<i;)(o=281474976710656*(31&e[a])+1099511627776*e[a+1]+4294967296*e[a+2]+16777216*e[a+3]+(e[a+4]<<16)+(e[a+5]<<8)+e[a+6])>=9e15?crypto.randomBytes(7).copy(e,a):(l.push(o%1e14),a+=7);a=i/7}if(!D)for(;a<i;)(o=A())<9e15&&(l[a++]=o%1e14);for(i=l[--a],t%=f,i&&t&&(o=p[f-t],l[a]=c(i/o)*o);0===l[a];l.pop(),a--);if(a<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=f);for(a=1,o=l[0];o>=10;o/=10,a++);a<f&&(n-=f-a)}return h.e=n,h.c=l,h}),Z.sum=function(){for(var t=1,e=arguments,r=new Z(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,o,a=[0],s=0,c=t.length;s<c;){for(o=a.length;o--;a[o]*=e);for(a[0]+=n.indexOf(t.charAt(s++)),i=0;i<a.length;i++)a[i]>r-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/r|0,a[i]%=r)}return a.reverse()}return function(n,i,o,a,s){var c,u,l,h,f,d,p,g,y=n.indexOf("."),w=C,b=P;for(y>=0&&(h=M,M=0,n=n.replace(".",""),d=(g=new Z(i)).pow(n.length-y),M=h,g.c=e(T(m(d.c),d.e,"0"),10,o,t),g.e=g.c.length),l=h=(p=e(n,i,o,s?(c=W,t):(c=t,W))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(y<0?--l:(d.c=p,d.e=l,d.s=a,p=(d=r(d,g,w,b,o)).c,f=d.r,l=d.e),y=p[u=l+w+1],h=o/2,f=f||u<0||null!=p[u+1],f=b<4?(null!=y||f)&&(0==b||b==(d.s<0?3:2)):y>h||y==h&&(4==b||f||6==b&&1&p[u-1]||b==(d.s<0?8:7)),u<1||!p[0])n=f?T(c.charAt(1),-w,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--o;++p[--u]>o;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=c.charAt(p[y++]));n=T(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,o,a,s=0,c=t.length,u=e%g,l=e/g|0;for(t=t.slice();c--;)s=((i=u*(o=t[c]%g)+(n=l*o+(a=t[c]/g|0)*u)%g*g+s)/r|0)+(n/g|0)+l*a,t[c]=i%r;return s&&(t=[s].concat(t)),t}function e(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,o,a,s){var u,l,d,p,g,y,m,b,v,E,S,T,A,k,I,O,R,B=n.s==i.s?1:-1,_=n.c,U=i.c;if(!(_&&_[0]&&U&&U[0]))return new Z(n.s&&i.s&&(_?!U||_[0]!=U[0]:U)?_&&0==_[0]||!U?0*B:B/0:NaN);for(v=(b=new Z(B)).c=[],B=o+(l=n.e-i.e)+1,s||(s=h,l=w(n.e/f)-w(i.e/f),B=B/f|0),d=0;U[d]==(_[d]||0);d++);if(U[d]>(_[d]||0)&&l--,B<0)v.push(1),p=!0;else{for(k=_.length,O=U.length,d=0,B+=2,(g=c(s/(U[0]+1)))>1&&(U=t(U,g,s),_=t(_,g,s),O=U.length,k=_.length),A=O,S=(E=_.slice(0,O)).length;S<O;E[S++]=0);R=U.slice(),R=[0].concat(R),I=U[0],U[1]>=s/2&&I++;do{if(g=0,(u=e(U,E,O,S))<0){if(T=E[0],O!=S&&(T=T*s+(E[1]||0)),(g=c(T/I))>1)for(g>=s&&(g=s-1),m=(y=t(U,g,s)).length,S=E.length;1==e(y,E,m,S);)g--,r(y,O<m?R:U,m,s),m=y.length,u=1;else 0==g&&(u=g=1),m=(y=U.slice()).length;if(m<S&&(y=[0].concat(y)),r(E,y,S,s),S=E.length,-1==u)for(;e(U,E,O,S)<1;)g++,r(E,O<S?R:U,S,s),S=E.length}else 0===u&&(g++,E=[0]);v[d++]=g,E[0]?E[S++]=_[A]||0:(E=[_[A]],S=1)}while((A++<k||null!=E[0])&&B--);p=null!=E[0],v[0]||v.splice(0,1)}if(s==h){for(d=1,B=v[0];B>=10;B/=10,d++);X(b,o+(b.e=d+l*f-1)+1,a,p)}else b.e=l,b.r=+p;return b}}(),k=/^(-?)0([xbo])(?=\w[\w.]*$)/i,I=/^([^.]+)\.$/,O=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,r,n){var i,o=r?e:e.replace(B,"");if(R.test(o))t.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(k,(function(t,e,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?t:e})),n&&(i=n,o=o.replace(I,"$1").replace(O,"0.$1")),e!=o))return new Z(o,i);if(Z.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},_.absoluteValue=_.abs=function(){var t=new Z(this);return t.s<0&&(t.s=1),t},_.comparedTo=function(t,e){return b(this,new Z(t,e))},_.decimalPlaces=_.dp=function(t,e){var r,n,i,o=this;if(null!=t)return v(t,0,y),null==e?e=P:v(e,0,8),X(new Z(o),t+o.e+1,e);if(!(r=o.c))return null;if(n=((i=r.length-1)-w(this.e/f))*f,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(t,e){return r(this,new Z(t,e),C,P)},_.dividedToIntegerBy=_.idiv=function(t,e){return r(this,new Z(t,e),0,1)},_.exponentiatedBy=_.pow=function(t,e){var r,n,i,o,a,l,h,d,p=this;if((t=new Z(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+V(t));if(null!=e&&(e=new Z(e)),a=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new Z(Math.pow(+V(p),a?t.s*(2-E(t)):+V(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new Z(NaN);(n=!l&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||a&&p.c[1]>=24e7:p.c[0]<8e13||a&&p.c[0]<=9999975e7)))return o=p.s<0&&E(t)?-0:0,p.e>-1&&(o=1/o),new Z(l?1/o:o);M&&(o=s(M/f+2))}for(a?(r=new Z(.5),l&&(t.s=1),h=E(t)):h=(i=Math.abs(+V(t)))%2,d=new Z(U);;){if(h){if(!(d=d.times(p)).c)break;o?d.c.length>o&&(d.c.length=o):n&&(d=d.mod(e))}if(i){if(0===(i=c(i/2)))break;h=i%2}else if(X(t=t.times(r),t.e+1,1),t.e>14)h=E(t);else{if(0===(i=+V(t)))break;h=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):n&&(p=p.mod(e))}return n?d:(l&&(d=U.div(d)),e?d.mod(e):o?X(d,M,P,undefined):d)},_.integerValue=function(t){var e=new Z(this);return null==t?t=P:v(t,0,8),X(e,e.e+1,t)},_.isEqualTo=_.eq=function(t,e){return 0===b(this,new Z(t,e))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(t,e){return b(this,new Z(t,e))>0},_.isGreaterThanOrEqualTo=_.gte=function(t,e){return 1===(e=b(this,new Z(t,e)))||0===e},_.isInteger=function(){return!!this.c&&w(this.e/f)>this.c.length-2},_.isLessThan=_.lt=function(t,e){return b(this,new Z(t,e))<0},_.isLessThanOrEqualTo=_.lte=function(t,e){return-1===(e=b(this,new Z(t,e)))||0===e},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(t,e){var r,n,i,o,a=this,s=a.s;if(e=(t=new Z(t,e)).s,!s||!e)return new Z(NaN);if(s!=e)return t.s=-e,a.plus(t);var c=a.e/f,u=t.e/f,l=a.c,d=t.c;if(!c||!u){if(!l||!d)return l?(t.s=-e,t):new Z(d?a:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new Z(l[0]?a:3==P?-0:0)}if(c=w(c),u=w(u),l=l.slice(),s=c-u){for((o=s<0)?(s=-s,i=l):(u=c,i=d),i.reverse(),e=s;e--;i.push(0));i.reverse()}else for(n=(o=(s=l.length)<(e=d.length))?s:e,s=e=0;e<n;e++)if(l[e]!=d[e]){o=l[e]<d[e];break}if(o&&(i=l,l=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=h-1;n>s;){if(l[--n]<d[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=h}l[n]-=d[n]}for(;0==l[0];l.splice(0,1),--u);return l[0]?G(t,l,u):(t.s=3==P?-1:1,t.c=[t.e=0],t)},_.modulo=_.mod=function(t,e){var n,i,o=this;return t=new Z(t,e),!o.c||!t.s||t.c&&!t.c[0]?new Z(NaN):!t.c||o.c&&!o.c[0]?new Z(o):(9==K?(i=t.s,t.s=1,n=r(o,t,0,3),t.s=i,n.s*=i):n=r(o,t,0,K),(t=o.minus(n.times(t))).c[0]||1!=K||(t.s=o.s),t)},_.multipliedBy=_.times=function(t,e){var r,n,i,o,a,s,c,u,l,d,p,y,m,b,v,E=this,S=E.c,T=(t=new Z(t,e)).c;if(!(S&&T&&S[0]&&T[0]))return!E.s||!t.s||S&&!S[0]&&!T||T&&!T[0]&&!S?t.c=t.e=t.s=null:(t.s*=E.s,S&&T?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=w(E.e/f)+w(t.e/f),t.s*=E.s,(c=S.length)<(d=T.length)&&(m=S,S=T,T=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(b=h,v=g,i=d;--i>=0;){for(r=0,p=T[i]%v,y=T[i]/v|0,o=i+(a=c);o>i;)r=((u=p*(u=S[--a]%v)+(s=y*u+(l=S[a]/v|0)*p)%v*v+m[o]+r)/b|0)+(s/v|0)+y*l,m[o--]=u%b;m[o]=r}return r?++n:m.splice(0,1),G(t,m,n)},_.negated=function(){var t=new Z(this);return t.s=-t.s||null,t},_.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new Z(t,e)).s,!i||!e)return new Z(NaN);if(i!=e)return t.s=-e,n.minus(t);var o=n.e/f,a=t.e/f,s=n.c,c=t.c;if(!o||!a){if(!s||!c)return new Z(i/0);if(!s[0]||!c[0])return c[0]?t:new Z(s[0]?n:0*i)}if(o=w(o),a=w(a),s=s.slice(),i=o-a){for(i>0?(a=o,r=c):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(e=c.length)<0&&(r=c,c=s,s=r,e=i),i=0;e;)i=(s[--e]=s[e]+c[e]+i)/h|0,s[e]=h===s[e]?0:s[e]%h;return i&&(s=[i].concat(s),++a),G(t,s,a)},_.precision=_.sd=function(t,e){var r,n,i,o=this;if(null!=t&&t!==!!t)return v(t,1,y),null==e?e=P:v(e,0,8),X(new Z(o),t,e);if(!(r=o.c))return null;if(n=(i=r.length-1)*f+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&o.e+1>n&&(n=o.e+1),n},_.shiftedBy=function(t){return v(t,-9007199254740991,d),this.times("1e"+t)},_.squareRoot=_.sqrt=function(){var t,e,n,i,o,a=this,s=a.c,c=a.s,u=a.e,l=C+4,h=new Z("0.5");if(1!==c||!s||!s[0])return new Z(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(c=Math.sqrt(+V(a)))||c==1/0?(((e=m(s)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=w((u+1)/2)-(u<0||u%2),n=new Z(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new Z(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(o=n,n=h.times(o.plus(r(a,o,l,1))),m(o.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(X(n,n.e+C+2,1),t=!n.times(n).eq(a));break}if(!i&&(X(o,o.e+C+2,0),o.times(o).eq(a))){n=o;break}l+=4,c+=4,i=1}return X(n,n.e+C+1,P,t)},_.toExponential=function(t,e){return null!=t&&(v(t,0,y),t++),H(this,t,e,1)},_.toFixed=function(t,e){return null!=t&&(v(t,0,y),t=t+this.e+1),H(this,t,e)},_.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=z;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var o,a=n.split("."),s=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=a[0],f=a[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(o=s,s=c,c=o,g-=o),s>0&&g>0){for(o=g%s||s,h=p.substr(0,o);o<g;o+=s)h+=l+p.substr(o,s);c>0&&(h+=l+p.slice(o)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(t){var e,n,i,o,a,s,c,l,h,d,g,y,w=this,b=w.c;if(null!=t&&(!(c=new Z(t)).isInteger()&&(c.c||1!==c.s)||c.lt(U)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+V(c));if(!b)return new Z(w);for(e=new Z(U),h=n=new Z(U),i=l=new Z(U),y=m(b),a=e.e=y.length-w.e-1,e.c[0]=p[(s=a%f)<0?f+s:s],t=!t||c.comparedTo(e)>0?a>0?e:h:c,s=j,j=1/0,c=new Z(y),l.c[0]=0;d=r(c,e,0,1),1!=(o=n.plus(d.times(i))).comparedTo(t);)n=i,i=o,h=l.plus(d.times(o=h)),l=o,e=c.minus(d.times(o=e)),c=o;return o=r(t.minus(n),i,0,1),l=l.plus(o.times(h)),n=n.plus(o.times(i)),l.s=h.s=w.s,g=r(h,i,a*=2,P).minus(w).abs().comparedTo(r(l,n,a,P).minus(w).abs())<1?[h,i]:[l,n],j=s,g},_.toNumber=function(){return+V(this)},_.toPrecision=function(t,e){return null!=t&&v(t,1,y),H(this,t,e,2)},_.toString=function(t){var e,r=this,i=r.s,o=r.e;return null===o?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=o<=x||o>=L?S(m(r.c),o):T(m(r.c),o,"0"):10===t&&F?e=T(m((r=X(new Z(r),C+o+1,P)).c),r.e,"0"):(v(t,2,W.length,"Base"),e=n(T(m(r.c),o,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},_.valueOf=_.toJSON=function(){return V(this)},_._isBigNumber=!0,null!=e&&Z.set(e),Z}(),o.default=o.BigNumber=o,void 0===(n=function(){return o}.call(e,r,e,t))||(t.exports=n)}()},764:(t,e,r)=>{"use strict";const n=r(742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=c,e.h2=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let n=s(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|p(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||J(t.length)?s(0):f(t);if("Buffer"===t.type&&Array.isArray(t.data))return f(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return l(t),s(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function p(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function g(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||V(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(t).length;default:if(i)return n?-1:$(t).length;e=(""+e).toLowerCase(),i=!0}}function y(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return I(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return B(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+c>s&&(r=s-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(J(n))return a;t[r+a]=n}return a}function E(t,e,r,n){return X($(e,t.length-r),t,r,n)}function S(t,e,r,n){return X(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function T(t,e,r,n){return X(G(e),t,r,n)}function A(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function I(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,c;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=O));return r}(n)}c.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},c.allocUnsafe=function(t){return h(t)},c.allocUnsafeSlow=function(t){return h(t)},c.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==c.prototype},c.compare=function(t,e){if(V(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),V(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).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}},c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=c.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(V(e,Uint8Array))i+e.length>n.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},c.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},c.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},c.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?I(this,0,t):y.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){let t="";const r=e.h2;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(V(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),u=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<s;++t)if(u[t]!==l[t]){o=u[t],a=l[t];break}return o<a?-1:a<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return S(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const O=4096;function R(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function B(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function _(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Y[t[n]];return i}function U(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function C(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i){W(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function L(t,e,r,n,i){W(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function N(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(t,e,r,n,o){return e=+e,r>>>=0,o||N(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,o){return e=+e,r>>>=0,o||N(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),c.prototype.readBigUInt64BE=q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),c.prototype.readBigInt64BE=q((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||Z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),c.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){P(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){P(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=q((function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=q((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=q((function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=q((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=c.isBuffer(t)?t:c.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const K={};function M(t,e,r){K[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function z(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function W(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new K.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){F(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||Z(e,t.length-(r+1))}(n,i,o)}function F(t,e){if("number"!=typeof t)throw new K.ERR_INVALID_ARG_TYPE(e,"number",t)}function Z(t,e,r){if(Math.floor(t)!==t)throw F(t,r),new K.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new K.ERR_BUFFER_OUT_OF_BOUNDS;throw new K.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),M("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),M("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=z(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function $(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function G(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function q(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},470:t=>{"use strict";var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===r.call(t)},a=function(t){if(!t||"[object Object]"!==r.call(t))return!1;var n,i=e.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&e.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!i&&!o)return!1;for(n in t);return void 0===n||e.call(t,n)},s=function(t,e){n&&"__proto__"===e.name?n(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,r){if("__proto__"===r){if(!e.call(t,r))return;if(i)return i(t,r).value}return t[r]};t.exports=function t(){var e,r,n,i,u,l,h=arguments[0],f=1,d=arguments.length,p=!1;for("boolean"==typeof h&&(p=h,h=arguments[1]||{},f=2),(null==h||"object"!=typeof h&&"function"!=typeof h)&&(h={});f<d;++f)if(null!=(e=arguments[f]))for(r in e)n=c(h,r),h!==(i=c(e,r))&&(p&&i&&(a(i)||(u=o(i)))?(u?(u=!1,l=n&&o(n)?n:[]):l=n&&a(n)?n:{},s(h,{name:r,newValue:t(p,l,i)})):void 0!==i&&s(h,{name:r,newValue:i}));return h}},645:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,c=(1<<s)-1,u=c>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=s;l>0;o=256*o+t[e+h],h+=f,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+t[e+h],h+=f,l-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=u}return(d?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(a++,c/=2),a+h>=l?(s=0,a=l):a+h>=1?(s=(e*c-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+d]=255&a,d+=p,a/=256,u-=8);t[r+d-p]|=128*g}},639:e=>{"use strict";e.exports=t}},a={};function s(t){var e=a[t];if(void 0!==e)return e.exports;var r=a[t]={exports:{}};return o[t].call(r.exports,r,r.exports,s),r.exports}s.m=o,s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,s.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);s.r(i);var o={};e=e||[null,r({}),r([]),r(r)];for(var a=2&n&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>o[e]=()=>t[e]));return o.default=()=>t,s.d(i,o),i},s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.f={},s.e=t=>Promise.all(Object.keys(s.f).reduce(((e,r)=>(s.f[r](t,e),e)),[])),s.u=t=>t+".onairos.bundle.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n={},i="onairos:",s.l=(t,e,r,o)=>{if(n[t])n[t].push(e);else{var a,c;if(void 0!==r)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var h=u[l];if(h.getAttribute("src")==t||h.getAttribute("data-webpack")==i+r){a=h;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",i+r),a.src=t),n[t]=[e];var f=(e,r)=>{a.onerror=a.onload=null,clearTimeout(d);var i=n[t];if(delete n[t],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach((t=>t(r))),e)return e(r)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=f.bind(null,a.onerror),a.onload=f.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&!t;)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})(),(()=>{var t={179:0};s.f.j=(e,r)=>{var n=s.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(((r,i)=>n=t[e]=[r,i]));r.push(n[2]=i);var o=s.p+s.u(e),a=new Error;s.l(o,(r=>{if(s.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+o+")",a.name="ChunkLoadError",a.type=i,a.request=o,n[1](a)}}),"chunk-"+e,e)}};var e=(e,r)=>{var n,i,o=r[0],a=r[1],c=r[2],u=0;if(o.some((e=>0!==t[e]))){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);if(c)c(s)}for(e&&e(r);u<o.length;u++)i=o[u],s.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=this.webpackChunkonairos=this.webpackChunkonairos||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();var c={};return(()=>{"use strict";s.r(c),s.d(c,{Onairos:()=>Yn});var t={};s.r(t),s.d(t,{hasBrowserEnv:()=>ee,hasStandardBrowserEnv:()=>re,hasStandardBrowserWebWorkerEnv:()=>ie});var e=s(639),r=s.n(e),n=s(764);function i(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}"function"==typeof SuppressedError&&SuppressedError;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==s.g?s.g:"undefined"!=typeof self?self:{};function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function u(t,e){return t(e={exports:{}},e.exports),e.exports}var l=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){var t=this;this.locked=new Map,this.addToLocked=function(e,r){var n=t.locked.get(e);void 0===n?void 0===r?t.locked.set(e,[]):t.locked.set(e,[r]):void 0!==r&&(n.unshift(r),t.locked.set(e,n))},this.isLocked=function(e){return t.locked.has(e)},this.lock=function(e){return new Promise((function(r,n){t.isLocked(e)?t.addToLocked(e,r):(t.addToLocked(e),r())}))},this.unlock=function(e){var r=t.locked.get(e);if(void 0!==r&&0!==r.length){var n=r.pop();t.locked.set(e,r),void 0!==n&&setTimeout(n,0)}else t.locked.delete(e)}}return t.getInstance=function(){return void 0===t.instance&&(t.instance=new t),t.instance},t}();e.default=function(){return r.getInstance()}}));a(l);var h=a(u((function(t,e){var r=o&&o.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new r((function(e){e(t.value)})).then(a,s)}c((n=n.apply(t,e||[])).next())}))},n=o&&o.__generator||function(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},i=o;Object.defineProperty(e,"__esModule",{value:!0});var a="browser-tabs-lock-key",s={key:function(t){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},getItem:function(t){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},clear:function(){return r(i,void 0,void 0,(function(){return n(this,(function(t){return[2,window.localStorage.clear()]}))}))},removeItem:function(t){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},setItem:function(t,e){return r(i,void 0,void 0,(function(){return n(this,(function(t){throw new Error("Unsupported")}))}))},keySync:function(t){return window.localStorage.key(t)},getItemSync:function(t){return window.localStorage.getItem(t)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(t){return window.localStorage.removeItem(t)},setItemSync:function(t,e){return window.localStorage.setItem(t,e)}};function c(t){return new Promise((function(e){return setTimeout(e,t)}))}function u(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",r="",n=0;n<t;n++)r+=e[Math.floor(61*Math.random())];return r}var h=function(){function t(e){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+u(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=e,void 0===t.waiters&&(t.waiters=[])}return t.prototype.acquireLock=function(e,i){return void 0===i&&(i=5e3),r(this,void 0,void 0,(function(){var r,o,l,h,f,d,p;return n(this,(function(n){switch(n.label){case 0:r=Date.now()+u(4),o=Date.now()+i,l=a+"-"+e,h=void 0===this.storageHandler?s:this.storageHandler,n.label=1;case 1:return Date.now()<o?[4,c(30)]:[3,8];case 2:return n.sent(),null!==h.getItemSync(l)?[3,5]:(f=this.id+"-"+e+"-"+r,[4,c(Math.floor(25*Math.random()))]);case 3:return n.sent(),h.setItemSync(l,JSON.stringify({id:this.id,iat:r,timeoutKey:f,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,c(30)];case 4:return n.sent(),null!==(d=h.getItemSync(l))&&(p=JSON.parse(d)).id===this.id&&p.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(l,r),[2,!0]):[3,7];case 5:return t.lockCorrector(void 0===this.storageHandler?s:this.storageHandler),[4,this.waitForSomethingToChange(o)];case 6:n.sent(),n.label=7;case 7:return r=Date.now()+u(4),[3,1];case 8:return[2,!1]}}))}))},t.prototype.refreshLockWhileAcquired=function(t,e){return r(this,void 0,void 0,(function(){var i=this;return n(this,(function(o){return setTimeout((function(){return r(i,void 0,void 0,(function(){var r,i,o;return n(this,(function(n){switch(n.label){case 0:return[4,l.default().lock(e)];case 1:return n.sent(),this.acquiredIatSet.has(e)?(r=void 0===this.storageHandler?s:this.storageHandler,null===(i=r.getItemSync(t))?(l.default().unlock(e),[2]):((o=JSON.parse(i)).timeRefreshed=Date.now(),r.setItemSync(t,JSON.stringify(o)),l.default().unlock(e),this.refreshLockWhileAcquired(t,e),[2])):(l.default().unlock(e),[2])}}))}))}),1e3),[2]}))}))},t.prototype.waitForSomethingToChange=function(e){return r(this,void 0,void 0,(function(){return n(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(r){var n=!1,i=Date.now(),o=!1;function a(){if(o||(window.removeEventListener("storage",a),t.removeFromWaiting(a),clearTimeout(s),o=!0),!n){n=!0;var e=50-(Date.now()-i);e>0?setTimeout(r,e):r(null)}}window.addEventListener("storage",a),t.addToWaiting(a);var s=setTimeout(a,Math.max(0,e-Date.now()))}))];case 1:return r.sent(),[2]}}))}))},t.addToWaiting=function(e){this.removeFromWaiting(e),void 0!==t.waiters&&t.waiters.push(e)},t.removeFromWaiting=function(e){void 0!==t.waiters&&(t.waiters=t.waiters.filter((function(t){return t!==e})))},t.notifyWaiters=function(){void 0!==t.waiters&&t.waiters.slice().forEach((function(t){return t()}))},t.prototype.releaseLock=function(t){return r(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this.releaseLock__private__(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.releaseLock__private__=function(e){return r(this,void 0,void 0,(function(){var r,i,o,c;return n(this,(function(n){switch(n.label){case 0:return r=void 0===this.storageHandler?s:this.storageHandler,i=a+"-"+e,null===(o=r.getItemSync(i))?[2]:(c=JSON.parse(o)).id!==this.id?[3,2]:[4,l.default().lock(c.iat)];case 1:n.sent(),this.acquiredIatSet.delete(c.iat),r.removeItemSync(i),l.default().unlock(c.iat),t.notifyWaiters(),n.label=2;case 2:return[2]}}))}))},t.lockCorrector=function(e){for(var r=Date.now()-5e3,n=e,i=[],o=0;;){var s=n.keySync(o);if(null===s)break;i.push(s),o++}for(var c=!1,u=0;u<i.length;u++){var l=i[u];if(l.includes(a)){var h=n.getItemSync(l);if(null!==h){var f=JSON.parse(h);(void 0===f.timeRefreshed&&f.timeAcquired<r||void 0!==f.timeRefreshed&&f.timeRefreshed<r)&&(n.removeItemSync(l),c=!0)}}}c&&t.notifyWaiters()},t.waiters=void 0,t}();e.default=h})));const f={timeoutInSeconds:60},d={name:"auth0-spa-js",version:"2.1.3"},p=()=>Date.now();class g extends Error{constructor(t,e){super(e),this.error=t,this.error_description=e,Object.setPrototypeOf(this,g.prototype)}static fromPayload({error:t,error_description:e}){return new g(t,e)}}class y extends g{constructor(t,e,r,n=null){super(t,e),this.state=r,this.appState=n,Object.setPrototypeOf(this,y.prototype)}}class w extends g{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,w.prototype)}}class m extends w{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,m.prototype)}}class b extends g{constructor(t){super("cancelled","Popup closed"),this.popup=t,Object.setPrototypeOf(this,b.prototype)}}class v extends g{constructor(t,e,r){super(t,e),this.mfa_token=r,Object.setPrototypeOf(this,v.prototype)}}class E extends g{constructor(t,e){super("missing_refresh_token",`Missing Refresh Token (audience: '${S(t,["default"])}', scope: '${S(e)}')`),this.audience=t,this.scope=e,Object.setPrototypeOf(this,E.prototype)}}function S(t,e=[]){return t&&!e.includes(t)?t:""}const T=()=>window.crypto,A=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(T().getRandomValues(new Uint8Array(43))).forEach((r=>e+=t[r%66])),e},k=t=>btoa(t),I=t=>{var{clientId:e}=t,r=i(t,["clientId"]);return new URLSearchParams((t=>Object.keys(t).filter((e=>void 0!==t[e])).reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:t[r]})),{}))(Object.assign({client_id:e},r))).toString()},O=t=>(t=>decodeURIComponent(atob(t).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),R=async(t,e)=>{const r=await fetch(t,e);return{ok:r.ok,json:await r.json()}},B=async(t,e,r,n,i,o,a=1e4)=>i?(async(t,e,r,n,i,o,a)=>{return s={auth:{audience:e,scope:r},timeout:i,fetchUrl:t,fetchOptions:n,useFormData:a},c=o,new Promise((function(t,e){const r=new MessageChannel;r.port1.onmessage=function(n){n.data.error?e(new Error(n.data.error)):t(n.data),r.port1.close()},c.postMessage(s,[r.port2])}));var s,c})(t,e,r,n,a,i,o):(async(t,e,r)=>{const n=new AbortController;let i;return e.signal=n.signal,Promise.race([R(t,e),new Promise(((t,e)=>{i=setTimeout((()=>{n.abort(),e(new Error("Timeout when executing 'fetch'"))}),r)}))]).finally((()=>{clearTimeout(i)}))})(t,n,a);async function _(t,e){var{baseUrl:r,timeout:n,audience:o,scope:a,auth0Client:s,useFormData:c}=t,u=i(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const l=c?I(u):JSON.stringify(u);return await async function(t,e,r,n,o,a,s){let c,u=null;for(let i=0;i<3;i++)try{c=await B(t,r,n,o,a,s,e),u=null;break}catch(t){u=t}if(u)throw u;const l=c.json,{error:h,error_description:f}=l,d=i(l,["error","error_description"]),{ok:p}=c;if(!p){const e=f||`HTTP error. Unable to fetch ${t}`;if("mfa_required"===h)throw new v(h,e,d.mfa_token);if("missing_refresh_token"===h)throw new E(r,n);throw new g(h||"request_error",e)}return d}(`${r}/oauth/token`,n,o||"default",a,{method:"POST",body:l,headers:{"Content-Type":c?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(s||d))}},e,c)}const U=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};class C{constructor(t,e="@@auth0spajs@@",r){this.prefix=e,this.suffix=r,this.clientId=t.clientId,this.scope=t.scope,this.audience=t.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(t){const[e,r,n,i]=t.split("::");return new C({clientId:r,scope:i,audience:n},e)}static fromCacheEntry(t){const{scope:e,audience:r,client_id:n}=t;return new C({scope:e,audience:r,clientId:n})}}class P{set(t,e){localStorage.setItem(t,JSON.stringify(e))}get(t){const e=window.localStorage.getItem(t);if(e)try{return JSON.parse(e)}catch(t){return}}remove(t){localStorage.removeItem(t)}allKeys(){return Object.keys(window.localStorage).filter((t=>t.startsWith("@@auth0spajs@@")))}}class x{constructor(){this.enclosedCache=function(){let t={};return{set(e,r){t[e]=r},get(e){const r=t[e];if(r)return r},remove(e){delete t[e]},allKeys:()=>Object.keys(t)}}()}}class L{constructor(t,e,r){this.cache=t,this.keyManifest=e,this.nowProvider=r||p}async setIdToken(t,e,r){var n;const i=this.getIdTokenCacheKey(t);await this.cache.set(i,{id_token:e,decodedToken:r}),await(null===(n=this.keyManifest)||void 0===n?void 0:n.add(i))}async getIdToken(t){const e=await this.cache.get(this.getIdTokenCacheKey(t.clientId));if(!e&&t.scope&&t.audience){const e=await this.get(t);if(!e)return;if(!e.id_token||!e.decodedToken)return;return{id_token:e.id_token,decodedToken:e.decodedToken}}if(e)return{id_token:e.id_token,decodedToken:e.decodedToken}}async get(t,e=0){var r;let n=await this.cache.get(t.toKey());if(!n){const e=await this.getCacheKeys();if(!e)return;const r=this.matchExistingCacheKey(t,e);r&&(n=await this.cache.get(r))}if(!n)return;const i=await this.nowProvider(),o=Math.floor(i/1e3);return n.expiresAt-e<o?n.body.refresh_token?(n.body={refresh_token:n.body.refresh_token},await this.cache.set(t.toKey(),n),n.body):(await this.cache.remove(t.toKey()),void await(null===(r=this.keyManifest)||void 0===r?void 0:r.remove(t.toKey()))):n.body}async set(t){var e;const r=new C({clientId:t.client_id,scope:t.scope,audience:t.audience}),n=await this.wrapCacheEntry(t);await this.cache.set(r.toKey(),n),await(null===(e=this.keyManifest)||void 0===e?void 0:e.add(r.toKey()))}async clear(t){var e;const r=await this.getCacheKeys();r&&(await r.filter((e=>!t||e.includes(t))).reduce((async(t,e)=>{await t,await this.cache.remove(e)}),Promise.resolve()),await(null===(e=this.keyManifest)||void 0===e?void 0:e.clear()))}async wrapCacheEntry(t){const e=await this.nowProvider();return{body:t,expiresAt:Math.floor(e/1e3)+t.expires_in}}async getCacheKeys(){var t;return this.keyManifest?null===(t=await this.keyManifest.get())||void 0===t?void 0:t.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(t){return new C({clientId:t},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(t,e){return e.filter((e=>{var r;const n=C.fromKey(e),i=new Set(n.scope&&n.scope.split(" ")),o=(null===(r=t.scope)||void 0===r?void 0:r.split(" "))||[],a=n.scope&&o.reduce(((t,e)=>t&&i.has(e)),!0);return"@@auth0spajs@@"===n.prefix&&n.clientId===t.clientId&&n.audience===t.audience&&a}))[0]}}class N{constructor(t,e,r){this.storage=t,this.clientId=e,this.cookieDomain=r,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(t){this.storage.save(this.storageKey,t,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}}const j=t=>"number"==typeof t,D=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"];var K=u((function(t,e){var r=o&&o.__assign||function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};function n(t,e){if(!e)return"";var r="; "+t;return!0===e?r:r+"="+e}function i(t,e,r){return encodeURIComponent(t).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(e).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(t){if("number"==typeof t.expires){var e=new Date;e.setMilliseconds(e.getMilliseconds()+864e5*t.expires),t.expires=e}return n("Expires",t.expires?t.expires.toUTCString():"")+n("Domain",t.domain)+n("Path",t.path)+n("Secure",t.secure)+n("SameSite",t.sameSite)}(r)}function a(t){for(var e={},r=t?t.split("; "):[],n=/(%[\dA-F]{2})+/gi,i=0;i<r.length;i++){var o=r[i].split("="),a=o.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1));try{e[o[0].replace(n,decodeURIComponent)]=a.replace(n,decodeURIComponent)}catch(t){}}return e}function s(){return a(document.cookie)}function c(t,e,n){document.cookie=i(t,e,r({path:"/"},n))}e.__esModule=!0,e.encode=i,e.parse=a,e.getAll=s,e.get=function(t){return s()[t]},e.set=c,e.remove=function(t,e){c(t,"",r(r({},e),{expires:-1}))}}));a(K),K.encode,K.parse,K.getAll;var M=K.get,z=K.set,W=K.remove;const F={get(t){const e=M(t);if(void 0!==e)return JSON.parse(e)},save(t,e,r){let n={};"https:"===window.location.protocol&&(n={secure:!0,sameSite:"none"}),(null==r?void 0:r.daysUntilExpire)&&(n.expires=r.daysUntilExpire),(null==r?void 0:r.cookieDomain)&&(n.domain=r.cookieDomain),z(t,JSON.stringify(e),n)},remove(t,e){let r={};(null==e?void 0:e.cookieDomain)&&(r.domain=e.cookieDomain),W(t,r)}},Z={get:t=>F.get(t)||F.get(`_legacy_${t}`),save(t,e,r){let n={};"https:"===window.location.protocol&&(n={secure:!0}),(null==r?void 0:r.daysUntilExpire)&&(n.expires=r.daysUntilExpire),(null==r?void 0:r.cookieDomain)&&(n.domain=r.cookieDomain),z(`_legacy_${t}`,JSON.stringify(e),n),F.save(t,e,r)},remove(t,e){let r={};(null==e?void 0:e.cookieDomain)&&(r.domain=e.cookieDomain),W(t,r),F.remove(t,e),F.remove(`_legacy_${t}`,e)}},H={get(t){if("undefined"==typeof sessionStorage)return;const e=sessionStorage.getItem(t);return null!=e?JSON.parse(e):void 0},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};var $,G=("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,!1,function(t){return $=$||function(t,e,r){var n=void 0===e?null:e,i=function(t,e){var r=atob(t);if(e){for(var n=new Uint8Array(r.length),i=0,o=r.length;i<o;++i)n[i]=r.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(n.buffer))}return r}(t,void 0!==r&&r),o=i.indexOf("\n",10)+1,a=i.substring(o)+(n?"//# sourceMappingURL="+n:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",null,false),new Worker($,t)});const X={};class V{constructor(t,e){this.cache=t,this.clientId=e,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(t){var e;const r=new Set((null===(e=await this.cache.get(this.manifestKey))||void 0===e?void 0:e.keys)||[]);r.add(t),await this.cache.set(this.manifestKey,{keys:[...r]})}async remove(t){const e=await this.cache.get(this.manifestKey);if(e){const r=new Set(e.keys);return r.delete(t),r.size>0?await this.cache.set(this.manifestKey,{keys:[...r]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(t){return`@@auth0spajs@@::${t}`}}const J={memory:()=>(new x).enclosedCache,localstorage:()=>new P},Y=t=>J[t],q=t=>{const{openUrl:e,onRedirect:r}=t,n=i(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},n),{openUrl:!1===e||e?e:r})},Q=new h;class tt{constructor(t){let e,r;if(this.userCache=(new x).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await Q.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),t),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),t.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!T())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===T().subtle)throw new Error("\n auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.\n ")})(),t.cache&&t.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),t.cache)r=t.cache;else{if(e=t.cacheLocation||"memory",!Y(e))throw new Error(`Invalid cache location "${e}"`);r=Y(e)()}this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===t.legacySameSiteCookie?F:Z,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(t=>`auth0.${this.options.clientId}.is.authenticated`)(),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const n=t.useCookiesForTransactions?this.cookieStorage:H;var i;this.scope=U("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new N(n,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||p,this.cacheManager=new L(r,r.allKeys?void 0:new V(r,this.options.clientId),this.nowProvider),this.domainUrl=(i=this.options.domain,/^https?:\/\//.test(i)?i:`https://${i}`),this.tokenIssuer=((t,e)=>t?t.startsWith("https://")?t:`https://${t}/`:`${e}/`)(this.options.issuer,this.domainUrl),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&"memory"===e&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new G)}_url(t){const e=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||d)));return`${this.domainUrl}${t}&auth0Client=${e}`}_authorizeUrl(t){return this._url(`/authorize?${I(t)}`)}async _verifyIdToken(t,e,r){const n=await this.nowProvider();return(t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(t=>{const e=t.split("."),[r,n,i]=e;if(3!==e.length||!r||!n||!i)throw new Error("ID token could not be decoded");const o=JSON.parse(O(n)),a={__raw:t},s={};return Object.keys(o).forEach((t=>{a[t]=o[t],D.includes(t)||(s[t]=o[t])})),{encoded:{header:r,payload:n,signature:i},header:JSON.parse(O(r)),claims:a,user:s}})(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==e.header.alg)throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||"string"!=typeof e.claims.aud&&!Array.isArray(e.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!j(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(null==e.claims.exp||!j(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!j(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const r=t.leeway||60,n=new Date(t.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(e.claims.exp+r),n>i)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${n}) is after expiration time (${i})`);if(null!=e.claims.nbf&&j(e.claims.nbf)){const t=new Date(0);if(t.setUTCSeconds(e.claims.nbf-r),n<t)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${n}) is before ${t}`)}if(null!=e.claims.auth_time&&j(e.claims.auth_time)){const i=new Date(0);if(i.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+r),n>i)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${n}) is after last auth at ${i}`)}if(t.organization){const r=t.organization.trim();if(r.startsWith("org_")){const t=r;if(!e.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(t!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${t}", found "${e.claims.org_id}"`)}else{const t=r.toLowerCase();if(!e.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(t!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${t}", found "${e.claims.org_name}"`)}}return e})({iss:this.tokenIssuer,aud:this.options.clientId,id_token:t,nonce:e,organization:r,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,"string"!=typeof i?i:parseInt(i,10)||void 0),now:n});var i}_processOrgHint(t){t?this.cookieStorage.save(this.orgHintCookieName,t,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(t,e,r){const n=k(A()),i=k(A()),o=A(),a=(t=>{const e=new Uint8Array(t);return(t=>{const e={"+":"-","/":"_","=":""};return t.replace(/[+/=]/g,(t=>e[t]))})(window.btoa(String.fromCharCode(...Array.from(e))))})(await(async t=>{const e=T().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(t));return await e})(o)),s=((t,e,r,n,i,o,a,s)=>Object.assign(Object.assign(Object.assign({client_id:t.clientId},t.authorizationParams),r),{scope:U(e,r.scope),response_type:"code",response_mode:s||"query",state:n,nonce:i,redirect_uri:a||t.authorizationParams.redirect_uri,code_challenge:o,code_challenge_method:"S256"}))(this.options,this.scope,t,n,i,a,t.redirect_uri||this.options.authorizationParams.redirect_uri||r,null==e?void 0:e.response_mode),c=this._authorizeUrl(s);return{nonce:i,code_verifier:o,scope:s.scope,audience:s.audience||"default",redirect_uri:s.redirect_uri,state:n,url:c}}async loginWithPopup(t,e){var r;if(t=t||{},!(e=e||{}).popup&&(e.popup=(t=>{const e=window.screenX+(window.innerWidth-400)/2,r=window.screenY+(window.innerHeight-600)/2;return window.open("","auth0:authorize:popup",`left=${e},top=${r},width=400,height=600,resizable,scrollbars=yes,status=1`)})(),!e.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const n=await this._prepareAuthorizeUrl(t.authorizationParams||{},{response_mode:"web_message"},window.location.origin);e.popup.location.href=n.url;const i=await(t=>new Promise(((e,r)=>{let n;const i=setInterval((()=>{t.popup&&t.popup.closed&&(clearInterval(i),clearTimeout(o),window.removeEventListener("message",n,!1),r(new b(t.popup)))}),1e3),o=setTimeout((()=>{clearInterval(i),r(new m(t.popup)),window.removeEventListener("message",n,!1)}),1e3*(t.timeoutInSeconds||60));n=function(a){if(a.data&&"authorization_response"===a.data.type){if(clearTimeout(o),clearInterval(i),window.removeEventListener("message",n,!1),t.popup.close(),a.data.response.error)return r(g.fromPayload(a.data.response));e(a.data.response)}},window.addEventListener("message",n)})))(Object.assign(Object.assign({},e),{timeoutInSeconds:e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(n.state!==i.state)throw new g("state_mismatch","Invalid state");const o=(null===(r=t.authorizationParams)||void 0===r?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:n.audience,scope:n.scope,code_verifier:n.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:n.redirect_uri},{nonceIn:n.nonce,organization:o})}async getUser(){var t;const e=await this._getIdTokenFromCache();return null===(t=null==e?void 0:e.decodedToken)||void 0===t?void 0:t.user}async getIdTokenClaims(){var t;const e=await this._getIdTokenFromCache();return null===(t=null==e?void 0:e.decodedToken)||void 0===t?void 0:t.claims}async loginWithRedirect(t={}){var e;const r=q(t),{openUrl:n,fragment:o,appState:a}=r,s=i(r,["openUrl","fragment","appState"]),c=(null===(e=s.authorizationParams)||void 0===e?void 0:e.organization)||this.options.authorizationParams.organization,u=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:l}=u,h=i(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:a}),c&&{organization:c}));const f=o?`${l}#${o}`:l;n?await n(f):window.location.assign(f)}async handleRedirectCallback(t=window.location.href){const e=t.split("?").slice(1);if(0===e.length)throw new Error("There are no query params available for parsing.");const{state:r,code:n,error:i,error_description:o}=(t=>{t.indexOf("#")>-1&&(t=t.substring(0,t.indexOf("#")));const e=new URLSearchParams(t);return{state:e.get("state"),code:e.get("code")||void 0,error:e.get("error")||void 0,error_description:e.get("error_description")||void 0}})(e.join("")),a=this.transactionManager.get();if(!a)throw new g("missing_transaction","Invalid state");if(this.transactionManager.remove(),i)throw new y(i,o||i,r,a.appState);if(!a.code_verifier||a.state&&a.state!==r)throw new g("state_mismatch","Invalid state");const s=a.organization,c=a.nonce,u=a.redirect_uri;return await this._requestToken(Object.assign({audience:a.audience,scope:a.scope,code_verifier:a.code_verifier,grant_type:"authorization_code",code:n},u?{redirect_uri:u}:{}),{nonceIn:c,organization:s}),{appState:a.appState}}async checkSession(t){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(t)}catch(t){}}async getTokenSilently(t={}){var e;const r=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:U(this.scope,null===(e=t.authorizationParams)||void 0===e?void 0:e.scope)})}),n=await((t,e)=>{let r=X[e];return r||(r=t().finally((()=>{delete X[e],r=null})),X[e]=r),r})((()=>this._getTokenSilently(r)),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return t.detailedResponse?n:null==n?void 0:n.access_token}async _getTokenSilently(t){const{cacheMode:e}=t,r=i(t,["cacheMode"]);if("off"!==e){const t=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(t)return t}if("cache-only"!==e){if(!await(async(t,e=3)=>{for(let r=0;r<e;r++)if(await t())return!0;return!1})((()=>Q.acquireLock("auth0.lock.getTokenSilently",5e3)),10))throw new w;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),"off"!==e){const t=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(t)return t}const t=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:n,access_token:i,oauthTokenScope:o,expires_in:a}=t;return Object.assign(Object.assign({id_token:n,access_token:i},o?{scope:o}:null),{expires_in:a})}finally{await Q.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(t={},e={}){var r;const n=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:U(this.scope,null===(r=t.authorizationParams)||void 0===r?void 0:r.scope)})});return e=Object.assign(Object.assign({},f),e),await this.loginWithPopup(n,e),(await this.cacheManager.get(new C({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(t){null!==t.clientId?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const e=t.logoutParams||{},{federated:r}=e,n=i(e,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${I(Object.assign({clientId:t.clientId},n))}`)+o}async logout(t={}){const e=q(t),{openUrl:r}=e,n=i(e,["openUrl"]);null===t.clientId?await this.cacheManager.clear():await this.cacheManager.clear(t.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(n);r?await r(o):!1!==r&&window.location.assign(o)}async _getTokenFromIFrame(t){const e=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!e.organization&&(e.organization=r);const{url:n,state:i,nonce:o,code_verifier:a,redirect_uri:s,scope:c,audience:u}=await this._prepareAuthorizeUrl(e,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new g("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const r=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,l=await((t,e,r=60)=>new Promise(((n,i)=>{const o=window.document.createElement("iframe");o.setAttribute("width","0"),o.setAttribute("height","0"),o.style.display="none";const a=()=>{window.document.body.contains(o)&&(window.document.body.removeChild(o),window.removeEventListener("message",s,!1))};let s;const c=setTimeout((()=>{i(new w),a()}),1e3*r);s=function(t){if(t.origin!=e)return;if(!t.data||"authorization_response"!==t.data.type)return;const r=t.source;r&&r.close(),t.data.response.error?i(g.fromPayload(t.data.response)):n(t.data.response),clearTimeout(c),window.removeEventListener("message",s,!1),setTimeout(a,2e3)},window.addEventListener("message",s,!1),window.document.body.appendChild(o),o.setAttribute("src",t)})))(n,this.domainUrl,r);if(i!==l.state)throw new g("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:a,code:l.code,grant_type:"authorization_code",redirect_uri:s,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:o,organization:e.organization});return Object.assign(Object.assign({},h),{scope:c,oauthTokenScope:h.scope,audience:u})}catch(t){throw"login_required"===t.error&&this.logout({openUrl:!1}),t}}async _getTokenUsingRefreshToken(t){const e=await this.cacheManager.get(new C({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(e&&e.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw new E(t.authorizationParams.audience||"default",t.authorizationParams.scope)}const r=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,n="number"==typeof t.timeoutInSeconds?1e3*t.timeoutInSeconds:null;try{const i=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:e&&e.refresh_token,redirect_uri:r}),n&&{timeout:n}));return Object.assign(Object.assign({},i),{scope:t.authorizationParams.scope,oauthTokenScope:i.scope,audience:t.authorizationParams.audience||"default"})}catch(e){if((e.message.indexOf("Missing Refresh Token")>-1||e.message&&e.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw e}}async _saveEntryInCache(t){const{id_token:e,decodedToken:r}=t,n=i(t,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:e,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(n)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||"default",e=await this.cacheManager.getIdToken(new C({clientId:this.options.clientId,audience:t,scope:this.scope})),r=this.userCache.get("@@user@@");return e&&e.id_token===(null==r?void 0:r.id_token)?r:(this.userCache.set("@@user@@",e),e)}async _getEntryFromCache({scope:t,audience:e,clientId:r}){const n=await this.cacheManager.get(new C({scope:t,audience:e,clientId:r}),60);if(n&&n.access_token){const{access_token:t,oauthTokenScope:e,expires_in:r}=n,i=await this._getIdTokenFromCache();return i&&Object.assign(Object.assign({id_token:i.id_token,access_token:t},e?{scope:e}:null),{expires_in:r})}}async _requestToken(t,e){const{nonceIn:r,organization:n}=e||{},i=await _(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},t),this.worker),o=await this._verifyIdToken(i.id_token,r,n);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},i),{decodedToken:o,scope:t.scope,audience:t.audience||"default"}),i.scope?{oauthTokenScope:i.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(n||o.claims.org_id),Object.assign(Object.assign({},i),{decodedToken:o})}}var et=s(470);function rt(t,e){return function(){return t.apply(e,arguments)}}const{toString:nt}=Object.prototype,{getPrototypeOf:it}=Object,ot=(at=Object.create(null),t=>{const e=nt.call(t);return at[e]||(at[e]=e.slice(8,-1).toLowerCase())});var at;const st=t=>(t=t.toLowerCase(),e=>ot(e)===t),ct=t=>e=>typeof e===t,{isArray:ut}=Array,lt=ct("undefined");const ht=st("ArrayBuffer");const ft=ct("string"),dt=ct("function"),pt=ct("number"),gt=t=>null!==t&&"object"==typeof t,yt=t=>{if("object"!==ot(t))return!1;const e=it(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||Symbol.toStringTag in t||Symbol.iterator in t)},wt=st("Date"),mt=st("File"),bt=st("Blob"),vt=st("FileList"),Et=st("URLSearchParams");function St(t,e,{allOwnKeys:r=!1}={}){if(null==t)return;let n,i;if("object"!=typeof t&&(t=[t]),ut(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const i=r?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let a;for(n=0;n<o;n++)a=i[n],e.call(null,t[a],a,t)}}function Tt(t,e){e=e.toLowerCase();const r=Object.keys(t);let n,i=r.length;for(;i-- >0;)if(n=r[i],e===n.toLowerCase())return n;return null}const At="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,kt=t=>!lt(t)&&t!==At;const It=(Ot="undefined"!=typeof Uint8Array&&it(Uint8Array),t=>Ot&&t instanceof Ot);var Ot;const Rt=st("HTMLFormElement"),Bt=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),_t=st("RegExp"),Ut=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};St(r,((r,i)=>{let o;!1!==(o=e(r,i,t))&&(n[i]=o||r)})),Object.defineProperties(t,n)},Ct="abcdefghijklmnopqrstuvwxyz",Pt="0123456789",xt={DIGIT:Pt,ALPHA:Ct,ALPHA_DIGIT:Ct+Ct.toUpperCase()+Pt};const Lt=st("AsyncFunction"),Nt={isArray:ut,isArrayBuffer:ht,isBuffer:function(t){return null!==t&&!lt(t)&&null!==t.constructor&&!lt(t.constructor)&&dt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)},isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||dt(t.append)&&("formdata"===(e=ot(t))||"object"===e&&dt(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&ht(t.buffer),e},isString:ft,isNumber:pt,isBoolean:t=>!0===t||!1===t,isObject:gt,isPlainObject:yt,isUndefined:lt,isDate:wt,isFile:mt,isBlob:bt,isRegExp:_t,isFunction:dt,isStream:t=>gt(t)&&dt(t.pipe),isURLSearchParams:Et,isTypedArray:It,isFileList:vt,forEach:St,merge:function t(){const{caseless:e}=kt(this)&&this||{},r={},n=(n,i)=>{const o=e&&Tt(r,i)||i;yt(r[o])&&yt(n)?r[o]=t(r[o],n):yt(n)?r[o]=t({},n):ut(n)?r[o]=n.slice():r[o]=n};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&St(arguments[t],n);return r},extend:(t,e,r,{allOwnKeys:n}={})=>(St(e,((e,n)=>{r&&dt(e)?t[n]=rt(e,r):t[n]=e}),{allOwnKeys:n}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},toFlatObject:(t,e,r,n)=>{let i,o,a;const s={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),o=i.length;o-- >0;)a=i[o],n&&!n(a,t,e)||s[a]||(e[a]=t[a],s[a]=!0);t=!1!==r&&it(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:ot,kindOfTest:st,endsWith:(t,e,r)=>{t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return-1!==n&&n===r},toArray:t=>{if(!t)return null;if(ut(t))return t;let e=t.length;if(!pt(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},forEachEntry:(t,e)=>{const r=(t&&t[Symbol.iterator]).call(t);let n;for(;(n=r.next())&&!n.done;){const r=n.value;e.call(t,r[0],r[1])}},matchAll:(t,e)=>{let r;const n=[];for(;null!==(r=t.exec(e));)n.push(r);return n},isHTMLForm:Rt,hasOwnProperty:Bt,hasOwnProp:Bt,reduceDescriptors:Ut,freezeMethods:t=>{Ut(t,((e,r)=>{if(dt(t)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=t[r];dt(n)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(t,e)=>{const r={},n=t=>{t.forEach((t=>{r[t]=!0}))};return ut(t)?n(t):n(String(t).split(e)),r},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(t,e,r){return e.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(t,e)=>(t=+t,Number.isFinite(t)?t:e),findKey:Tt,global:At,isContextDefined:kt,ALPHABET:xt,generateString:(t=16,e=xt.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r},isSpecCompliantForm:function(t){return!!(t&&dt(t.append)&&"FormData"===t[Symbol.toStringTag]&&t[Symbol.iterator])},toJSONObject:t=>{const e=new Array(10),r=(t,n)=>{if(gt(t)){if(e.indexOf(t)>=0)return;if(!("toJSON"in t)){e[n]=t;const i=ut(t)?[]:{};return St(t,((t,e)=>{const o=r(t,n+1);!lt(o)&&(i[e]=o)})),e[n]=void 0,i}}return t};return r(t,0)},isAsyncFn:Lt,isThenable:t=>t&&(gt(t)||dt(t))&&dt(t.then)&&dt(t.catch)};function jt(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}Nt.inherits(jt,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Nt.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Dt=jt.prototype,Kt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{Kt[t]={value:t}})),Object.defineProperties(jt,Kt),Object.defineProperty(Dt,"isAxiosError",{value:!0}),jt.from=(t,e,r,n,i,o)=>{const a=Object.create(Dt);return Nt.toFlatObject(t,a,(function(t){return t!==Error.prototype}),(t=>"isAxiosError"!==t)),jt.call(a,t.message,e,r,n,i),a.cause=t,a.name=t.name,o&&Object.assign(a,o),a};const Mt=jt;function zt(t){return Nt.isPlainObject(t)||Nt.isArray(t)}function Wt(t){return Nt.endsWith(t,"[]")?t.slice(0,-2):t}function Ft(t,e,r){return t?t.concat(e).map((function(t,e){return t=Wt(t),!r&&e?"["+t+"]":t})).join(r?".":""):e}const Zt=Nt.toFlatObject(Nt,{},null,(function(t){return/^is[A-Z]/.test(t)}));const Ht=function(t,e,r){if(!Nt.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const n=(r=Nt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!Nt.isUndefined(e[t])}))).metaTokens,i=r.visitor||u,o=r.dots,a=r.indexes,s=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Nt.isSpecCompliantForm(e);if(!Nt.isFunction(i))throw new TypeError("visitor must be a function");function c(t){if(null===t)return"";if(Nt.isDate(t))return t.toISOString();if(!s&&Nt.isBlob(t))throw new Mt("Blob is not supported. Use a Buffer instead.");return Nt.isArrayBuffer(t)||Nt.isTypedArray(t)?s&&"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}function u(t,r,i){let s=t;if(t&&!i&&"object"==typeof t)if(Nt.endsWith(r,"{}"))r=n?r:r.slice(0,-2),t=JSON.stringify(t);else if(Nt.isArray(t)&&function(t){return Nt.isArray(t)&&!t.some(zt)}(t)||(Nt.isFileList(t)||Nt.endsWith(r,"[]"))&&(s=Nt.toArray(t)))return r=Wt(r),s.forEach((function(t,n){!Nt.isUndefined(t)&&null!==t&&e.append(!0===a?Ft([r],n,o):null===a?r:r+"[]",c(t))})),!1;return!!zt(t)||(e.append(Ft(i,r,o),c(t)),!1)}const l=[],h=Object.assign(Zt,{defaultVisitor:u,convertValue:c,isVisitable:zt});if(!Nt.isObject(t))throw new TypeError("data must be an object");return function t(r,n){if(!Nt.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),Nt.forEach(r,(function(r,o){!0===(!(Nt.isUndefined(r)||null===r)&&i.call(e,r,Nt.isString(o)?o.trim():o,n,h))&&t(r,n?n.concat(o):[o])})),l.pop()}}(t),e};function $t(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function(t){return e[t]}))}function Gt(t,e){this._pairs=[],t&&Ht(t,this,e)}const Xt=Gt.prototype;Xt.append=function(t,e){this._pairs.push([t,e])},Xt.toString=function(t){const e=t?function(e){return t.call(this,e,$t)}:$t;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")};const Vt=Gt;function Jt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Yt(t,e,r){if(!e)return t;const n=r&&r.encode||Jt,i=r&&r.serialize;let o;if(o=i?i(e,r):Nt.isURLSearchParams(e)?e.toString():new Vt(e,r).toString(n),o){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+o}return t}const qt=class{constructor(){this.handlers=[]}use(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Nt.forEach(this.handlers,(function(e){null!==e&&t(e)}))}},Qt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},te={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Vt,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ee="undefined"!=typeof window&&"undefined"!=typeof document,re=(ne="undefined"!=typeof navigator&&navigator.product,ee&&["ReactNative","NativeScript","NS"].indexOf(ne)<0);var ne;const ie="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,oe={...t,...te};const ae=function(t){function e(t,r,n,i){let o=t[i++];if("__proto__"===o)return!0;const a=Number.isFinite(+o),s=i>=t.length;if(o=!o&&Nt.isArray(n)?n.length:o,s)return Nt.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!a;n[o]&&Nt.isObject(n[o])||(n[o]=[]);return e(t,r,n[o],i)&&Nt.isArray(n[o])&&(n[o]=function(t){const e={},r=Object.keys(t);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],e[o]=t[o];return e}(n[o])),!a}if(Nt.isFormData(t)&&Nt.isFunction(t.entries)){const r={};return Nt.forEachEntry(t,((t,n)=>{e(function(t){return Nt.matchAll(/\w+|\[(\w*)]/g,t).map((t=>"[]"===t[0]?"":t[1]||t[0]))}(t),n,r,0)})),r}return null};const se={transitional:Qt,adapter:["xhr","http"],transformRequest:[function(t,e){const r=e.getContentType()||"",n=r.indexOf("application/json")>-1,i=Nt.isObject(t);i&&Nt.isHTMLForm(t)&&(t=new FormData(t));if(Nt.isFormData(t))return n&&n?JSON.stringify(ae(t)):t;if(Nt.isArrayBuffer(t)||Nt.isBuffer(t)||Nt.isStream(t)||Nt.isFile(t)||Nt.isBlob(t))return t;if(Nt.isArrayBufferView(t))return t.buffer;if(Nt.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return Ht(t,new oe.classes.URLSearchParams,Object.assign({visitor:function(t,e,r,n){return oe.isNode&&Nt.isBuffer(t)?(this.append(e,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}(t,this.formSerializer).toString();if((o=Nt.isFileList(t))||r.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return Ht(o?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||n?(e.setContentType("application/json",!1),function(t,e,r){if(Nt.isString(t))try{return(e||JSON.parse)(t),Nt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||se.transitional,r=e&&e.forcedJSONParsing,n="json"===this.responseType;if(t&&Nt.isString(t)&&(r&&!this.responseType||n)){const r=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(t){if(r){if("SyntaxError"===t.name)throw Mt.from(t,Mt.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:oe.classes.FormData,Blob:oe.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Nt.forEach(["delete","get","head","post","put","patch"],(t=>{se.headers[t]={}}));const ce=se,ue=Nt.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"]),le=Symbol("internals");function he(t){return t&&String(t).trim().toLowerCase()}function fe(t){return!1===t||null==t?t:Nt.isArray(t)?t.map(fe):String(t)}function de(t,e,r,n,i){return Nt.isFunction(n)?n.call(this,e,r):(i&&(e=r),Nt.isString(e)?Nt.isString(n)?-1!==e.indexOf(n):Nt.isRegExp(n)?n.test(e):void 0:void 0)}class pe{constructor(t){t&&this.set(t)}set(t,e,r){const n=this;function i(t,e,r){const i=he(e);if(!i)throw new Error("header name must be a non-empty string");const o=Nt.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||e]=fe(t))}const o=(t,e)=>Nt.forEach(t,((t,r)=>i(t,r,e)));return Nt.isPlainObject(t)||t instanceof this.constructor?o(t,e):Nt.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim())?o((t=>{const e={};let r,n,i;return t&&t.split("\n").forEach((function(t){i=t.indexOf(":"),r=t.substring(0,i).trim().toLowerCase(),n=t.substring(i+1).trim(),!r||e[r]&&ue[r]||("set-cookie"===r?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)})),e})(t),e):null!=t&&i(e,t,r),this}get(t,e){if(t=he(t)){const r=Nt.findKey(this,t);if(r){const t=this[r];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}(t);if(Nt.isFunction(e))return e.call(this,t,r);if(Nt.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=he(t)){const r=Nt.findKey(this,t);return!(!r||void 0===this[r]||e&&!de(0,this[r],r,e))}return!1}delete(t,e){const r=this;let n=!1;function i(t){if(t=he(t)){const i=Nt.findKey(r,t);!i||e&&!de(0,r[i],i,e)||(delete r[i],n=!0)}}return Nt.isArray(t)?t.forEach(i):i(t),n}clear(t){const e=Object.keys(this);let r=e.length,n=!1;for(;r--;){const i=e[r];t&&!de(0,this[i],i,t,!0)||(delete this[i],n=!0)}return n}normalize(t){const e=this,r={};return Nt.forEach(this,((n,i)=>{const o=Nt.findKey(r,i);if(o)return e[o]=fe(n),void delete e[i];const a=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,r)=>e.toUpperCase()+r))}(i):String(i).trim();a!==i&&delete e[i],e[a]=fe(n),r[a]=!0})),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return Nt.forEach(this,((r,n)=>{null!=r&&!1!==r&&(e[n]=t&&Nt.isArray(r)?r.join(", "):r)})),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const r=new this(t);return e.forEach((t=>r.set(t))),r}static accessor(t){const e=(this[le]=this[le]={accessors:{}}).accessors,r=this.prototype;function n(t){const n=he(t);e[n]||(!function(t,e){const r=Nt.toCamelCase(" "+e);["get","set","has"].forEach((n=>{Object.defineProperty(t,n+r,{value:function(t,r,i){return this[n].call(this,e,t,r,i)},configurable:!0})}))}(r,t),e[n]=!0)}return Nt.isArray(t)?t.forEach(n):n(t),this}}pe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Nt.reduceDescriptors(pe.prototype,(({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[r]=t}}})),Nt.freezeMethods(pe);const ge=pe;function ye(t,e){const r=this||ce,n=e||r,i=ge.from(n.headers);let o=n.data;return Nt.forEach(t,(function(t){o=t.call(r,o,i.normalize(),e?e.status:void 0)})),i.normalize(),o}function we(t){return!(!t||!t.__CANCEL__)}function me(t,e,r){Mt.call(this,null==t?"canceled":t,Mt.ERR_CANCELED,e,r),this.name="CanceledError"}Nt.inherits(me,Mt,{__CANCEL__:!0});const be=me;const ve=oe.hasStandardBrowserEnv?{write(t,e,r,n,i,o){const a=[t+"="+encodeURIComponent(e)];Nt.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),Nt.isString(n)&&a.push("path="+n),Nt.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ee(t,e){return t&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const Se=oe.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let r;function n(r){let n=r;return t&&(e.setAttribute("href",n),n=e.href),e.setAttribute("href",n),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname}}return r=n(window.location.href),function(t){const e=Nt.isString(t)?n(t):t;return e.protocol===r.protocol&&e.host===r.host}}():function(){return!0};const Te=function(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i,o=0,a=0;return e=void 0!==e?e:1e3,function(s){const c=Date.now(),u=n[a];i||(i=c),r[o]=s,n[o]=c;let l=a,h=0;for(;l!==o;)h+=r[l++],l%=t;if(o=(o+1)%t,o===a&&(a=(a+1)%t),c-i<e)return;const f=u&&c-u;return f?Math.round(1e3*h/f):void 0}};function Ae(t,e){let r=0;const n=Te(50,250);return i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,s=o-r,c=n(s);r=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:s,rate:c||void 0,estimated:c&&a&&o<=a?(a-o)/c:void 0,event:i};u[e?"download":"upload"]=!0,t(u)}}const ke={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(t){return new Promise((function(e,r){let n=t.data;const i=ge.from(t.headers).normalize();let o,a,{responseType:s,withXSRFToken:c}=t;function u(){t.cancelToken&&t.cancelToken.unsubscribe(o),t.signal&&t.signal.removeEventListener("abort",o)}if(Nt.isFormData(n))if(oe.hasStandardBrowserEnv||oe.hasStandardBrowserWebWorkerEnv)i.setContentType(!1);else if(!1!==(a=i.getContentType())){const[t,...e]=a?a.split(";").map((t=>t.trim())).filter(Boolean):[];i.setContentType([t||"multipart/form-data",...e].join("; "))}let l=new XMLHttpRequest;if(t.auth){const e=t.auth.username||"",r=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";i.set("Authorization","Basic "+btoa(e+":"+r))}const h=Ee(t.baseURL,t.url);function f(){if(!l)return;const n=ge.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders());!function(t,e,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?e(new Mt("Request failed with status code "+r.status,[Mt.ERR_BAD_REQUEST,Mt.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}((function(t){e(t),u()}),(function(t){r(t),u()}),{data:s&&"text"!==s&&"json"!==s?l.response:l.responseText,status:l.status,statusText:l.statusText,headers:n,config:t,request:l}),l=null}if(l.open(t.method.toUpperCase(),Yt(h,t.params,t.paramsSerializer),!0),l.timeout=t.timeout,"onloadend"in l?l.onloadend=f:l.onreadystatechange=function(){l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))&&setTimeout(f)},l.onabort=function(){l&&(r(new Mt("Request aborted",Mt.ECONNABORTED,t,l)),l=null)},l.onerror=function(){r(new Mt("Network Error",Mt.ERR_NETWORK,t,l)),l=null},l.ontimeout=function(){let e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const n=t.transitional||Qt;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(new Mt(e,n.clarifyTimeoutError?Mt.ETIMEDOUT:Mt.ECONNABORTED,t,l)),l=null},oe.hasStandardBrowserEnv&&(c&&Nt.isFunction(c)&&(c=c(t)),c||!1!==c&&Se(h))){const e=t.xsrfHeaderName&&t.xsrfCookieName&&ve.read(t.xsrfCookieName);e&&i.set(t.xsrfHeaderName,e)}void 0===n&&i.setContentType(null),"setRequestHeader"in l&&Nt.forEach(i.toJSON(),(function(t,e){l.setRequestHeader(e,t)})),Nt.isUndefined(t.withCredentials)||(l.withCredentials=!!t.withCredentials),s&&"json"!==s&&(l.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&l.addEventListener("progress",Ae(t.onDownloadProgress,!0)),"function"==typeof t.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",Ae(t.onUploadProgress)),(t.cancelToken||t.signal)&&(o=e=>{l&&(r(!e||e.type?new be(null,t,l):e),l.abort(),l=null)},t.cancelToken&&t.cancelToken.subscribe(o),t.signal&&(t.signal.aborted?o():t.signal.addEventListener("abort",o)));const d=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(h);d&&-1===oe.protocols.indexOf(d)?r(new Mt("Unsupported protocol "+d+":",Mt.ERR_BAD_REQUEST,t)):l.send(n||null)}))}};Nt.forEach(ke,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const Ie=t=>`- ${t}`,Oe=t=>Nt.isFunction(t)||null===t||!1===t,Re=t=>{t=Nt.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let o=0;o<e;o++){let e;if(r=t[o],n=r,!Oe(r)&&(n=ke[(e=String(r)).toLowerCase()],void 0===n))throw new Mt(`Unknown adapter '${e}'`);if(n)break;i[e||"#"+o]=n}if(!n){const t=Object.entries(i).map((([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build")));let r=e?t.length>1?"since :\n"+t.map(Ie).join("\n"):" "+Ie(t[0]):"as no adapter specified";throw new Mt("There is no suitable adapter to dispatch the request "+r,"ERR_NOT_SUPPORT")}return n};function Be(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new be(null,t)}function _e(t){Be(t),t.headers=ge.from(t.headers),t.data=ye.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1);return Re(t.adapter||ce.adapter)(t).then((function(e){return Be(t),e.data=ye.call(t,t.transformResponse,e),e.headers=ge.from(e.headers),e}),(function(e){return we(e)||(Be(t),e&&e.response&&(e.response.data=ye.call(t,t.transformResponse,e.response),e.response.headers=ge.from(e.response.headers))),Promise.reject(e)}))}const Ue=t=>t instanceof ge?t.toJSON():t;function Ce(t,e){e=e||{};const r={};function n(t,e,r){return Nt.isPlainObject(t)&&Nt.isPlainObject(e)?Nt.merge.call({caseless:r},t,e):Nt.isPlainObject(e)?Nt.merge({},e):Nt.isArray(e)?e.slice():e}function i(t,e,r){return Nt.isUndefined(e)?Nt.isUndefined(t)?void 0:n(void 0,t,r):n(t,e,r)}function o(t,e){if(!Nt.isUndefined(e))return n(void 0,e)}function a(t,e){return Nt.isUndefined(e)?Nt.isUndefined(t)?void 0:n(void 0,t):n(void 0,e)}function s(r,i,o){return o in e?n(r,i):o in t?n(void 0,r):void 0}const c={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(t,e)=>i(Ue(t),Ue(e),!0)};return Nt.forEach(Object.keys(Object.assign({},t,e)),(function(n){const o=c[n]||i,a=o(t[n],e[n],n);Nt.isUndefined(a)&&o!==s||(r[n]=a)})),r}const Pe="1.6.5",xe={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{xe[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));const Le={};xe.transitional=function(t,e,r){function n(t,e){return"[Axios v1.6.5] Transitional option '"+t+"'"+e+(r?". "+r:"")}return(r,i,o)=>{if(!1===t)throw new Mt(n(i," has been removed"+(e?" in "+e:"")),Mt.ERR_DEPRECATED);return e&&!Le[i]&&(Le[i]=!0,console.warn(n(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,i,o)}};const Ne={assertOptions:function(t,e,r){if("object"!=typeof t)throw new Mt("options must be an object",Mt.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const o=n[i],a=e[o];if(a){const e=t[o],r=void 0===e||a(e,o,t);if(!0!==r)throw new Mt("option "+o+" must be "+r,Mt.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new Mt("Unknown option "+o,Mt.ERR_BAD_OPTION)}},validators:xe},je=Ne.validators;class De{constructor(t){this.defaults=t,this.interceptors={request:new qt,response:new qt}}request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Ce(this.defaults,e);const{transitional:r,paramsSerializer:n,headers:i}=e;void 0!==r&&Ne.assertOptions(r,{silentJSONParsing:je.transitional(je.boolean),forcedJSONParsing:je.transitional(je.boolean),clarifyTimeoutError:je.transitional(je.boolean)},!1),null!=n&&(Nt.isFunction(n)?e.paramsSerializer={serialize:n}:Ne.assertOptions(n,{encode:je.function,serialize:je.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=i&&Nt.merge(i.common,i[e.method]);i&&Nt.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete i[t]})),e.headers=ge.concat(o,i);const a=[];let s=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(s=s&&t.synchronous,a.unshift(t.fulfilled,t.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(t){c.push(t.fulfilled,t.rejected)}));let l,h=0;if(!s){const t=[_e.bind(this),void 0];for(t.unshift.apply(t,a),t.push.apply(t,c),l=t.length,u=Promise.resolve(e);h<l;)u=u.then(t[h++],t[h++]);return u}l=a.length;let f=e;for(h=0;h<l;){const t=a[h++],e=a[h++];try{f=t(f)}catch(t){e.call(this,t);break}}try{u=_e.call(this,f)}catch(t){return Promise.reject(t)}for(h=0,l=c.length;h<l;)u=u.then(c[h++],c[h++]);return u}getUri(t){return Yt(Ee((t=Ce(this.defaults,t)).baseURL,t.url),t.params,t.paramsSerializer)}}Nt.forEach(["delete","get","head","options"],(function(t){De.prototype[t]=function(e,r){return this.request(Ce(r||{},{method:t,url:e,data:(r||{}).data}))}})),Nt.forEach(["post","put","patch"],(function(t){function e(e){return function(r,n,i){return this.request(Ce(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}De.prototype[t]=e(),De.prototype[t+"Form"]=e(!0)}));const Ke=De;class Me{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise((function(t){e=t}));const r=this;this.promise.then((t=>{if(!r._listeners)return;let e=r._listeners.length;for(;e-- >0;)r._listeners[e](t);r._listeners=null})),this.promise.then=t=>{let e;const n=new Promise((t=>{r.subscribe(t),e=t})).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t((function(t,n,i){r.reason||(r.reason=new be(t,n,i),e(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}static source(){let t;const e=new Me((function(e){t=e}));return{token:e,cancel:t}}}const ze=Me;const We={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};Object.entries(We).forEach((([t,e])=>{We[e]=t}));const Fe=We;const Ze=function t(e){const r=new Ke(e),n=rt(Ke.prototype.request,r);return Nt.extend(n,Ke.prototype,r,{allOwnKeys:!0}),Nt.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return t(Ce(e,r))},n}(ce);Ze.Axios=Ke,Ze.CanceledError=be,Ze.CancelToken=ze,Ze.isCancel=we,Ze.VERSION=Pe,Ze.toFormData=Ht,Ze.AxiosError=Mt,Ze.Cancel=Ze.CanceledError,Ze.all=function(t){return Promise.all(t)},Ze.spread=function(t){return function(e){return t.apply(null,e)}},Ze.isAxiosError=function(t){return Nt.isObject(t)&&!0===t.isAxiosError},Ze.mergeConfig=Ce,Ze.AxiosHeaders=ge,Ze.formToJSON=t=>ae(Nt.isHTMLForm(t)?new FormData(t):t),Ze.getAdapter=Re,Ze.HttpStatusCode=Fe,Ze.default=Ze;const He=Ze;var $e=s(742),Ge=Object.create,Xe=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Je=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty,Qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tr=(t,e,r)=>(r=null!=t?Ge(Ye(t)):{},((t,e,r,n)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let i of Je(e))!qe.call(t,i)&&i!==r&&Xe(t,i,{get:()=>e[i],enumerable:!(n=Ve(e,i))||n.enumerable});return t})(!e&&t&&t.__esModule?r:Xe(r,"default",{value:t,enumerable:!0}),t)),er=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){var e=t.length,r=e%4;if(!r)return t;var n=e,i=4-r,o=e+i,a=Buffer.alloc(o);for(a.write(t);i--;)a.write("=",n++);return a.toString()}})),rr=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=er();function r(t,e){return void 0===e&&(e="utf8"),Buffer.isBuffer(t)?i(t.toString("base64")):i(Buffer.from(t,e).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var o=r;o.encode=r,o.decode=function(t,e){return void 0===e&&(e="utf8"),Buffer.from(n(t),"base64").toString(e)},o.toBase64=n,o.fromBase64=i,o.toBuffer=function(t){return Buffer.from(n(t),"base64")},t.default=o})),nr=Qe(((t,e)=>{e.exports=rr().default,e.exports.default=e.exports})),ir=Qe((t=>{t.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},t.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),l=0,h=c>0?s-4:s;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},t.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,u=n-i;s<u;s+=a)o.push(c(t,s,s+a>u?u:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};var e,r=[],n=[],i=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(e=0,64;e<64;++e)r[e]=o[e],n[o.charCodeAt(e)]=e;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function s(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function c(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(s(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63})),or=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;var e=ir();function r(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function n(t){return(new TextEncoder).encode(t)}function i(t){return new Uint8Array(e.toByteArray(c(t)))}function o(t){return e.fromByteArray(new Uint8Array(t))}function a(t){return s(o(t))}function s(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}function c(t){let e;return e=(t=t.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-t.length%4,t.concat("=".repeat(e))}t.concatBuffers=function(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let e=1;e<t.length;e++)r.set(new Uint8Array(t[e]),n),n+=t[e].byteLength;return r},t.b64UrlToString=function(t){return r(i(t))},t.bufferToString=r,t.stringToBuffer=n,t.stringToB64Url=function(t){return a(n(t))},t.b64UrlToBuffer=i,t.bufferTob64=o,t.bufferTob64Url=a,t.b64UrlEncode=s,t.b64UrlDecode=c})),ar=Qe((t=>{Object.defineProperty(t,"__esModule",{value:!0});var e=or();t.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let t=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),e=await this.driver.exportKey("jwk",t.privateKey);return{kty:e.kty,e:e.e,n:e.n,d:e.d,p:e.p,q:e.q,dp:e.dp,dq:e.dq,qi:e.qi}}async sign(t,e,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(n)}async hash(t,e="SHA-256"){let r=await this.driver.digest(e,t);return new Uint8Array(r)}async verify(t,e,r){let n={kty:"RSA",e:"AQAB",n:t},i=await this.jwkToPublicCryptoKey(n),o=await this.driver.digest("SHA-256",e),a=await this.driver.verify({name:"RSA-PSS",saltLength:0},i,r,e),s=await this.driver.verify({name:"RSA-PSS",saltLength:32},i,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((i.algorithm.modulusLength-1)/8)-o.byteLength-2},i,r,e);return a||s||c}async jwkToCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let t=crypto?.subtle;return void 0!==t&&["generateKey","importKey","exportKey","digest","sign"].every((e=>"function"==typeof t[e]))}async encrypt(t,r,n){let i=await this.driver.importKey("raw","string"==typeof r?e.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:n?e.stringToBuffer(n):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),a=new Uint8Array(16);crypto.getRandomValues(a);let s=await this.driver.encrypt({name:"AES-CBC",iv:a},o,t);return e.concatBuffers([a,s])}async decrypt(t,r,n){let i=await this.driver.importKey("raw","string"==typeof r?e.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),o=await this.driver.deriveKey({name:"PBKDF2",salt:n?e.stringToBuffer(n):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},i,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),a=t.slice(0,16),s=await this.driver.decrypt({name:"AES-CBC",iv:a},o,t.slice(16));return e.concatBuffers([s])}}})),sr=Qe((t=>{t.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,c=(1<<s)-1,u=c>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=s;l>0;o=256*o+t[e+h],h+=f,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+t[e+h],h+=f,l-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=u}return(d?-1:1)*a*Math.pow(2,o-n)},t.write=function(t,e,r,n,i,o){var a,s,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(a++,c/=2),a+h>=l?(s=0,a=l):a+h>=1?(s=(e*c-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+d]=255&a,d+=p,a/=256,u-=8);t[r+d-p]|=128*g}})),cr=Qe((t=>{var e=ir(),r=sr(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=function(t){return+t!=t&&(t=0),a.alloc(+t)},t.INSPECT_MAX_BYTES=50;var i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if(("string"!=typeof e||""===e)&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=0|d(t,e),n=o(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(G(t,Uint8Array)){let e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(G(t,ArrayBuffer)||t&&G(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(t,SharedArrayBuffer)||t&&G(t.buffer,SharedArrayBuffer)))return h(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);let i=function(t){if(a.isBuffer(t)){let e=0|f(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||X(t.length)?o(0):l(t);if("Buffer"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if(typeof Symbol<"u"&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return c(t),o(t<0?0:0|f(t))}function l(t){let e=t.length<0?0:0|f(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function h(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function f(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||G(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(i)return n?-1:Z(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0)||(r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),X(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){let o,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+c>s&&(r=s-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;let o,a=e.length;for(n>a/2&&(n=a/2),o=0;o<n;++o){let n=parseInt(e.substr(2*o,2),16);if(X(n))return o;t[r+o]=n}return o}function b(t,e,r,n){return $(Z(e,t.length-r),t,r,n)}function v(t,e,r,n){return $(function(t){let e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return $(H(e),t,r,n)}function S(t,e,r,n){return $(function(t,e){let r,n,i,o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function A(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let e=t[i],o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,c;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){let e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=k));return r}(n)}t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=function(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch{return!1}}(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&"function"==typeof console.error&&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."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return s(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},a.allocUnsafe=function(t){return u(t)},a.allocUnsafeSlow=function(t){return u(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(G(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),G(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).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}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;let n=a.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){let e=t[r];if(G(e,Uint8Array))i+e.length>n.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},a.byteLength=d,a.prototype._isBuffer=!0,a.prototype.swap16=function(){let t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},a.prototype.swap32=function(){let t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},a.prototype.swap64=function(){let t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},a.prototype.toString=function(){let t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):p.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,i){if(G(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),c=Math.min(o,s),u=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<c;++t)if(u[t]!==l[t]){o=u[t],s=l[t];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}let i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=V[t[n]];return i}function B(t,e,r){let n=t.slice(e,r),i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function _(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,i){M(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function P(t,e,r,n,i){M(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function x(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,n,i,o){return e=+e,n>>>=0,o||x(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function N(t,e,n,i,o){return e=+e,n>>>=0,o||x(t,0,n,8),r.write(t,e,n,i,52,8),n+8}a.prototype.slice=function(t,e){let r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);let n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||_(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),a.prototype.readBigUInt64BE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||_(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||_(t,2,this.length);let r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||_(t,2,this.length);let r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=J((function(t){z(t>>>=0,"offset");let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&W(t,this.length-8);let n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||_(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||_(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||_(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||_(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){U(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=J((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=J((function(t,e=0){return P(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){let n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){let n=Math.pow(2,8*r-1);U(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=J((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=J((function(t,e=0){return P(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!n&&0!==n&&(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r||0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);let i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){let e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{let o=a.isBuffer(t)?t:a.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};var j={};function D(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function K(t){let e="",r=t.length,n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function M(t,e,r,n,i,o){if(t>r||t<e){let n,i="bigint"==typeof e?"n":"";throw n=o>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){z(e,"offset"),(void 0===t[e]||void 0===t[e+r])&&W(e,t.length-(r+1))}(n,i,o)}function z(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){throw Math.floor(t)!==t?(z(t,r),new j.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=K(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=K(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);var F=/[^+/0-9A-Za-z-_]/g;function Z(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function $(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function G(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function X(t){return t!=t}var V=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function J(t){return typeof BigInt>"u"?Y:t}function Y(){throw new Error("BigInt not supported")}})),ur=Qe(((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:cr().Buffer,Crypto:window.crypto}):e.exports={Buffer:cr().Buffer,Crypto:crypto}})),lr={};((t,e)=>{for(var r in e)Xe(t,r,{get:e[r],enumerable:!0})})(lr,{AVSCTap:()=>Rr,ArweaveSigner:()=>Tr,DataItem:()=>Dr,MAX_TAG_BYTES:()=>Nr,MIN_BINARY_SIZE:()=>jr,SIG_CONFIG:()=>Sr,SignatureConfig:()=>wr,Signer:()=>hr,createData:()=>Mr,deserializeTags:()=>Ur,indexToType:()=>Ar,serializeTags:()=>Br,tagsExceedLimit:()=>_r});var hr=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,r,n){throw new Error("You must implement verify method on child")}},fr=tr(nr(),1),dr=tr(or(),1);async function pr(t){if(Array.isArray(t)){let e=(0,dr.concatBuffers)([(0,dr.stringToBuffer)("list"),(0,dr.stringToBuffer)(t.length.toString())]);return await gr(t,await Er().hash(e,"SHA-384"))}let e=t,r=(0,dr.concatBuffers)([(0,dr.stringToBuffer)("blob"),(0,dr.stringToBuffer)(e.byteLength.toString())]),n=(0,dr.concatBuffers)([await Er().hash(r,"SHA-384"),await Er().hash(e,"SHA-384")]);return await Er().hash(n,"SHA-384")}async function gr(t,e){if(t.length<1)return e;let r=(0,dr.concatBuffers)([e,await pr(t[0])]),n=await Er().hash(r,"SHA-384");return await gr(t.slice(1),n)}var yr,wr,mr=tr(ar(),1),br=mr.default.default?mr.default.default:mr.default,vr=class extends br{getPublicKey(t){throw new Error("Unimplemented")}};function Er(){return yr??=new vr}!function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM"}(wr||(wr={}));var Sr={[wr.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[wr.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[wr.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[wr.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[wr.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[wr.MULTIAPTOS]:{sigLength:2052,pubLength:1025,sigName:"multiAptos"},[wr.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},Tr=class{signatureType=1;ownerLength=Sr[1].pubLength;signatureLength=Sr[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return fr.default.toBuffer(this.pk)}sign(t){return Er().sign(this.jwk,t)}static async verify(t,e,r){return await Er().verify(t,e,r)}},Ar={1:Tr},kr=tr(nr(),1);async function Ir(t){return pr([(0,dr.stringToBuffer)("dataitem"),(0,dr.stringToBuffer)("1"),(0,dr.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function Or(t,e){let{signature:r,id:n}=await async function(t,e){let r=await Ir(t),n=await e.sign(r),i=await Er().hash(n);return{signature:Buffer.from(n),id:Buffer.from(i)}}(t,e);return t.getRaw().set(r,2),n}var Rr=class{buf;pos;constructor(t=Buffer.alloc(Nr),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e,r=t.length;if(r)for(this.writeLong(r),e=0;e<r;e++){let r=t[e];if(void 0===r?.name||void 0===r?.value)throw new Error(`Invalid tag format for ${r}, expected {name:string, value: string}`);this.writeString(r.name),this.writeString(r.value)}this.writeLong(0)}toBuffer(){let t=Buffer.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(t,0,0,this.pos),t}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(t){let e,r,n=this.buf;if(t>=-1073741824&&t<1073741824){r=t>=0?t<<1:~t<<1|1;do{n[this.pos]=127&r,r>>=7}while(r&&(n[this.pos++]|=128))}else{e=t>=0?2*t:2*-t-1;do{n[this.pos]=127&e,e/=128}while(e>=1&&(n[this.pos++]|=128))}this.pos++,this.buf=n}writeString(t){let e=Buffer.byteLength(t),r=this.buf;this.writeLong(e);let n=this.pos;if(this.pos+=e,!(this.pos>r.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let i,o,a,s;for(i=0,o=e;i<o;i++)a=t.charCodeAt(i),a<128?r[n++]=a:a<2048?(r[n++]=a>>6|192,r[n++]=63&a|128):55296==(64512&a)&&56320==(64512&(s=t.charCodeAt(i+1)))?(a=65536+((1023&a)<<10)+(1023&s),i++,r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}this.buf=r}}readLong(){let t,e,r,n,i=0,o=0,a=this.buf;do{t=a[this.pos++],e=128&t,i|=(127&t)<<o,o+=7}while(e&&o<28);if(e){r=i,n=268435456;do{t=a[this.pos++],r+=(127&t)*n,n*=128}while(128&t);return(r%2?-(r+1):r)/2}return i>>1^-(1&i)}skipLong(){let t=this.buf;for(;128&t[this.pos++];);}readTags(){let t,e=[];for(;t=this.readLong();)for(t<0&&(t=-t,this.skipLong());t--;){let t=this.readString(),r=this.readString();e.push({name:t,value:r})}return e}readString(){let t=this.readLong(),e=this.pos,r=this.buf;if(this.pos+=t,!(this.pos>r.length))return this.buf.slice(e,e+t).toString()}};function Br(t){let e=new Rr;return e.writeTags(t),e.toBuffer()}function _r(t){let e=new Rr;return e.writeTags(t),e.tagsExceedLimit()}function Ur(t){return new Rr(t).readTags()}function Cr(t){let e=0;for(let r=t.length-1;r>=0;r--)e=256*e+t[r];return e}function Pr(t){let e=[0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++){let n=255&t;e[r]=n,t=(t-n)/256}return Uint8Array.from(e)}var xr=tr(ur(),1),Lr=tr(cr(),1),Nr=4096,jr=80,Dr=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return void 0!==t.binary}get signatureType(){let t=Cr(this.binary.subarray(0,2));if(void 0!==wr?.[t])return t;throw new Error("Unknown signature type: "+t)}async isValid(){return Dr.verify(this.binary)}get id(){return(async()=>kr.default.encode(await this.rawId))()}set id(t){this._id=kr.default.toBuffer(t)}get rawId(){return(async()=>Lr.Buffer.from(await xr.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(t){this._id=t}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return kr.default.encode(this.rawSignature)}set rawOwner(t){if(t.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${t.byteLength} bytes.`);this.binary.set(t,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Sr[this.signatureType].sigLength}get owner(){return kr.default.encode(this.rawOwner)}get ownerLength(){return Sr[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):Lr.Buffer.alloc(0)}get target(){return kr.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return 1==this.binary[t]?this.binary.subarray(t+1,t+33):Lr.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=Cr(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(0==Cr(this.binary.subarray(t,t+8)))return[];let e=Cr(this.binary.subarray(t+8,t+16));return Ur(Lr.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map((t=>({name:kr.default.encode(t.name),value:kr.default.encode(t.value)})))}getStartOfData(){let t=this.getTagsStart();return t+16+Cr(this.binary.subarray(t+8,t+16))}get rawData(){let t=this.getTagsStart(),e=t+16+Cr(this.binary.subarray(t+8,t+16));return this.binary.subarray(e,this.binary.length)}get data(){return kr.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await Or(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=Lr.Buffer.from(await Er().hash(t))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map((t=>({name:kr.default.encode(t.name),value:kr.default.encode(t.value)}))),data:this.data}}static async verify(t){if(t.byteLength<jr)return!1;let e=new Dr(t),r=e.signatureType,n=e.getTagsStart(),i=Cr(t.subarray(n,n+8)),o=Cr(t.subarray(n+8,n+16));if(o>Nr)return!1;if(i>0)try{if(Ur(Lr.Buffer.from(t.subarray(n+16,n+16+o))).length!==i)return!1}catch{return!1}let a=Ar[r],s=await Ir(e);return await a.verify(e.rawOwner,s,e.rawSignature)}async getSignatureData(){return Ir(this)}getTagsStart(){let t=this.getTargetStart(),e=t+(1==this.binary[t]?33:1);return e+=1==this.binary[e]?33:1,e}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let t=this.getTargetStart()+1;return t+=1==this.binary[this.getTargetStart()]?32:0,t}},Kr=tr(nr(),1);function Mr(t,e,r){let n=e.publicKey,i=r?.target?Kr.default.toBuffer(r.target):null,o=1+(i?.byteLength??0),a=r?.anchor?Buffer.from(r.anchor):null,s=1+(a?.byteLength??0),c=(r?.tags?.length??0)>0?Br(r.tags):null,u=16+(c?c.byteLength:0),l=Buffer.from(t),h=l.byteLength,f=2+e.signatureLength+e.ownerLength+o+s+u+h,d=Buffer.alloc(f);if(d.set(function(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let r=0;r<e.length;r++){let n=255&t;e[r]=n,t=(t-n)/256}return Uint8Array.from(e)}(e.signatureType),0),d.set(new Uint8Array(e.signatureLength).fill(0),2),n.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${n.byteLength}`);d.set(n,2+e.signatureLength);let p=2+e.signatureLength+e.ownerLength;if(d[p]=i?1:0,i){if(32!==i.byteLength)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);d.set(i,p+1)}let g=p+o,y=g+1;if(d[g]=a?1:0,a){if(y+=a.byteLength,32!==a.byteLength)throw new Error("Anchor must be 32 bytes");d.set(a,g+1)}d.set(Pr(r?.tags?.length??0),y);let w=Pr(c?.byteLength??0);d.set(w,y+8),c&&d.set(c,y+16);let m=y+u;return d.set(l,m),new Dr(d)}var zr={...lr};globalThis.arbundles??=zr;const{Axios:Wr,AxiosError:Fr,CanceledError:Zr,isCancel:Hr,CancelToken:$r,VERSION:Gr,all:Xr,Cancel:Vr,isAxiosError:Jr,spread:Yr,toFormData:qr,AxiosHeaders:Qr,HttpStatusCode:tn,formToJSON:en,getAdapter:rn,mergeConfig:nn}=He;var on=s(386),an={debug:!1,inject:!1,auth0Domain:"auth.othent.io",auth0ClientId:"uXkRmJoIa0NfzYgYEDAgj6Rss4wR1tIc",auth0Strategy:"refresh-tokens",auth0Cache:"memory",auth0RefreshTokenExpirationMs:1296e6,auth0LogInMethod:"popup",auth0RedirectURI:null,auth0ReturnToURI:null,serverBaseURL:"https://kms-server.othent.io",autoConnect:"lazy",cookieKey:null,localStorageKey:null,throwErrors:!0,tags:[]},sn={...an,appName:"",appVersion:"",persistCookie:!1,persistLocalStorage:!1,auth0Cache:"memory"},cn={host:"arweave.net",protocol:"https",port:443},un="othentUserDetails",ln="Othent KMS",hn="2.0.0-beta.10",fn=[{name:"Client",value:ln},{name:"Client-Version",value:hn}],dn=class{constructor(t){this.listeners=new Set,this.initializedListeners=new Set,this.lastEmittedUpdateId="",this.lastEmittedParams=null,this.options={diffParams:!1,replyOnListen:!1},this.options={...this.options,...t}}getUpdateId(t){const{getUpdateIdTransform:e}=this.options,r=e?e(t):t;return JSON.stringify(r,((t,e)=>e&&"oject"===e&&!Array.isArray(e)?Object.entries(e).sort(((t,e)=>t[0].localeCompare(e[0]))):e))}get hasListeners(){return this.listeners.size>0}add(t){this.listeners.add(t),this.options.replyOnListen&&this.lastEmittedParams&&this.emit(...this.lastEmittedParams)}delete(t){this.listeners.add(t)}emit(...t){const{initializedListeners:e,lastEmittedUpdateId:r}=this,n=this.getUpdateId(t),i=r===n;return this.lastEmittedUpdateId=n,this.lastEmittedParams=t,this.listeners.forEach((r=>{if(!i||!e.has(r)){e.add(r);try{r(...t)}catch(t){}}})),i}};function pn(t,e){return et(!0,{},e,t)}var gn={secure:!0,domain:!0,ttlHours:360},yn=class t{constructor(e=gn){this.secureParam=null,this.domainParam=null,this.ttlMs=1296e6;const{secureParam:r,domainParam:n,ttlMs:i}=this.parseCookieOptions(pn(e,gn));return this.secureParam=r,this.domainParam=n,this.ttlMs=i,new Proxy(this,{get:(t,e)=>e in t||"string"!=typeof e?t[e]:t.getItem(e),ownKeys:e=>document.cookie.split(t.COOKIE_SEPARATOR).map((e=>e.split(t.COOKIE_VALUE_SEPARATOR)[0])),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}parseCookieOptions({secure:t,domain:e,ttlHours:r}={}){return{secureParam:t?"secure":void 0===t?this.secureParam:null,domainParam:e?`domain=${!0===e?location.host:e}`:void 0===e?this.domainParam:null,ttlMs:r?36e5*r:void 0===r?this.ttlMs:0}}getCookieParams(t){const{secureParam:e,domainParam:r,ttlMs:n}=this.parseCookieOptions(t),i=[`expires=${new Date(Date.now()+n).toUTCString()}`,e,r,"path=/"].filter(Boolean).join("; ");return i?` ${i};`:""}get length(){return document.cookie?document.cookie.split(t.COOKIE_SEPARATOR).length:0}key(e){return(document.cookie.split(t.COOKIE_SEPARATOR)[e]||"").split(t.COOKIE_VALUE_SEPARATOR)[0]||null}getItem(e){const r=document.cookie.split(t.COOKIE_SEPARATOR).find((r=>r.split(t.COOKIE_VALUE_SEPARATOR)[0]===e));return r&&r.split(t.COOKIE_VALUE_SEPARATOR)[1]||null}setItem(t,e,r){const n=`${t}=${"string"==typeof e?e:JSON.stringify(e)};${this.getCookieParams(r)}`;return document.cookie=n,n}removeItem(t,e){return this.setItem(t,"",{...e,ttlHours:-1})}clear(){document.cookie.split(t.COOKIE_SEPARATOR).forEach((e=>{this.removeItem(e.split(t.COOKIE_VALUE_SEPARATOR)[0])}))}};yn.COOKIE_SEPARATOR=/\s*;\s*/,yn.COOKIE_VALUE_SEPARATOR=/\s*=\s*/;var wn=yn,mn=null;var bn=class t{constructor({debug:t,domain:e,clientId:r,strategy:n,cache:i,refreshTokenExpirationMs:o,loginMethod:a,redirectURI:s,returnToURI:c,appInfo:u,initialUserDetails:l,cookieKey:h,localStorageKey:f}){this.debug=!1,this.auth0ClientPromise=Promise.resolve(null),this.authEventListenerHandler=new dn({diffParams:!0,replyOnListen:!0}),this.userDetails=null,this.userDetailsExpirationTimeoutID=0,this.cookieKey=null,this.localStorageKey=null,this.refreshTokenExpirationMs=+an.auth0RefreshTokenExpirationMs,this.appInfo={name:"",version:""},this.isReady=!1,this.isAuthenticated=!1,this.debug=t,this.loginMethod=a,this.redirectURI=s,this.returnToURI=c,this.auth0ClientPromise=async function(t){const e=new tt(t);return await e.checkSession(),e}({domain:e,clientId:r,useRefreshTokens:"refresh-tokens"===n,cacheLocation:"string"==typeof i?i:void 0,cache:"object"==typeof i?i:void 0,authorizationParams:{redirect_uri:this.redirectURI}}).then((t=>(this.isReady=!0,t))),this.cookieKey=h,this.localStorageKey=f,this.refreshTokenExpirationMs=o,this.appInfo=u,this.restoreUserDetails(l||null),this.handleStorage=this.handleStorage.bind(this)}static isIdTokenValidUser(t){return!!(t&&t.sub&&t.owner&&t.walletAddress&&"KMS"===t.authSystem)}static async getUserDetails(e){const{email:r="",walletAddress:n}=e,i=e.sub||"",o=i.split("|")[0];let a=await async function(t){try{const e=(await He.get("https://api.mem.tech/api/state/Tih8T1uESATJNzdwBIY3rpe25kWTzjw8uNiMRYe9I5M",{timeout:2e3})).data.balances.find((e=>e.address===t)),r=e&&(e.primary_domain||e.ownedDomains[0].domain)||null;return r?`${r}.ar`:null}catch(e){return console.warn(`Error resolving ANS domain for ${t} =\n`,e),null}}(n);if(!a){a=`${t.PROVIDER_LABELS[o]||"Unknown Provider"} (${r})`}return{sub:i,name:e.name||"",givenName:e.given_name||"",middleName:e.middle_name||"",familyName:e.family_name||"",nickname:e.nickname||"",preferredUsername:e.preferred_username||"",profile:e.profile||"",picture:e.picture||"",website:e.website||"",locale:e.locale||"",updatedAt:e.updated_at||"",email:r,emailVerified:!!e.email_verified,owner:e.owner,walletAddress:e.walletAddress,walletAddressLabel:a,authSystem:e.authSystem,authProvider:o}}getAuthEventListenerHandler(){return this.authEventListenerHandler}setAppInfo(t){this.appInfo=t}initStorageSyncing(){this.localStorageKey&&window.addEventListener("storage",this.handleStorage)}stopStorageSyncing(){window.removeEventListener("storage",this.handleStorage)}handleStorage(t){t.key===this.localStorageKey&&(t.newValue?this.restoreUserDetails():this.logOut())}persistUserDetails(t){const{cookieKey:e,localStorageKey:r}=this;if(e){const r=function(){if(!mn){const t=!1;mn=new wn({secure:!t&&void 0,domain:!t&&void 0})}return mn}();t?r.setItem(e,JSON.stringify(t)):null!==r.getItem(e)&&r.removeItem(e)}if(r)if(t){const e=new Date,n=JSON.stringify({userDetails:t,createdAt:e.toUTCString(),expiredBy:new Date(e.getTime()+this.refreshTokenExpirationMs).toUTCString()});localStorage.setItem(r,n)}else this.clearStoredUserDetails()}setUserDetails(t,e=!0){window.clearTimeout(this.userDetailsExpirationTimeoutID),t&&(this.userDetailsExpirationTimeoutID=window.setTimeout(this.logOut,this.refreshTokenExpirationMs));return this.authEventListenerHandler.emit(t,e?!!t:this.isAuthenticated)||(this.userDetails=t),e&&(this.isAuthenticated=!!t,this.persistUserDetails(t)),t}restoreUserDetails(t){let e=t||null;if(!e&&this.localStorageKey)try{const t=JSON.parse(localStorage.getItem(this.localStorageKey)||"null");if(t){const r=new Date(t.expiredBy).getTime();!isNaN(r)&&r>Date.now()?e=t.userDetails:this.clearStoredUserDetails()}}catch(t){}this.setUserDetails(e,!1)}clearStoredUserDetails(){Object.keys(localStorage).forEach((t=>{t.startsWith("othent")&&localStorage.removeItem(t)}))}async updateUserDetails(e){const r=e&&t.isIdTokenValidUser(e)?await t.getUserDetails(e):null;return this.setUserDetails(r)}getAuthorizationParams(t={}){const{authorizationParams:e,data:r}=t.hasOwnProperty("keyName")?{authorizationParams:null,data:t}:{authorizationParams:t,data:null},n={othentFunction:"KMS",othentSDKVersion:ln,othentAPIVersion:hn,appName:this.appInfo.name,appVersion:this.appInfo.version};return r&&(n.data=r),{...e,transaction_input:JSON.stringify(n,((t,e)=>{let r=[];if(e instanceof Buffer||e instanceof DataView||ArrayBuffer.isView(e))r=Array.from(new Uint8Array(e.buffer));else{if(!(e instanceof ArrayBuffer))return e;r=Array.from(new Uint8Array(e))}return"data"===t?Object.fromEntries(Object.entries(r)):{type:"Buffer",data:r}}))}}async getTokenSilently(t){const e=await this.auth0ClientPromise;if(!e)throw new Error("Missing Auth0 Client");const r=this.getAuthorizationParams(t);if(this.debug)try{console.log("getTokenSilently() =",{...r,transaction_input:JSON.parse(r.transaction_input)})}catch(t){console.error("Error logging/parsing `authorizationParams`:",t)}try{const t=await e.getTokenSilently({detailedResponse:!0,authorizationParams:r,cacheMode:"off"}),n=await e.getUser();if(!n)throw new Error("Could not get the user's details");const i=await this.updateUserDetails(n);return{...t,idToken:n,userDetails:i}}catch(t){throw t}}async logIn(){const t=await this.auth0ClientPromise;if(!t)throw new Error("Missing Auth0 Client");this.debug&&console.log("logIn()");if(await t.isAuthenticated())throw new Error("Already logged in");const e=this.getAuthorizationParams({redirect_uri:this.redirectURI});if("popup"!==this.loginMethod)throw t.loginWithRedirect({authorizationParams:e}),new Error("Redirecting...");return await t.loginWithPopup({authorizationParams:e},{}),this.getTokenSilently()}async handleRedirectCallback(t){this.debug&&console.log(`handleRedirectCallback(${t})`);const e=await this.auth0ClientPromise;if(!e)throw new Error("Missing Auth0 Client");await e.handleRedirectCallback(t);const r=await e.getUser();if(!r)throw new Error("Could not get the user's details");return this.updateUserDetails(r)}async logOut(){this.setUserDetails(null);const t=await this.auth0ClientPromise;if(!t)throw new Error("Missing Auth0 Client");return t.logout({logoutParams:{returnTo:this.returnToURI}}).catch((t=>{console.warn(t instanceof Error?t.message:t),"undefined"!=typeof location&&location.reload()}))}async encodeToken(t){return(await this.getTokenSilently(t)).id_token}getCachedUserDetails(){return this.userDetails}getCachedUserPublicKey(){var t;return(null==(t=this.userDetails)?void 0:t.owner)||null}getCachedUserSub(){var t;return(null==(t=this.userDetails)?void 0:t.sub)||null}getCachedUserAddress(){var t;return(null==(t=this.userDetails)?void 0:t.walletAddress)||null}getCachedUserAddressLabel(){var t;return(null==(t=this.userDetails)?void 0:t.walletAddressLabel)||null}getCachedUserEmail(){var t;return(null==(t=this.userDetails)?void 0:t.email)||null}};bn.PROVIDER_LABELS={apple:"Apple",auth0:"E-Mail","google-oauth2":"Google","<LinkedIn>":"LinkedIn","<X>":"X","<Meta>":"Meta","<Twitch>":"Twitch",github:"GitHub"};var vn=bn;function En(t){return"string"==typeof t?Sn(t):t}function Sn(t){return(new TextEncoder).encode(t)}function Tn(t){return e=function(t){return $e.fromByteArray(new Uint8Array(t))}(t),e.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"");var e}async function An(t,e="SHA-256"){let r=await crypto.subtle.digest(e,t);return new Uint8Array(r)}var kn=(t=>(t.Unexpected="Unexpected",t.Validation="Validation",t.UserCreation="UserCreation",t.Encryption="Encryption",t.Decryption="Decryption",t.Signing="Signing",t.PublicKey="PublicKey",t))(kn||{}),In=class extends Error{constructor(t,e,r,n=!1){super(),this.name=t,this.message=e||"",n?this.stack=`${t} (from server): ${e}\n`:Error.captureStackTrace(this),this.id=t,this.developerMessage=e,r instanceof Error?this.cause=r:"string"!=typeof r&&"number"!=typeof r||(this.cause=new Error(`${r}`))}};function On(t){var e;if(Jr(t)){const r=null==(e=t.response)?void 0:e.data;if(!function(t){return"object"==typeof t&&!0===t.error&&!!t.id&&!!kn[t.id]}(r))return t;const{id:n,developerMessage:i,cause:o}=r;let a;return o&&(a=new Error(o.message),a.name=o.name,a.stack=o.stack),new In(n,i||"",a,!0)}return t instanceof Error?t:new Error("Unknown error")}async function Rn(t,e,r,n){var i;const o=await e.encodeToken({ciphertext:r,keyName:n});let a=null;try{a=null!=(i=(await t.post("/decrypt",{encodedData:o})).data.data)?i:null}catch(t){throw On(t)}if(null===a)throw new Error("Error decrypting on server.");return"string"==typeof a?a:(s=new Uint8Array(a.data),(new TextDecoder).decode(s));var s}var Bn=class{constructor(t,e){this.api=He.create({baseURL:t}),this.auth0=e}async createUser(t){return async function(t,e){let r=!1;try{r=(await t.post("/create-user",{encodedData:e})).data.data}catch(t){throw On(t)}if(!r)throw new Error("Error creating user on server.");return!0}(this.api,t)}async decrypt(t,e){return Rn(this.api,this.auth0,t,e)}async encrypt(t,e){return async function(t,e,r,n){var i;const o=await e.encodeToken({plaintext:r,keyName:n});let a=null;try{a=null!=(i=(await t.post("/encrypt",{encodedData:o})).data.data)?i:null}catch(t){throw On(t)}if(null===a)throw new Error("Error encrypting on server.");return"string"==typeof a?Sn(a):new Uint8Array(a.data)}(this.api,this.auth0,t,e)}async sign(t,e){return async function(t,e,r,n){const i=await e.encodeToken({data:r,keyName:n});let o=null;try{o=(await t.post("/sign",{encodedData:i})).data.data}catch(t){throw On(t)}if(null===o)throw new Error("Error signing data on server.");return"string"==typeof o?Sn(o):new Uint8Array(o.data)}(this.api,this.auth0,t,e)}getSignerSignFn(t){return async e=>await this.sign(e,t)}};function _n(t,e="utf8"){return n.lW.isBuffer(t)?Cn(t.toString("base64")):Cn(n.lW.from(t,e).toString("base64"))}function Un(t){return function(t){let e=t.length,r=e%4;if(!r)return t;let i=e,o=4-r,a=e+o,s=n.lW.alloc(a);for(s.write(t);o--;)s.write("=",i++);return s.toString()}(t=t.toString()).replace(/\-/g,"+").replace(/_/g,"/")}function Cn(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Pn(t){return n.lW.from(Un(t),"base64")}var xn=_n;function Ln(t){return on.default.init(t)}xn.encode=_n,xn.decode=function(t,e="utf8"){return n.lW.from(Un(t),"base64").toString(e)},xn.toBase64=Un,xn.fromBase64=Cn,xn.toBuffer=Pn;var Nn=class t{constructor(t=sn){this.errorEventListenerHandler=new dn,this.tokens=new Set,this.walletName=ln,this.walletVersion=hn,this.config=an,this.appInfo={name:"",version:""},this.gatewayConfig=cn;let{appName:e,appVersion:r,persistCookie:n,persistLocalStorage:i,auth0Cache:o=an.auth0Cache,auth0RedirectURI:a,auth0ReturnToURI:s,gatewayConfig:c,initialUserDetails:u,...l}=t;const h="undefined"==typeof location?null:location.origin;this.config={...pn(l,an),cookieKey:"string"==typeof n?n:n?un:null,localStorageKey:"string"==typeof i?i:i?un:null,auth0Cache:"object"==typeof o?"custom":o,auth0RedirectURI:a||h,auth0ReturnToURI:s||h};const{config:f}=this,{cookieKey:d,localStorageKey:p}=f;if("string"==typeof d&&!d.startsWith("othent"))throw new Error('`persistCookie` / `cookieKey` must start with "othent".');if("string"==typeof p&&!p.startsWith("othent"))throw new Error('`persistLocalStorage` / `localStorageKey` must start with "othent".');if(!f.auth0RedirectURI)throw new Error("`auth0RedirectURI` is required.");if(!f.auth0ReturnToURI)throw new Error("`auth0ReturnToURI` is required.");this.appInfo={name:e,version:r},this.gatewayConfig=c||cn;let g=null;if("undefined"!=typeof window)g=window.crypto;else{if("undefined"==typeof global)throw new Error("A Crypto module is needed for Othent to work. If your environment doesn't natively provide one, you should polyfill it.");g=global.crypto}if(this.crypto=g,"eager"===f.autoConnect&&"popup"===f.auth0LogInMethod&&"refresh-tokens"===f.auth0Strategy&&"memory"===o)throw new Error('The browser cannot open the authentication modal automatically before an user interaction. Use `autoConnect = "lazy"` or change any of these other options: `auth0LogInMethod`, `auth0Strategy` or `auth0Cache`.');if(this.auth0=new vn({debug:f.debug,domain:f.auth0Domain,clientId:f.auth0ClientId,strategy:f.auth0Strategy,cache:o,refreshTokenExpirationMs:f.auth0RefreshTokenExpirationMs,redirectURI:f.auth0RedirectURI,returnToURI:f.auth0ReturnToURI,loginMethod:f.auth0LogInMethod,appInfo:this.appInfo,initialUserDetails:u,cookieKey:f.cookieKey,localStorageKey:f.localStorageKey}),"eager"===this.config.autoConnect){let t="undefined"==typeof location;if(!t){const e=new URL(location.href),{searchParams:r}=e;r.has("code")||r.has("state")||(t=!0)}t&&this.connect()}if(f.inject&&(window.arweaveWallet=this),!f.throwErrors){["connect","disconnect","getActiveAddress","getActivePublicKey","getAllAddresses","getWalletNames","getUserDetails","getSyncActiveAddress","getSyncActivePublicKey","getSyncAllAddresses","getSyncWalletNames","getSyncUserDetails","sign","dispatch","encrypt","decrypt","signature","signDataItem","signMessage","verifyMessage","privateHash","getArweaveConfig","getPermissions"].forEach((t=>{let e=this[t];"function"==typeof e&&(e=e.bind(this),this[t]=(...t)=>{try{let n=e(...t);return!(r=n)||"object"!=typeof r&&"function"!=typeof r||"function"!=typeof r.then||(n=n.catch((t=>(this.onError(t),null)))),n}catch(t){this.onError(t)}var r;return null})}))}this.api=new Bn(this.config.serverBaseURL,this.auth0)}startTabSynching(){return this.config.localStorageKey||console.warn("Calling `Othent.startTabSynching()` is a NOOP unless the `persistLocalStorage` option is used."),this.auth0.initStorageSyncing(),()=>{this.auth0.stopStorageSyncing()}}async completeConnectionAfterRedirect(t){"redirect"!==this.config.auth0LogInMethod&&console.warn('Calling `Othent.completeConnectionAfterRedirect()` is a NOOP unless the `auth0LogInMethod` options is `"redirect"`.');const e=t||("undefined"==typeof location?"":location.href),r=new URL(e.replace(/.+\.auth0:\/\//,"https://")),{searchParams:n}=r;if(!n.has("code")||!n.has("state")||!e)return null;let i=null;try{i=await this.auth0.handleRedirectCallback(e)}finally{"undefined"!=typeof location&&"undefined"!=typeof history&&(n.delete("code"),n.delete("state"),history.replaceState(null,"",r))}return i}get isReady(){return this.auth0.isReady}onError(t){t instanceof Error?this.errorEventListenerHandler.hasListeners?this.errorEventListenerHandler.emit(t):console.warn("Unhandled unthrown error:\n",t,'\nWhen using `throwErrors = false`, you must add at least one error event listener with `othent.addEventListener("error", () => { ... })`'):console.warn("Unknown error type",t)}addEventListener(t,e){let r=null;if("auth"===t)r=this.auth0.getAuthEventListenerHandler();else if("error"===t){if(this.config.throwErrors)throw new Error("You can only listen for `error` events if `throwErrors = false`.");r=this.errorEventListenerHandler}if(!r)throw new Error("Unknown event type");return r.add(e),()=>{r.delete(e)}}removeEventListener(t,e){let r=null;if("auth"===t?r=this.auth0.getAuthEventListenerHandler():"error"===t&&(r=this.errorEventListenerHandler),!r)throw new Error("Unknown event type");r.delete(e)}get isAuthenticated(){return this.auth0.isAuthenticated}requireAuth(){return this.requireUserDataOrThrow().then((()=>{}))}async requireUserDataOrThrow(){"off"===this.config.autoConnect||this.auth0.isAuthenticated||await this.connect(void 0,void 0,this.gatewayConfig);const{sub:t,owner:e}=this.auth0.getCachedUserDetails()||{};if(!t||!e)throw new Error("Missing cached user.");return{sub:t,publicKey:e}}async connect(e,r,n){if(e&&e.toSorted().join("-")!==t.ALL_PERMISSIONS.join("-"))throw new Error("Othent implicitly has access to all available permissions. You should pass `permissions = undefined` or include all of them.");r&&(this.appInfo=r,this.auth0.setAppInfo(r)),this.gatewayConfig=n||cn;let i="",o=null;try{const t=await this.auth0.getTokenSilently();i=t.id_token,o=t.userDetails}catch(t){if(!(t instanceof Error))throw t;if("Login required"!==t.message&&!(t instanceof E))throw t;console.warn(t.message)}if(!i)try{const t=await this.auth0.logIn();i=t.id_token,o=t.userDetails}catch(t){if(!(t instanceof Error))throw t;if("Redirecting..."===t.message&&await new Promise((()=>{})),t.message.startsWith("Unable to open a popup")||t instanceof b||t instanceof m)return t instanceof m&&t.popup.close(),console.warn(t.message),null;throw t}if(i&&!o){await this.api.createUser(i);const t=await this.auth0.getTokenSilently();i=t.id_token,o=t.userDetails}if(i&&o)return o;throw this.auth0.logOut(),new Error("Unexpected authentication error")}async disconnect(){return this.auth0.logOut()}getActiveAddress(){return Promise.resolve(this.getSyncActiveAddress())}getActivePublicKey(){return Promise.resolve(this.getSyncActivePublicKey())}getAllAddresses(){return Promise.resolve(this.getSyncAllAddresses())}getWalletNames(){return Promise.resolve(this.getSyncWalletNames())}getUserDetails(){return Promise.resolve(this.getSyncUserDetails())}getSyncActiveAddress(){return this.auth0.getCachedUserAddress()||""}getSyncActivePublicKey(){return this.auth0.getCachedUserPublicKey()||""}getSyncAllAddresses(){const t=this.auth0.getCachedUserAddress();return t?[t]:[]}getSyncWalletNames(){const t=this.auth0.getCachedUserAddress(),e=this.auth0.getCachedUserAddressLabel();return Promise.resolve(t&&e?{[t]:e}:{})}getSyncUserDetails(){return this.auth0.getCachedUserDetails()}addCommonTags(t=[]){if(Array.isArray(t)){const e=[{name:"App-Name",value:this.appInfo.name},{name:"App-Version",value:this.appInfo.version}];return[...t,...this.config.tags,...e,...fn]}for(const{name:e,value:r}of this.config.tags)t.addTag(e,r);t.addTag("App-Name",this.appInfo.name),t.addTag("App-Version",this.appInfo.version);for(const{name:e,value:r}of fn)t.addTag(e,r)}async sign(t){const{sub:e,publicKey:r}=await this.requireUserDataOrThrow(),n=Ln(this.gatewayConfig),i=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),o=this.addCommonTags(i),a=await n.createTransaction({data:t.data,owner:r,reward:t.reward});o.forEach((t=>{a.addTag(t.name,t.value)}));const s=await a.getSignatureData(),c=await this.api.sign(s,e),u=await An(c);return a.setSignature({id:Tn(u),owner:r,signature:Tn(c),tags:a.tags,reward:a.reward}),a}async dispatch(t,e){var r;const n=t.get("tags").map((t=>({name:t.get("name",{decode:!0,string:!0}),value:t.get("value",{decode:!0,string:!0})}))),i=await this.signDataItem({data:t.data,tags:n,target:t.target}),o=`${(null==e?void 0:e.node)||"https://turbo.ardrive.io"}/tx`;try{const t=await He.post(o,i,{headers:{"Content-Type":"application/octet-stream"},maxBodyLength:1/0,maxContentLength:1/0,responseType:"json"});if(t.status>=400)throw new Error(`${t.status} - ${JSON.stringify(t.data)}`);return{...t.data,type:"BUNDLED"}}catch(n){console.warn(`Error dispatching transaction to ${o} =\n`,n);const i=await this.sign(t),a=null!=(r=null==e?void 0:e.arweave)?r:Ln(this.gatewayConfig),s=await a.transactions.getUploader(i);for(;!s.isComplete;)await s.uploadChunk();return{id:i.id,signature:i.signature,owner:i.owner,type:"BASE"}}}async encrypt(t){const{sub:e}=await this.requireUserDataOrThrow();return await this.api.encrypt(t,e)}async decrypt(t){const{sub:e}=await this.requireUserDataOrThrow();return await this.api.decrypt(t,e)}async signature(t){const{sub:e}=await this.requireUserDataOrThrow();return await this.api.sign(t,e)}async signDataItem(t){const{sub:e,publicKey:r}=await this.requireUserDataOrThrow(),{data:n,tags:i,...o}=t,a={publicKey:Pn(r),signatureType:1,signatureLength:512,ownerLength:512,sign:this.api.getSignerSignFn(e)},s=Mr(n,a,{...o,tags:this.addCommonTags(i)});return await s.sign(a),s.getRaw().buffer}async signMessage(t,e){const{sub:r}=await this.requireUserDataOrThrow(),n=(null==e?void 0:e.hashAlgorithm)||"SHA-256",i=await this.crypto.subtle.digest(n,En(t));return await this.api.sign(i,r)}async verifyMessage(t,e,r,n={hashAlgorithm:"SHA-256"}){if(!r){const t=await this.requireUserDataOrThrow();r||(r=t.publicKey)}const i=(null==n?void 0:n.hashAlgorithm)||"SHA-256",o=await this.crypto.subtle.digest(i,En(t)),a={e:"AQAB",ext:!0,kty:"RSA",n:r},s=await this.crypto.subtle.importKey("jwk",a,{name:"RSA-PSS",hash:n.hashAlgorithm},!1,["verify"]);return await this.crypto.subtle.verify({name:"RSA-PSS",saltLength:32},s,En(e),o)}async privateHash(t,e){return An(En(t),null==e?void 0:e.hashAlgorithm)}getArweaveConfig(){return Promise.resolve(this.gatewayConfig)}getPermissions(){return Promise.resolve(t.ALL_PERMISSIONS)}addToken(t,e,r){return console.warn("Othent doesn't currently support this feature and only tracks added tokens temporarily in memory."),this.tokens.add(t),Promise.resolve()}isTokenAdded(t){return console.warn("Othent doesn't currently support this feature and only tracks added tokens temporarily in memory."),Promise.resolve(this.tokens.has(t))}};Nn.walletName=ln,Nn.walletVersion=hn,Nn.ALL_PERMISSIONS=["ACCESS_ADDRESS","ACCESS_ALL_ADDRESSES","ACCESS_ARWEAVE_CONFIG","ACCESS_PUBLIC_KEY","DECRYPT","DISPATCH","ENCRYPT","SIGN_TRANSACTION","SIGNATURE"];var jn=Nn;async function Dn(t,e){try{const r=function(t){const e=t.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),r=window.atob(e),n=new Uint8Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n.buffer}(t),n=await window.crypto.subtle.importKey("spki",r,{name:"RSA-OAEP",hash:{name:"SHA-256"}},!0,["encrypt"]);return function(t){try{let e="";const r=new Uint8Array(t),n=r.byteLength;for(let t=0;t<n;t++)e+=String.fromCharCode(r[t]);return window.btoa(e)}catch(t){console.error("Eror in buffertoBase64 : ",t)}}(await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,(new TextEncoder).encode(e)))}catch(t){return console.error("rsaEncrypt error:",t),null}}async function Kn(t){const e={Info:{hashedOthentSub:t},request:"PIN"};return await fetch("https://api2.onairos.uk/getAccountInfoFromOthentSub",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t)).catch((t=>console.error(t)))}window.Buffer=n.lW;const Mn=(0,e.createContext)(null);function zn({clientId:t,nonce:n,onScriptLoadSuccess:i,onScriptLoadError:o,children:a}){const s=function(t={}){const{nonce:r,onScriptLoadSuccess:n,onScriptLoadError:i}=t,[o,a]=(0,e.useState)(!1),s=(0,e.useRef)(n);s.current=n;const c=(0,e.useRef)(i);return c.current=i,(0,e.useEffect)((()=>{const t=document.createElement("script");return t.src="https://accounts.google.com/gsi/client",t.async=!0,t.defer=!0,t.nonce=r,t.onload=()=>{var t;a(!0),null===(t=s.current)||void 0===t||t.call(s)},t.onerror=()=>{var t;a(!1),null===(t=c.current)||void 0===t||t.call(c)},document.body.appendChild(t),()=>{document.body.removeChild(t)}}),[r]),o}({nonce:n,onScriptLoadSuccess:i,onScriptLoadError:o}),c=(0,e.useMemo)((()=>({clientId:t,scriptLoadedSuccessfully:s})),[t,s]);return r().createElement(Mn.Provider,{value:c},a)}function Wn(){const t=(0,e.useContext)(Mn);if(!t)throw new Error("Google OAuth components must be used within GoogleOAuthProvider");return t}function Fn(t){var e;return null!==(e=null==t?void 0:t.clientId)&&void 0!==e?e:null==t?void 0:t.client_id}const Zn={large:40,medium:32,small:20};function Hn({onSuccess:t,onError:n,useOneTap:i,promptMomentNotification:o,type:a="standard",theme:s="outline",size:c="large",text:u,shape:l,logo_alignment:h,width:f,locale:d,click_listener:p,containerProps:g,...y}){const w=(0,e.useRef)(null),{clientId:m,scriptLoadedSuccessfully:b}=Wn(),v=(0,e.useRef)(t);v.current=t;const E=(0,e.useRef)(n);E.current=n;const S=(0,e.useRef)(o);return S.current=o,(0,e.useEffect)((()=>{var t,e,r,n,o,g,T,A,k;if(b)return null===(r=null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.accounts)||void 0===e?void 0:e.id)||void 0===r||r.initialize({client_id:m,callback:t=>{var e;if(!(null==t?void 0:t.credential))return null===(e=E.current)||void 0===e?void 0:e.call(E);const{credential:r,select_by:n}=t;v.current({credential:r,clientId:Fn(t),select_by:n})},...y}),null===(g=null===(o=null===(n=null===window||void 0===window?void 0:window.google)||void 0===n?void 0:n.accounts)||void 0===o?void 0:o.id)||void 0===g||g.renderButton(w.current,{type:a,theme:s,size:c,text:u,shape:l,logo_alignment:h,width:f,locale:d,click_listener:p}),i&&(null===(k=null===(A=null===(T=null===window||void 0===window?void 0:window.google)||void 0===T?void 0:T.accounts)||void 0===A?void 0:A.id)||void 0===k||k.prompt(S.current)),()=>{var t,e,r;i&&(null===(r=null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.accounts)||void 0===e?void 0:e.id)||void 0===r||r.cancel())}}),[m,b,i,a,s,c,u,l,h,f,d]),r().createElement("div",{...g,ref:w,style:{height:Zn[c],...null==g?void 0:g.style}})}class $n extends Error{}function Gn(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,((t,e)=>{let r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return atob(e)}}$n.prototype.name="InvalidTokenError";const Xn=process.env.REACT_APP_API_URL||"https://api.onairos.com";function Vn(t){let{dataRequester:r,NoAccount:n,NoModel:i,activeModels:o,requestData:a,handleConnectionSelection:s,changeGranted:c,granted:u,allowSubmit:l,rejectDataRequest:h,sendDataRequest:f,avatar:d,traits:p,isAuthenticated:g,loading:y,onLoginSuccess:w}=t;const[m,b]=(0,e.useState)(null),[v,E]=(0,e.useState)({email:"",password:""}),S=async t=>{try{b(null);const e=function(t,e){if("string"!=typeof t)throw new $n("Invalid token specified: must be a string");e||(e={});const r=!0===e.header?0:1,n=t.split(".")[r];if("string"!=typeof n)throw new $n(`Invalid token specified: missing part #${r+1}`);let i;try{i=Gn(n)}catch(t){throw new $n(`Invalid token specified: invalid base64 for part #${r+1} (${t.message})`)}try{return JSON.parse(i)}catch(t){throw new $n(`Invalid token specified: invalid json for part #${r+1} (${t.message})`)}}(t.credential),r=await fetch("".concat(Xn,"/auth/google"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t.credential,email:e.email})});if(!r.ok)throw new Error("Google authentication failed");const{token:n}=await r.json();localStorage.setItem("onairosToken",n),await w(e.email)}catch(t){console.error("Google login failed:",t),b("Google login failed. Please try again.")}},T=()=>{b("Google login failed. Please try again.")},A=t=>{E({...v,[t.target.name]:t.target.value})},k=async t=>{t.preventDefault();try{b(null);const t={details:{username:v.username,password:v.password}},e=await fetch("https://api2.onairos.uk/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await e.json();if("Accepted"!==r.authentication)throw new Error("Invalid credentials");localStorage.setItem("onairosToken",r.token),localStorage.setItem("username",v.username),await w(v.username)}catch(t){console.error("Login failed:",t),b("Invalid email or password")}};return y?React.createElement("div",{className:"fixed inset-x-0 bottom-0 bg-white rounded-t-3xl shadow-2xl transform transition-transform duration-300 ease-out min-h-[200px] flex items-center justify-center"},React.createElement("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})):g?React.createElement("div",{className:"fixed inset-x-0 bottom-0 bg-white rounded-t-3xl shadow-2xl transform transition-transform duration-300 ease-out"},React.createElement("div",{className:"w-full flex justify-center pt-3 pb-2"},React.createElement("div",{className:"w-12 h-1.5 bg-gray-300 rounded-full"})),React.createElement("div",{className:"px-4 pb-8"},React.createElement("div",{className:"flex flex-col items-center justify-start max-w-sm mx-auto space-y-6"},m&&React.createElement("div",{className:"w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg mb-4"},m),React.createElement(Hn,{onSuccess:S,onError:T,useOneTap:!0,theme:"outline",size:"large",text:"continue_with",shape:"rectangular",width:"320"}),React.createElement("div",{className:"w-full flex items-center justify-center space-x-4"},React.createElement("hr",{className:"flex-grow border-gray-300"}),React.createElement("span",{className:"text-gray-500"},"or"),React.createElement("hr",{className:"flex-grow border-gray-300"})),React.createElement("form",{onSubmit:k,className:"w-full space-y-4"},React.createElement("input",{type:"email",name:"email",value:v.email,onChange:A,placeholder:"Email",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),React.createElement("input",{type:"password",name:"password",value:v.password,onChange:A,placeholder:"Password",className:"w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),React.createElement("button",{type:"submit",className:"w-full bg-blue-500 text-white font-semibold py-3 px-4 rounded-lg hover:bg-blue-600 transition-colors"},"Sign In"))))):React.createElement("div",{className:"fixed inset-x-0 bottom-0 h-[50vh] bg-white rounded-t-3xl shadow-2xl transform transition-transform duration-300 ease-out"},React.createElement("div",{className:"w-full h-full overflow-y-auto px-4 py-6"},React.createElement("div",{className:"flex flex-col items-center justify-start max-w-sm mx-auto space-y-6"},m&&React.createElement("div",{className:"w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded"},m),React.createElement(Hn,{onSuccess:S,onError:T,useOneTap:!0,theme:"outline",size:"large",text:"continue_with",shape:"rectangular",width:"320"}),React.createElement("div",{className:"w-full flex items-center justify-center space-x-4"},React.createElement("hr",{className:"flex-grow border-gray-300"}),React.createElement("span",{className:"text-gray-500"},"or"),React.createElement("hr",{className:"flex-grow border-gray-300"})),React.createElement("form",{onSubmit:k,className:"w-full space-y-4"},React.createElement("input",{type:"username",name:"username",value:v.username,onChange:A,placeholder:"username",className:"w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),React.createElement("input",{type:"password",name:"password",value:v.password,onChange:A,placeholder:"Password",className:"w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),React.createElement("button",{type:"submit",className:"w-full bg-blue-500 text-white font-semibold py-2 px-4 rounded hover:bg-blue-600 transition-colors"},"Sign In")))))}const Jn=async()=>(await s.e(423).then(s.t.bind(s,153,23))).default;function Yn(t){let{requestData:n,webpageName:i,inferenceData:o=null,onComplete:a=null,autoFetch:s=!0,proofMode:c=!1,textLayout:u="below",textColor:l="white",login:h=!1,buttonType:f="pill",loginReturn:d=null,loginType:p="signIn",visualType:g="full"}=t;const[y,w]=(0,e.useState)(null),[m,b]=(0,e.useState)(!1),[v,E]=(0,e.useState)([]),[S,T]=(0,e.useState)(0),[A,k]=(0,e.useState)({}),[I,O]=(0,e.useState)(!1),[R,B]=(0,e.useState)(!1),_=(0,e.useRef)(!1),U=(0,e.useRef)(!1),[C,P]=(0,e.useState)(!1),[x,L]=(0,e.useState)(null),[N,j]=(0,e.useState)(!0),D=()=>{const t=navigator.userAgent||navigator.vendor||window.opera;return/android|iphone|ipad|ipod|windows phone/i.test(t)};(0,e.useEffect)((()=>{if(s&&o&&"function"==typeof a){const t=async t=>{if(t.data&&"content-script"===t.data.source&&"API_URL_RESPONSE"===t.data.type&&"Onairos-Response"===t.data.unique){const{APIurl:e,approved:r,accessToken:n}=t.data,i=(t=>{const e={Small:16,Medium:32,Large:64};let r=null,n=0;return t.forEach((t=>{const i=e[t.data];i>n&&(n=i,r=t)})),n})(r),s={Input:o.slice(0,i)};try{const t=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)},body:JSON.stringify(s)}),r=await t.json();a(r)}catch(t){console.error(t),a(null,t)}}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}}),[]);const K=(t,e,r,n,i,o)=>{k((a=>({...a,["".concat(t,"-").concat(e,"-").concat(r)]:{type:n,reward:i,isSelected:o}})))},M=t=>{T((e=>e+t))},z=async()=>{if(D())b(!0);else if(s){const t=(t=>{const e=t=>Array.isArray(t)?t.map((t=>e(t))):null!==t&&"object"==typeof t?Object.keys(t).reduce(((r,n)=>(r[n]=e(t[n]),r)),{}):Math.random();return e(t)})(o);a(t)}else window.postMessage({type:"API_URL_RESPONSE",APIurl:"https://onairos.uk/capx",source:"content-script",approved:"message.approved",accessToken:"message.accessToken",unique:"Onairos-Response",username:"CapX-Telegram"},"*")},W=()=>{b(!1),a&&a(null,"rejected")},F=async()=>{if(S>0){const t=Object.values(A).filter((t=>t.isSelected)).map((t=>({type:t.type,reward:t.reward})));try{const e=await fetch("https://onairos.uk/capx",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(localStorage.getItem("onairosToken"))},body:JSON.stringify({Input:o?o.slice(0,S):null,approvedRequests:t})}),r=await e.json();a&&a(r)}catch(t){console.error(t),a&&a(null,t)}}b(!1)},Z=window.location.href,H=async()=>{try{if(D()){console.log("Connecting to Onairos");return void await z()}console.log("Connecting to Onairos");const t=new jn({appInfo:{name:"Onairos",version:"1.0.0",env:"production"},throwErrors:!1}),e=await t.connect(),r=(await Jn())(e.sub).toString();function o(t){try{const e=window.atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r.buffer}catch(t){console.error("Error converting to Buffer :",t)}}const a=o((await Kn(r)).result),s=await t.decrypt(a);console.log("Retrieved PIN Working"),Dn("\n -----BEGIN PUBLIC KEY-----\n MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4wkWvRPaJiY8CwQ5BoJI\n amcGAYV91Bk8NrvWq4PXM+J/RJugfgTNCYKQ/c6g4xa1YES/tJEzFS7nf0Kdoqxm\n 5aav0ru5vS4fc4vCOLTI9W1T7nj02NY91rogsQm2/KMxUQ8DaLeTZKi+0Wjsa9YO\n 6XGGd1wh4azgQkj04MWW5J1EBCcBavKoY+C85oA9jkkklQ8nGWgbugmZs7eXHNQb\n qH8/ZHcB9Kx1CZ6XjQuVd6YE/A+swV+DksbkXANcYjr6SY/2TbB8GfpcOMM3bkyN\n Q8e0A51q5a8abfuAkDZXe67MwKMWu/626abwPZhJrKr5HhRZZDwPtnXlktYHhOK6\n lQIDAQAB\n -----END PUBLIC KEY-----\n ",s).then((t=>{window.postMessage({source:"webpage",type:"GET_API_URL",webpageName:i,domain:Z,requestData:n,proofMode:c,HashedOthentSub:r,EncryptedUserPin:t})})).catch((t=>{console.error("Encryption failed:",t)}))}catch(u){console.error({fix:"Please ensure you have stored your model"}),console.error("Error Sending Data to Terminal: ",u)}},$="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===f?"px-4 py-2":"w-12 h-12"," ").concat(h?"bg-white border border-gray-300":"bg-transparent","\n ").concat(D()?"":"OnairosConnect","\n "),G={flexDirection:"below"===u?"column":"row",backgroundColor:h?"#ffffff":"transparent",color:h?"black":l,border:h?"1px solid #ddd":"1px solid transparent"},X={width:"20px",height:"20px",marginRight:"full"===g?"12px":"0"},V=process.env.REACT_APP_GOOGLE_CLIENT_ID,J=async t=>{try{const e=localStorage.getItem("onairosToken")||localStorage.getItem("token"),r=await fetch("https://api2.onairos.uk/getAccountInfo",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({Info:{email:t}})});if(!r.ok)throw new Error("Failed to fetch account info");const n=await r.json();O(!!n.avatar),B(!!n.traits),E(n.activeModels||[])}catch(t){console.error("Failed to fetch account info:",t)}};return(0,e.useEffect)((()=>{D()&&(async()=>{try{const t=localStorage.getItem("onairosToken"),e=localStorage.getItem("token"),r=t||e;if(r){const t=await fetch("https://api2.onairos.uk/verify",{headers:{Authorization:"Bearer ".concat(r)}});if(t.ok){const e=await t.json();e.valid?(L(r),P(!0),await J(e.email)):(localStorage.removeItem("onairosToken"),localStorage.removeItem("token"))}}}catch(t){console.error("Token verification failed:",t)}finally{j(!1)}})()}),[]),m&&D()?r().createElement(zn,{clientId:V},r().createElement(Vn,{dataRequester:i,NoAccount:_,NoModel:U,activeModels:v,requestData:n,handleConnectionSelection:K,changeGranted:M,granted:S,allowSubmit:S>0,rejectDataRequest:W,sendDataRequest:F,avatar:I,traits:R,isAuthenticated:C,authToken:x,loading:N,onLoginSuccess:async t=>{await J(t)}})):r().createElement("div",{className:"flex items-center justify-center"},r().createElement("button",{className:$,onClick:H,style:G},("full"===g||"icon"===g)&&r().createElement("img",{src:h?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:X,className:"".concat("pill"===f?"w-6 h-6":"w-8 h-8"," object-contain")}),("full"===g||"textOnly"===g)&&r().createElement("span",{className:"".concat(h||"black"===l?"text-black":"text-white"," ").concat("icon"===g?"sr-only":""," ").concat("right"===u?"ml-2":"left"===u?"mr-2":"")},(()=>{switch(p){case"signUp":return"Sign Up with Onairos";case"signOut":return"Sign Out of Onairos";default:return"Sign In with Onairos"}})())))}})(),c})()));
2
2
  //# sourceMappingURL=onairos.bundle.js.map